CLOUDSTACK-7593: allow nic type to be fetched from vm's details

(cherry picked from commit 43db75c319b425f3b39770d556df59333921bf92)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
This commit is contained in:
Rohit Yadav 2015-04-13 14:25:34 +05:30
parent c158cff68c
commit 37820e15f2
3 changed files with 20 additions and 3 deletions

View File

@ -22,11 +22,14 @@ package com.cloud.agent.api;
import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.NicTO;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
import java.util.Map;
public class PlugNicCommand extends Command { public class PlugNicCommand extends Command {
NicTO nic; NicTO nic;
String instanceName; String instanceName;
VirtualMachine.Type vmType; VirtualMachine.Type vmType;
Map<String, String> details;
public NicTO getNic() { public NicTO getNic() {
return nic; return nic;
@ -46,6 +49,13 @@ public class PlugNicCommand extends Command {
this.vmType = vmtype; this.vmType = vmtype;
} }
public PlugNicCommand(NicTO nic, String instanceName, VirtualMachine.Type vmtype, Map<String, String> details) {
this.nic = nic;
this.instanceName = instanceName;
this.vmType = vmtype;
this.details = details;
}
public String getVmName() { public String getVmName() {
return instanceName; return instanceName;
} }
@ -53,4 +63,8 @@ public class PlugNicCommand extends Command {
public VirtualMachine.Type getVMType() { public VirtualMachine.Type getVMType() {
return vmType; return vmType;
} }
public Map<String, String> getDetails() {
return this.details;
}
} }

View File

@ -3422,8 +3422,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
final VMInstanceVO router = _vmDao.findById(vm.getId()); final VMInstanceVO router = _vmDao.findById(vm.getId());
if (router.getState() == State.Running) { if (router.getState() == State.Running) {
try { try {
final PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType()); final PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType(), vm.getDetails());
final Commands cmds = new Commands(Command.OnError.Stop); final Commands cmds = new Commands(Command.OnError.Stop);
cmds.addCommand("plugnic", plugNicCmd); cmds.addCommand("plugnic", plugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds); _agentMgr.send(dest.getHost().getId(), cmds);

View File

@ -916,8 +916,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due to " + 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 // Fallback to E1000 if no specific nicAdapter is passed
VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000; VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000;
Map details = cmd.getDetails();
if (details != null) {
nicDeviceType = VirtualEthernetCardType.valueOf((String) details.get("nicAdapter"));
}
// find a usable device number in VMware environment // find a usable device number in VMware environment
VirtualDevice[] nicDevices = vmMo.getNicDevices(); VirtualDevice[] nicDevices = vmMo.getNicDevices();