mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
CLOUDSTACK-6888: Read postable IP configuration from config
This commit is contained in:
parent
887f027a9a
commit
8e0aba4609
@ -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
|
||||
|
||||
@ -63,7 +63,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 *
|
||||
@ -1147,3 +1147,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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user