http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f3931993/test/integration/component/test_shared_networks.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_shared_networks.py b/test/integration/component/test_shared_networks.py index 4d71ed3..4492a3e 100644 --- a/test/integration/component/test_shared_networks.py +++ b/test/integration/component/test_shared_networks.py @@ -17,139 +17,140 @@ """ P1 tests for shared networks """ -# Import Local Modules from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase, unittest from marvin.lib.base import (Account, - Network, - NetworkOffering, - VirtualMachine, - Project, - PhysicalNetwork, - Domain, - StaticNATRule, - FireWallRule, - ServiceOffering, - PublicIPAddress) + Network, + NetworkOffering, + VirtualMachine, + Project, + PhysicalNetwork, + Domain, + StaticNATRule, + FireWallRule, + ServiceOffering, + PublicIPAddress) from marvin.lib.utils import (cleanup_resources, - validateList, - xsplit) + validateList) from marvin.lib.common import (get_domain, - get_zone, - get_template, - wait_for_cleanup, - get_free_vlan) -from marvin.codes import * + get_zone, + get_template, + wait_for_cleanup, + get_free_vlan) +from marvin.codes import PASS import random import netaddr + class Services: + """ Test shared networks """ def __init__(self): self.services = { - "domain": { - "name": "DOM", - }, - "project": { - "name": "Project", - "displaytext": "Test project", - }, - "account": { - "email": "[email protected]", - "firstname": "admin-XABU1", - "lastname": "admin-XABU1", - "username": "admin-XABU1", - # Random characters are appended for unique - # username - "password": "password", - }, - "service_offering": { - "name": "Tiny Instance", - "displaytext": "Tiny Instance", - "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 128, # In MBs - }, - "network_offering": { - "name": 'MySharedOffering', - "displaytext": 'MySharedOffering', - "guestiptype": 'Shared', - "supportedservices": 'Dhcp,Dns,UserData', - "specifyVlan" : "False", - "specifyIpRanges" : "False", - "traffictype": 'GUEST', - "serviceProviderList" : { - "Dhcp": 'VirtualRouter', - "Dns": 'VirtualRouter', - "UserData": 'VirtualRouter' - }, - }, - "network": { - "name": "MySharedNetwork - Test", - "displaytext": "MySharedNetwork", - "gateway" :"", - "netmask" :"255.255.255.0", - "startip" :"", - "endip" :"", - "acltype" : "Domain", - "scope":"all", - }, - "network1": { - "name": "MySharedNetwork - Test1", - "displaytext": "MySharedNetwork1", - "gateway" :"", - "netmask" :"255.255.255.0", - "startip" :"", - "endip" :"", - "acltype" : "Domain", - "scope":"all", - }, - "isolated_network_offering": { - "name": 'Network offering-VR services', - "displaytext": 'Network offering-VR services', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat', - "traffictype": 'GUEST', - "availability": 'Optional', - "serviceProviderList": { - "Dhcp": 'VirtualRouter', - "Dns": 'VirtualRouter', - "SourceNat": 'VirtualRouter', - "PortForwarding": 'VirtualRouter', - "Vpn": 'VirtualRouter', - "Firewall": 'VirtualRouter', - "Lb": 'VirtualRouter', - "UserData": 'VirtualRouter', - "StaticNat": 'VirtualRouter', - }, - }, - "isolated_network": { - "name": "Isolated Network", - "displaytext": "Isolated Network", - }, - "fw_rule": { - "startport": 22, - "endport": 22, - "cidr": '0.0.0.0/0', - }, - "virtual_machine": { - "displayname": "Test VM", - "username": "root", - "password": "password", - "ssh_port": 22, - "hypervisor": 'XenServer', - # Hypervisor type should be same as - # hypervisor type of cluster - "privateport": 22, - "publicport": 22, - "protocol": 'TCP', - }, - "ostype": 'CentOS 5.3 (64-bit)', - # Cent OS 5.3 (64 bit) - "timeout": 10, - "mode": 'advanced' - } + "domain": { + "name": "DOM", + }, + "project": { + "name": "Project", + "displaytext": "Test project", + }, + "account": { + "email": "[email protected]", + "firstname": "admin-XABU1", + "lastname": "admin-XABU1", + "username": "admin-XABU1", + # Random characters are appended for unique + # username + "password": "password", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, # in MHz + "memory": 128, # In MBs + }, + "network_offering": { + "name": 'MySharedOffering', + "displaytext": 'MySharedOffering', + "guestiptype": 'Shared', + "supportedservices": 'Dhcp,Dns,UserData', + "specifyVlan": "False", + "specifyIpRanges": "False", + "traffictype": 'GUEST', + "serviceProviderList": { + "Dhcp": 'VirtualRouter', + "Dns": 'VirtualRouter', + "UserData": 'VirtualRouter' + }, + }, + "network": { + "name": "MySharedNetwork - Test", + "displaytext": "MySharedNetwork", + "gateway": "", + "netmask": "255.255.255.0", + "startip": "", + "endip": "", + "acltype": "Domain", + "scope": "all", + }, + "network1": { + "name": "MySharedNetwork - Test1", + "displaytext": "MySharedNetwork1", + "gateway": "", + "netmask": "255.255.255.0", + "startip": "", + "endip": "", + "acltype": "Domain", + "scope": "all", + }, + "isolated_network_offering": { + "name": 'Network offering-VR services', + "displaytext": 'Network offering-VR services', + "guestiptype": 'Isolated', + "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat', + "traffictype": 'GUEST', + "availability": 'Optional', + "serviceProviderList": { + "Dhcp": 'VirtualRouter', + "Dns": 'VirtualRouter', + "SourceNat": 'VirtualRouter', + "PortForwarding": 'VirtualRouter', + "Vpn": 'VirtualRouter', + "Firewall": 'VirtualRouter', + "Lb": 'VirtualRouter', + "UserData": 'VirtualRouter', + "StaticNat": 'VirtualRouter', + }, + }, + "isolated_network": { + "name": "Isolated Network", + "displaytext": "Isolated Network", + }, + "fw_rule": { + "startport": 22, + "endport": 22, + "cidr": '0.0.0.0/0', + }, + "virtual_machine": { + "displayname": "Test VM", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + # Hypervisor type should be same as + # hypervisor type of cluster + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + }, + "ostype": 'CentOS 5.3 (64-bit)', + # Cent OS 5.3 (64 bit) + "timeout": 10, + "mode": 'advanced' + } + class TestSharedNetworks(cloudstackTestCase): @@ -163,22 +164,22 @@ class TestSharedNetworks(cloudstackTestCase): cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"] - ) + cls.api_client, + cls.services["service_offering"] + ) cls._cleanup = [ - cls.service_offering, - ] + cls.service_offering, + ] return @classmethod @@ -198,13 +199,19 @@ class TestSharedNetworks(cloudstackTestCase): # of each test case to avoid overlapping of ip addresses shared_network_subnet_number = random.randrange(1, 254) - self.services["network"]["gateway"] = "172.16." + str(shared_network_subnet_number) + ".1" - self.services["network"]["startip"] = "172.16." + str(shared_network_subnet_number) + ".2" - self.services["network"]["endip"] = "172.16." + str(shared_network_subnet_number) + ".20" + self.services["network"]["gateway"] = "172.16." + \ + str(shared_network_subnet_number) + ".1" + self.services["network"]["startip"] = "172.16." + \ + str(shared_network_subnet_number) + ".2" + self.services["network"]["endip"] = "172.16." + \ + str(shared_network_subnet_number) + ".20" - self.services["network1"]["gateway"] = "172.16." + str(shared_network_subnet_number + 1) + ".1" - self.services["network1"]["startip"] = "172.16." + str(shared_network_subnet_number + 1) + ".2" - self.services["network1"]["endip"] = "172.16." + str(shared_network_subnet_number + 1) + ".20" + self.services["network1"]["gateway"] = "172.16." + \ + str(shared_network_subnet_number + 1) + ".1" + self.services["network1"]["startip"] = "172.16." + \ + str(shared_network_subnet_number + 1) + ".2" + self.services["network1"]["endip"] = "172.16." + \ + str(shared_network_subnet_number + 1) + ".20" self.cleanup = [] self.cleanup_networks = [] @@ -221,26 +228,34 @@ class TestSharedNetworks(cloudstackTestCase): except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) - # below components is not a part of cleanup because to mandate the order and to cleanup network + # below components is not a part of cleanup because to mandate the + # order and to cleanup network try: for vm in self.cleanup_vms: - vm.delete(self.api_client) + vm.delete(self.api_client) except Exception as e: - raise Exception("Warning: Exception during virtual machines cleanup : %s" % e) + raise Exception( + "Warning: Exception during virtual machines cleanup : %s" % + e) try: for project in self.cleanup_projects: - project.delete(self.api_client) + project.delete(self.api_client) except Exception as e: - raise Exception("Warning: Exception during project cleanup : %s" % e) + raise Exception( + "Warning: Exception during project cleanup : %s" % + e) try: for account in self.cleanup_accounts: account.delete(self.api_client) except Exception as e: - raise Exception("Warning: Exception during account cleanup : %s" % e) + raise Exception( + "Warning: Exception during account cleanup : %s" % + e) - # Wait till all resources created are cleaned up completely and then attempt to delete domains + # Wait till all resources created are cleaned up completely and then + # attempt to delete domains wait_for_cleanup(self.api_client, ["account.cleanup.interval"]) try: @@ -254,7 +269,9 @@ class TestSharedNetworks(cloudstackTestCase): for domain in self.cleanup_domains: domain.delete(self.api_client) except Exception as e: - raise Exception("Warning: Exception during domain cleanup : %s" % e) + raise Exception( + "Warning: Exception during domain cleanup : %s" % + e) return @@ -278,57 +295,59 @@ class TestSharedNetworks(cloudstackTestCase): # 1. listAccounts name=admin-XABU1, state=enabled returns your account # 2. listPhysicalNetworks should return at least one active physical network # 3. listNetworkOfferings - name=mysharedoffering , should list offering in disabled state - # 4. listNetworkOfferings - name=mysharedoffering, should list enabled offering + # 4. listNetworkOfferings - name=mysharedoffering, should list enabled + # offering # Create an account self.account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.account.id, - listall=True - ) + self.api_client, + id=self.account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin Type account created: %s" % self.account.name) - # Verify that there should be at least one physical network present in zone. + # Verify that there should be at least one physical network present in + # zone. list_physical_networks_response = PhysicalNetwork.list( - self.api_client, - zoneid=self.zone.id - ) + self.api_client, + zoneid=self.zone.id + ) self.assertEqual( isinstance(list_physical_networks_response, list), True, "listPhysicalNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_physical_networks_response), 0, "listPhysicalNetworks should return at least one physical network." - ) + ) physical_network = list_physical_networks_response[0] @@ -339,60 +358,62 @@ class TestSharedNetworks(cloudstackTestCase): # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) + self.api_client, + self.services["network_offering"], + conservemode=False + ) # Verify that the network offering got created list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Disabled", "The network offering created should be bydefault disabled." - ) + ) # Update network offering state from disabled to enabled. NetworkOffering.update( - self.shared_network_offering, - self.api_client, - id=self.shared_network_offering.id, - state="enabled" - ) + self.shared_network_offering, + self.api_client, + id=self.shared_network_offering.id, + state="enabled" + ) # Verify that the state of the network offering is updated list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Enabled", "The network offering state should get updated to Enabled." - ) - self.debug("NetworkOffering created and enabled: %s" % self.shared_network_offering.id) + ) + self.debug( + "NetworkOffering created and enabled: %s" % + self.shared_network_offering.id) @attr(tags=["advanced", "advancedns"], required_hardware="false") def test_sharedNetworkOffering_02(self): @@ -412,57 +433,59 @@ class TestSharedNetworks(cloudstackTestCase): # Validations, # 1. listAccounts name=admin-XABU1, state=enabled returns your account # 2. listPhysicalNetworks should return at least one active physical network - # 3. createNetworkOffering fails - vlan should be specified in advanced zone + # 3. createNetworkOffering fails - vlan should be specified in advanced + # zone # Create an account self.account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.account.id, - listall=True - ) + self.api_client, + id=self.account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin type account created: %s" % self.account.name) - # Verify that there should be at least one physical network present in zone. + # Verify that there should be at least one physical network present in + # zone. list_physical_networks_response = PhysicalNetwork.list( - self.api_client, - zoneid=self.zone.id - ) + self.api_client, + zoneid=self.zone.id + ) self.assertEqual( isinstance(list_physical_networks_response, list), True, "listPhysicalNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_physical_networks_response), 0, "listPhysicalNetworks should return at least one physical network." - ) + ) physical_network = list_physical_networks_response[0] @@ -474,14 +497,16 @@ class TestSharedNetworks(cloudstackTestCase): try: # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) - self.fail("Network offering got created with vlan as False in advance mode and shared guest type, which is invalid case.") + self.api_client, + self.services["network_offering"], + conservemode=False + ) + self.fail( + "Network offering got created with vlan as False in advance mode and shared guest type, which is invalid case.") except Exception as e: - self.debug("Network Offering creation failed with vlan as False in advance mode and shared guest type. Exception: %s" % - e) + self.debug( + "Network Offering creation failed with vlan as False in advance mode and shared guest type. Exception: %s" % + e) @attr(tags=["advanced", "advancedns"], required_hardware="false") def test_sharedNetworkOffering_03(self): @@ -501,58 +526,59 @@ class TestSharedNetworks(cloudstackTestCase): # Validations, # 1. listAccounts name=admin-XABU1, state=enabled returns your account # 2. listPhysicalNetworks should return at least one active physical network - # 3. createNetworkOffering fails - ip ranges should be specified when creating shared network offering - + # 3. createNetworkOffering fails - ip ranges should be specified when + # creating shared network offering # Create an account self.account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.account.id, - listall=True - ) + self.api_client, + id=self.account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin Type account created: %s" % self.account.name) - # Verify that there should be at least one physical network present in zone. + # Verify that there should be at least one physical network present in + # zone. list_physical_networks_response = PhysicalNetwork.list( - self.api_client, - zoneid=self.zone.id - ) + self.api_client, + zoneid=self.zone.id + ) self.assertEqual( isinstance(list_physical_networks_response, list), True, "listPhysicalNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_physical_networks_response), 0, "listPhysicalNetworks should return at least one physical network." - ) + ) physical_network = list_physical_networks_response[0] @@ -564,14 +590,17 @@ class TestSharedNetworks(cloudstackTestCase): try: # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) - self.fail("Network offering got created with vlan as True and ip ranges as False in advance mode and with shared guest type, which is invalid case.") + self.api_client, + self.services["network_offering"], + conservemode=False + ) + self.fail( + "Network offering got created with vlan as True and ip ranges as False in advance mode and with shared guest type, which is invalid case.") except Exception as e: - self.debug("Network Offering creation failed with vlan as true and ip ranges as False in advance mode and with shared guest type.\ - Exception : %s" % e) + self.debug( + "Network Offering creation failed with vlan as true and ip ranges as False in advance mode and with shared guest type.\ + Exception : %s" % + e) @attr(tags=["advanced", "advancedns"], required_hardware="false") def test_createSharedNetwork_All(self): @@ -609,73 +638,74 @@ class TestSharedNetworks(cloudstackTestCase): # Create admin account self.admin_account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.admin_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.admin_account.id, - listall=True - ) + self.api_client, + id=self.admin_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin type account created: %s" % self.admin_account.name) # Create an user account self.user_account = Account.create( - self.api_client, - self.services["account"], - admin=False, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=False, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.user_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.user_account.id, - listall=True - ) + self.api_client, + id=self.user_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The user account created is not enabled." - ) + ) self.debug("User type account created: %s" % self.user_account.name) - physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id) + physical_network, shared_vlan = get_free_vlan( + self.api_client, self.zone.id) if shared_vlan is None: self.fail("Failed to get free vlan id for shared network") @@ -684,165 +714,180 @@ class TestSharedNetworks(cloudstackTestCase): self.services["network_offering"]["specifyVlan"] = "True" self.services["network_offering"]["specifyIpRanges"] = "True" - # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) - - + self.api_client, + self.services["network_offering"], + conservemode=False + ) # Verify that the network offering got created list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Disabled", "The network offering created should be bydefault disabled." - ) + ) - self.debug("Shared Network offering created: %s" % self.shared_network_offering.id) + self.debug( + "Shared Network offering created: %s" % + self.shared_network_offering.id) # Update network offering state from disabled to enabled. NetworkOffering.update( - self.shared_network_offering, - self.api_client, - id=self.shared_network_offering.id, - state="enabled" - ) + self.shared_network_offering, + self.api_client, + id=self.shared_network_offering.id, + state="enabled" + ) # Verify that the state of the network offering is updated list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Enabled", "The network offering state should get updated to Enabled." - ) + ) # create network using the shared network offering created self.services["network"]["acltype"] = "Domain" - self.services["network"]["networkofferingid"] = self.shared_network_offering.id + self.services["network"][ + "networkofferingid"] = self.shared_network_offering.id self.services["network"]["physicalnetworkid"] = physical_network.id self.services["network"]["vlan"] = shared_vlan self.network = Network.create( - self.api_client, - self.services["network"], - networkofferingid=self.shared_network_offering.id, - zoneid=self.zone.id, - ) + self.api_client, + self.services["network"], + networkofferingid=self.shared_network_offering.id, + zoneid=self.zone.id, + ) self.cleanup_networks.append(self.network) list_networks_response = Network.list( - self.api_client, - id=self.network.id - ) + self.api_client, + id=self.network.id + ) self.assertEqual( isinstance(list_networks_response, list), True, "listNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_networks_response), 0, "listNetworks returned empty list." - ) + ) self.assertEqual( list_networks_response[0].specifyipranges, True, - "The network is created with ip range but the flag is set to False." - ) + "The network is created with ip range but the flag is set to False.") - self.debug("Shared Network created for scope domain: %s" % self.network.id) + self.debug( + "Shared Network created for scope domain: %s" % + self.network.id) self.admin_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - networkids=self.network.id, - serviceofferingid=self.service_offering.id - ) + self.api_client, + self.services["virtual_machine"], + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) self.cleanup_vms.append(self.admin_account_virtual_machine) vms = VirtualMachine.list( - self.api_client, - id=self.admin_account_virtual_machine.id, - listall=True - ) + self.api_client, + id=self.admin_account_virtual_machine.id, + listall=True + ) self.assertEqual( isinstance(vms, list), True, "listVirtualMachines returned invalid object in response." - ) + ) self.assertNotEqual( len(vms), 0, "listVirtualMachines returned empty list." - ) + ) - self.debug("Virtual Machine created: %s" % self.admin_account_virtual_machine.id) + self.debug( + "Virtual Machine created: %s" % + self.admin_account_virtual_machine.id) - ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"]))) + ip_range = list( + netaddr.iter_iprange( + unicode( + self.services["network"]["startip"]), unicode( + self.services["network"]["endip"]))) if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range: - self.fail("Virtual machine ip should be from the ip range assigned to network created.") + self.fail( + "Virtual machine ip should be from the ip range assigned to network created.") self.user_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - accountid=self.user_account.name, - domainid=self.user_account.domainid, - serviceofferingid=self.service_offering.id, - networkids=self.network.id - ) + self.api_client, + self.services["virtual_machine"], + accountid=self.user_account.name, + domainid=self.user_account.domainid, + serviceofferingid=self.service_offering.id, + networkids=self.network.id + ) vms = VirtualMachine.list( - self.api_client, - id=self.user_account_virtual_machine.id, - listall=True - ) + self.api_client, + id=self.user_account_virtual_machine.id, + listall=True + ) self.assertEqual( isinstance(vms, list), True, "listVirtualMachines returned invalid object in response." - ) + ) self.assertNotEqual( len(vms), 0, "listVirtualMachines returned empty list." - ) + ) - self.debug("Virtual Machine created: %s" % self.user_account_virtual_machine.id) + self.debug( + "Virtual Machine created: %s" % + self.user_account_virtual_machine.id) - ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"]))) + ip_range = list( + netaddr.iter_iprange( + unicode( + self.services["network"]["startip"]), unicode( + self.services["network"]["endip"]))) if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range: - self.fail("Virtual machine ip should be from the ip range assigned to network created.") + self.fail( + "Virtual machine ip should be from the ip range assigned to network created.") @attr(tags=["advanced", "advancedns"], required_hardware="false") def test_createSharedNetwork_accountSpecific(self): @@ -880,73 +925,74 @@ class TestSharedNetworks(cloudstackTestCase): # Create admin account self.admin_account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.admin_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.admin_account.id, - listall=True - ) + self.api_client, + id=self.admin_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin type account created: %s" % self.admin_account.name) # Create an user account self.user_account = Account.create( - self.api_client, - self.services["account"], - admin=False, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=False, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.user_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.user_account.id, - listall=True - ) + self.api_client, + id=self.user_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The user account created is not enabled." - ) + ) self.debug("User type account created: %s" % self.user_account.name) - physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id) + physical_network, shared_vlan = get_free_vlan( + self.api_client, self.zone.id) if shared_vlan is None: self.fail("Failed to get free vlan id for shared network") @@ -957,141 +1003,151 @@ class TestSharedNetworks(cloudstackTestCase): # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) + self.api_client, + self.services["network_offering"], + conservemode=False + ) # Verify that the network offering got created list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Disabled", "The network offering created should be by default disabled." - ) + ) - self.debug("Shared Network Offering created: %s" % self.shared_network_offering.id) + self.debug( + "Shared Network Offering created: %s" % + self.shared_network_offering.id) # Update network offering state from disabled to enabled. NetworkOffering.update( - self.shared_network_offering, - self.api_client, - id=self.shared_network_offering.id, - state="enabled" - ) + self.shared_network_offering, + self.api_client, + id=self.shared_network_offering.id, + state="enabled" + ) # Verify that the state of the network offering is updated list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Enabled", "The network offering state should get updated to Enabled." - ) + ) # create network using the shared network offering created self.services["network"]["acltype"] = "Account" - self.services["network"]["networkofferingid"] = self.shared_network_offering.id + self.services["network"][ + "networkofferingid"] = self.shared_network_offering.id self.services["network"]["physicalnetworkid"] = physical_network.id self.services["network"]["vlan"] = shared_vlan self.network = Network.create( - self.api_client, - self.services["network"], - accountid=self.user_account.name, - domainid=self.user_account.domainid, - networkofferingid=self.shared_network_offering.id, - zoneid=self.zone.id - ) + self.api_client, + self.services["network"], + accountid=self.user_account.name, + domainid=self.user_account.domainid, + networkofferingid=self.shared_network_offering.id, + zoneid=self.zone.id + ) self.cleanup_networks.append(self.network) list_networks_response = Network.list( - self.api_client, - id=self.network.id - ) + self.api_client, + id=self.network.id + ) self.assertEqual( isinstance(list_networks_response, list), True, "listNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_networks_response), 0, "listNetworks returned empty list." - ) + ) self.assertEqual( list_networks_response[0].specifyipranges, True, - "The network is created with ip range but the flag is set to False." - ) + "The network is created with ip range but the flag is set to False.") self.debug("Network created: %s" % self.network.id) try: self.admin_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - accountid=self.admin_account.name, - domainid=self.admin_account.domainid, - networkids=self.network.id, - serviceofferingid=self.service_offering.id - ) - self.fail("Virtual Machine got created in admin account with network created but the network used is of scope account and for user account.") + self.api_client, + self.services["virtual_machine"], + accountid=self.admin_account.name, + domainid=self.admin_account.domainid, + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) + self.fail( + "Virtual Machine got created in admin account with network created but the network used is of scope account and for user account.") except Exception as e: - self.debug("Virtual Machine creation failed as network used have scoped only for user account. Exception: %s" % e) + self.debug( + "Virtual Machine creation failed as network used have scoped only for user account. Exception: %s" % + e) self.user_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - accountid=self.user_account.name, - domainid=self.user_account.domainid, - networkids=self.network.id, - serviceofferingid=self.service_offering.id - ) + self.api_client, + self.services["virtual_machine"], + accountid=self.user_account.name, + domainid=self.user_account.domainid, + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) vms = VirtualMachine.list( - self.api_client, - id=self.user_account_virtual_machine.id, - listall=True - ) + self.api_client, + id=self.user_account_virtual_machine.id, + listall=True + ) self.assertEqual( isinstance(vms, list), True, "listVirtualMachines returned invalid object in response." - ) + ) self.assertNotEqual( len(vms), 0, "listVirtualMachines returned empty list." - ) + ) - ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"]))) + ip_range = list( + netaddr.iter_iprange( + unicode( + self.services["network"]["startip"]), unicode( + self.services["network"]["endip"]))) if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range: - self.fail("Virtual machine ip should be from the ip range assigned to network created.") + self.fail( + "Virtual machine ip should be from the ip range assigned to network created.") @attr(tags=["advanced", "advancedns"], required_hardware="false") def test_createSharedNetwork_domainSpecific(self): @@ -1131,133 +1187,138 @@ class TestSharedNetworks(cloudstackTestCase): # Create admin account self.admin_account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.admin_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.admin_account.id, - listall=True - ) + self.api_client, + id=self.admin_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin type account created: %s" % self.admin_account.id) # create domain self.dom_domain = Domain.create( - self.api_client, - self.services["domain"], - ) + self.api_client, + self.services["domain"], + ) self.cleanup_domains.append(self.dom_domain) # verify that the account got created with state enabled list_domains_response = Domain.list( - self.api_client, - id=self.dom_domain.id - ) + self.api_client, + id=self.dom_domain.id + ) self.assertEqual( isinstance(list_domains_response, list), True, "listDomains returned invalid object in response." - ) + ) self.assertNotEqual( len(list_domains_response), 0, "listDomains returned empty list." - ) + ) self.debug("Domain created: %s" % self.dom_domain.id) # Create admin account self.domain_admin_account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.dom_domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.dom_domain.id + ) self.cleanup_accounts.append(self.domain_admin_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.domain_admin_account.id, - listall=True - ) + self.api_client, + id=self.domain_admin_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The domain admin account created is not enabled." - ) + ) - self.debug("Domain admin account created: %s" % self.domain_admin_account.id) + self.debug( + "Domain admin account created: %s" % + self.domain_admin_account.id) # Create an user account self.domain_user_account = Account.create( - self.api_client, - self.services["account"], - admin=False, - domainid=self.dom_domain.id - ) + self.api_client, + self.services["account"], + admin=False, + domainid=self.dom_domain.id + ) self.cleanup_accounts.append(self.domain_user_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.domain_user_account.id, - listall=True - ) + self.api_client, + id=self.domain_user_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The domain user account created is not enabled." - ) + ) - self.debug("Domain user account created: %s" % self.domain_user_account.id) + self.debug( + "Domain user account created: %s" % + self.domain_user_account.id) - physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id) + physical_network, shared_vlan = get_free_vlan( + self.api_client, self.zone.id) if shared_vlan is None: self.fail("Failed to get free vlan id for shared network") @@ -1268,174 +1329,188 @@ class TestSharedNetworks(cloudstackTestCase): # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) - + self.api_client, + self.services["network_offering"], + conservemode=False + ) # Verify that the network offering got created list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Disabled", "The network offering created should be by default disabled." - ) + ) - self.debug("Shared Network Offering created: %s" % self.shared_network_offering.id) + self.debug( + "Shared Network Offering created: %s" % + self.shared_network_offering.id) # Update network offering state from disabled to enabled. NetworkOffering.update( - self.shared_network_offering, - self.api_client, - id=self.shared_network_offering.id, - state="enabled" - ) + self.shared_network_offering, + self.api_client, + id=self.shared_network_offering.id, + state="enabled" + ) # Verify that the state of the network offering is updated list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Enabled", "The network offering state should get updated to Enabled." - ) + ) # create network using the shared network offering created self.services["network"]["acltype"] = "domain" - self.services["network"]["networkofferingid"] = self.shared_network_offering.id + self.services["network"][ + "networkofferingid"] = self.shared_network_offering.id self.services["network"]["physicalnetworkid"] = physical_network.id self.services["network"]["vlan"] = shared_vlan self.network = Network.create( - self.api_client, - self.services["network"], - accountid=self.domain_admin_account.name, - domainid=self.dom_domain.id, - networkofferingid=self.shared_network_offering.id, - zoneid=self.zone.id - ) + self.api_client, + self.services["network"], + accountid=self.domain_admin_account.name, + domainid=self.dom_domain.id, + networkofferingid=self.shared_network_offering.id, + zoneid=self.zone.id + ) self.cleanup_networks.append(self.network) list_networks_response = Network.list( - self.api_client, - id=self.network.id, - listall=True - ) + self.api_client, + id=self.network.id, + listall=True + ) self.assertEqual( isinstance(list_networks_response, list), True, "listNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_networks_response), 0, "listNetworks returned empty list." - ) + ) self.assertEqual( list_networks_response[0].specifyipranges, True, - "The network is created with ip range but the flag is set to False." - ) + "The network is created with ip range but the flag is set to False.") self.debug("Shared Network created: %s" % self.network.id) try: self.admin_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - accountid=self.admin_account.name, - domainid=self.admin_account.domainid, - networkids=self.network.id, - serviceofferingid=self.service_offering.id - ) - self.fail("Virtual Machine got created in admin account with network specified but the network used is of scope domain and admin account is not part of this domain.") + self.api_client, + self.services["virtual_machine"], + accountid=self.admin_account.name, + domainid=self.admin_account.domainid, + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) + self.fail( + "Virtual Machine got created in admin account with network specified but the network used is of scope domain and admin account is not part of this domain.") except Exception as e: - self.debug("Virtual Machine creation failed as network used have scoped only for DOM domain. Exception: %s" % e) + self.debug( + "Virtual Machine creation failed as network used have scoped only for DOM domain. Exception: %s" % + e) self.domain_user_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - accountid=self.domain_user_account.name, - domainid=self.domain_user_account.domainid, - networkids=self.network.id, - serviceofferingid=self.service_offering.id - ) + self.api_client, + self.services["virtual_machine"], + accountid=self.domain_user_account.name, + domainid=self.domain_user_account.domainid, + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) self.cleanup_vms.append(self.domain_user_account_virtual_machine) vms = VirtualMachine.list( - self.api_client, - id=self.domain_user_account_virtual_machine.id, - listall=True - ) + self.api_client, + id=self.domain_user_account_virtual_machine.id, + listall=True + ) self.assertEqual( isinstance(vms, list), True, "listVirtualMachines returned invalid object in response." - ) + ) self.assertNotEqual( len(vms), 0, "listVirtualMachines returned empty list." - ) + ) - ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"]))) + ip_range = list( + netaddr.iter_iprange( + unicode( + self.services["network"]["startip"]), unicode( + self.services["network"]["endip"]))) if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range: - self.fail("Virtual machine ip should be from the ip range assigned to network created.") + self.fail( + "Virtual machine ip should be from the ip range assigned to network created.") self.domain_admin_account_virtual_machine = VirtualMachine.create( - self.api_client, - self.services["virtual_machine"], - accountid=self.domain_admin_account.name, - domainid=self.domain_admin_account.domainid, - networkids=self.network.id, - serviceofferingid=self.service_offering.id - ) + self.api_client, + self.services["virtual_machine"], + accountid=self.domain_admin_account.name, + domainid=self.domain_admin_account.domainid, + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) self.cleanup_vms.append(self.domain_admin_account_virtual_machine) vms = VirtualMachine.list( - self.api_client, - id=self.domain_admin_account_virtual_machine.id, - listall=True - ) + self.api_client, + id=self.domain_admin_account_virtual_machine.id, + listall=True + ) self.assertEqual( isinstance(vms, list), True, "listVirtualMachines returned invalid object in response." - ) + ) self.assertNotEqual( len(vms), 0, "listVirtualMachines returned empty list." - ) + ) - ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"]))) + ip_range = list( + netaddr.iter_iprange( + unicode( + self.services["network"]["startip"]), unicode( + self.services["network"]["endip"]))) if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range: - self.fail("Virtual machine ip should be from the ip range assigned to network created.") + self.fail( + "Virtual machine ip should be from the ip range assigned to network created.") @attr(tags=["advanced", "advancedns"], required_hardware="false") def test_createSharedNetwork_projectSpecific(self): @@ -1474,35 +1549,35 @@ class TestSharedNetworks(cloudstackTestCase): # Create admin account self.admin_account = Account.create( - self.api_client, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.api_client, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup_accounts.append(self.admin_account) # verify that the account got created with state enabled list_accounts_response = Account.list( - self.api_client, - id=self.admin_account.id, - listall=True - ) + self.api_client, + id=self.admin_account.id, + listall=True + ) self.assertEqual( isinstance(list_accounts_response, list), True, "listAccounts returned invalid object in response." - ) + ) self.assertNotEqual( len(list_accounts_response), 0, "listAccounts returned empty list." - ) + ) self.assertEqual( list_accounts_response[0].state, "enabled", "The admin account created is not enabled." - ) + ) self.debug("Admin account created: %s" % self.admin_account.id) @@ -1510,29 +1585,29 @@ class TestSharedNetworks(cloudstackTestCase): self.services["project"]["displaytext"] = "proj-SADJKS" self.project1 = Project.create( - self.api_client, - self.services["project"], - account=self.admin_account.name, - domainid=self.admin_account.domainid - ) + self.api_client, + self.services["project"], + account=self.admin_account.name, + domainid=self.admin_account.domainid + ) self.cleanup_projects.append(self.project1) list_projects_response = Project.list( - self.api_client, - id=self.project1.id, - listall=True - ) + self.api_client, + id=self.project1.id, + listall=True + ) self.assertEqual( isinstance(list_projects_response, list), True, "listProjects returned invalid object in response." - ) + ) self.assertNotEqual( len(list_projects_response), 0, "listProjects should return at least one." - ) + ) self.debug("Project created: %s" % self.project1.id) @@ -1540,33 +1615,34 @@ class TestSharedNetworks(cloudstackTestCase): self.services["project"]["displaytext"] = "proj-SLDJK" self.project2 = Project.create( - self.api_client, - self.services["project"], - account=self.admin_account.name, - domainid=self.admin_account.domainid - ) + self.api_client, + self.services["project"], + account=self.admin_account.name, + domainid=self.admin_account.domainid + ) self.cleanup_projects.append(self.project2) list_projects_response = Project.list( - self.api_client, - id=self.project2.id, - listall=True - ) + self.api_client, + id=self.project2.id, + listall=True + ) self.assertEqual( isinstance(list_projects_response, list), True, "listProjects returned invalid object in response." - ) + ) self.assertNotEqual( len(list_projects_response), 0, "listProjects should return at least one." - ) + ) self.debug("Project2 created: %s" % self.project2.id) - physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id) + physical_network, shared_vlan = get_free_vlan( + self.api_client, self.zone.id) if shared_vlan is None: self.fail("Failed to get free vlan id for shared network") @@ -1575,145 +1651,150 @@ class TestSharedNetworks(cloudstackTestCase): self.services["network_offering"]["specifyVlan"] = "True" self.services["network_offering"]["specifyIpRanges"] = "True" - # Create Network Offering self.shared_network_offering = NetworkOffering.create( - self.api_client, - self.services["network_offering"], - conservemode=False - ) - + self.api_client, + self.services["network_offering"], + conservemode=False + ) # Verify that the network offering got created list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Disabled", "The network offering created should be by default disabled." - ) + ) # Update network offering state from disabled to enabled. NetworkOffering.update( - self.shared_network_offering, - self.api_client, - id=self.shared_network_offering.id, - state="enabled" - ) + self.shared_network_offering, + self.api_client, + id=self.shared_network_offering.id, + state="enabled" + ) # Verify that the state of the network offering is updated list_network_offerings_response = NetworkOffering.list( - self.api_client, - id=self.shared_network_offering.id - ) + self.api_client, + id=self.shared_network_offering.id + ) self.assertEqual( isinstance(list_network_offerings_response, list), True, "listNetworkOfferings returned invalid object in response." - ) + ) self.assertNotEqual( len(list_network_offerings_response), 0, "listNetworkOfferings returned empty list." - ) + ) self.assertEqual( list_network_offerings_response[0].state, "Enabled", "The network offering state should get updated to Enabled." - ) + ) - self.debug("Shared Network found: %s" % self.shared_network_offering.id) + self.debug( + "Shared Network found: %s" % + self.shared_network_offering.id) # create network using the shared network offering created self.services["network"]["acltype"] = "account" - self.services["network"]["networkofferingid"] = self.shared_network_offering.id + self.services["network"][ + "networkofferingid"] = self.shared_network_offering.id self.services["network"]["physicalnetworkid"] = physical_network.id self.services["network"]["vlan"] = shared_vlan self.network = Network.create( - self.api_client, - self.services["network"], - projectid=self.project1.id, - domainid=self.admin_account.domainid, - networkofferingid=self.shared_network_offering.id, - zoneid=self.zone.id - ) + self.api_client, + self.services["network"], + projectid=self.project1.id, + domainid=self.admin_account.domainid, + networkofferingid=self.shared_network_offering.id, + zoneid=self.zone.id + ) self.cleanup_networks.append(self.network) list_networks_response = Network.list( - self.api_client, - id=self.network.id, - projectid=self.project1.id, - listall=True - ) + self.api_client, + id=self.network.id, + projectid=self.project1.id, + listall=True + ) self.assertEqual( isinstance(list_networks_response, list), True, "listNetworks returned invalid object in response." - ) + ) self.assertNotEqual( len(list_networks_response), 0, "listNetworks returned empty list." - ) + ) self.assertEqual(
<TRUNCATED>
