VPC,  implement plug/unplug nic

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

Branch: refs/heads/vpc
Commit: daf1aa4b926e2869b58be9975bd8c6c25f0b3fff
Parents: 7297483
Author: anthony <[email protected]>
Authored: Tue Jun 5 15:38:25 2012 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Fri Jun 15 14:22:29 2012 -0700

----------------------------------------------------------------------
 .../xen/resource/CitrixResourceBase.java           |   47 +++++++++++++-
 .../debian/config/etc/iptables/iptables-router     |    2 -
 wscript                                            |    2 +-
 3 files changed, 44 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/daf1aa4b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java 
b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 2605b2e..4a61633 100644
--- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -6973,8 +6973,31 @@ public abstract class CitrixResourceBase implements 
ServerResource, HypervisorRe
      * @return
      */
     private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
-        // TODO Auto-generated method stub
-        return null;
+        Connection conn = getConnection();
+        VirtualMachineTO vmto = cmd.getVirtualMachine();
+        String vmName = vmto.getName();
+        try {
+            Set<VM> vms = VM.getByNameLabel(conn, vmName);
+            if ( vms == null || vms.isEmpty() ) {
+                return new UnPlugNicAnswer(cmd, false, "Can not find VM " + 
vmName);
+            }
+            VM vm = vms.iterator().next();
+            NicTO nic = cmd.getNic();
+            String mac = nic.getMac();
+            for ( VIF vif : vm.getVIFs(conn)) {
+                String lmac = vif.getMAC(conn);
+                if ( lmac.equals(mac) ) {
+                    vif.unplug(conn);
+                    vif.destroy(conn);
+                    break;
+                }
+            }
+            return new UnPlugNicAnswer(cmd, true, "success");
+        } catch (Exception e) {
+            String msg = " UnPlug Nic failed due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new UnPlugNicAnswer(cmd, false, msg);
+        }
     }
 
     /**
@@ -6982,8 +7005,24 @@ public abstract class CitrixResourceBase implements 
ServerResource, HypervisorRe
      * @return
      */
     private PlugNicAnswer execute(PlugNicCommand cmd) {
-        // TODO Auto-generated method stub
-        return null;
+        Connection conn = getConnection();
+        VirtualMachineTO vmto = cmd.getVirtualMachine();
+        String vmName = vmto.getName();
+        try {
+            Set<VM> vms = VM.getByNameLabel(conn, vmName);
+            if ( vms == null || vms.isEmpty() ) {
+                return new PlugNicAnswer(cmd, false, "Can not find VM " + 
vmName);
+            }
+            VM vm = vms.iterator().next();
+            NicTO nic = cmd.getNic();
+            VIF vif = createVif(conn, vmName, vm, nic);
+            vif.plug(conn);
+            return new PlugNicAnswer(cmd, true, "success");
+        } catch (Exception e) {
+            String msg = " Plug Nic failed due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new PlugNicAnswer(cmd, false, msg);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/daf1aa4b/patches/systemvm/debian/config/etc/iptables/iptables-router
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/iptables/iptables-router 
b/patches/systemvm/debian/config/etc/iptables/iptables-router
index ac40ed4..193d54f 100644
--- a/patches/systemvm/debian/config/etc/iptables/iptables-router
+++ b/patches/systemvm/debian/config/etc/iptables/iptables-router
@@ -10,8 +10,6 @@ COMMIT
 -A INPUT -d 224.0.0.18/32 -j ACCEPT
 -A INPUT -d 225.0.0.50/32 -j ACCEPT
 -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
--A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
--A INPUT -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
 -A INPUT -p icmp -j ACCEPT
 -A INPUT -i lo -j ACCEPT
 -A INPUT -i eth0 -p tcp -m state --state NEW --dport 3922 -j ACCEPT

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/daf1aa4b/wscript
----------------------------------------------------------------------
diff --git a/wscript b/wscript
index d38cc11..e41b860 100644
--- a/wscript
+++ b/wscript
@@ -4,7 +4,7 @@
 # the following two variables are used by the target "waf dist"
 # if you change 'em here, you need to change it also in cloud.spec, add a 
%changelog entry there, and add an entry in debian/changelog
 
-VERSION = '3.0.3.2012-06-05T18:30:03Z'
+VERSION = '3.0.3.2012-06-05T22:35:08Z'
 APPNAME = 'cloud'
 
 import shutil,os

Reply via email to