Repository: cloudstack Updated Branches: refs/heads/master 05913e3cb -> e5efa702b
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b9938ce/test/integration/component/test_escalations_ipaddresses.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_escalations_ipaddresses.py b/test/integration/component/test_escalations_ipaddresses.py index 00aacbf..b29cd1d 100644 --- a/test/integration/component/test_escalations_ipaddresses.py +++ b/test/integration/component/test_escalations_ipaddresses.py @@ -43,6 +43,7 @@ from marvin.lib.utils import validateList, cleanup_resources from marvin.codes import PASS from nose.plugins.attrib import attr + class TestIpAddresses(cloudstackTestCase): @classmethod @@ -55,30 +56,41 @@ class TestIpAddresses(cloudstackTestCase): cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Domain, Zone, Template cls.domain = get_domain(cls.api_client) - cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) + 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"] + ) if cls.zone.localstorageenabled: cls.storagetype = 'local' - cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' + cls.services["service_offerings"][ + "tiny"]["storagetype"] = 'local' else: cls.storagetype = 'shared' - cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared' + cls.services["service_offerings"][ + "tiny"]["storagetype"] = 'shared' cls.services['mode'] = cls.zone.networktype - cls.services["virtual_machine"]["hypervisor"] = cls.testClient.getHypervisorInfo() + cls.services["virtual_machine"][ + "hypervisor"] = cls.testClient.getHypervisorInfo() 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_offerings"]["tiny"] - ) + cls.api_client, + cls.services["service_offerings"]["tiny"] + ) cls._cleanup.append(cls.service_offering) cls.services['mode'] = cls.zone.networktype + cls.vpc_offering = VpcOffering.create(cls.api_client, + cls.services["vpc_offering"] + ) + cls.vpc_offering.update(cls.api_client, state='Enabled') + cls._cleanup.append(cls.vpc_offering) + except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) @@ -89,14 +101,15 @@ class TestIpAddresses(cloudstackTestCase): self.apiClient = self.testClient.getApiClient() self.cleanup = [] self.account = Account.create( - self.apiClient, - self.services["account"], - domainid=self.domain.id - ) + self.apiClient, + self.services["account"], + domainid=self.domain.id + ) # Getting authentication for user in newly created Account self.user = self.account.user[0] - self.userapiclient = self.testClient.getUserApiClient(self.user.username, self.domain.name) -# self.cleanup.append(self.account) + self.userapiclient = self.testClient.getUserApiClient( + self.user.username, + self.domain.name) def tearDown(self): # Clean up, terminate the created volumes @@ -111,13 +124,14 @@ class TestIpAddresses(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) def __verify_values(self, expected_vals, actual_vals): - """ + """ @summary: Function to verify expected and actual values Step1: Initializing return flag to True - Step1: Verifying length of expected and actual dictionaries is matching. + Step1: Verifying length of expected and actual dictionaries is matching If not matching returning false Step2: Listing all the keys from expected dictionary - Step3: Looping through each key from step2 and verifying expected and actual dictionaries have same value + Step3: Looping through each key from step2 and verifying expected + and actual dictionaries have same value If not making return flag to False Step4: returning the return flag after all the values are verified """ @@ -134,10 +148,10 @@ class TestIpAddresses(cloudstackTestCase): return_flag = return_flag and True else: return_flag = return_flag and False - self.debug("expected Value: %s, is not matching with actual value: %s" % ( - exp_val, - act_val - )) + self.debug( + "expected Value: %s, is not matching with actual value: %s" + % + (exp_val, act_val)) return return_flag @attr(tags=["advanced"], required_hardware="true") @@ -152,7 +166,8 @@ class TestIpAddresses(cloudstackTestCase): Step5: Listing all the IP Addresses again Step6: Verifying the length of the IP Addresses is (page size + 1) Step7: Listing all the IP Addresses in page1 - Step8: Verifying that the length of the IP Addresses in page 1 is (page size) + Step8: Verifying that the length of the IP Addresses in page 1 is + (page size) Step9: Listing all the IP Addresses in page2 Step10: Verifying that the length of the IP Addresses in page 2 is 1 Step11: Dis-Associating the IP Addresses present in page 2 @@ -161,154 +176,154 @@ class TestIpAddresses(cloudstackTestCase): """ # Listing all the networks available networks_list_before = Network.list( - self.userapiclient, - forvpc="false", - domainid=self.domain.id, - account=self.account.name, - type="Isolated" - ) + self.userapiclient, + forvpc="false", + domainid=self.domain.id, + account=self.account.name, + type="Isolated" + ) self.assertIsNone( - networks_list_before, - "Networks listed for newly created user" - ) + networks_list_before, + "Networks listed for newly created user" + ) # Listing Network Offerings network_offerings_list = NetworkOffering.list( - self.apiClient, - forvpc="false", - guestiptype="Isolated", - state="Enabled", - supportedservices="SourceNat", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat enabled are not found" + ) # Creating a network network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=network_offerings_list[0].id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=network_offerings_list[0].id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) # Listing all the networks available networks_list_after = Network.list( - self.userapiclient, - forvpc="false", - domainid=self.domain.id, - account=self.account.name, - type="Isolated" - ) + self.userapiclient, + forvpc="false", + domainid=self.domain.id, + account=self.account.name, + type="Isolated" + ) status = validateList(networks_list_after) self.assertEquals( - PASS, - status[0], - "Network Creation Failed" - ) + PASS, + status[0], + "Network Creation Failed" + ) self.assertEquals( - 1, - len(networks_list_after), - "Network creation failed" - ) + 1, + len(networks_list_after), + "Network creation failed" + ) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) self.assertIsNone( - list_ipaddresses_before, - "IP Addresses listed for newly created user" - ) + list_ipaddresses_before, + "IP Addresses listed for newly created user" + ) # Associating (pagesize + 1) number of IP Addresses for i in range(0, (self.services["pagesize"] + 1)): ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - ipaddress, - "Failed to Associate IP Address" - ) + ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_after) self.assertEquals( - PASS, - status[0], - "IP Addresses Association Failed" - ) + PASS, + status[0], + "IP Addresses Association Failed" + ) # Verifying the length of the volumes is (page size + 1) self.assertEqual( - (self.services["pagesize"] + 1), - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + (self.services["pagesize"] + 1), + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing IP Address in page 1 list_ipaddress_page1 = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"] - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"] + ) status = validateList(list_ipaddress_page1) self.assertEquals( - PASS, - status[0], - "Failed to list IP Addresses in page1" - ) + PASS, + status[0], + "Failed to list IP Addresses in page1" + ) # Verifying that list size is equals to pagesize self.assertEquals( - self.services["pagesize"], - len(list_ipaddress_page1), - "Failed to list pagesize number of IP Addresses in page1" - ) + self.services["pagesize"], + len(list_ipaddress_page1), + "Failed to list pagesize number of IP Addresses in page1" + ) # Listing IP Address in page 2 list_ipaddress_page2 = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"], - page=2, - pagesize=self.services["pagesize"] - ) + self.userapiclient, + listall=self.services["listall"], + page=2, + pagesize=self.services["pagesize"] + ) status = validateList(list_ipaddress_page2) self.assertEquals( - PASS, - status[0], - "Failed to list IP Addresses in page2" - ) + PASS, + status[0], + "Failed to list IP Addresses in page2" + ) # Verifying that List size is equal to 1 self.assertEquals( - 1, - len(list_ipaddress_page2), - "Failed to list IP Addresses in page2" - ) + 1, + len(list_ipaddress_page2), + "Failed to list IP Addresses in page2" + ) # Dis-associating an IP Address ipaddress.delete(self.userapiclient) # Listing IP Address in page 2 list_ipaddress_page2 = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"], - page=2, - pagesize=self.services["pagesize"] - ) + self.userapiclient, + listall=self.services["listall"], + page=2, + pagesize=self.services["pagesize"] + ) # Verifying that no IP Addresses are listed self.assertIsNone( - list_ipaddress_page2, - "Disassociation of IP Address Failed" - ) + list_ipaddress_page2, + "Disassociation of IP Address Failed" + ) self.cleanup.append(self.account) return @@ -329,163 +344,166 @@ class TestIpAddresses(cloudstackTestCase): """ # Listing all the networks available networks_list_before = Network.list( - self.userapiclient, - forvpc="false", - domainid=self.domain.id, - account=self.account.name, - type="Isolated" - ) + self.userapiclient, + forvpc="false", + domainid=self.domain.id, + account=self.account.name, + type="Isolated" + ) self.assertIsNone( - networks_list_before, - "Networks listed for newly created user" - ) + networks_list_before, + "Networks listed for newly created user" + ) # Listing Network Offerings network_offerings_list = NetworkOffering.list( - self.apiClient, - forvpc="false", - guestiptype="Isolated", - state="Enabled", - supportedservices="SourceNat", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat enabled are not found" + ) # Creating a network network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=network_offerings_list[0].id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=network_offerings_list[0].id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) # Listing all the networks available networks_list_after = Network.list( - self.userapiclient, - forvpc="false", - domainid=self.domain.id, - account=self.account.name, - type="Isolated" - ) + self.userapiclient, + forvpc="false", + domainid=self.domain.id, + account=self.account.name, + type="Isolated" + ) status = validateList(networks_list_after) self.assertEquals( - PASS, - status[0], - "Network Creation Failed" - ) + PASS, + status[0], + "Network Creation Failed" + ) self.assertEquals( - 1, - len(networks_list_after), - "Network creation failed" - ) + 1, + len(networks_list_after), + "Network creation failed" + ) # Listing the Network By ID network_list_byid = Network.list( - self.userapiclient, - listall=self.services["listall"], - id=network.id - ) + self.userapiclient, + listall=self.services["listall"], + id=network.id + ) status = validateList(network_list_byid) self.assertEquals( - PASS, - status[0], - "Failed to list Network by Id" - ) + PASS, + status[0], + "Failed to list Network by Id" + ) self.assertEquals( - 1, - len(network_list_byid), - "Failed to list Network by Id" - ) + 1, + len(network_list_byid), + "Failed to list Network by Id" + ) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) self.assertIsNone( - list_ipaddresses_before, - "IP Addresses listed for newly created user" - ) + list_ipaddresses_before, + "IP Addresses listed for newly created user" + ) # Associating an IP Addresses to Network created associated_ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network_list_byid[0].id - ) + self.userapiclient, + services=self.services["network"], + networkid=network_list_byid[0].id + ) self.assertIsNotNone( - associated_ipaddress, - "Failed to Associate IP Address" - ) + associated_ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_after) self.assertEquals( - PASS, - status[0], - "IP Addresses Association Failed" - ) + PASS, + status[0], + "IP Addresses Association Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 1, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing IP Address by id list_ipaddress_byid = PublicIPAddress.list( - self.userapiclient, - id=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + id=associated_ipaddress.ipaddress.id + ) status = validateList(list_ipaddress_byid) self.assertEquals( - PASS, - status[0], - "Failed to list IP Addresses by ID" - ) + PASS, + status[0], + "Failed to list IP Addresses by ID" + ) # Verifying that list size is equals to 1 self.assertEquals( - 1, - len(list_ipaddress_byid), - "Failed to list IP Addresses by ID" - ) - # Verifying details of the listed IP Address to be same as IP Address created above + 1, + len(list_ipaddress_byid), + "Failed to list IP Addresses by ID" + ) + # Verifying details of the listed IP Address to be same as + # IP Address created above # Creating expected and actual values dictionaries expected_dict = { - "id":associated_ipaddress.ipaddress.id, - "associatednetworkid":associated_ipaddress.ipaddress.associatednetworkid, - "associatednetworkname":associated_ipaddress.ipaddress.associatednetworkname, - "ipaddress":associated_ipaddress.ipaddress.ipaddress, - "issourcenat":associated_ipaddress.ipaddress.issourcenat, - "isstaticnat":associated_ipaddress.ipaddress.isstaticnat, - "networkid":associated_ipaddress.ipaddress.networkid - } + "id": associated_ipaddress.ipaddress.id, + "associatednetworkid": + associated_ipaddress.ipaddress.associatednetworkid, + "associatednetworkname": + associated_ipaddress.ipaddress.associatednetworkname, + "ipaddress": associated_ipaddress.ipaddress.ipaddress, + "issourcenat": associated_ipaddress.ipaddress.issourcenat, + "isstaticnat": associated_ipaddress.ipaddress.isstaticnat, + "networkid": associated_ipaddress.ipaddress.networkid} actual_dict = { - "id":list_ipaddress_byid[0].id, - "associatednetworkid":list_ipaddress_byid[0].associatednetworkid, - "associatednetworkname":list_ipaddress_byid[0].associatednetworkname, - "ipaddress":list_ipaddress_byid[0].ipaddress, - "issourcenat":list_ipaddress_byid[0].issourcenat, - "isstaticnat":list_ipaddress_byid[0].isstaticnat, - "networkid":list_ipaddress_byid[0].networkid - } + "id": list_ipaddress_byid[0].id, + "associatednetworkid": + list_ipaddress_byid[0].associatednetworkid, + "associatednetworkname": + list_ipaddress_byid[0].associatednetworkname, + "ipaddress": list_ipaddress_byid[0].ipaddress, + "issourcenat": list_ipaddress_byid[0].issourcenat, + "isstaticnat": list_ipaddress_byid[0].isstaticnat, + "networkid": list_ipaddress_byid[0].networkid} ipaddress_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - ipaddress_status, - "Listed IP Address details are not as expected" - ) + True, + ipaddress_status, + "Listed IP Address details are not as expected" + ) self.cleanup.append(self.account) return @@ -508,713 +526,720 @@ class TestIpAddresses(cloudstackTestCase): list_vpc_before = VPC.list(self.userapiclient) # Verifying No VPCs are listed self.assertIsNone( - list_vpc_before, - "VPC's Listed for newly Created User" - ) - # Listing VPC Offerings - list_vpc_offering = VpcOffering.list(self.userapiclient) - status = validateList(list_vpc_offering) - self.assertEquals( - PASS, - status[0], - "list vpc offering is none") + list_vpc_before, + "VPC's Listed for newly Created User" + ) # Creating a vpc vpc_created = VPC.create( - self.userapiclient, - self.services["vpc"], - list_vpc_offering[0].id, - self.zone.id - ) + self.userapiclient, + self.services["vpc"], + self.vpc_offering.id, + self.zone.id + ) self.assertIsNotNone( - vpc_created, - "VPC Creation Failed" - ) + vpc_created, + "VPC Creation Failed" + ) self.cleanup.append(vpc_created) # Listing the vpc for a user after creating a vpc list_vpc_after = VPC.list(self.userapiclient) status = validateList(list_vpc_after) self.assertEquals( - PASS, - status[0], - "list VPC not as expected" - ) + PASS, + status[0], + "list VPC not as expected" + ) # Verifying the list vpc size is increased by 1 self.assertEquals( - 1, - len(list_vpc_after), - "list VPC not equal as expected" - ) + 1, + len(list_vpc_after), + "list VPC not equal as expected" + ) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_before) self.assertEquals( - PASS, - status[0], - "Failed to List VPC IP Address" - ) + PASS, + status[0], + "Failed to List VPC IP Address" + ) self.assertEquals( - 1, - len(list_ipaddresses_before), - "Failed to List VPC IP Address" - ) + 1, + len(list_ipaddresses_before), + "Failed to List VPC IP Address" + ) # Associating an IP Addresses to VPC created associated_ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - vpcid=vpc_created.id - ) + self.userapiclient, + services=self.services["network"], + vpcid=vpc_created.id + ) self.assertIsNotNone( - associated_ipaddress, - "Failed to Associate IP Address" - ) + associated_ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_after) self.assertEquals( - PASS, - status[0], - "IP Addresses Association Failed" - ) + PASS, + status[0], + "IP Addresses Association Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - len(list_ipaddresses_before) + 1, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + len(list_ipaddresses_before) + 1, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing IP Address by id list_ipaddress_byid = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - id=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + id=associated_ipaddress.ipaddress.id + ) status = validateList(list_ipaddress_byid) self.assertEquals( - PASS, - status[0], - "Failed to list IP Addresses by ID" - ) + PASS, + status[0], + "Failed to list IP Addresses by ID" + ) # Verifying that list size is equals to 1 self.assertEquals( - 1, - len(list_ipaddress_byid), - "Failed to list IP Addresses by ID" - ) - # Verifying details of the listed IP Address to be same as IP Address created above + 1, + len(list_ipaddress_byid), + "Failed to list IP Addresses by ID" + ) + # Verifying details of the listed IP Address to be same as + # IP Address created above # Creating expected and actual values dictionaries expected_dict = { - "id":associated_ipaddress.ipaddress.id, - "associatednetworkid":associated_ipaddress.ipaddress.associatednetworkid, - "associatednetworkname":associated_ipaddress.ipaddress.associatednetworkname, - "ipaddress":associated_ipaddress.ipaddress.ipaddress, - "issourcenat":associated_ipaddress.ipaddress.issourcenat, - "isstaticnat":associated_ipaddress.ipaddress.isstaticnat, - "networkid":associated_ipaddress.ipaddress.networkid, - "vpcid":associated_ipaddress.ipaddress.vpcid - } + "id": associated_ipaddress.ipaddress.id, + "associatednetworkid": + associated_ipaddress.ipaddress.associatednetworkid, + "associatednetworkname": + associated_ipaddress.ipaddress.associatednetworkname, + "ipaddress": associated_ipaddress.ipaddress.ipaddress, + "issourcenat": associated_ipaddress.ipaddress.issourcenat, + "isstaticnat": associated_ipaddress.ipaddress.isstaticnat, + "networkid": associated_ipaddress.ipaddress.networkid, + "vpcid": associated_ipaddress.ipaddress.vpcid} actual_dict = { - "id":list_ipaddress_byid[0].id, - "associatednetworkid":list_ipaddress_byid[0].associatednetworkid, - "associatednetworkname":list_ipaddress_byid[0].associatednetworkname, - "ipaddress":list_ipaddress_byid[0].ipaddress, - "issourcenat":list_ipaddress_byid[0].issourcenat, - "isstaticnat":list_ipaddress_byid[0].isstaticnat, - "networkid":list_ipaddress_byid[0].networkid, - "vpcid":list_ipaddress_byid[0].vpcid - } + "id": list_ipaddress_byid[0].id, + "associatednetworkid": + list_ipaddress_byid[0].associatednetworkid, + "associatednetworkname": + list_ipaddress_byid[0].associatednetworkname, + "ipaddress": list_ipaddress_byid[0].ipaddress, + "issourcenat": list_ipaddress_byid[0].issourcenat, + "isstaticnat": list_ipaddress_byid[0].isstaticnat, + "networkid": list_ipaddress_byid[0].networkid, + "vpcid": list_ipaddress_byid[0].vpcid} ipaddress_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - ipaddress_status, - "Listed IP Address details are not as expected" - ) + True, + ipaddress_status, + "Listed IP Address details are not as expected" + ) self.cleanup.append(self.account) return @attr(tags=["advanced"], required_hardware="true") def test_04_create_delete_lbrule_fornonvpc(self): """ - @summary: Test to list, create and delete Load Balancer Rule for IP Address associated to Non VPC network + @summary: Test to list, create and delete Load Balancer Rule + for IP Address associated to Non VPC network @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network - Step3: Listing Load Balancer Rules for the IP Address associated in Step2 + Step3: Listing Load Balancer Rules for the IP Address associated in + Step2 Step4: Verifying that no Load Balancer Rules are listed - Step5: Creating a Load Balancer Rule for IP Address associated in Step2 - Step6: Listing Load Balancer Rules for the IP Address associated in Step2 + Step5: Creating a Load Balancer Rule for IP Address associated in + Step2 + Step6: Listing Load Balancer Rules for the IP Address associated in + Step2 Step7: Verifying 1 Load Balancer Rule is listed Step8: Deleting the Load Balancer Rule created in Step5 - Step9: Listing Load Balancer Rules for the IP Address associated in Step2 + Step9: Listing Load Balancer Rules for the IP Address associated in + Step2 Step10: Verifying that no Load Balancer Rules are listed """ # Listing all the Networks's for a user list_networks_before = Network.list( - self.userapiclient, - listall=self.services["listall"], - type="Isolated" - ) + self.userapiclient, + listall=self.services["listall"], + type="Isolated" + ) # Verifying No Networks are listed self.assertIsNone( - list_networks_before, - "Networks listed for newly created User" - ) + list_networks_before, + "Networks listed for newly created User" + ) # Listing Network Offerings network_offerings_list = NetworkOffering.list( - self.apiClient, - forvpc="false", - guestiptype="Isolated", - state="Enabled", - supportedservices="SourceNat,Lb", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Lb", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Lb enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat, Lb enabled are\ + not found" + ) # Creating a network network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=network_offerings_list[0].id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=network_offerings_list[0].id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) # Verifying no IP Addresses are listed self.assertIsNone( - list_ipaddresses_before, - "IP Addresses listed for newly created User" - ) + list_ipaddresses_before, + "IP Addresses listed for newly created User" + ) # Associating an IP Addresses to Network created associated_ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress, - "Failed to Associate IP Address" - ) + associated_ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_after) self.assertEquals( - PASS, - status[0], - "IP Addresses Association Failed" - ) + PASS, + status[0], + "IP Addresses Association Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 1, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing Load Balancer Rules for the Ip Address list_lbrules_before = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) # Verifying no Load Balancer Rules are listed self.assertIsNone( - list_lbrules_before, - "Load Balancer Rules listed for newly Acquired Ip Address" - ) + list_lbrules_before, + "Load Balancer Rules listed for newly Acquired Ip Address" + ) self.services["lbrule"]["openfirewall"] = 'false' # Creating a Load Balancer Rule for Ip Address lb_rule = LoadBalancerRule.create( - self.userapiclient, - self.services["lbrule"], - ipaddressid=associated_ipaddress.ipaddress.id, - ) + self.userapiclient, + self.services["lbrule"], + ipaddressid=associated_ipaddress.ipaddress.id, + ) self.assertIsNotNone( - lb_rule, - "Failed to create Load Balancer Rule" - ) + lb_rule, + "Failed to create Load Balancer Rule" + ) # Verifying details of created Load Balancer Rule # Creating expected and actual values dictionaries expected_dict = { - "algorithm":self.services["lbrule"]["alg"], - "privateport":str(self.services["lbrule"]["privateport"]), - "publicport":str(self.services["lbrule"]["publicport"]), - "name":self.services["lbrule"]["name"], - } + "algorithm": self.services["lbrule"]["alg"], + "privateport": str(self.services["lbrule"]["privateport"]), + "publicport": str(self.services["lbrule"]["publicport"]), + "name": self.services["lbrule"]["name"], + } actual_dict = { - "algorithm":str(lb_rule.algorithm), - "privateport":str(lb_rule.privateport), - "publicport":str(lb_rule.publicport), - "name":str(lb_rule.name), - } + "algorithm": str(lb_rule.algorithm), + "privateport": str(lb_rule.privateport), + "publicport": str(lb_rule.publicport), + "name": str(lb_rule.name), + } lbrule_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - lbrule_status, - "Created Load Balancer Rule details are not as expected" - ) + True, + lbrule_status, + "Created Load Balancer Rule details are not as expected" + ) # Listing Load Balancer Rules for the Ip Address list_lbrules_after = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) status = validateList(list_lbrules_after) self.assertEquals( - PASS, - status[0], - "Load Balancer Rule creation Failed" - ) + PASS, + status[0], + "Load Balancer Rule creation Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbrules_after), - "Load Balancer Rule creation Failed" - ) + 1, + len(list_lbrules_after), + "Load Balancer Rule creation Failed" + ) # Deleting Load Balancer Rule lb_rule.delete(self.userapiclient) # Listing Load Balancer Rules for the Ip Address list_lbrules_after = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) # Verifying no Load Balancer Rules are Listed self.assertIsNone( - list_lbrules_after, - "Failed to delete Load Balancer Rule" - ) + list_lbrules_after, + "Failed to delete Load Balancer Rule" + ) self.cleanup.append(self.account) return @attr(tags=["advanced"], required_hardware="true") def test_05_create_delete_lbrule_forvpc(self): """ - @summary: Test to list, create and delete Load Balancer Rule for IP Address associated to VPC + @summary: Test to list, create and delete Load Balancer Rule for IP + Address associated to VPC @Steps: Step1: Creating a VPC for the user Step2: Creating Network inside VPC Step3: Associating an IP Addresses for VPC - Step4: Listing Load Balancer Rules for the IP Address associated in Step2 + Step4: Listing Load Balancer Rules for the IP Address associated in + Step2 Step5: Verifying that no Load Balancer Rules are listed - Step6: Creating a Load Balancer Rule for IP Address associated in Step2 - Step7: Listing Load Balancer Rules for the IP Address associated in Step2 + Step6: Creating a Load Balancer Rule for IP Address associated in + Step2 + Step7: Listing Load Balancer Rules for the IP Address associated in + Step2 Step8: Verifying 1 Load Balancer Rule is listed Step9: Deleting the Load Balancer Rule created in Step5 - Step10: Listing Load Balancer Rules for the IP Address associated in Step2 + Step10: Listing Load Balancer Rules for the IP Address associated in + Step2 Step11: Verifying that no Load Balancer Rules are listed """ # Listing all the vpc's for a user list_vpc_before = VPC.list(self.userapiclient) # Verifying No VPCs are listed self.assertIsNone( - list_vpc_before, - "VPC's Listed for newly Created User" - ) - # Listing VPC Offerings - list_vpc_offering = VpcOffering.list(self.userapiclient) - status = validateList(list_vpc_offering) - self.assertEquals( - PASS, - status[0], - "list vpc offering is none") + list_vpc_before, + "VPC's Listed for newly Created User" + ) # Creating a vpc vpc_created = VPC.create( - self.userapiclient, - self.services["vpc"], - list_vpc_offering[0].id, - self.zone.id - ) + self.userapiclient, + self.services["vpc"], + self.vpc_offering.id, + self.zone.id + ) self.assertIsNotNone( - vpc_created, - "VPC Creation Failed" - ) + vpc_created, + "VPC Creation Failed" + ) # Listing the vpc for a user after creating a vpc list_vpc_after = VPC.list(self.userapiclient) status = validateList(list_vpc_after) self.assertEquals( - PASS, - status[0], - "list VPC not as expected" - ) + PASS, + status[0], + "list VPC not as expected" + ) # Verifying the list vpc size is increased by 1 self.assertEquals( - 1, - len(list_vpc_after), - "list VPC not equal as expected" - ) + 1, + len(list_vpc_after), + "list VPC not equal as expected" + ) # List network offering for vpc = true network_offering_vpc_true_list = NetworkOffering.list( - self.userapiclient, - forvpc="true", - zoneid=self.zone.id, - supportedServices="Lb", - state="Enabled" - ) + self.userapiclient, + forvpc="true", + zoneid=self.zone.id, + supportedServices="Lb", + state="Enabled" + ) status = validateList(network_offering_vpc_true_list) - self.assertEquals(PASS, status[0], "Default network offering not present for vpc = true with Lb") + self.assertEquals( + PASS, + status[0], + "Default network offering not present for vpc = true with Lb") # Creating network under VPC network_created = Network.create( - self.userapiclient, - self.services["ntwk"], - networkofferingid=network_offering_vpc_true_list[0].id, - vpcid=vpc_created.id, - zoneid=self.zone.id, - gateway=self.services["ntwk"]["gateway"], - netmask=self.services["ntwk"]["netmask"] - ) + self.userapiclient, + self.services["ntwk"], + networkofferingid=network_offering_vpc_true_list[0].id, + vpcid=vpc_created.id, + zoneid=self.zone.id, + gateway=self.services["ntwk"]["gateway"], + netmask=self.services["ntwk"]["netmask"] + ) self.cleanup.append(network_created) self.assertIsNotNone( - network_created, - "Network is not created" - ) + network_created, + "Network is not created" + ) self.cleanup.append(vpc_created) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_before) self.assertEquals( - PASS, - status[0], - "list IP Addresses not as expected" - ) + PASS, + status[0], + "list IP Addresses not as expected" + ) # Verifying the list vpc size is increased by 1 self.assertEquals( - 1, - len(list_ipaddresses_before), - "list IP Addresses not equal as expected" - ) + 1, + len(list_ipaddresses_before), + "list IP Addresses not equal as expected" + ) # Associating an IP Addresses to VPC created associated_ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - vpcid=vpc_created.id - ) + self.userapiclient, + services=self.services["network"], + vpcid=vpc_created.id + ) self.assertIsNotNone( - associated_ipaddress, - "Failed to Associate IP Address" - ) + associated_ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_after) self.assertEquals( - PASS, - status[0], - "IP Addresses Association Failed" - ) + PASS, + status[0], + "IP Addresses Association Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - len(list_ipaddresses_before) + 1, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + len(list_ipaddresses_before) + 1, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing Load Balancer Rules for the Ip Address list_lbrules_before = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) # Verifying no Load Balancer Rules are listed self.assertIsNone( - list_lbrules_before, - "Load Balancer Rules listed for newly Acquired Ip Address" - ) + list_lbrules_before, + "Load Balancer Rules listed for newly Acquired Ip Address" + ) self.services["lbrule"]["openfirewall"] = 'false' # Creating a Load Balancer Rule for Ip Address lb_rule = LoadBalancerRule.create( - self.userapiclient, - self.services["lbrule"], - ipaddressid=associated_ipaddress.ipaddress.id, - networkid=network_created.id - ) + self.userapiclient, + self.services["lbrule"], + ipaddressid=associated_ipaddress.ipaddress.id, + networkid=network_created.id + ) self.assertIsNotNone( - lb_rule, - "Failed to create Load Balancer Rule" - ) + lb_rule, + "Failed to create Load Balancer Rule" + ) # Verifying details of created Load Balancer Rule # Creating expected and actual values dictionaries expected_dict = { - "algorithm":self.services["lbrule"]["alg"], - "privateport":str(self.services["lbrule"]["privateport"]), - "publicport":str(self.services["lbrule"]["publicport"]), - "name":self.services["lbrule"]["name"], - } + "algorithm": self.services["lbrule"]["alg"], + "privateport": str(self.services["lbrule"]["privateport"]), + "publicport": str(self.services["lbrule"]["publicport"]), + "name": self.services["lbrule"]["name"], + } actual_dict = { - "algorithm":str(lb_rule.algorithm), - "privateport":str(lb_rule.privateport), - "publicport":str(lb_rule.publicport), - "name":str(lb_rule.name), - } + "algorithm": str(lb_rule.algorithm), + "privateport": str(lb_rule.privateport), + "publicport": str(lb_rule.publicport), + "name": str(lb_rule.name), + } lbrule_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - lbrule_status, - "Created Load Balancer Rule details are not as expected" - ) - # Listing Load Balancer Rules for the Ip Address + True, + lbrule_status, + "Created Load Balancer Rule details are not as expected" + ) + # Listing Load Balancer Rules for the Ip Address list_lbrules_after = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id, - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id, + ) status = validateList(list_lbrules_after) self.assertEquals( - PASS, - status[0], - "Load Balancer Rule creation Failed" - ) + PASS, + status[0], + "Load Balancer Rule creation Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbrules_after), - "Load Balancer Rule creation Failed" - ) + 1, + len(list_lbrules_after), + "Load Balancer Rule creation Failed" + ) # Deleting Load Balancer Rule lb_rule.delete(self.userapiclient) # Listing Load Balancer Rules for the Ip Address list_lbrules_after = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) # Verifying no Load Balancer Rules are Listed self.assertIsNone( - list_lbrules_after, - "Failed to delete Load Balancer Rule" - ) + list_lbrules_after, + "Failed to delete Load Balancer Rule" + ) self.cleanup.append(self.account) return @attr(tags=["advanced"], required_hardware="true") def test_06_update_lbrule_name(self): """ - @summary: Test to Update Load Balancer Rule Name for IP Address associated to Non VPC network + @summary: Test to Update Load Balancer Rule Name for + IP Address associated to Non VPC network @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network - Step3: Listing Load Balancer Rules for the IP Address associated in Step2 + Step3: Listing Load Balancer Rules for the IP Address associated + in Step2 Step4: Verifying that no Load Balancer Rules are listed Step5: Creating a Load Balancer Rule for IP Address associated in Step2 - Step6: Listing Load Balancer Rules for the IP Address associated in Step2 + Step6: Listing Load Balancer Rules for the IP Address associated in + Step2 Step7: Verifying 1 Load Balancer Rule is listed Step8: Updating the Load Balancer Rule created in Step5 Step9: Verifying that Load Balancer Rule details are updated """ # Listing all the Networks's for a user list_networks_before = Network.list( - self.userapiclient, - listall=self.services["listall"], - type="Isolated" - ) + self.userapiclient, + listall=self.services["listall"], + type="Isolated" + ) # Verifying No Networks are listed self.assertIsNone( - list_networks_before, - "Networks listed for newly created User" - ) + list_networks_before, + "Networks listed for newly created User" + ) # Listing Network Offerings network_offerings_list = NetworkOffering.list( - self.apiClient, - forvpc="false", - guestiptype="Isolated", - state="Enabled", - supportedservices="SourceNat,Lb", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Lb", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Lb enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Lb enabled are not found" + ) # Creating a network network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=network_offerings_list[0].id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=network_offerings_list[0].id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) # Listing Networks again list_networks_after = Network.list( - self.userapiclient, - listall=self.services["listall"], - type="Isolated" - ) + self.userapiclient, + listall=self.services["listall"], + type="Isolated" + ) status = validateList(list_networks_after) self.assertEquals( - PASS, - status[0], - "Network Creation Failed" - ) + PASS, + status[0], + "Network Creation Failed" + ) # Verifying network list count is increased by 1 self.assertEquals( - 1, - len(list_networks_after), - "Network Creation Failed" - ) + 1, + len(list_networks_after), + "Network Creation Failed" + ) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) # Verifying no IP Addresses are listed self.assertIsNone( - list_ipaddresses_before, - "IP Addresses listed for newly created User" - ) + list_ipaddresses_before, + "IP Addresses listed for newly created User" + ) # Associating an IP Addresses to Network created associated_ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress, - "Failed to Associate IP Address" - ) + associated_ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_ipaddresses_after) self.assertEquals( - PASS, - status[0], - "IP Addresses Association Failed" - ) + PASS, + status[0], + "IP Addresses Association Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 1, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing Load Balancer Rules for the Ip Address list_lbrules_before = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) # Verifying no Load Balancer Rules are listed self.assertIsNone( - list_lbrules_before, - "Load Balancer Rules listed for newly Acquired Ip Address" - ) + list_lbrules_before, + "Load Balancer Rules listed for newly Acquired Ip Address" + ) self.services["lbrule"]["openfirewall"] = 'false' # Creating a Load Balancer Rule for Ip Address lb_rule = LoadBalancerRule.create( - self.userapiclient, - self.services["lbrule"], - ipaddressid=associated_ipaddress.ipaddress.id, - ) + self.userapiclient, + self.services["lbrule"], + ipaddressid=associated_ipaddress.ipaddress.id, + ) self.assertIsNotNone( - lb_rule, - "Failed to create Load Balancer Rule" - ) + lb_rule, + "Failed to create Load Balancer Rule" + ) # Listing Load Balancer Rules for the Ip Address list_lbrules_after = LoadBalancerRule.list( - self.userapiclient, - listall=self.services["listall"], - publicipid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + publicipid=associated_ipaddress.ipaddress.id + ) status = validateList(list_lbrules_after) self.assertEquals( - PASS, - status[0], - "Load Balancer Rule creation Failed" - ) + PASS, + status[0], + "Load Balancer Rule creation Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbrules_after), - "Load Balancer Rule creation Failed" - ) + 1, + len(list_lbrules_after), + "Load Balancer Rule creation Failed" + ) # Updating Load Balancer Rule Name updated_lb_rule = LoadBalancerRule.update( - lb_rule, - self.userapiclient, - algorithm="source", - name="NewLBRuleName" - ) + lb_rule, + self.userapiclient, + algorithm="source", + name="NewLBRuleName" + ) self.assertIsNotNone( - updated_lb_rule, - "Failed to update Load Balancer Rule details" - ) + updated_lb_rule, + "Failed to update Load Balancer Rule details" + ) # Verifying details of the updated Load Balancer Rule # Creating expected and actual values dictionaries expected_dict = { - "id":lb_rule.id, - "account":lb_rule.account, - "algorithm":"source", - "domainid":lb_rule.domainid, - "name":"NewLBRuleName", - "networkid":lb_rule.networkid, - "zoneid":lb_rule.zoneid, - "privateport":lb_rule.privateport, - "publicip":lb_rule.publicip, - "publicport":lb_rule.publicport, - } + "id": lb_rule.id, + "account": lb_rule.account, + "algorithm": "source", + "domainid": lb_rule.domainid, + "name": "NewLBRuleName", + "networkid": lb_rule.networkid, + "zoneid": lb_rule.zoneid, + "privateport": lb_rule.privateport, + "publicip": lb_rule.publicip, + "publicport": lb_rule.publicport, + } actual_dict = { - "id":updated_lb_rule.id, - "account":updated_lb_rule.account, - "algorithm":updated_lb_rule.algorithm, - "domainid":updated_lb_rule.domainid, - "name":updated_lb_rule.name, - "networkid":updated_lb_rule.networkid, - "zoneid":updated_lb_rule.zoneid, - "privateport":updated_lb_rule.privateport, - "publicip":updated_lb_rule.publicip, - "publicport":updated_lb_rule.publicport, - } + "id": updated_lb_rule.id, + "account": updated_lb_rule.account, + "algorithm": updated_lb_rule.algorithm, + "domainid": updated_lb_rule.domainid, + "name": updated_lb_rule.name, + "networkid": updated_lb_rule.networkid, + "zoneid": updated_lb_rule.zoneid, + "privateport": updated_lb_rule.privateport, + "publicip": updated_lb_rule.publicip, + "publicport": updated_lb_rule.publicport, + } lbrule_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - lbrule_status, - "Updated Load Balancer Rule details are not as expected" - ) + True, + lbrule_status, + "Updated Load Balancer Rule details are not as expected" + ) self.cleanup.append(self.account) return @@ -1244,291 +1269,301 @@ class TestIpAddresses(cloudstackTestCase): """ # Listing all the Networks's for a user list_networks_before = Network.list( - self.userapiclient, - listall=self.services["listall"], - type="Isolated" - ) + self.userapiclient, + listall=self.services["listall"], + type="Isolated" + ) # Verifying No Networks are listed self.assertIsNone( - list_networks_before, - "Networks listed for newly created User" - ) + list_networks_before, + "Networks listed for newly created User" + ) # Listing Network Offerings network_offerings_list = NetworkOffering.list( - self.apiClient, - forvpc="false", - guestiptype="Isolated", - state="Enabled", - supportedservices="SourceNat,Lb", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Lb", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Lb enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Lb enabled are not found" + ) # Creating a network network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=network_offerings_list[0].id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=network_offerings_list[0].id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) # Listing all the IP Addresses for a user list_ipaddresses_before = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) # Verifying no IP Addresses are listed self.assertIsNone( - list_ipaddresses_before, - "IP Addresses listed for newly created User" - ) + list_ipaddresses_before, + "IP Addresses listed for newly created User" + ) # Associating an IP Addresses to Network created associated_ipaddress = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress, - "Failed to Associate IP Address" - ) + associated_ipaddress, + "Failed to Associate IP Address" + ) # Listing all the IP Addresses for a user list_ipaddresses_after = PublicIPAddress.list( - self.userapiclient, - listall=self.services["listall"] - ) + <TRUNCATED>