cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/2] git commit: updated refs/heads/4.2 to c1131d1
Date Tue, 22 Oct 2013 20:40:53 GMT
Updated Branches:
  refs/heads/4.2 c31f87c07 -> c1131d1b7


CLOUDSTACK-4649: addResourceDetail - added support for userVm resource. Now "hypervisortoolsversion"
get stored in user_vm_details table, and being returned as a part of listVirtualMachines call
("details" parameter)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c1131d1b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c1131d1b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c1131d1b

Branch: refs/heads/4.2
Commit: c1131d1b7f21a213dbf5b1e20c20901827f5ec69
Parents: 9d41fdf
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Oct 22 13:28:14 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Oct 22 13:34:50 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/vm/VmDetailConstants.java     |   1 +
 .../cloudstack/api/response/UserVmResponse.java |  10 +-
 .../src/com/cloud/vm/dao/UserVmDetailsDao.java  |   2 +
 .../com/cloud/vm/dao/UserVmDetailsDaoImpl.java  |  11 ++
 .../cloud/api/query/dao/UserVmJoinDaoImpl.java  |  13 +-
 .../com/cloud/api/query/vo/UserVmJoinVO.java    |  14 ++
 .../metadata/ResourceMetaDataManagerImpl.java   |   6 +-
 setup/db/db/schema-420to421.sql                 | 190 ++++++++++++++++++-
 8 files changed, 242 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/api/src/com/cloud/vm/VmDetailConstants.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VmDetailConstants.java b/api/src/com/cloud/vm/VmDetailConstants.java
index 5ff3ce0..87f4b5d 100644
--- a/api/src/com/cloud/vm/VmDetailConstants.java
+++ b/api/src/com/cloud/vm/VmDetailConstants.java
@@ -21,4 +21,5 @@ public interface VmDetailConstants {
 	public static final String NIC_ADAPTER = "nicAdapter";
 	public static final String ROOK_DISK_CONTROLLER = "rootDiskController";
 	public static final String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
+	public static final String HYPERVISOR_TOOLS_VERSION  = "hypervisortoolsversion";
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
index e49e16b..80fa41e 100644
--- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
@@ -17,8 +17,8 @@
 package org.apache.cloudstack.api.response;
 
 import java.util.Date;
-import java.util.HashSet;
 import java.util.LinkedHashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -193,6 +193,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
     private Boolean isDynamicallyScalable;
     @SerializedName(ApiConstants.SERVICE_STATE) @Param(description="State of the Service
from LB rule")
     private String serviceState;
+    
+    @SerializedName(ApiConstants.DETAILS) @Param(description="Template details in key/value
pairs.", since="4.2.1")
+    private Map details;
 
     public UserVmResponse(){
         securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
@@ -444,5 +447,8 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
     public void setServiceState(String state) {
         this.serviceState = state;
     }
-
+    
+    public void setDetails(Map details) {
+        this.details = details;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDao.java b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDao.java
index bdccec9..f17a530 100644
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDao.java
@@ -29,4 +29,6 @@ public interface UserVmDetailsDao extends GenericDao<UserVmDetailVO,
Long> {
     UserVmDetailVO findDetail(long vmId, String name);
     
 	void deleteDetails(long vmId);
+	
+    void addVmDetail(Long vmId, String key, String value);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
index 6ec6f68..be166b5 100644
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
@@ -96,4 +96,15 @@ public class UserVmDetailsDaoImpl extends GenericDaoBase<UserVmDetailVO,
Long> i
         txn.commit();		
 	}
 
+    @Override
+    public void addVmDetail(Long vmId, String key, String value) {
+        UserVmDetailVO detail = findDetail(vmId, key);
+        if (detail == null) {
+            UserVmDetailVO newEntry = new UserVmDetailVO(vmId, key, value);
+            persist(newEntry);
+        } else {
+            detail.setValue(value);
+            update(detail.getId(), detail);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index 7c16cc0..f8835a8 100644
--- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@ -19,8 +19,10 @@ package com.cloud.api.query.dao;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.EnumSet;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.ejb.Local;
@@ -44,8 +46,9 @@ import com.cloud.uservm.UserVm;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.VmStats;
 import com.cloud.vm.VirtualMachine.State;
+import com.cloud.vm.VmDetailConstants;
+import com.cloud.vm.VmStats;
 
 
 @Component
@@ -259,6 +262,14 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO,
Long> implem
                 userVmResponse.addAffinityGroup(resp);
             }
         }
+        
+        // set resource details map
+        // only hypervisortoolsversion can be returned to the end user       }
+        if (userVm.getDetailName() != null && userVm.getDetailName().equalsIgnoreCase(VmDetailConstants.HYPERVISOR_TOOLS_VERSION)){
+            Map<String, String> resourceDetails = new HashMap<String, String>();
+            resourceDetails.put(userVm.getDetailName(), userVm.getDetailValue());
+            userVmResponse.setDetails(resourceDetails);
+        }
 
         userVmResponse.setObjectName(objectName);
         if (userVm.isDynamicallyScalable() == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
index 745db56..4260662 100644
--- a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
@@ -393,6 +393,12 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
 
     @Column(name="dynamically_scalable")
     private boolean isDynamicallyScalable;
+    
+    @Column(name="detail_name")
+    private String detailName;
+
+    @Column(name="detail_value")
+    private String detailValue;
 
     public UserVmJoinVO() {
     }
@@ -1729,4 +1735,12 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     }
 
 
+    public String getDetailName() {
+        return detailName;
+    }
+
+
+    public String getDetailValue() {
+        return detailValue;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
index 5056bca..52b224c 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -62,6 +62,7 @@ import com.cloud.vm.NicDetailVO;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.NicDetailDao;
 import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.dao.UserVmDetailsDao;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
 
 
@@ -123,6 +124,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
     TaggedResourceService _taggedResourceMgr;
     @Inject
     VMTemplateDetailsDao _templateDetailsDao;
+    @Inject
+    UserVmDetailsDao _userVmDetailsDao;
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
@@ -204,10 +207,11 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
                     _nicDetailDao.persist(n);
                 } else if (resourceType == TaggedResourceType.Template) {
                     _templateDetailsDao.addTemplateDetail(id, key, value);
+                } else if (resourceType == TaggedResourceType.UserVm) {
+                    _userVmDetailsDao.addVmDetail(id, key, value);
                 } else{
                     throw new InvalidParameterValueException("The resource type " + resourceType
+ " is not supported by the API yet");
                 }
-
         }
 
         txn.commit();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1131d1b/setup/db/db/schema-420to421.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-420to421.sql b/setup/db/db/schema-420to421.sql
index abe97a4..e72e1b2 100644
--- a/setup/db/db/schema-420to421.sql
+++ b/setup/db/db/schema-420to421.sql
@@ -27,4 +27,192 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Storage", 'DEFAULT',
'manage
 
 -- Remove Windows Server 8 from guest_os_type dropdown to use Windows Server 2012
 DELETE FROM `cloud`.`guest_os_hypervisor` where guest_os_id=168;
-DELETE FROM `cloud`.`guest_os` where id=168;
\ No newline at end of file
+DELETE FROM `cloud`.`guest_os` where id=168;
+
+
+--Add details to the user_vm_view (CLOUDSTACK-4649 - xen and UI code needs to retrieve the
value of "hypervisortoolsversion" detail)
+
+DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
+CREATE VIEW `cloud`.`user_vm_view` AS
+    select
+        vm_instance.id id,
+        vm_instance.name name,
+        user_vm.display_name display_name,
+        user_vm.user_data user_data,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        instance_group.id instance_group_id,
+        instance_group.uuid instance_group_uuid,
+        instance_group.name instance_group_name,
+        vm_instance.uuid uuid,
+        vm_instance.last_host_id last_host_id,
+        vm_instance.vm_type type,
+        vm_instance.vnc_password vnc_password,
+        vm_instance.limit_cpu_use limit_cpu_use,
+        vm_instance.created created,
+        vm_instance.state state,
+        vm_instance.removed removed,
+        vm_instance.ha_enabled ha_enabled,
+        vm_instance.hypervisor_type hypervisor_type,
+        vm_instance.instance_name instance_name,
+        vm_instance.guest_os_id guest_os_id,
+        vm_instance.display_vm display_vm,
+        guest_os.uuid guest_os_uuid,
+        vm_instance.pod_id pod_id,
+        host_pod_ref.uuid pod_uuid,
+        vm_instance.private_ip_address private_ip_address,
+        vm_instance.private_mac_address private_mac_address,
+        vm_instance.vm_type vm_type,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        data_center.is_security_group_enabled security_group_enabled,
+        data_center.networktype data_center_type,
+        host.id host_id,
+        host.uuid host_uuid,
+        host.name host_name,
+        vm_template.id template_id,
+        vm_template.uuid template_uuid,
+        vm_template.name template_name,
+        vm_template.display_text template_display_text,
+        vm_template.enable_password password_enabled,
+        iso.id iso_id,
+        iso.uuid iso_uuid,
+        iso.name iso_name,
+        iso.display_text iso_display_text,
+        service_offering.id service_offering_id,
+        disk_offering.uuid service_offering_uuid,
+        service_offering.cpu cpu,
+        service_offering.speed speed,
+        service_offering.ram_size ram_size,
+        disk_offering.name service_offering_name,
+        storage_pool.id pool_id,
+        storage_pool.uuid pool_uuid,
+        storage_pool.pool_type pool_type,
+        volumes.id volume_id,
+        volumes.uuid volume_uuid,
+        volumes.device_id volume_device_id,
+        volumes.volume_type volume_type,
+        security_group.id security_group_id,
+        security_group.uuid security_group_uuid,
+        security_group.name security_group_name,
+        security_group.description security_group_description,
+        nics.id nic_id,
+        nics.uuid nic_uuid,
+        nics.network_id network_id,
+        nics.ip4_address ip_address,
+        nics.ip6_address ip6_address,
+        nics.ip6_gateway ip6_gateway,
+        nics.ip6_cidr ip6_cidr,
+        nics.default_nic is_default_nic,
+        nics.gateway gateway,
+        nics.netmask netmask,
+        nics.mac_address mac_address,
+        nics.broadcast_uri broadcast_uri,
+        nics.isolation_uri isolation_uri,
+        vpc.id vpc_id,
+        vpc.uuid vpc_uuid,
+        networks.uuid network_uuid,
+        networks.name network_name,
+        networks.traffic_type traffic_type,
+        networks.guest_type guest_type,
+        user_ip_address.id public_ip_id,
+        user_ip_address.uuid public_ip_uuid,
+        user_ip_address.public_ip_address public_ip_address,
+        ssh_keypairs.keypair_name keypair_name,
+        resource_tags.id tag_id,
+        resource_tags.uuid tag_uuid,
+        resource_tags.key tag_key,
+        resource_tags.value tag_value,
+        resource_tags.domain_id tag_domain_id,
+        resource_tags.account_id tag_account_id,
+        resource_tags.resource_id tag_resource_id,
+        resource_tags.resource_uuid tag_resource_uuid,
+        resource_tags.resource_type tag_resource_type,
+        resource_tags.customer tag_customer,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id,
+        affinity_group.id affinity_group_id,
+        affinity_group.uuid affinity_group_uuid,
+        affinity_group.name affinity_group_name,
+        affinity_group.description affinity_group_description,
+        vm_instance.dynamically_scalable dynamically_scalable,
+        all_details.name detail_name,
+        all_details.value detail_value
+
+    from
+        `cloud`.`user_vm`
+            inner join
+        `cloud`.`vm_instance` ON vm_instance.id = user_vm.id
+            and vm_instance.removed is NULL
+            inner join
+        `cloud`.`account` ON vm_instance.account_id = account.id
+            inner join
+        `cloud`.`domain` ON vm_instance.domain_id = domain.id
+            left join
+        `cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id
+            left join
+        `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = account.id
+            left join
+        `cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id
+            left join
+        `cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id
+            left join
+        `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
+            left join
+        `cloud`.`host` ON vm_instance.host_id = host.id
+            left join
+        `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
+            left join
+        `cloud`.`vm_template` iso ON iso.id = user_vm.iso_id
+            left join
+        `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
+            left join
+        `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
+            left join
+        `cloud`.`volumes` ON vm_instance.id = volumes.instance_id
+            left join
+        `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
+            left join
+        `cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id
+            left join
+        `cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id
+            left join
+        `cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
+            left join
+        `cloud`.`networks` ON nics.network_id = networks.id
+            left join
+        `cloud`.`vpc` ON networks.vpc_id = vpc.id and vpc.removed is null
+            left join
+        `cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id
+            left join
+        `cloud`.`user_vm_details` as ssh_details ON ssh_details.vm_id = vm_instance.id
+            and ssh_details.name = 'SSH.PublicKey'
+            left join
+        `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = ssh_details.value
+            left join
+        `cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id
+            and resource_tags.resource_type = 'UserVm'
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
+            and async_job.instance_type = 'VirtualMachine'
+            and async_job.job_status = 0
+            left join
+        `cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
+            left join
+        `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id
+            left join
+        `cloud`.`user_vm_details` as all_details ON all_details.vm_id = vm_instance.id;
\ No newline at end of file


Mime
View raw message