You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2013/08/19 20:12:37 UTC
git commit: updated refs/heads/4.2 to e2710f8
Updated Branches:
refs/heads/4.2 a2951b57b -> e2710f8bc
CLOUDSTACK-4176
hot unplug NIC in VR when there is no ips on this NIC
Author: Jayapal Reddy Uradi <ja...@citrix.com>
Reviewed-by: Anthony
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e2710f8b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e2710f8b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e2710f8b
Branch: refs/heads/4.2
Commit: e2710f8bc59332df21789ed57c764d70a15206a9
Parents: a2951b5
Author: Anthony Xu <an...@citrix.com>
Authored: Mon Aug 19 11:09:46 2013 -0700
Committer: Anthony Xu <an...@citrix.com>
Committed: Mon Aug 19 11:09:46 2013 -0700
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 35 ++++++++++++++++++++
.../debian/config/opt/cloud/bin/ipassoc.sh | 18 +++++++++-
.../kvm/resource/LibvirtComputingResource.java | 33 ++++++++++++++++++
.../xen/resource/CitrixResourceBase.java | 12 +++++++
4 files changed, 97 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e2710f8b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 1fb86e0..ec8bc8d 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -1002,6 +1002,41 @@ public class VirtualRoutingResource implements Manager {
return routerProxy("ipassoc.sh", privateIpAddress, args);
}
+
+ public String checkPublicIpsCount(final String vmName,
+ final String privateIpAddress, final String publicIpAddress,
+ final boolean firstIP, final boolean sourceNat,
+ final String vlanId, final String vlanGateway,
+ final String vlanNetmask, final String vifMacAddress, int nicNum, boolean newNic){
+
+ String args = "";
+ args += "-D";
+
+ String cidrSize = Long.toString(NetUtils.getCidrSize(vlanNetmask));
+ if (sourceNat) {
+ args +=" -s";
+ }
+ if (firstIP) {
+ args += " -f";
+ }
+ args += " -l ";
+ args += publicIpAddress + "/" + cidrSize;
+
+ String publicNic = "eth" + nicNum;
+ args += " -c ";
+ args += publicNic;
+
+ args +=" -g ";
+ args += vlanGateway;
+
+ if (newNic) {
+ args += " -n";
+ }
+ args += " -d";
+
+ return routerProxy("ipassoc.sh", privateIpAddress, args);
+
+ }
private void deleteBridge(String brName) {
Script cmd = new Script("/bin/sh", _timeout);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e2710f8b/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh b/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
index ae2d7e4..0b1bfba 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/ipassoc.sh
@@ -332,6 +332,14 @@ enable_rpsrfs() {
fi
}
+
+check_for_iface_numof_ips () {
+ ip addr show $ethDev | grep 'inet '
+ return $?
+}
+
+
+
#set -x
sflag=0
lflag=
@@ -358,7 +366,7 @@ then
if_keep_state=1
fi
-while getopts 'sfADna:l:c:g:' OPTION
+while getopts 'sfADdna:l:c:g:' OPTION
do
case $OPTION in
A) Aflag=1
@@ -382,6 +390,8 @@ do
;;
n) nflag=1
;;
+ d) dflag=1
+ ;;
?) usage
unlock_exit 2 $lock $locked
;;
@@ -401,6 +411,12 @@ then
unlock_exit 2 $lock $locked
fi
+ if [ "$Dflag" == "1" ] && [ "$dflag" == "1" ]
+ then
+ check_for_iface_numof_ips
+ unlock_exit $? $lock $locked
+
+ fi
if [ "$Aflag" == "1" ] && [ "$nflag" == "1" ]
then
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e2710f8b/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 9104504..8d00cb7 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
@@ -1722,6 +1722,25 @@ ServerResource {
return new Answer(cmd, true, result);
}
+ private void vifHotUnPlug (Connect conn, String vmName, String vlanId,
+ String macAddr) throws InternalErrorException, LibvirtException {
+
+ Domain vm = null;
+ conn = LibvirtConnection.getConnectionByVmName(vmName);
+ 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 vlanId,
String macAddr) throws InternalErrorException, LibvirtException {
NicTO nicTO = new NicTO();
@@ -2043,6 +2062,20 @@ ServerResource {
} else {
results[i++] = ip.getPublicIp() + " - success";
;
+
+ if (!ip.isAdd()) {
+ result = _virtRouterResource.checkPublicIpsCount(routerName,
+ routerIp, ip.getPublicIp(), ip.isFirstIP(),
+ ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(),
+ ip.getVlanNetmask(), ip.getVifMacAddress(), nicNum, newNic);
+
+ if (result != null) {
+ // There are no ips on the vm so delete the vif
+ networkUsage(routerIp, "deleteVif", "eth" + nicNum);
+ vifHotUnPlug(conn, routerName, ip.getVlanId(),
+ ip.getVifMacAddress());
+ }
+ }
}
}
return new IpAssocAnswer(cmd, results);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e2710f8b/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 338e741..4de9ab9 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
@@ -2352,6 +2352,18 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
throw new InternalErrorException("Xen plugin \"ipassoc\" failed.");
}
+ if (!add) {
+ args += " -d";
+ String zeroIpsRes = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
+ if (zeroIpsRes == null || zeroIpsRes.isEmpty()) {
+ //There are no ip address set on the interface. So unplug the interface
+ // If it is not unplugged then the interface is not resuable.
+ removeVif = true;
+ }
+ }
+
+
+
if (removeVif) {
network = correctVif.getNetwork(conn);