Skip to content

Commit 37820e1

Browse files
committed
CLOUDSTACK-7593: allow nic type to be fetched from vm's details
(cherry picked from commit 43db75c) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
1 parent c158cff commit 37820e1

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎core/src/com/cloud/agent/api/PlugNicCommand.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
import com.cloud.agent.api.to.NicTO;
2323
import com.cloud.vm.VirtualMachine;
2424

25+
import java.util.Map;
26+
2527
public class PlugNicCommand extends Command {
2628

2729
NicTO nic;
2830
String instanceName;
2931
VirtualMachine.Type vmType;
32+
Map<String, String> details;
3033

3134
public NicTO getNic() {
3235
return nic;
@@ -46,11 +49,22 @@ public PlugNicCommand(NicTO nic, String instanceName, VirtualMachine.Type vmtype
4649
this.vmType = vmtype;
4750
}
4851

52+
public PlugNicCommand(NicTO nic, String instanceName, VirtualMachine.Type vmtype, Map<String, String> details) {
53+
this.nic = nic;
54+
this.instanceName = instanceName;
55+
this.vmType = vmtype;
56+
this.details = details;
57+
}
58+
4959
public String getVmName() {
5060
return instanceName;
5161
}
5262

5363
public VirtualMachine.Type getVMType() {
5464
return vmType;
5565
}
66+
67+
public Map<String, String> getDetails() {
68+
return this.details;
69+
}
5670
}

‎engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,8 +3422,7 @@ public boolean plugNic(final Network network, final NicTO nic, final VirtualMach
34223422
final VMInstanceVO router = _vmDao.findById(vm.getId());
34233423
if (router.getState() == State.Running) {
34243424
try {
3425-
final PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType());
3426-
3425+
final PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType(), vm.getDetails());
34273426
final Commands cmds = new Commands(Command.OnError.Stop);
34283427
cmds.addCommand("plugnic", plugNicCmd);
34293428
_agentMgr.send(dest.getHost().getId(), cmds);

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,12 @@ private PlugNicAnswer execute(PlugNicCommand cmd) {
916916
return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due to " + errMsg);
917917
}
918918
*/
919-
// TODO need a way to specify the control of NIC device type
919+
// Fallback to E1000 if no specific nicAdapter is passed
920920
VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000;
921+
Map details = cmd.getDetails();
922+
if (details != null) {
923+
nicDeviceType = VirtualEthernetCardType.valueOf((String) details.get("nicAdapter"));
924+
}
921925

922926
// find a usable device number in VMware environment
923927
VirtualDevice[] nicDevices = vmMo.getNicDevices();

0 commit comments

Comments
 (0)