cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [3/9] git commit: updated refs/heads/internallb to def0861
Date Thu, 09 May 2013 18:00:41 GMT
fix CLOUDSTACK-2277 Add approriate message for the user informing about the absence of vm-tools
when adding nics to vm on vmware


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

Branch: refs/heads/internallb
Commit: 600f140df67e8521e118691f92b460d55e7ec656
Parents: 6ef615e
Author: Mice Xia <mice_xia@tcloudcomputing.com>
Authored: Thu May 9 14:27:13 2013 +0800
Committer: Mice Xia <mice_xia@tcloudcomputing.com>
Committed: Thu May 9 14:27:13 2013 +0800

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResource.java |   18 +++++++++++++++
 server/src/com/cloud/vm/UserVmManagerImpl.java     |    4 +-
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/600f140d/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 030eff0..d87da64 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -237,6 +237,7 @@ import com.vmware.vim25.ClusterDasConfigInfo;
 import com.vmware.vim25.ComputeResourceSummary;
 import com.vmware.vim25.DatastoreSummary;
 import com.vmware.vim25.DynamicProperty;
+import com.vmware.vim25.GuestInfo;
 import com.vmware.vim25.HostCapability;
 import com.vmware.vim25.HostFirewallInfo;
 import com.vmware.vim25.HostFirewallRuleset;
@@ -1326,6 +1327,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                 throw new Exception(msg);
             }
 
+            if(!isVMWareToolsInstalled(vmMo)){
+                String errMsg = "vmware tools is not installed or not running, cannot add
nic to vm " + vmName;
+                s_logger.debug(errMsg);
+                return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due
to " + errMsg); 
+            }
+
             // TODO need a way to specify the control of NIC device type
             VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000;
 
@@ -1400,6 +1407,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                 throw new Exception(msg);
             }
 
+            if(!isVMWareToolsInstalled(vmMo)){
+                String errMsg = "vmware tools not installed or not running, cannot remove
nic from vm " + vmName;
+                s_logger.debug(errMsg);
+                return new UnPlugNicAnswer(cmd, false, "Unable to execute unPlugNicCommand
due to " + errMsg);
+            }
+
             VirtualDevice nic = findVirtualNicDevice(vmMo, cmd.getNic().getMac());
             if ( nic == null ) {
                 return new UnPlugNicAnswer(cmd, true, "success");
@@ -5237,4 +5250,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 		// TODO Auto-generated method stub
 
 	}
+
+    private boolean isVMWareToolsInstalled(VirtualMachineMO vmMo) throws Exception{
+        GuestInfo guestInfo = vmMo.getVmGuestInfo();
+        return (guestInfo != null && guestInfo.getGuestState() != null &&
guestInfo.getGuestState().equalsIgnoreCase("running"));
+    }	
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/600f140d/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 644f5ed..eee8503 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4248,7 +4248,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                 _agentMgr.send(dest.getHost().getId(),cmds);
                 PlugNicAnswer plugNicAnswer = cmds.getAnswer(PlugNicAnswer.class);
                 if (!(plugNicAnswer != null && plugNicAnswer.getResult())) {
-                    s_logger.warn("Unable to plug nic for " + vmVO);
+                    s_logger.warn("Unable to plug nic for " + vmVO + " due to: " + " due
to: " + plugNicAnswer.getDetails());
                     return false;
                 }
             } catch (OperationTimedoutException e) {
@@ -4276,7 +4276,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                 _agentMgr.send(dest.getHost().getId(),cmds);
                 UnPlugNicAnswer unplugNicAnswer = cmds.getAnswer(UnPlugNicAnswer.class);
                 if (!(unplugNicAnswer != null && unplugNicAnswer.getResult())) {
-                    s_logger.warn("Unable to unplug nic for " + vmVO);
+                    s_logger.warn("Unable to unplug nic for " + vmVO + " due to: " + unplugNicAnswer.getDetails());
                     return false;
                 }
             } catch (OperationTimedoutException e) {


Mime
View raw message