From e1e5e12aaa649c05f2d5bebe1bdaec00e284dcf0 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sat, 6 Dec 2014 05:54:39 +0530 Subject: [PATCH 1/3] CLOUDSTACK-6212: Let vm_instance table's ID field be unique and auto_increment `vm_instance` table's id column is unique but does not auto_increment like other resource tables. The fix simply alter the table's id column to have it auto_increment which may avoid id conflicts in a multi-master mysql setup. Signed-off-by: Rohit Yadav --- setup/db/db/schema-442to450.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql index d158c513e23..4469eccdfad 100644 --- a/setup/db/db/schema-442to450.sql +++ b/setup/db/db/schema-442to450.sql @@ -35,6 +35,7 @@ CREATE VIEW `cloud`.`storage_tag_view` AS ALTER TABLE `cloud`.`volumes` ADD COLUMN `provisioning_type` VARCHAR(32) NOT NULL DEFAULT 'thin' COMMENT 'pre allocation setting of the volume'; ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `provisioning_type` VARCHAR(32) NOT NULL DEFAULT 'thin' COMMENT 'pre allocation setting of the volume'; +ALTER TABLE `cloud`.`vm_instance` MODIFY id bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; DROP VIEW IF EXISTS `cloud`.`disk_offering_view`; CREATE VIEW `cloud`.`disk_offering_view` AS From a11ddf307747ef03785c27519fb535a36d4be145 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sat, 6 Dec 2014 06:26:31 +0530 Subject: [PATCH 2/3] CLOUDSTACK-6212: auto_increment for some other resource tables This fix alters table columns which are primary keys but don't have them auto_increment such as region, domain_router, user_vm etc. Signed-off-by: Rohit Yadav --- setup/db/db/schema-442to450.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql index 4469eccdfad..3981415f5d5 100644 --- a/setup/db/db/schema-442to450.sql +++ b/setup/db/db/schema-442to450.sql @@ -35,7 +35,15 @@ CREATE VIEW `cloud`.`storage_tag_view` AS ALTER TABLE `cloud`.`volumes` ADD COLUMN `provisioning_type` VARCHAR(32) NOT NULL DEFAULT 'thin' COMMENT 'pre allocation setting of the volume'; ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `provisioning_type` VARCHAR(32) NOT NULL DEFAULT 'thin' COMMENT 'pre allocation setting of the volume'; -ALTER TABLE `cloud`.`vm_instance` MODIFY id bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; + +-- Have primary keys of following table AUTO_INCREMENT +ALTER TABLE `cloud`.`region` MODIFY `id` int unsigned AUTO_INCREMENT UNIQUE NOT NULL; +ALTER TABLE `cloud`.`vm_instance` MODIFY `id` bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; +ALTER TABLE `cloud`.`user_vm` MODIFY `id` bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; +ALTER TABLE `cloud`.`domain_router` MODIFY `id` bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; +ALTER TABLE `cloud`.`service_offering` MODIFY `id` bigint unsigned AUTO_INCREMENT NOT NULL; +ALTER TABLE `cloud`.`load_balancing_rules` MODIFY `id` bigint unsigned AUTO_INCREMENT NOT NULL; +ALTER TABLE `cloud`.`port_forwarding_rules` MODIFY `id` bigint unsigned AUTO_INCREMENT NOT NULL; DROP VIEW IF EXISTS `cloud`.`disk_offering_view`; CREATE VIEW `cloud`.`disk_offering_view` AS From 0347b2f5f333c38ed1395d31fe26b3d5f6a9d6ab Mon Sep 17 00:00:00 2001 From: Sudhansu Date: Fri, 28 Nov 2014 16:31:08 +0530 Subject: [PATCH 3/3] 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 --- .../network/resource/F5BigIpResource.java | 92 +++++++++++++++++-- 1 file changed, 84 insertions(+), 8 deletions(-) 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 e797bac0fa5..0f70a9b5139 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 allVlans = getVlans(); + List 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 allVlans = getVlans(); + List allVlans = getStrippedVlans(); if (allVlans.contains(vlanName)) { _vlanApi.delete_vlan(genStringArray(vlanName)); @@ -522,7 +524,7 @@ public class F5BigIpResource implements ServerResource { vlanSelfIp = stripRouteDomainFromAddress(vlanSelfIp); List virtualServersToDelete = new ArrayList(); - List allVirtualServers = getVirtualServers(); + List allVirtualServers = getStrippedVirtualServers(); for (String virtualServerName : allVirtualServers) { // Check if the virtual server's default pool has members in this guest VLAN List 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 getVlans() throws ExecutionException { try { List vlans = new ArrayList(); @@ -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 getStrippedVlans() throws ExecutionException { + try { + List vlans = new ArrayList(); + 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 getVirtualServers() throws ExecutionException { try { List virtualServers = new ArrayList(); @@ -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 getStrippedVirtualServers() throws ExecutionException { + try { + List virtualServers = new ArrayList(); + 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 lbPools = getAllLbPools(); + List 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 getAllLbPools() throws ExecutionException { try { List lbPools = new ArrayList(); @@ -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 getAllStrippedLbPools() throws ExecutionException { + try { + List lbPools = new ArrayList(); + 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 getMembers(String virtualServerName) throws ExecutionException { try { List members = new ArrayList();