Repository: cloudstack
Updated Branches:
  refs/heads/4.3 14287f7d3 -> 7d17e9599


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 <[email protected]>


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

Branch: refs/heads/4.3
Commit: 7d17e95991035beeb802483a4b3d98df0dc9c8e8
Parents: 14287f7
Author: Sudhansu <[email protected]>
Authored: Fri Nov 28 16:31:08 2014 +0530
Committer: Rajani Karuturi <[email protected]>
Committed: Mon Dec 8 16:41:19 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/7d17e959/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 211edde..0094416 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
@@ -422,7 +422,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);
@@ -436,8 +436,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);
                                }
                        }
@@ -507,7 +509,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));
 
@@ -524,7 +526,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);
@@ -577,6 +579,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>();
@@ -592,6 +597,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 {
@@ -680,7 +706,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);
                                }       
 
@@ -698,9 +724,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>();
@@ -716,6 +745,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();
@@ -842,7 +893,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>();
@@ -906,6 +960,28 @@ public class F5BigIpResource implements ServerResource {
 
                        return lbPools;
                } catch (RemoteException e) {
+            throw new ExecutionException(e.getMessage());
+        }
+    }
+
+    //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());
                }
        }

Reply via email to