Repository: cloudstack Updated Branches: refs/heads/4.4-forward 43e479d23 -> 49467f295
CLOUDSTACK-6888: Read postable IP configuration from config Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/49467f29 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/49467f29 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/49467f29 Branch: refs/heads/4.4-forward Commit: 49467f295410f1f0e265e7ce5ee6dd849207c3e8 Parents: 43e479d Author: Girish Shilamkar <[email protected]> Authored: Fri Jun 13 09:38:16 2014 +0530 Committer: Girish Shilamkar <[email protected]> Committed: Fri Jun 13 09:38:16 2014 +0530 ---------------------------------------------------------------------- test/integration/component/test_portable_ip.py | 51 +++++++++------------ tools/marvin/marvin/lib/common.py | 37 ++++++++++++++- 2 files changed, 58 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49467f29/test/integration/component/test_portable_ip.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_portable_ip.py b/test/integration/component/test_portable_ip.py index 77a5ab6..538318d 100644 --- a/test/integration/component/test_portable_ip.py +++ b/test/integration/component/test_portable_ip.py @@ -37,10 +37,11 @@ from marvin.lib.common import (get_zone, get_domain, get_region, get_pod, - isIpInDesiredState) + isIpInDesiredState, + getPortableIpRangeServices) from netaddr import IPAddress from marvin.sshClient import SshClient - +from marvin.codes import FAILED from nose.plugins.attrib import attr class Services: @@ -142,15 +143,7 @@ class Services: "publicport": 22, "protocol": 'TCP', }, - "ostype": 'CentOS 5.3 (64-bit)', - "portableIpRange": { - "gateway" : "10.223.252.195", - "netmask" : "255.255.255.192", - "startip" : "10.223.252.196", - "endip" : "10.223.252.197", - "vlan" : "1001" - } - + "ostype": 'CentOS 5.3 (64-bit)' } class TestCreatePortablePublicIpRanges(cloudstackTestCase): @@ -208,8 +201,8 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase): # 1. Create new portable ip range with root admin api # 2. Portable ip range should be created successfully - portable_ip_range_services = self.services["portableIpRange"] - if portable_ip_range_services is None: + portable_ip_range_services = getPortableIpRangeServices(self.config) + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') portable_ip_range_services["regionid"] = self.region.id @@ -231,9 +224,9 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase): # 1. Create new portable ip range with non root admin api client # 2. Portable ip range should not be created - portable_ip_range_services = self.services["portableIpRange"] + portable_ip_range_services = getPortableIpRangeServices(self.config) - if portable_ip_range_services is None: + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') try: @@ -267,9 +260,9 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase): # 1. Try to create new portable ip range with invalid region id # 2. Portable ip range creation should fail - portable_ip_range_services = self.services["portableIpRange"] + portable_ip_range_services = getPortableIpRangeServices(self.config) - if portable_ip_range_services is None: + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') portable_ip_range_services["regionid"] = -1 @@ -321,9 +314,9 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() - portable_ip_range_services = self.services["portableIpRange"] + portable_ip_range_services = getPortableIpRangeServices(self.config) - if portable_ip_range_services is None: + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') portable_ip_range_services["regionid"] = self.region.id @@ -480,9 +473,9 @@ class TestListPortablePublicIpRanges(cloudstackTestCase): self.dbclient = self.testClient.getDbConnection() #create new portable ip range - self.portable_ip_range_services = self.services["portableIpRange"] + self.portable_ip_range_services = getPortableIpRangeServices(self.config) - if self.portable_ip_range_services is None: + if self.portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') self.portable_ip_range_services["regionid"] = self.region.id @@ -643,9 +636,9 @@ class TestAssociatePublicIp(cloudstackTestCase): self.cleanup = [] - portable_ip_range_services = self.services["portableIpRange"] + portable_ip_range_services = getPortableIpRangeServices(self.config) - if portable_ip_range_services is None: + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') portable_ip_range_services["regionid"] = self.region.id @@ -978,9 +971,9 @@ class TestDisassociatePublicIp(cloudstackTestCase): self.dbclient = self.testClient.getDbConnection() self.cleanup = [] - portable_ip_range_services = self.services["portableIpRange"] + portable_ip_range_services = getPortableIpRangeServices(self.config) - if portable_ip_range_services is None: + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') portable_ip_range_services["regionid"] = self.region.id @@ -1172,8 +1165,8 @@ class TestDeleteAccount(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() - portable_ip_range_services = self.services["portableIpRange"] - if portable_ip_range_services is None: + portable_ip_range_services = getPortableIpRangeServices(self.config) + if portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') self.cleanup = [] @@ -1432,9 +1425,9 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase): self.dbclient = self.testClient.getDbConnection() #create new portable ip range - self.portable_ip_range_services = self.services["portableIpRange"] + self.portable_ip_range_services = getPortableIpRangeServices(self.config) - if self.portable_ip_range_services is None: + if self.portable_ip_range_services is FAILED: self.skipTest('Failed to read config values related to portable ip range') self.portable_ip_range_services["regionid"] = self.region.id http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49467f29/tools/marvin/marvin/lib/common.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py index 91fe053..7753385 100644 --- a/tools/marvin/marvin/lib/common.py +++ b/tools/marvin/marvin/lib/common.py @@ -61,7 +61,7 @@ from marvin.cloudstackAPI import (listConfigurations, from marvin.sshClient import SshClient from marvin.codes import (PASS, ISOLATED_NETWORK, VPC_NETWORK, - BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE) + BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE, FAILED) import random from marvin.lib.utils import * from marvin.lib.base import * @@ -1187,3 +1187,38 @@ def createNetworkRulesForVM(apiclient, virtualmachine, ruletype, except Exception as e: [FAIL, e] return [PASS, public_ip] + +def getPortableIpRangeServices(config): + """ Reads config values related to portable ip and fills up + services accordingly""" + + services = {} + attributeError = False + + if config.portableIpRange.startip: + services["startip"] = config.portableIpRange.startip + else: + attributeError = True + + if config.portableIpRange.endip: + services["endip"] = config.portableIpRange.endip + else: + attributeError = True + + if config.portableIpRange.netmask: + services["netmask"] = config.portableIpRange.netmask + else: + attributeError = True + + if config.portableIpRange.gateway: + services["gateway"] = config.portableIpRange.gateway + else: + attributeError = True + + if config.portableIpRange.vlan: + services["vlan"] = config.portableIpRange.vlan + + if attributeError: + services = FAILED + + return services
