cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [7/41] git commit: Keep the instance-id and vm-id values prior to Acton, use UUID for VMs created poast Acton.
Date Wed, 12 Sep 2012 06:43:29 GMT
Keep the instance-id and vm-id values prior to Acton, use UUID for VMs created poast Acton.


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

Branch: refs/heads/4.0
Commit: 6fd7da8f5698e37692fab23f6e2a4bccc290fcd8
Parents: cc80d09
Author: Fang Wang <fang.wang@citrix.com>
Authored: Tue Sep 11 16:18:07 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Sep 11 17:03:11 2012 -0700

----------------------------------------------------------------------
 .../network/element/CloudZonesNetworkElement.java  |   22 ++++++++--
 .../router/VirtualNetworkApplianceManagerImpl.java |   35 ++++++++++-----
 2 files changed, 42 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6fd7da8f/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
index 0d4c1c1..ca88a72 100644
--- a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
+++ b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
@@ -152,7 +152,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
     }
 
     private VmDataCommand generateVmDataCommand(String vmPrivateIpAddress,
-            String userData, String serviceOffering, String zoneName, String guestIpAddress,
String vmName, String vmUuid, String publicKey) {
+            String userData, String serviceOffering, String zoneName, String guestIpAddress,
String vmName, String vmInstanceName, long vmId, String vmUuid, String publicKey) {
         VmDataCommand cmd = new VmDataCommand(vmPrivateIpAddress, vmName);
 
         cmd.addVmData("userdata", "user-data", userData);
@@ -162,13 +162,27 @@ public class CloudZonesNetworkElement extends AdapterBase implements
NetworkElem
         cmd.addVmData("metadata", "local-hostname", vmName);
         cmd.addVmData("metadata", "public-ipv4", guestIpAddress);
         cmd.addVmData("metadata", "public-hostname", guestIpAddress);
-        cmd.addVmData("metadata", "instance-id", vmUuid);
-        cmd.addVmData("metadata", "vm-id", vmUuid);
+        if (vmUuid == null) {
+            setVmInstanceId(vmInstanceName, vmId, cmd);
+        }  else {
+            setVmInstanceId(vmUuid, cmd);
+        }
         cmd.addVmData("metadata", "public-keys", publicKey);
 
         return cmd;
     }
 
+        private void setVmInstanceId(String vmUuid, VmDataCommand cmd) {
+            cmd.addVmData("metadata", "instance-id", vmUuid);
+            cmd.addVmData("metadata", "vm-id", vmUuid);
+        }
+
+        private void setVmInstanceId(String vmInstanceName, long vmId, VmDataCommand cmd)
{
+            cmd.addVmData("metadata", "instance-id", vmInstanceName);
+            cmd.addVmData("metadata", "vm-id", String.valueOf(vmId));
+        }
+
+
     @Override
     public boolean isReady(PhysicalNetworkServiceProvider provider) {
         // TODO Auto-generated method stub
@@ -213,7 +227,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
             cmds.addCommand(
                     "vmdata",
                     generateVmDataCommand(nic.getIp4Address(), userData, serviceOffering,
zoneName, nic.getIp4Address(), uservm.getVirtualMachine().getHostName(),
-                            uservm.getUuid(), sshPublicKey));
+                            uservm.getInstanceName(), uservm.getId(), uservm.getUuid(), sshPublicKey));
             try {
                 _agentManager.send(dest.getHost().getId(), cmds);
             } catch (OperationTimedoutException e) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6fd7da8f/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 613548b..a7b5c1e 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -695,7 +695,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
     private VmDataCommand generateVmDataCommand(VirtualRouter router, String vmPrivateIpAddress,
String userData, 
             String serviceOffering, String zoneName, String guestIpAddress, String vmName,
-            String vmUuid, String publicKey, long guestNetworkId) {
+            String vmInstanceName, long vmId, String vmUuid, String publicKey, long guestNetworkId)
{
         VmDataCommand cmd = new VmDataCommand(vmPrivateIpAddress, vmName);
 
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
@@ -713,17 +713,19 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (dcVo.getNetworkType() == NetworkType.Basic) {
             cmd.addVmData("metadata", "public-ipv4", guestIpAddress);
             cmd.addVmData("metadata", "public-hostname",  StringUtils.unicodeEscape(vmName));
-        } else
-        {
-        	if (router.getPublicIpAddress() == null) {
-        		 cmd.addVmData("metadata", "public-ipv4", guestIpAddress);
-        	} else {
-        		cmd.addVmData("metadata", "public-ipv4", router.getPublicIpAddress());
-        	}
+        } else{
+            if (router.getPublicIpAddress() == null) {
+                cmd.addVmData("metadata", "public-ipv4", guestIpAddress);
+            } else {
+                cmd.addVmData("metadata", "public-ipv4", router.getPublicIpAddress());
+            }
             cmd.addVmData("metadata", "public-hostname", router.getPublicIpAddress());
         }
-        cmd.addVmData("metadata", "instance-id", vmUuid);
-        cmd.addVmData("metadata", "vm-id", vmUuid);
+        if (vmUuid == null) {
+            setVmInstanceId(vmInstanceName, vmId, cmd);
+        } else {
+            setVmInstanceId(vmUuid, cmd);
+        }
         cmd.addVmData("metadata", "public-keys", publicKey);
 
         String cloudIdentifier = _configDao.getValue("cloud.identifier");
@@ -737,6 +739,17 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         return cmd;
     }
 
+        private void setVmInstanceId(String vmUuid, VmDataCommand cmd) {
+            cmd.addVmData("metadata", "instance-id", vmUuid);
+	        cmd.addVmData("metadata", "vm-id", vmUuid);
+        }
+
+        private void setVmInstanceId(String vmInstanceName, long vmId,VmDataCommand cmd)
{
+            cmd.addVmData("metadata", "instance-id", vmInstanceName);
+            cmd.addVmData("metadata", "vm-id", String.valueOf(vmId));
+        }
+
+
     protected class NetworkUsageTask implements Runnable {
 
         public NetworkUsageTask() {
@@ -2816,7 +2829,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         String zoneName = _dcDao.findById(router.getDataCenterIdToDeployIn()).getName();
         cmds.addCommand("vmdata",
                 generateVmDataCommand(router, nic.getIp4Address(), vm.getUserData(), serviceOffering,
zoneName, nic.getIp4Address(),
-                        vm.getHostName(), vm.getUuid(), publicKey, nic.getNetworkId()));
+                        vm.getHostName(), vm.getInstanceName(), vm.getId(), vm.getUuid(),
publicKey, nic.getNetworkId()));
         
     }
 


Mime
View raw message