cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [11/50] git commit: updated refs/heads/4.3 to f304df0
Date Wed, 04 Jun 2014 23:50:23 GMT
CLOUDSTACK-6183: unplug the nic when all the ips of  public vlan range is removed


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

Branch: refs/heads/4.3
Commit: 7700a1b71622c1d45b2b54aa7444be5adc4fb8ab
Parents: 793a6a7
Author: Jayapal <jayapal@apache.org>
Authored: Thu Feb 27 18:39:37 2014 +0530
Committer: Jayapal <jayapal@apache.org>
Committed: Fri Feb 28 16:54:06 2014 +0530

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  | 31 ++++++++++++++++++++
 .../xen/resource/CitrixResourceBase.java        | 15 ++++++++--
 2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7700a1b7/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 34770e4..ab7b9b5 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1789,6 +1789,23 @@ ServerResource {
     	return new Answer(cmd, true, result);
     }
 
+    private void vifHotUnPlug (Connect conn, String vmName, String macAddr) throws InternalErrorException,
LibvirtException {
+
+        Domain vm = null;
+        vm = getDomain(conn, vmName);
+        List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
+        for (InterfaceDef pluggedNic : pluggedNics) {
+            if (pluggedNic.getMacAddress().equalsIgnoreCase(macAddr)) {
+                vm.detachDevice(pluggedNic.toString());
+                // We don't know which "traffic type" is associated with
+                // each interface at this point, so inform all vif drivers
+                for (VifDriver vifDriver : getAllVifDrivers()) {
+                    vifDriver.unplug(pluggedNic);
+                }
+            }
+        }
+    }
+
     private void VifHotPlug(Connect conn, String vmName, String broadcastUri,
             String macAddr) throws InternalErrorException, LibvirtException {
         NicTO nicTO = new NicTO();
@@ -2103,6 +2120,12 @@ ServerResource {
             String result = null;
             int nicNum = 0;
             boolean newNic = false;
+            int numOfIps = 0;
+
+            if (ips != null) {
+                numOfIps = ips.length;
+            }
+
             for (IpAddressTO ip : ips) {
                 if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) {
                     /* plug a vif into router */
@@ -2121,6 +2144,14 @@ ServerResource {
                 if (result == null) {
                     results[i++] = ip.getPublicIp() + " - success";
                 }
+
+                //there is only only ip in public subnet and it is deleted so unplug the
vif
+                if (numOfIps == 1 && !ip.isAdd()) {
+                    // There are no ips on the vm so delete the vif
+                    networkUsage(routerIp, "deleteVif", "eth" + nicNum);
+                    vifHotUnPlug(conn, routerName, ip.getVifMacAddress());
+                }
+
             }
             return new IpAssocAnswer(cmd, results);
         } catch (LibvirtException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7700a1b7/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index b398ca5..7199d28 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -2372,7 +2372,8 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
 
     protected void assignPublicIpAddress(Connection conn, String vmName, String privateIpAddress,
String publicIpAddress, boolean add, boolean firstIP,
-            boolean sourceNat, String vlanId, String vlanGateway, String vlanNetmask, String
vifMacAddress, Integer networkRate, TrafficType trafficType, String name) throws InternalErrorException
{
+            boolean sourceNat, String vlanId, String vlanGateway, String vlanNetmask, String
vifMacAddress, Integer networkRate, TrafficType trafficType, String name,
+            int numOfips) throws InternalErrorException {
 
         try {
             VM router = getVM(conn, vmName);
@@ -2463,6 +2464,11 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
                 throw new InternalErrorException("Xen plugin \"ipassoc\" failed.");
             }
 
+            //there is only only ip in public subnet and it is deleted so unplug the vif
+            if (numOfips == 1 && !add) {
+                removeVif = true;
+            }
+
             if (removeVif) {
                 network = correctVif.getNetwork(conn);
 
@@ -2564,14 +2570,19 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         Connection conn = getConnection();
         String[] results = new String[cmd.getIpAddresses().length];
         int i = 0;
+        int numOfIps = 0;
         String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         try {
             IpAddressTO[] ips = cmd.getIpAddresses();
+            if (ips != null) {
+                numOfIps = ips.length;
+            }
+
             for (IpAddressTO ip : ips) {
 
                 assignPublicIpAddress(conn, routerName, routerIp, ip.getPublicIp(), ip.isAdd(),
ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(),
-                        ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(),
ip.getNetworkRate(), ip.getTrafficType(), ip.getNetworkName());
+                        ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(),
ip.getNetworkRate(), ip.getTrafficType(), ip.getNetworkName(), numOfIps);
                 results[i++] = ip.getPublicIp() + " - success";
             }
         } catch (InternalErrorException e) {


Mime
View raw message