cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [1/2] git commit: updated refs/heads/master to ca6873a
Date Fri, 19 Apr 2013 02:52:36 GMT
Updated Branches:
  refs/heads/master f8d4a2334 -> ca6873a9d


CLOUDSTACK-2086 UI shows added NIC even if Actual NIC addition has failed


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

Branch: refs/heads/master
Commit: ca6873a9d0a7085d3cbcd1a6d12f78c4137edfb2
Parents: 4fd9212
Author: Mice Xia <mice_xia@tcloudcomputing.com>
Authored: Fri Apr 19 10:51:22 2013 +0800
Committer: Mice Xia <mice_xia@tcloudcomputing.com>
Committed: Fri Apr 19 10:52:00 2013 +0800

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   23 ++++++++++----
 1 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca6873a9/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index a53e380..19f4005 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2537,13 +2537,22 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
             VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vmVO);
 
             s_logger.debug("Plugging nic for vm " + vm + " in network " + network);
-            if (vmGuru.plugNic(network, nicTO, vmTO, context, dest)) {
-                s_logger.debug("Nic is plugged successfully for vm " + vm + " in network
" + network + ". Vm  is a part of network now");
-                return nic;
-            } else {
-                s_logger.warn("Failed to plug nic to the vm " + vm + " in network " + network);
-                return null;
-            }
+            
+            boolean result = false;
+            try{
+                result = vmGuru.plugNic(network, nicTO, vmTO, context, dest);
+                if (result) {
+                    s_logger.debug("Nic is plugged successfully for vm " + vm + " in network
" + network + ". Vm  is a part of network now");
+                    return nic;
+                } else {
+                    s_logger.warn("Failed to plug nic to the vm " + vm + " in network " +
network);
+                    return null;
+                }                
+            }finally{
+                if(!result){
+                    _networkMgr.removeNic(vmProfile, _nicsDao.findById(nic.getId()));
+                }
+            }            
         } else if (vm.getState() == State.Stopped) {
             //1) allocate nic
             return _networkMgr.createNicForVm(network, requested, context, vmProfile, false);


Mime
View raw message