incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke4...@apache.org
Subject [46/50] git commit: CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Date Sun, 27 May 2012 22:30:44 GMT
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Adding api to remove from a service policy
	(policy map) from a port profile.


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

Branch: refs/heads/master
Commit: 8d1b9c24779636b762336ab2be6030b4632ea500
Parents: ec19fac
Author: Devdeep Singh <devdeep.singh@citrix.com>
Authored: Fri May 11 15:33:11 2012 +0530
Committer: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Committed: Fri May 25 17:36:48 2012 -0700

----------------------------------------------------------------------
 .../cloud/utils/cisco/n1kv/vsm/NetconfHelper.java  |   15 ++++++++-
 .../com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java |   27 +++++++++++----
 2 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8d1b9c24/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
index cc5b287..a81b1c3 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
@@ -135,7 +135,7 @@ public class NetconfHelper {
 
     public void attachServicePolicy(String policyMap, String portProfile)
             throws CloudRuntimeException {
-        String command = VsmCommand.getAttachServicePolicy(policyMap, portProfile);
+        String command = VsmCommand.getServicePolicy(policyMap, portProfile, true);
         if (command != null) {
             command = command.concat(SSH_NETCONF_TERMINATOR);
             send(command);
@@ -146,6 +146,19 @@ public class NetconfHelper {
         }
     }
 
+    public void detachServicePolicy(String policyMap, String portProfile)
+            throws CloudRuntimeException {
+        String command = VsmCommand.getServicePolicy(policyMap, portProfile, false);
+        if (command != null) {
+            command = command.concat(SSH_NETCONF_TERMINATOR);
+            send(command);
+            // parse the rpc reply.
+            parseReply(receive());
+        } else {
+            throw new CloudRuntimeException("Error generating rpc request for removing policy
map.");
+        }
+    }
+
     private void exchangeHello() {
         String ack = receive();
         String hello = VsmCommand.getHello() + SSH_NETCONF_TERMINATOR;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8d1b9c24/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
index 2b2a73c..abf902b 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
@@ -221,7 +221,7 @@ public class VsmCommand {
         }
     }
 
-    public static String getAttachServicePolicy(String policyMap, String portProfile) {
+    public static String getServicePolicy(String policyMap, String portProfile, boolean attach)
{
         try {
             // Create the document and root element.
             DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
@@ -241,7 +241,7 @@ public class VsmCommand {
 
             // Command to create the port profile with the desired configuration.
             Element config = doc.createElement("nf:config");
-            config.appendChild(attachServiceDetails(doc, policyMap, portProfile));
+            config.appendChild(serviceDetails(doc, policyMap, portProfile, attach));
             editConfig.appendChild(config);
 
             return serialize(domImpl, doc);
@@ -511,7 +511,8 @@ public class VsmCommand {
         return configure;
     }
 
-    private static Element attachServiceDetails(Document doc, String policyMap, String portProfile)
{
+    private static Element serviceDetails(Document doc, String policyMap,
+            String portProfile, boolean attach) {
         // In mode, exec_configure.
         Element configure = doc.createElementNS(s_ciscons, "nxos:configure");
         Element modeConfigure = doc.createElement("nxos:" + s_configuremode);
@@ -535,11 +536,23 @@ public class VsmCommand {
         Element portProfMode = doc.createElement(s_portprofmode);
         portDetails.appendChild(portProfMode);
 
-        // Associate the policy for input.
-        portProfMode.appendChild(getServicePolicyCmd(doc, policyMap, "input"));
+        // Associate/Remove the policy for input.
+        if (attach) {
+            portProfMode.appendChild(getServicePolicyCmd(doc, policyMap, "input"));
+        } else {
+            Element detach = doc.createElement("no");
+            portProfMode.appendChild(detach);
+            detach.appendChild(getServicePolicyCmd(doc, policyMap, "input"));
+        }
 
-        // Associate the policy for output.
-        portProfMode.appendChild(getServicePolicyCmd(doc, policyMap, "output"));
+        // Associate/Remove the policy for output.
+        if (attach) {
+            portProfMode.appendChild(getServicePolicyCmd(doc, policyMap, "output"));
+        } else {
+            Element detach = doc.createElement("no");
+            portProfMode.appendChild(detach);
+            detach.appendChild(getServicePolicyCmd(doc, policyMap, "output"));
+        }
 
         // Persist the configuration across reboots.
         modeConfigure.appendChild(persistConfiguration(doc));


Mime
View raw message