cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/4.2 to a505b5b
Date Tue, 09 Jul 2013 04:54:47 GMT
Updated Branches:
  refs/heads/4.2 9a9720cee -> a505b5b48


Summary: update user data on all networks a VM is connected to

Detail: Get list of all nics and update user data on them, rather than just
the default nic for the VM. This makes the results consistent with the password
and SSH key metadata.

BUG-ID: CLOUDSTACK-3408
Bugfix-for: 4.1.1, 4.2.0
Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1373345338 -0600


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

Branch: refs/heads/4.2
Commit: a505b5b489ab9fc449f40214d0593d10b7403822
Parents: 9a9720c
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Mon Jul 8 22:48:58 2013 -0600
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Mon Jul 8 22:54:37 2013 -0600

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java | 32 ++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a505b5b4/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index e5faaf1..0486071 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1833,24 +1833,30 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
     private boolean updateUserDataInternal(UserVm vm)
             throws ResourceUnavailableException, InsufficientCapacityException {
         VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
-        Nic defaultNic = _networkModel.getDefaultNic(vm.getId());
-        if (defaultNic == null) {
-            s_logger.error("Unable to update userdata for vm id=" + vm.getId() + " as the
instance doesn't have default nic");
-            return false;
+
+        List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
+        if (nics == null || nics.isEmpty()) {
+           s_logger.error("unable to find any nics for vm " + vm.getUuid());
+           return false;
         }
 
-        Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
-        NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null,
null,
-                _networkModel.isSecurityGroupSupportedInNetwork(defaultNetwork),
-                _networkModel.getNetworkTag(template.getHypervisorType(), defaultNetwork));
+        for (Nic nic : nics) {
+             Network network = _networkDao.findById(nic.getNetworkId());
+             NicProfile nicProfile = new NicProfile(nic, network, null, null, null,
+                 _networkModel.isSecurityGroupSupportedInNetwork(network),
+                 _networkModel.getNetworkTag(template.getHypervisorType(), network));
 
-        VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>((VMInstanceVO)vm);
+             VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>((VMInstanceVO)vm);
 
-        UserDataServiceProvider element = _networkModel.getUserDataUpdateProvider(defaultNetwork);
-        if (element == null) {
-            throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName()
+ " provider needed for UserData update");
+             UserDataServiceProvider element = _networkModel.getUserDataUpdateProvider(network);
+             if (element == null) {
+                 throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName()
+ " provider needed for UserData update");
+             }
+             boolean result = element.saveUserData(network, nicProfile, vmProfile);
+             if (!result) {
+                 s_logger.error("Failed to update userdata for vm " + vm + " and nic " +
nic);
+             }
         }
-        boolean result = element.saveUserData(defaultNetwork, defaultNicProfile, vmProfile);
 
         return true;
     }


Mime
View raw message