You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/04/13 12:15:11 UTC

[03/12] git commit: updated refs/heads/4.5 to eea716b

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

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 43db75c319b425f3b39770d556df59333921bf92
Parents: dcb6d7c
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Apr 13 14:25:34 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Apr 13 15:44:09 2015 +0530

----------------------------------------------------------------------
 core/src/com/cloud/agent/api/PlugNicCommand.java      | 14 ++++++++++++++
 .../src/com/cloud/vm/VirtualMachineManagerImpl.java   |  6 +++++-
 .../hypervisor/vmware/resource/VmwareResource.java    |  6 +++++-
 3 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43db75c3/core/src/com/cloud/agent/api/PlugNicCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/PlugNicCommand.java b/core/src/com/cloud/agent/api/PlugNicCommand.java
index e68931d..322b755 100644
--- a/core/src/com/cloud/agent/api/PlugNicCommand.java
+++ b/core/src/com/cloud/agent/api/PlugNicCommand.java
@@ -22,11 +22,14 @@ package com.cloud.agent.api;
 import com.cloud.agent.api.to.NicTO;
 import com.cloud.vm.VirtualMachine;
 
+import java.util.Map;
+
 public class PlugNicCommand extends Command {
 
     NicTO nic;
     String instanceName;
     VirtualMachine.Type vmType;
+    Map<String, String> details;
 
     public NicTO getNic() {
         return nic;
@@ -46,6 +49,13 @@ public class PlugNicCommand extends Command {
         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() {
         return instanceName;
     }
@@ -53,4 +63,8 @@ public class PlugNicCommand extends Command {
     public VirtualMachine.Type getVMType() {
         return vmType;
     }
+
+    public Map<String, String> getDetails() {
+        return this.details;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43db75c3/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 609aa5b..387abda 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -148,6 +148,7 @@ import com.cloud.network.Network;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.offering.DiskOfferingInfo;
 import com.cloud.offering.ServiceOffering;
@@ -609,6 +610,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         } catch (InsufficientCapacityException e) {
             throw new CloudRuntimeException("Unable to start a VM due to insufficient capacity", e).add(VirtualMachine.class, vmUuid);
         } catch (ResourceUnavailableException e) {
+            if (e.getScope() != null && e.getScope().equals(VirtualRouter.class)) {
+                throw new CloudRuntimeException("Network is not available. Please contact admin.", e).add(VirtualMachine.class, vmUuid);
+            }
             throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid);
         }
     }
@@ -3399,7 +3403,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         VMInstanceVO router = _vmDao.findById(vm.getId());
         if (router.getState() == State.Running) {
             try {
-                PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType());
+                PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType(), vm.getDetails());
 
                 Commands cmds = new Commands(Command.OnError.Stop);
                 cmds.addCommand("plugnic", plugNicCmd);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43db75c3/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 315b161..0777201 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
@@ -916,8 +916,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 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;
+            Map details = cmd.getDetails();
+            if (details != null) {
+                nicDeviceType = VirtualEthernetCardType.valueOf((String) details.get("nicAdapter"));
+            }
 
             // find a usable device number in VMware environment
             VirtualDevice[] nicDevices = vmMo.getNicDevices();