mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4144: Add free vlan to shared network in TestVMLifeCycleSharedNwVPC
Shared network has to have specifyVlan = True. So changed it to True
and aded a function to get free vlan.
Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit 9ff40829a9)
This commit is contained in:
parent
aec21b3a36
commit
6c73308d0c
|
|
@ -115,8 +115,8 @@ class Services:
|
|||
"traffictype": 'GUEST',
|
||||
"availability": 'Optional',
|
||||
"useVpc": 'on',
|
||||
"specifyIpRanges": False,
|
||||
"specifyVlan": False
|
||||
"specifyIpRanges": True,
|
||||
"specifyVlan": True
|
||||
},
|
||||
"vpc_offering": {
|
||||
"name": 'VPC off',
|
||||
|
|
@ -863,9 +863,35 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
|
|||
)
|
||||
return
|
||||
|
||||
@unittest.skip("skipped - The setup of shared network is wrong, need to be fixed ")
|
||||
class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def getFreeVlan(cls, apiclient, zoneid):
|
||||
"""
|
||||
Find an unallocated VLAN outside the range allocated to the physical network.
|
||||
|
||||
@note: This does not guarantee that the VLAN is available for use in
|
||||
the deployment's network gear
|
||||
@return: physical_network, shared_vlan_tag
|
||||
"""
|
||||
list_physical_networks_response = PhysicalNetwork.list(
|
||||
apiclient,
|
||||
zoneid=zoneid
|
||||
)
|
||||
assert isinstance(list_physical_networks_response, list)
|
||||
assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
|
||||
|
||||
physical_network = list_physical_networks_response[0]
|
||||
vlans = xsplit(physical_network.vlan, ['-', ','])
|
||||
|
||||
assert len(vlans) > 0
|
||||
assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
|
||||
shared_ntwk_vlan = int(vlans[-1]) + random.randrange(1, 20)
|
||||
if shared_ntwk_vlan > 4095:
|
||||
shared_ntwk_vlan = int(vlans[0]) - random.randrange(1, 20)
|
||||
assert shared_ntwk_vlan > 0, "VLAN chosen %s is invalid < 0" % shared_ntwk_vlan
|
||||
return physical_network, shared_ntwk_vlan
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_client = super(
|
||||
|
|
@ -942,6 +968,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
|
|||
cls.services["network_offering_no_lb"],
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
cls.shared_nw_off = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_off_shared"],
|
||||
|
|
@ -950,6 +977,13 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
|
|||
# Enable Network offering
|
||||
cls.shared_nw_off.update(cls.api_client, state='Enabled')
|
||||
|
||||
|
||||
physical_network, shared_vlan = cls.getFreeVlan(cls.api_client, cls.zone.id)
|
||||
#create network using the shared network offering created
|
||||
cls.services["network"]["acltype"] = "Domain"
|
||||
cls.services["network"]["physicalnetworkid"] = physical_network.id
|
||||
cls.services["network"]["vlan"] = shared_vlan
|
||||
|
||||
# Creating network using the network offering created
|
||||
cls.network_2 = Network.create(
|
||||
cls.api_client,
|
||||
|
|
|
|||
Loading…
Reference in New Issue