cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject git commit: updated refs/heads/4.5 to 0347b2f
Date Mon, 08 Dec 2014 11:00:14 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.5 57a210ede -> 0347b2f5f


CLOUDSTACK-7986 [F5 LB] Failed to execute IPAssocCommand due to com.cloud.utils.exception.ExecutionException:
Exception caught in Networking::urn:iControl:Networking/VLAN::create()

added 3 new method to strip partition information from VirtualServer, LBPool, VLAN api response.

With BigIP V11.x VirtualServer, LBPool, VLAN api response has been modified.
Now BigIP returns resource  name with user partition information
ex: if vlanname is vlan-100 then the get_list() will return /Common/vlan-100 (/Common ->
Suer portition)
This method will strip the partition information and only returns a list with vlan name (vlan-100)

Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>


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

Branch: refs/heads/4.5
Commit: 0347b2f5f333c38ed1395d31fe26b3d5f6a9d6ab
Parents: 57a210e
Author: Sudhansu <sudhansu.sahu@citrix.com>
Authored: Fri Nov 28 16:31:08 2014 +0530
Committer: Rajani Karuturi <rajanikaruturi@gmail.com>
Committed: Mon Dec 8 15:46:58 2014 +0530

----------------------------------------------------------------------
 .../cloud/network/resource/F5BigIpResource.java | 92 ++++++++++++++++++--
 1 file changed, 84 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0347b2f5/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
b/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
index e797bac..0f70a9b 100644
--- a/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
+++ b/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
@@ -420,7 +420,7 @@ public class F5BigIpResource implements ServerResource {
     private void addGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask, boolean
inline) throws ExecutionException {
         try {
             String vlanName = genVlanName(vlanTag);
-            List<String> allVlans = getVlans();
+            List<String> allVlans = getStrippedVlans();
             if (!allVlans.contains(vlanName)) {
                 String[] vlanNames = genStringArray(vlanName);
                 long[] vlanTags = genLongArray(vlanTag);
@@ -434,8 +434,10 @@ public class F5BigIpResource implements ServerResource {
 
                 s_logger.debug("Creating a guest VLAN with tag " + vlanTag);
                 _vlanApi.create(vlanNames, vlanTags, vlanMemberEntries, commonEnabledState,
new long[] {10L}, new String[] {"00:00:00:00:00:00"});
+                s_logger.debug("vlanName " + vlanName);
+                s_logger.debug("getStrippedVlans " + getStrippedVlans());
 
-                if (!getVlans().contains(vlanName)) {
+                if (!getStrippedVlans().contains(vlanName)) {
                     throw new ExecutionException("Failed to create vlan with tag " + vlanTag);
                 }
             }
@@ -505,7 +507,7 @@ public class F5BigIpResource implements ServerResource {
             }
 
             String vlanName = genVlanName(vlanTag);
-            List<String> allVlans = getVlans();
+            List<String> allVlans = getStrippedVlans();
             if (allVlans.contains(vlanName)) {
                 _vlanApi.delete_vlan(genStringArray(vlanName));
 
@@ -522,7 +524,7 @@ public class F5BigIpResource implements ServerResource {
         vlanSelfIp = stripRouteDomainFromAddress(vlanSelfIp);
         List<String> virtualServersToDelete = new ArrayList<String>();
 
-        List<String> allVirtualServers = getVirtualServers();
+        List<String> allVirtualServers = getStrippedVirtualServers();
         for (String virtualServerName : allVirtualServers) {
             // Check if the virtual server's default pool has members in this guest VLAN
             List<String> poolMembers = getMembers(virtualServerName);
@@ -576,6 +578,9 @@ public class F5BigIpResource implements ServerResource {
         }
     }
 
+    //This was working with Big IP 10.x
+    //getVlans retuns vlans with user partition information
+    //ex: if vlanname is vlan-100 then the get_list() will return /Common/vlan-100
     private List<String> getVlans() throws ExecutionException {
         try {
             List<String> vlans = new ArrayList<String>();
@@ -591,6 +596,27 @@ public class F5BigIpResource implements ServerResource {
         }
     }
 
+    //getVlans retuns vlan names without user partition information
+    //ex: if vlanname is vlan-100 then the get_list() will return /Common/vlan-100
+    // This method will strip the partition information and only returns a list with vlan
name (vlan-100)
+    private List<String> getStrippedVlans() throws ExecutionException {
+        try {
+            List<String> vlans = new ArrayList<String>();
+            String[] vlansArray = _vlanApi.get_list();
+
+            for (String vlan : vlansArray) {
+                if(vlan.contains("/")){
+                    vlans.add(vlan.substring(vlan.lastIndexOf("/") + 1));
+                }else{
+                    vlans.add(vlan);
+                }
+            }
+
+            return vlans;
+        } catch (RemoteException e) {
+            throw new ExecutionException(e.getMessage());
+        }
+    }
     // Login
 
     private void login() throws ExecutionException {
@@ -681,7 +707,7 @@ public class F5BigIpResource implements ServerResource {
                 s_logger.debug("Deleting virtual server " + virtualServerName);
                 _virtualServerApi.delete_virtual_server(genStringArray(virtualServerName));
 
-                if (getVirtualServers().contains(virtualServerName)) {
+                if (getStrippedVirtualServers().contains(virtualServerName)) {
                     throw new ExecutionException("Failed to delete virtual server " + virtualServerName);
                 }
 
@@ -699,9 +725,12 @@ public class F5BigIpResource implements ServerResource {
     }
 
     private boolean virtualServerExists(String virtualServerName) throws ExecutionException
{
-        return getVirtualServers().contains(virtualServerName);
+        return getStrippedVirtualServers().contains(virtualServerName);
     }
 
+    //This was working with Big IP 10.x
+    //getVirtualServers retuns VirtualServers with user partition information
+    //ex: if VirtualServers is vs-tcp-10.147.44.8-22 then the get_list() will return /Common/vs-tcp-10.147.44.8-22
     private List<String> getVirtualServers() throws ExecutionException {
         try {
             List<String> virtualServers = new ArrayList<String>();
@@ -717,6 +746,28 @@ public class F5BigIpResource implements ServerResource {
         }
     }
 
+/*    getStrippedVirtualServers retuns VirtualServers without user partition information
+    ex: if VirtualServers is vs-tcp-10.147.44.8-22 then the get_list() will return /Common/vs-tcp-10.147.44.8-22
+    This method will strip the partition information and only returns a list with VirtualServers
(vs-tcp-10.147.44.8-22)*/
+    private List<String> getStrippedVirtualServers() throws ExecutionException {
+        try {
+            List<String> virtualServers = new ArrayList<String>();
+            String[] virtualServersArray = _virtualServerApi.get_list();
+
+            for (String virtualServer : virtualServersArray) {
+                if(virtualServer.contains("/")){
+                    virtualServers.add(virtualServer.substring(virtualServer.lastIndexOf("/")
+ 1));
+                }else{
+                    virtualServers.add(virtualServer);
+                }
+            }
+
+            return virtualServers;
+        } catch (RemoteException e) {
+            throw new ExecutionException(e.getMessage());
+        }
+    }
+
     private boolean persistenceProfileExists(String profileName) throws ExecutionException
{
         try {
             String[] persistenceProfileArray = _persistenceProfileApi.get_list();
@@ -843,7 +894,7 @@ public class F5BigIpResource implements ServerResource {
     private void deletePoolMember(String virtualServerName, String destIp, int destPort)
throws ExecutionException {
         try {
             String memberIdentifier = destIp + "-" + destPort;
-            List<String> lbPools = getAllLbPools();
+            List<String> lbPools = getAllStrippedLbPools();
 
             if (lbPools.contains(virtualServerName) && memberExists(virtualServerName,
memberIdentifier)) {
                 s_logger.debug("Deleting member " + memberIdentifier + " from pool for virtual
server " + virtualServerName);
@@ -880,7 +931,7 @@ public class F5BigIpResource implements ServerResource {
     }
 
     private boolean poolExists(String poolName) throws ExecutionException {
-        return getAllLbPools().contains(poolName);
+        return getAllStrippedLbPools().contains(poolName);
     }
 
     private boolean memberExists(String poolName, String memberIdentifier) throws ExecutionException
{
@@ -895,6 +946,9 @@ public class F5BigIpResource implements ServerResource {
         return memberIdentifier.split("-");
     }
 
+    //This was working with Big IP 10.x
+    //getAllLbPools retuns LbPools with user partition information
+    //ex: if LbPools is vs-tcp-10.147.44.8-22 then the get_list() will return /Common/vs-tcp-10.147.44.8-22
     public List<String> getAllLbPools() throws ExecutionException {
         try {
             List<String> lbPools = new ArrayList<String>();
@@ -910,6 +964,28 @@ public class F5BigIpResource implements ServerResource {
         }
     }
 
+    //Big IP 11.x
+    //getAllLbPools retuns LbPools without user partition information
+    //ex: if LbPools is vs-tcp-10.147.44.8-22 then the get_list() will return /Common/vs-tcp-10.147.44.8-22
+    //This method will strip the partition information and only returns a list with LbPools
(vs-tcp-10.147.44.8-22)
+    public List<String> getAllStrippedLbPools() throws ExecutionException {
+        try {
+            List<String> lbPools = new ArrayList<String>();
+            String[] pools = _loadbalancerApi.get_list();
+
+            for (String pool : pools) {
+                 if(pool.contains("/")){
+                    lbPools.add(pool.substring(pool.lastIndexOf("/") + 1));
+                }else{
+                    lbPools.add(pool);
+                }
+             }
+                return lbPools;
+            } catch (RemoteException e) {
+            throw new ExecutionException(e.getMessage());
+        }
+    }
+
     private List<String> getMembers(String virtualServerName) throws ExecutionException
{
         try {
             List<String> members = new ArrayList<String>();


Mime
View raw message