mirror of https://github.com/apache/cloudstack.git
fix CLOUDSTACK-2277 Add approriate message for the user informing about the absence of vm-tools when adding nics to vm on vmware
This commit is contained in:
parent
6ef615e40d
commit
600f140df6
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue