Resource metadata support for autoscaleVmProfile CS object

This commit is contained in:
Alena Prokharchyk 2014-01-29 13:11:29 -08:00
parent 3b781d1a22
commit fdb25d6f5b
9 changed files with 186 additions and 19 deletions

View File

@ -51,7 +51,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
CustomerGateway(false, true),
VpnConnection(false, true),
User(true, true),
DiskOffering(false, true);
DiskOffering(false, true),
AutoScaleVmProfile(false, true);
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
this.resourceTagsSupport = resourceTagsSupport;

View File

@ -19,15 +19,15 @@ package org.apache.cloudstack.api.command.user.autoscale;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.log4j.Logger;
import com.cloud.network.as.AutoScaleVmProfile;
@ -47,6 +47,9 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "the templateid of the autoscale vm profile")
private Long templateId;
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "list profiles by service offering id")
private Long serviceOffId;
@Parameter(name = ApiConstants.OTHER_DEPLOY_PARAMS, type = CommandType.STRING, description = "the otherdeployparameters of the autoscale vm profile")
private String otherDeployParams;
@ -66,6 +69,10 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc
return otherDeployParams;
}
public Long getServiceOfferingId() {
return serviceOffId;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////

View File

@ -36,7 +36,7 @@
<entry key="cache.size" value="50" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
@ -45,7 +45,7 @@
<entry key="cache.size" value="50" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl">
@ -54,7 +54,7 @@
<entry key="cache.size" value="50" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl">
@ -63,7 +63,7 @@
<entry key="cache.size" value="50" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl">
@ -72,7 +72,7 @@
<entry key="cache.size" value="30" />
<entry key="cache.time.to.live" value="3600" />
</map>
</property>
</property>
</bean>
<bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl">
@ -81,7 +81,7 @@
<entry key="cache.size" value="5000" />
<entry key="cache.time.to.live" value="300" />
</map>
</property>
</property>
</bean>
<bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl">
@ -90,7 +90,7 @@
<entry key="cache.size" value="100" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl">
@ -99,7 +99,7 @@
<entry key="cache.size" value="100" />
<entry key="cache.time.to.live" value="600" />
</map>
</property>
</property>
</bean>
<bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
<property name="configParams">
@ -109,7 +109,7 @@
</map>
</property>
</bean>
<!--
DAOs with default configuration
-->
@ -172,12 +172,12 @@
<bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
<bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
<bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl" />
<bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" />
<bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />
<bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" />
<bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" />
<bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" />
<bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />
<bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" />
<bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" />
<bean id="templateJoinDaoImpl" class="com.cloud.api.query.dao.TemplateJoinDaoImpl" />
<bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />
<bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />
<bean id="inlineLoadBalancerNicMapDaoImpl" class="com.cloud.network.dao.InlineLoadBalancerNicMapDaoImpl" />
<bean id="instanceGroupDaoImpl" class="com.cloud.vm.dao.InstanceGroupDaoImpl" />
<bean id="instanceGroupJoinDaoImpl" class="com.cloud.api.query.dao.InstanceGroupJoinDaoImpl" />
@ -331,6 +331,7 @@
<bean id="Site2SiteVpnConnectionDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.Site2SiteVpnConnectionDetailsDaoImpl" />
<bean id="DiskOfferingDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDaoImpl" />
<bean id="UserDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserDetailsDaoImpl" />
<bean id="AutoScaleVmProfileDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.AutoScaleVmProfileDetailsDaoImpl" />
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
</beans>

View File

@ -0,0 +1,81 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.resourcedetail;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.ResourceDetail;
@Entity
@Table(name = "autoscale_vmprofile_details")
public class AutoScaleVmProfileDetailVO implements ResourceDetail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "autoscale_vmprofile_id")
private long resourceId;
@Column(name = "name")
private String name;
@Column(name = "value", length = 1024)
private String value;
@Column(name = "display")
private boolean display;
public AutoScaleVmProfileDetailVO() {
}
public AutoScaleVmProfileDetailVO(long id, String name, String value) {
this.resourceId = id;
this.name = name;
this.value = value;
}
@Override
public long getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public String getValue() {
return value;
}
@Override
public long getResourceId() {
return resourceId;
}
@Override
public boolean isDisplay() {
return display;
}
}

View File

@ -0,0 +1,26 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.resourcedetail.dao;
import org.apache.cloudstack.resourcedetail.AutoScaleVmProfileDetailVO;
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
import com.cloud.utils.db.GenericDao;
public interface AutoScaleVmProfileDetailsDao extends GenericDao<AutoScaleVmProfileDetailVO, Long>, ResourceDetailsDao<AutoScaleVmProfileDetailVO> {
}

View File

@ -0,0 +1,33 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.resourcedetail.dao;
import javax.ejb.Local;
import org.apache.cloudstack.resourcedetail.AutoScaleVmProfileDetailVO;
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
import org.springframework.stereotype.Component;
@Component
@Local(value = {AutoScaleVmProfileDetailsDao.class})
public class AutoScaleVmProfileDetailsDaoImpl extends ResourceDetailsDaoBase<AutoScaleVmProfileDetailVO> implements AutoScaleVmProfileDetailsDao {
@Override
public void addDetail(long resourceId, String key, String value) {
super.addDetail(new AutoScaleVmProfileDetailVO(resourceId, key, value));
}
}

View File

@ -437,12 +437,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
Long id = cmd.getId();
Long templateId = cmd.getTemplateId();
String otherDeployParams = cmd.getOtherDeployParams();
Long serviceOffId = cmd.getServiceOfferingId();
SearchWrapper<AutoScaleVmProfileVO> searchWrapper = new SearchWrapper<AutoScaleVmProfileVO>(_autoScaleVmProfileDao, AutoScaleVmProfileVO.class, cmd, cmd.getId());
SearchBuilder<AutoScaleVmProfileVO> sb = searchWrapper.getSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("templateId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
sb.and("serviceOfferingId", sb.entity().getServiceOfferingId(), SearchCriteria.Op.EQ);
sb.and("otherDeployParams", sb.entity().getOtherDeployParams(), SearchCriteria.Op.LIKE);
SearchCriteria<AutoScaleVmProfileVO> sc = searchWrapper.buildSearchCriteria();
@ -455,6 +457,11 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
if (otherDeployParams != null) {
sc.addAnd("otherDeployParams", SearchCriteria.Op.LIKE, "%" + otherDeployParams + "%");
}
if (serviceOffId != null) {
sc.setParameters("serviceOfferingId", serviceOffId);
}
return searchWrapper.search();
}

View File

@ -25,12 +25,11 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import com.cloud.api.query.dao.ResourceTagJoinDao;
import com.cloud.dc.DataCenterVO;
@ -40,6 +39,7 @@ import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.as.AutoScaleVmProfileVO;
import com.cloud.network.dao.IPAddressVO;
import com.cloud.network.dao.LoadBalancerVO;
import com.cloud.network.dao.NetworkVO;
@ -116,6 +116,7 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
s_typeMap.put(ResourceObjectType.VpnConnection, Site2SiteVpnConnectionVO.class);
s_typeMap.put(ResourceObjectType.User, UserVO.class);
s_typeMap.put(ResourceObjectType.DiskOffering, DiskOfferingVO.class);
s_typeMap.put(ResourceObjectType.AutoScaleVmProfile, AutoScaleVmProfileVO.class);
}
@Inject

View File

@ -447,3 +447,13 @@ CREATE VIEW `cloud`.`user_vm_view` AS
`cloud`.`user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_ram_size`.`name` = 'memory')));
INSERT INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('NetworkManager', 'DEFAULT', 'management-server', 'vm.network.nic.max.secondary.ipaddresses', NULL, 'Specify the number of secondary ip addresses per nic per vm', '256') ON DUPLICATE KEY UPDATE category='NetworkManager';
CREATE TABLE `cloud`.`autoscale_vmprofile_details` (
`id` bigint unsigned NOT NULL auto_increment,
`autoscale_vmprofile_id` bigint unsigned NOT NULL COMMENT 'VPC gateway id',
`name` varchar(255) NOT NULL,
`value` varchar(1024) NOT NULL,
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end autoscale_vmprofile',
PRIMARY KEY (`id`),
CONSTRAINT `fk_autoscale_vmprofile_details__autoscale_vmprofile_id` FOREIGN KEY `fk_autoscale_vmprofile_details__autoscale_vmprofile_id`(`autoscale_vmprofile_id`) REFERENCES `autoscale_vmprofiles`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;