diff --git a/test/integration/component/test_escalations_ipaddresses.py b/test/integration/component/test_escalations_ipaddresses.py index 00aacbff24a..b29cd1d275f 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"] - ) + 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" + ) # Launching a Virtual Machine with above created Network vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) self.cleanup.append(network) - # Listing Virtual Machines in Running state in the network created above + # Listing Virtual Machines in Running state in the network created + # above list_vms_running = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id, - state="Running", - networkid=network.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id, + state="Running", + networkid=network.id + ) status = validateList(list_vms_running) self.assertEquals( - PASS, - status[0], - "VM Created is not in Running state" - ) + PASS, + status[0], + "VM Created is not in Running state" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_vms_running), - "VM Created is not in Running state" - ) + 1, + len(list_vms_running), + "VM Created is not in Running state" + ) self.assertEquals( - vm_created.id, - list_vms_running[0].id, - "VM Created is not in Running state" - ) - # Listing Virtual Machines in Stopped state in the network created above + vm_created.id, + list_vms_running[0].id, + "VM Created is not in Running state" + ) + # Listing Virtual Machines in Stopped state in the network created + # above list_vms_stopped = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id, - state="Stopped", - networkid=network.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id, + state="Stopped", + networkid=network.id + ) # Verifying that no vms are listed self.assertIsNone( - list_vms_stopped, - "Created VM is in Stopped state" - ) + list_vms_stopped, + "Created VM is in Stopped state" + ) # 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" + ) # Listing Load Balancer Rule Instances for applied as true - list_lbruleinstance_applied_true = LoadBalancerRule.listLoadBalancerRuleInstances( - self.userapiclient, - id=lb_rule.id, - applied="true" - ) + list_lbruleinstance_applied_true =\ + LoadBalancerRule.listLoadBalancerRuleInstances( + self.userapiclient, + id=lb_rule.id, + applied="true" + ) # Verifying No Instances are assigned to the Load Balancer Rule self.assertIsNone( - list_lbruleinstance_applied_true, - "Instances are assigned to Newly created Load Balancer Rule" - ) + list_lbruleinstance_applied_true, + "Instances are assigned to Newly created Load Balancer Rule" + ) # Listing Load Balancer Rule Instances for applied as false - list_lbruleinstance_applied_false = LoadBalancerRule.listLoadBalancerRuleInstances( - self.userapiclient, - id=lb_rule.id, - applied="false" - ) + list_lbruleinstance_applied_false =\ + LoadBalancerRule.listLoadBalancerRuleInstances( + self.userapiclient, + id=lb_rule.id, + applied="false" + ) status = validateList(list_lbruleinstance_applied_false) self.assertEquals( - PASS, - status[0], - "No Instances are available to assign to Load Balancer Rule" - ) + PASS, + status[0], + "No Instances are available to assign to Load Balancer Rule" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbruleinstance_applied_false), - "No Instances are available to assign to Load Balancer Rule" - ) + 1, + len(list_lbruleinstance_applied_false), + "No Instances are available to assign to Load Balancer Rule" + ) # Verifying that Instance created above is listed self.assertEquals( - vm_created.id, - list_lbruleinstance_applied_false[0].id, - "Failed to list Instance available to asign a Load Balancer Rule" - ) + vm_created.id, + list_lbruleinstance_applied_false[0].id, + "Failed to list Instance available to asign a Load Balancer Rule" + ) # Assigning Instance created to Load Balancer Rule LoadBalancerRule.assign( - lb_rule, - self.userapiclient, - vms=[vm_created] - ) + lb_rule, + self.userapiclient, + vms=[vm_created] + ) # Listing Load Balancer Rule Instances for applied as true - list_lbruleinstance_applied_true = LoadBalancerRule.listLoadBalancerRuleInstances( - self.userapiclient, - id=lb_rule.id, - applied="true" - ) + list_lbruleinstance_applied_true =\ + LoadBalancerRule.listLoadBalancerRuleInstances( + self.userapiclient, + id=lb_rule.id, + applied="true" + ) status = validateList(list_lbruleinstance_applied_false) self.assertEquals( - PASS, - status[0], - "No Instances are available to assign to Load Balancer Rule" - ) + PASS, + status[0], + "No Instances are available to assign to Load Balancer Rule" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbruleinstance_applied_false), - "No Instances are available to assign to Load Balancer Rule" - ) + 1, + len(list_lbruleinstance_applied_false), + "No Instances are available to assign to Load Balancer Rule" + ) # Verifying Instances is assigned to the Load Balancer Rule self.assertEquals( - vm_created.id, - list_lbruleinstance_applied_true[0].id, - "Failed to assign Load Balancer Rule to given Instance" - ) + vm_created.id, + list_lbruleinstance_applied_true[0].id, + "Failed to assign Load Balancer Rule to given Instance" + ) # Listing Load Balancer Rule Instances for applied as false - list_lbruleinstance_applied_false = LoadBalancerRule.listLoadBalancerRuleInstances( - self.userapiclient, - id=lb_rule.id, - applied="false" - ) + list_lbruleinstance_applied_false =\ + LoadBalancerRule.listLoadBalancerRuleInstances( + self.userapiclient, + id=lb_rule.id, + applied="false" + ) # Verifying No Load Balancer Rules Instances are available to assign self.assertIsNone( - list_lbruleinstance_applied_false, - "Instances are available for assigning a Load Balancer Rule" - ) + list_lbruleinstance_applied_false, + "Instances are available for assigning a Load Balancer Rule" + ) # Removing Load balancer Rule from Instance LoadBalancerRule.remove( - lb_rule, - self.userapiclient, - vms=[vm_created] - ) + lb_rule, + self.userapiclient, + vms=[vm_created] + ) # Listing Load Balancer Rule Instances for applied as true - list_lbruleinstance_applied_true = LoadBalancerRule.listLoadBalancerRuleInstances( - self.userapiclient, - id=lb_rule.id, - applied="true" - ) - # Verifying that there are no Instances assigned to the Load Balancer Rule + list_lbruleinstance_applied_true =\ + LoadBalancerRule.listLoadBalancerRuleInstances( + self.userapiclient, + id=lb_rule.id, + applied="true" + ) + # Verifying that there are no Instances assigned to the Load Balancer + # Rule self.assertIsNone( - list_lbruleinstance_applied_true, - "Instances is assigned to Load balancer Rule" - ) + list_lbruleinstance_applied_true, + "Instances is assigned to Load balancer Rule" + ) # Listing Load Balancer Rule Instances for applied as false - list_lbruleinstance_applied_false = LoadBalancerRule.listLoadBalancerRuleInstances( - self.userapiclient, - id=lb_rule.id, - applied="false" - ) + list_lbruleinstance_applied_false =\ + LoadBalancerRule.listLoadBalancerRuleInstances( + self.userapiclient, + id=lb_rule.id, + applied="false" + ) status = validateList(list_lbruleinstance_applied_false) self.assertEquals( - PASS, - status[0], - "No Instances are available to assign to Load Balancer Rule" - ) + PASS, + status[0], + "No Instances are available to assign to Load Balancer Rule" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbruleinstance_applied_false), - "No Instances are available to assign to Load Balancer Rule" - ) + 1, + len(list_lbruleinstance_applied_false), + "No Instances are available to assign to Load Balancer Rule" + ) # Verifying that Instance created above is listed self.assertEquals( - vm_created.id, - list_lbruleinstance_applied_false[0].id, - "Failed to list Instance available to asign a Load Balancer Rule" - ) + vm_created.id, + list_lbruleinstance_applied_false[0].id, + "Failed to list Instance available to asign a Load Balancer Rule" + ) # Destroying the VM Launched vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -1541,457 +1576,469 @@ class TestIpAddresses(cloudstackTestCase): @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network - Step3: Creating a Load Balancer Rule for IP Address associated in Step2 - Step4: Listing Load Balancer Sticky Policies for LB Rule created in Step3 + Step3: Creating a Load Balancer Rule for IP Address associated + in Step2 + Step4: Listing Load Balancer Sticky Policies for LB Rule created in + Step3 Step5: Verifying that no Load Balancer Sticky Policies are listed - Step6: Creating a Load Balancer Sticky Policies for LB Rule created in Step3 - Step7: Listing Load Balancer Sticky Policies for LB Rule created in Step3 + Step6: Creating a Load Balancer Sticky Policies for LB Rule created in + Step3 + Step7: Listing Load Balancer Sticky Policies for LB Rule created in + Step3 Step8: Verifying 1 Load Balancer Sticky Policy is listed Step9: Deleting the Load Balancer Sticky Policies - Step10: Listing Load Balancer Sticky Policies for LB Rule created in Step3 + Step10: Listing Load Balancer Sticky Policies for LB Rule created in + Step3 Step11: Verifying that no Load Balancer Sticky Policies 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 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" + ) # Listing Load Balancer Stickyness Policies for LB Rule list_lbstickypolicy_before = LoadBalancerRule.listStickyPolicies( - self.userapiclient, - lbruleid=lb_rule.id, - listall=self.services["listall"] - ) + self.userapiclient, + lbruleid=lb_rule.id, + listall=self.services["listall"] + ) # Verifying no Sticky Policies are listed self.assertEquals( - 0, - len(list_lbstickypolicy_before[0].stickinesspolicy), - "Sticky Policy listed for newly created Load Balancer Rule" - ) + 0, + len(list_lbstickypolicy_before[0].stickinesspolicy), + "Sticky Policy listed for newly created Load Balancer Rule" + ) # Creating a Sticy Policy for Load Balancer Rule sticky_policy = LoadBalancerRule.createSticky( - lb_rule, - self.userapiclient, - methodname='LbCookie', - name='LbCookieSticky' - ) + lb_rule, + self.userapiclient, + methodname='LbCookie', + name='LbCookieSticky' + ) self.assertIsNotNone( - sticky_policy, - "Failed to create Sticky Policy for Load Balancer Rule" - ) + sticky_policy, + "Failed to create Sticky Policy for Load Balancer Rule" + ) # Verifying details of Sticky Policy created # Creating expected and actual values dictionaries expected_dict = { - "account":self.account.name, - "domainid":self.domain.id, - "lbruleid":lb_rule.id, - "methodname":"LbCookie", - "name":"LbCookieSticky", - } + "account": self.account.name, + "domainid": self.domain.id, + "lbruleid": lb_rule.id, + "methodname": "LbCookie", + "name": "LbCookieSticky", + } actual_dict = { - "account":sticky_policy.account, - "domainid":sticky_policy.domainid, - "lbruleid":sticky_policy.lbruleid, - "methodname":sticky_policy.stickinesspolicy[0].methodname, - "name":sticky_policy.stickinesspolicy[0].name, - } + "account": sticky_policy.account, + "domainid": sticky_policy.domainid, + "lbruleid": sticky_policy.lbruleid, + "methodname": sticky_policy.stickinesspolicy[0].methodname, + "name": sticky_policy.stickinesspolicy[0].name, + } lbstickypolicy_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - lbstickypolicy_status, - "Created Load Balancer Sticky Policy details are not as expected" - ) + True, + lbstickypolicy_status, + "Created Load Balancer Sticky Policy details are not as expected" + ) # Listing Load Balancer Stickyness Policies for LB Rule list_lbstickypolicy_after = LoadBalancerRule.listStickyPolicies( - self.userapiclient, - lbruleid=lb_rule.id, - listall=self.services["listall"] - ) + self.userapiclient, + lbruleid=lb_rule.id, + listall=self.services["listall"] + ) status = validateList(list_lbstickypolicy_after[0].stickinesspolicy) self.assertEquals( - PASS, - status[0], - "Load Balancer Sticky Policy creation Failed" - ) + PASS, + status[0], + "Load Balancer Sticky Policy creation Failed" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_lbstickypolicy_after[0].stickinesspolicy), - "Load Balancer Sticky Policy creation Failed" - ) + 1, + len(list_lbstickypolicy_after[0].stickinesspolicy), + "Load Balancer Sticky Policy creation Failed" + ) # Deleting the Sticky Policy LoadBalancerRule.deleteSticky( - lb_rule, - self.userapiclient, - id=sticky_policy.stickinesspolicy[0].id - ) + lb_rule, + self.userapiclient, + id=sticky_policy.stickinesspolicy[0].id + ) # Listing Load Balancer Stickyness Policies for LB Rule list_lbstickypolicy_after = LoadBalancerRule.listStickyPolicies( - self.userapiclient, - lbruleid=lb_rule.id, - listall=self.services["listall"] - ) + self.userapiclient, + lbruleid=lb_rule.id, + listall=self.services["listall"] + ) # Verifying no Sticky Policies are listed self.assertEquals( - 0, - len(list_lbstickypolicy_after[0].stickinesspolicy), - "Sticky Policy listed for newly created Load Balancer Rule" - ) + 0, + len(list_lbstickypolicy_after[0].stickinesspolicy), + "Sticky Policy listed for newly created Load Balancer Rule" + ) self.cleanup.append(self.account) return @attr(tags=["advanced"], required_hardware="true") def test_09_create_delete_portforwarding_fornonvpc(self): """ - @summary: Test to list, create and delete Port Forwarding for IP Address associated to Non VPC network + @summary: Test to list, create and delete Port Forwarding for + IP Address associated to Non VPC network @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network Step3: Launching Virtual Machine in network created in step 2 - Step4: Listing Port Forwarding Rules for the IP Address associated in Step2 + Step4: Listing Port Forwarding Rules for the IP Address associated + in Step2 Step5: Verifying that no Port Forwarding Rules are listed - Step6: Creating a Port Forwarding Rule for IP Address associated in Step2 - Step7: Listing Port Forwarding Rules for the IP Address associated in Step2 + Step6: Creating a Port Forwarding Rule for IP Address associated in + Step2 + Step7: Listing Port Forwarding Rules for the IP Address associated in + Step2 Step8: Verifying 1 Port Forwarding Rule is listed Step9: Deleting the Port Forwarding Rule created in Step6 - Step10: Listing Port Forwarding Rules for the IP Address associated in Step2 + Step10: Listing Port Forwarding Rules for the IP Address associated in + Step2 Step11: Verifying that no Port Forwarding 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,PortForwarding", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,PortForwarding", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, PortForwarding enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + PortForwarding 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"] - ) + 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" + ) # Launching a Virtual Machine with above created Network vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) self.cleanup.append(network) # Listing Virtual Machines in running state in above created network list_vms_running = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - state="Running", - networkid=network.id - ) + self.userapiclient, + listall=self.services["listall"], + state="Running", + networkid=network.id + ) status = validateList(list_vms_running) self.assertEquals( - PASS, - status[0], - "VM Created is not in Running state" - ) + PASS, + status[0], + "VM Created is not in Running state" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_after), - "VM Created is not in Runnning state" - ) + 1, + len(list_ipaddresses_after), + "VM Created is not in Runnning state" + ) self.assertEquals( - vm_created.id, - list_vms_running[0].id, - "VM Created is not in Runnning state" - ) + vm_created.id, + list_vms_running[0].id, + "VM Created is not in Runnning state" + ) # Listing Virtual Machines in stopped state in above created network list_vms_stopped = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - state="Stopped", - networkid=network.id - ) + self.userapiclient, + listall=self.services["listall"], + state="Stopped", + networkid=network.id + ) # Verifying no VMs are in stopped state self.assertIsNone( - list_vms_stopped, - "VM Created is in stopped state" - ) + list_vms_stopped, + "VM Created is in stopped state" + ) # Listing Port Forwarding Rules for the IP Address associated list_prtfwdrule_before = NATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no port forwarding rules are listed self.assertIsNone( - list_prtfwdrule_before, - "Port Forwarding Rules listed for newly associated IP Address" - ) + list_prtfwdrule_before, + "Port Forwarding Rules listed for newly associated IP Address" + ) # Creating a Port Forwarding rule portfwd_rule = NATRule.create( - self.userapiclient, - virtual_machine=vm_created, - services=self.services["natrule"], - ipaddressid=associated_ipaddress.ipaddress.id, - ) + self.userapiclient, + virtual_machine=vm_created, + services=self.services["natrule"], + ipaddressid=associated_ipaddress.ipaddress.id, + ) self.assertIsNotNone( - portfwd_rule, - "Failed to create Port Forwarding Rule" - ) + portfwd_rule, + "Failed to create Port Forwarding Rule" + ) # Verifying details of Sticky Policy created # Creating expected and actual values dictionaries expected_dict = { - "ipaddressid":associated_ipaddress.ipaddress.id, - "privateport":str(self.services["natrule"]["privateport"]), - "publicport":str(self.services["natrule"]["publicport"]), - "protocol":str(self.services["natrule"]["protocol"]).lower(), - } + "ipaddressid": associated_ipaddress.ipaddress.id, + "privateport": str(self.services["natrule"]["privateport"]), + "publicport": str(self.services["natrule"]["publicport"]), + "protocol": str(self.services["natrule"]["protocol"]).lower(), + } actual_dict = { - "ipaddressid":portfwd_rule.ipaddressid, - "privateport":str(portfwd_rule.privateport), - "publicport":str(portfwd_rule.publicport), - "protocol":portfwd_rule.protocol, - } + "ipaddressid": portfwd_rule.ipaddressid, + "privateport": str(portfwd_rule.privateport), + "publicport": str(portfwd_rule.publicport), + "protocol": portfwd_rule.protocol, + } portfwd_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - portfwd_status, - "Created Port Forward Rule details are not as expected" - ) + True, + portfwd_status, + "Created Port Forward Rule details are not as expected" + ) # Listing Port Forwarding Rules for the IP Address associated list_prtfwdrule_after = NATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) status = validateList(list_prtfwdrule_after) self.assertEquals( - PASS, - status[0], - "Failed to create Port Forwarding Rule" - ) + PASS, + status[0], + "Failed to create Port Forwarding Rule" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_prtfwdrule_after), - "Failed to create Port Forwarding Rule" - ) + 1, + len(list_prtfwdrule_after), + "Failed to create Port Forwarding Rule" + ) # Deleting Port Forwarding Rule portfwd_rule.delete(self.userapiclient) - # # Listing Port Forwarding Rules for the IP Address associated + # Listing Port Forwarding Rules for the IP Address associated list_prtfwdrule_after = NATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no port forwarding rules are listed self.assertIsNone( - list_prtfwdrule_after, - "Port Forwarding Rules listed after deletion" - ) + list_prtfwdrule_after, + "Port Forwarding Rules listed after deletion" + ) # Destroying the VM Launched vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -2000,221 +2047,222 @@ class TestIpAddresses(cloudstackTestCase): @attr(tags=["advanced"], required_hardware="true") def test_10_create_delete_portforwarding_forvpc(self): """ - @summary: Test to list, create and delete Port Forwarding Rule for IP Address associated to VPC + @summary: Test to list, create and delete Port Forwarding 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: Launching a VM in the Network created in Step 2 - Step5: Listing Port Forwarding Rules for the IP Address associated in Step3 + Step5: Listing Port Forwarding Rules for the IP Address + associated in Step3 Step6: Verifying that no Port Forwarding Rules are listed - Step7: Creating a Port Forwarding Rule for IP Address associated in Step3 - Step8: Listing Port Forwarding Rules for the IP Address associated in Step3 + Step7: Creating a Port Forwarding Rule for IP Address associated + in Step3 + Step8: Listing Port Forwarding Rules for the IP Address + associated in Step3 Step9: Verifying 1 Port Forwarding Rule is listed Step10: Deleting the Port Forwarding Rule created in Step7 - Step11: Listing Port Forwarding Rules for the IP Address associated in Step3 + Step11: Listing Port Forwarding Rules for the IP Address + associated in Step3 Step12: Verifying that no Port Forwarding 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="SourceNat,PortForwarding", - state="Enabled" - ) + self.userapiclient, + forvpc="true", + zoneid=self.zone.id, + supportedServices="SourceNat,PortForwarding", + state="Enabled" + ) status = validateList(network_offering_vpc_true_list) - self.assertEquals(PASS, status[0], "Default network offering not present for vpc = true with PortForwarding") + self.assertEquals( + PASS, + status[0], + "Default network offering not present for\ + vpc = true with PortForwarding") # 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.assertIsNotNone( - network_created, - "Network is not created" - ) + network_created, + "Network is not 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" + ) # Launching a Virtual Machine with above created Network vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network_created.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network_created.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) self.cleanup.append(network_created) self.cleanup.append(vpc_created) # Listing Port Forwarding Rules for the IP Address associated list_prtfwdrule_before = NATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no port forwarding rules are listed self.assertIsNone( - list_prtfwdrule_before, - "Port Forwarding Rules listed for newly associated IP Address" - ) + list_prtfwdrule_before, + "Port Forwarding Rules listed for newly associated IP Address" + ) # Creating a Port Forwarding rule portfwd_rule = NATRule.create( - self.userapiclient, - virtual_machine=vm_created, - services=self.services["natrule"], - ipaddressid=associated_ipaddress.ipaddress.id, - networkid=network_created.id - ) + self.userapiclient, + virtual_machine=vm_created, + services=self.services["natrule"], + ipaddressid=associated_ipaddress.ipaddress.id, + networkid=network_created.id + ) self.assertIsNotNone( - portfwd_rule, - "Failed to create Port Forwarding Rule" - ) + portfwd_rule, + "Failed to create Port Forwarding Rule" + ) # Verifying details of Sticky Policy created # Creating expected and actual values dictionaries expected_dict = { - "ipaddressid":associated_ipaddress.ipaddress.id, - "privateport":str(self.services["natrule"]["privateport"]), - "publicport":str(self.services["natrule"]["publicport"]), - "protocol":str(self.services["natrule"]["protocol"]).lower(), - } + "ipaddressid": associated_ipaddress.ipaddress.id, + "privateport": str(self.services["natrule"]["privateport"]), + "publicport": str(self.services["natrule"]["publicport"]), + "protocol": str(self.services["natrule"]["protocol"]).lower(), + } actual_dict = { - "ipaddressid":portfwd_rule.ipaddressid, - "privateport":str(portfwd_rule.privateport), - "publicport":str(portfwd_rule.publicport), - "protocol":portfwd_rule.protocol, - } + "ipaddressid": portfwd_rule.ipaddressid, + "privateport": str(portfwd_rule.privateport), + "publicport": str(portfwd_rule.publicport), + "protocol": portfwd_rule.protocol, + } portfwd_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - portfwd_status, - "Created Port Forward Rule details are not as expected" - ) + True, + portfwd_status, + "Created Port Forward Rule details are not as expected" + ) # Listing Port Forwarding Rules for the IP Address associated list_prtfwdrule_after = NATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) status = validateList(list_prtfwdrule_after) self.assertEquals( - PASS, - status[0], - "Failed to create Port Forwarding Rule" - ) + PASS, + status[0], + "Failed to create Port Forwarding Rule" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_prtfwdrule_after), - "Failed to create Port Forwarding Rule" - ) + 1, + len(list_prtfwdrule_after), + "Failed to create Port Forwarding Rule" + ) # Deleting Port Forwarding Rule portfwd_rule.delete(self.userapiclient) - # # Listing Port Forwarding Rules for the IP Address associated + # Listing Port Forwarding Rules for the IP Address associated list_prtfwdrule_after = NATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no port forwarding rules are listed self.assertIsNone( - list_prtfwdrule_after, - "Port Forwarding Rules listed after deletion" - ) + list_prtfwdrule_after, + "Port Forwarding Rules listed after deletion" + ) # Destroying the VM Launched vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -2223,7 +2271,8 @@ class TestIpAddresses(cloudstackTestCase): @attr(tags=["advanced"], required_hardware="true") def test_11_create_delete_firewallrule(self): """ - @summary: Test to list, create and delete Firewall Rule for IP Address associated to Non VPC network + @summary: Test to list, create and delete Firewall Rule for + IP Address associated to Non VPC network @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network @@ -2238,161 +2287,162 @@ 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,Firewall", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Firewall", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Firewall enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Firewall 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 Firewall rules for the IP Associated list_firewalls_before = FireWallRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no firewall rules are listed self.assertIsNone( - list_firewalls_before, - "Firewall Rules listed for newly associated IP Address" - ) + list_firewalls_before, + "Firewall Rules listed for newly associated IP Address" + ) # Creating a Firewall Rule firewall_rule = FireWallRule.create( - self.userapiclient, - ipaddressid=associated_ipaddress.ipaddress.id, - protocol='tcp', - cidrlist='10.1.1.1/16', - startport='22', - endport='2222' - ) + self.userapiclient, + ipaddressid=associated_ipaddress.ipaddress.id, + protocol='tcp', + cidrlist='10.1.1.1/16', + startport='22', + endport='2222' + ) self.assertIsNotNone( - firewall_rule, - "Failed to create Firewall Rule" - ) + firewall_rule, + "Failed to create Firewall Rule" + ) # Verifying details of the created Firewall Rule # Creating expected and actual values dictionaries expected_dict = { - "ipaddressid":associated_ipaddress.ipaddress.id, - "startport":"22", - "endport":"2222", - "protocol":"tcp", - "cidrlist":"10.1.1.1/16" - } + "ipaddressid": associated_ipaddress.ipaddress.id, + "startport": "22", + "endport": "2222", + "protocol": "tcp", + "cidrlist": "10.1.1.1/16" + } actual_dict = { - "ipaddressid":firewall_rule.ipaddressid, - "startport":firewall_rule.startport, - "endport":firewall_rule.endport, - "protocol":firewall_rule.protocol, - "cidrlist":firewall_rule.cidrlist - } + "ipaddressid": firewall_rule.ipaddressid, + "startport": firewall_rule.startport, + "endport": firewall_rule.endport, + "protocol": firewall_rule.protocol, + "cidrlist": firewall_rule.cidrlist + } firewall_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - firewall_status, - "Created Firewall Rule details are not as expected" - ) + True, + firewall_status, + "Created Firewall Rule details are not as expected" + ) # Listing Firewall rules for the IP Associated list_firewalls_after = FireWallRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) status = validateList(list_firewalls_after) self.assertEquals( - PASS, - status[0], - "Failed to create Firewall Rule" - ) + PASS, + status[0], + "Failed to create Firewall Rule" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_firewalls_after), - "Failed to create Firewall Rule" - ) + 1, + len(list_firewalls_after), + "Failed to create Firewall Rule" + ) # Deleting the Firewall Rule firewall_rule.delete(self.userapiclient) # Listing Firewall rules for the IP Associated list_firewalls_after = FireWallRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no firewall rules are listed self.assertIsNone( - list_firewalls_after, - "Failed to create Firewall Rule" - ) + list_firewalls_after, + "Failed to create Firewall Rule" + ) self.cleanup.append(self.account) return @@ -2403,169 +2453,174 @@ class TestIpAddresses(cloudstackTestCase): @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network - Step3: Listing Remore Access VPNs for the IP Address associated in Step2 + Step3: Listing Remore Access VPNs for the IP Address associated + in Step2 Step4: Verifying that no Remore Access VPNs are listed - Step5: Creating a Remore Access VPN for IP Address associated in Step2 - Step6: Listing Remore Access VPNs for the IP Address associated in Step2 + Step5: Creating a Remore Access VPN for IP Address associated + in Step2 + Step6: Listing Remore Access VPNs for the IP Address associated in + Step2 Step7: Verifying 1 Remore Access VPN is listed Step8: Deleting the Remore Access VPNs created in Step5 - Step9: Listing Remore Access VPNs for the IP Address associated in Step2 + Step9: Listing Remore Access VPNs for the IP Address associated i + Step2 Step10: Verifying that no Remore Access VPNs 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,Vpn", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Vpn", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Vpn enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Vpn 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 Remote access VPNs for the IP Associated list_vpns_before = Vpn.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no Remote Access VPNs are listed self.assertIsNone( - list_vpns_before, - "Remote Access VPNs listed for newly associated IP Address" - ) + list_vpns_before, + "Remote Access VPNs listed for newly associated IP Address" + ) # Creating a Remote Access VPN vpn_created = Vpn.create( - self.userapiclient, - publicipid=associated_ipaddress.ipaddress.id, - account=self.account.name, - domainid=self.domain.id, - openfirewall='false' - ) + self.userapiclient, + publicipid=associated_ipaddress.ipaddress.id, + account=self.account.name, + domainid=self.domain.id, + openfirewall='false' + ) self.assertIsNotNone( - vpn_created, - "Failed to create Remote Access VPN" - ) + vpn_created, + "Failed to create Remote Access VPN" + ) # Verifying details of the created Remote Access VPN # Creating expected and actual values dictionaries expected_dict = { - "ipaddressid":associated_ipaddress.ipaddress.id, - "account":self.account.name, - "domainid":self.domain.id, - "state":"Running", - } + "ipaddressid": associated_ipaddress.ipaddress.id, + "account": self.account.name, + "domainid": self.domain.id, + "state": "Running", + } actual_dict = { - "ipaddressid":vpn_created.publicipid, - "account":vpn_created.account, - "domainid":vpn_created.domainid, - "state":vpn_created.state, - } + "ipaddressid": vpn_created.publicipid, + "account": vpn_created.account, + "domainid": vpn_created.domainid, + "state": vpn_created.state, + } vpn_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - vpn_status, - "Created Remote Access VPN details are not as expected" - ) + True, + vpn_status, + "Created Remote Access VPN details are not as expected" + ) # Listing Remote Access VPNs for the IP Associated list_vpns_after = Vpn.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) status = validateList(list_vpns_after) self.assertEquals( - PASS, - status[0], - "Failed to create Remote Access VPN" - ) + PASS, + status[0], + "Failed to create Remote Access VPN" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_vpns_after), - "Failed to create Remote Access VPN" - ) + 1, + len(list_vpns_after), + "Failed to create Remote Access VPN" + ) # Deleting the Remote Access VPN vpn_created.delete(self.userapiclient) # Listing Remote Access VPNs for the IP Associated list_vpns_after = Vpn.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no Remote Access VPNs are listed self.assertIsNone( - list_vpns_after, - "Failed to create Remote Access VPN" - ) + list_vpns_after, + "Failed to create Remote Access VPN" + ) self.cleanup.append(self.account) return @@ -2589,192 +2644,193 @@ 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,Vpn", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Vpn", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Vpn enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Vpn 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" + ) # Launching Virtual Machine vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) # Listing Remote access VPNs for the IP Associated list_vpns_before = Vpn.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) # Verifying no Remote Access VPNs are listed self.assertIsNone( - list_vpns_before, - "Remote Access VPNs listed for newly associated IP Address" - ) + list_vpns_before, + "Remote Access VPNs listed for newly associated IP Address" + ) # Creating a Remote Access VPN vpn_created = Vpn.create( - self.userapiclient, - publicipid=associated_ipaddress.ipaddress.id, - account=self.account.name, - domainid=self.domain.id, - openfirewall='false' - ) + self.userapiclient, + publicipid=associated_ipaddress.ipaddress.id, + account=self.account.name, + domainid=self.domain.id, + openfirewall='false' + ) self.assertIsNotNone( - vpn_created, - "Failed to create Remote Access VPN" - ) + vpn_created, + "Failed to create Remote Access VPN" + ) # Listing Remote Access VPNs for the IP Associated list_vpns_after = Vpn.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress.ipaddress.id + ) status = validateList(list_vpns_after) self.assertEquals( - PASS, - status[0], - "Failed to create Remote Access VPN" - ) + PASS, + status[0], + "Failed to create Remote Access VPN" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_vpns_after), - "Failed to create Remote Access VPN" - ) + 1, + len(list_vpns_after), + "Failed to create Remote Access VPN" + ) # Listing VPN Users list_vpnusers_beore = VpnUser.list( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) # Verifying no VPN Users listed self.assertIsNone( - list_vpnusers_beore, - "VPN Users listed for newly created VPN" - ) + list_vpnusers_beore, + "VPN Users listed for newly created VPN" + ) # Creating a VPN User vpnuser_created = VpnUser.create( - self.userapiclient, - username=self.services["vpn_user"]["username"], - password=self.services["vpn_user"]["password"], - account=self.account.name, - domainid=self.domain.id - ) + self.userapiclient, + username=self.services["vpn_user"]["username"], + password=self.services["vpn_user"]["password"], + account=self.account.name, + domainid=self.domain.id + ) self.assertIsNotNone( - vpnuser_created, - "Failed to create VPN User" - ) + vpnuser_created, + "Failed to create VPN User" + ) # Listing VPN Users list_vpnusers_after = VpnUser.list( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) status = validateList(list_vpnusers_after) self.assertEquals( - PASS, - status[0], - "Failed to list VPN user after creation" - ) + PASS, + status[0], + "Failed to list VPN user after creation" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_vpnusers_after), - "Failed to list VPN user after creation" - ) + 1, + len(list_vpnusers_after), + "Failed to list VPN user after creation" + ) # Deleting the VPN User vpnuser_created.delete(self.userapiclient) # Listing VPN Users list_vpnusers_after = VpnUser.list( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) # Verifying no VPN Users are listed self.assertIsNone( - list_vpnusers_after, - "VPN User listed after deletion" - ) + list_vpnusers_after, + "VPN User listed after deletion" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -2783,7 +2839,8 @@ class TestIpAddresses(cloudstackTestCase): @attr(tags=["advanced"], required_hardware="true") def test_14_enable_disable_staticnat_fornonvpc(self): """ - @summary: Test to Enable and Disable StaticNat for IP Address associated to Non VPC Network + @summary: Test to Enable and Disable StaticNat for + IP Address associated to Non VPC Network @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network created in step1 @@ -2796,161 +2853,162 @@ 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,StaticNat", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,StaticNat", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Vpn enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Vpn 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_ipaddress1 = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress1, - "Failed to Associate IP Address" - ) + associated_ipaddress1, + "Failed to Associate IP Address" + ) # Associating another IP Addresses to Network created associated_ipaddress2 = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress2, - "Failed to Associate IP Address" - ) + associated_ipaddress2, + "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( - 2, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 2, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Launching a Virtual Machine vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) # Enabling static Nat for Ip Address associated StaticNATRule.enable( - self.userapiclient, - ipaddressid=associated_ipaddress2.ipaddress.id, - virtualmachineid=vm_created.id, - ) + self.userapiclient, + ipaddressid=associated_ipaddress2.ipaddress.id, + virtualmachineid=vm_created.id, + ) # Listing Ip Address by id list_ipaddress = PublicIPAddress.list( - self.userapiclient, - id=associated_ipaddress2.ipaddress.id, - listall=self.services["listall"] - ) + self.userapiclient, + id=associated_ipaddress2.ipaddress.id, + listall=self.services["listall"] + ) status = validateList(list_ipaddress) self.assertEquals( - PASS, - status[0], - "Failed to List IP Address" - ) + PASS, + status[0], + "Failed to List IP Address" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddress), - "Failed to List IP Address" - ) + 1, + len(list_ipaddress), + "Failed to List IP Address" + ) self.assertEquals( - True, - list_ipaddress[0].isstaticnat, - "Failed to Enable Static Nat" - ) + True, + list_ipaddress[0].isstaticnat, + "Failed to Enable Static Nat" + ) # Disabling static Nat StaticNATRule.disable( - self.userapiclient, - ipaddressid=associated_ipaddress2.ipaddress.id - ) + self.userapiclient, + ipaddressid=associated_ipaddress2.ipaddress.id + ) # Listing Ip Address by id list_ipaddress = PublicIPAddress.list( - self.userapiclient, - id=associated_ipaddress2.ipaddress.id, - listall=self.services["listall"] - ) + self.userapiclient, + id=associated_ipaddress2.ipaddress.id, + listall=self.services["listall"] + ) status = validateList(list_ipaddress) self.assertEquals( - PASS, - status[0], - "Failed to List IP Address" - ) + PASS, + status[0], + "Failed to List IP Address" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddress), - "Failed to List IP Address" - ) + 1, + len(list_ipaddress), + "Failed to List IP Address" + ) self.assertEquals( - False, - list_ipaddress[0].isstaticnat, - "Failed to Disable Static Nat" - ) + False, + list_ipaddress[0].isstaticnat, + "Failed to Disable Static Nat" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -2959,7 +3017,8 @@ class TestIpAddresses(cloudstackTestCase): @attr(tags=["advanced"], required_hardware="true") def test_15_enable_disable_staticnat_forvpc(self): """ - @summary: Test to Enable and Disable StaticNat for IP Address associated to VPC Network + @summary: Test to Enable and Disable StaticNat for + IP Address associated to VPC Network @Steps: Step1: Creating a VPC Step2: Creating a Network under VPC for the user @@ -2970,187 +3029,183 @@ class TestIpAddresses(cloudstackTestCase): Step7: Disabling the staticNat to IP Associated in Step3 Step8: Verifying that StaticNat is disabled """ - # Listing all the vpc's for a user + # 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="SourceNat,PortForwarding,StaticNat", - state="Enabled" - ) + self.userapiclient, + forvpc="true", + zoneid=self.zone.id, + supportedServices="SourceNat,PortForwarding,StaticNat", + state="Enabled" + ) status = validateList(network_offering_vpc_true_list) - self.assertEquals(PASS, status[0], "Default network offering not present for vpc = true with PortForwarding") + self.assertEquals( + PASS, + status[0], + "Default network offering not present\ + for vpc = true with PortForwarding") # 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.assertIsNotNone( - network_created, - "Network is not created" - ) + network_created, + "Network is not 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" + ) # Launching a Virtual Machine with above created Network vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network_created.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network_created.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) self.cleanup.append(network_created) self.cleanup.append(vpc_created) # Enabling static Nat for Ip Address associated StaticNATRule.enable( - self.userapiclient, - ipaddressid=associated_ipaddress.ipaddress.id, - virtualmachineid=vm_created.id, - networkid=network_created.id - ) + self.userapiclient, + ipaddressid=associated_ipaddress.ipaddress.id, + virtualmachineid=vm_created.id, + networkid=network_created.id + ) # Listing Ip Address by id list_ipaddress = PublicIPAddress.list( - self.userapiclient, - id=associated_ipaddress.ipaddress.id, - listall=self.services["listall"] - ) + self.userapiclient, + id=associated_ipaddress.ipaddress.id, + listall=self.services["listall"] + ) status = validateList(list_ipaddress) self.assertEquals( - PASS, - status[0], - "Failed to List IP Address" - ) + PASS, + status[0], + "Failed to List IP Address" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddress), - "Failed to List IP Address" - ) + 1, + len(list_ipaddress), + "Failed to List IP Address" + ) self.assertEquals( - True, - list_ipaddress[0].isstaticnat, - "Failed to Enable Static Nat" - ) + True, + list_ipaddress[0].isstaticnat, + "Failed to Enable Static Nat" + ) # Disabling static Nat StaticNATRule.disable( - self.userapiclient, - ipaddressid=associated_ipaddress.ipaddress.id - ) + self.userapiclient, + ipaddressid=associated_ipaddress.ipaddress.id + ) # Listing Ip Address by id list_ipaddress = PublicIPAddress.list( - self.userapiclient, - id=associated_ipaddress.ipaddress.id, - listall=self.services["listall"] - ) + self.userapiclient, + id=associated_ipaddress.ipaddress.id, + listall=self.services["listall"] + ) status = validateList(list_ipaddress) self.assertEquals( - PASS, - status[0], - "Failed to List IP Address" - ) + PASS, + status[0], + "Failed to List IP Address" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddress), - "Failed to List IP Address" - ) + 1, + len(list_ipaddress), + "Failed to List IP Address" + ) self.assertEquals( - False, - list_ipaddress[0].isstaticnat, - "Failed to Disable Static Nat" - ) + False, + list_ipaddress[0].isstaticnat, + "Failed to Disable Static Nat" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -3159,7 +3214,8 @@ class TestIpAddresses(cloudstackTestCase): @attr(tags=["advanced"], required_hardware="true") def test_16_create_delete_ipforwardingrule(self): """ - @summary: Test to list, create and delete IP Forwarding Rules for IP Address + @summary: Test to list, create and + delete IP Forwarding Rules for IP Address @Steps: Step1: Creating a Network for the user Step2: Associating an IP Addresses for Network created in step1 @@ -3177,188 +3233,189 @@ 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,Vpn", - zoneid=self.zone.id - ) + self.apiClient, + forvpc="false", + guestiptype="Isolated", + state="Enabled", + supportedservices="SourceNat,Vpn", + zoneid=self.zone.id + ) status = validateList(network_offerings_list) self.assertEquals( - PASS, - status[0], - "Isolated Network Offerings with sourceNat, Vpn enabled are not found" - ) + PASS, + status[0], + "Isolated Network Offerings with sourceNat,\ + Vpn 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_ipaddress1 = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress1, - "Failed to Associate IP Address" - ) + associated_ipaddress1, + "Failed to Associate IP Address" + ) # Associating another IP Addresses to Network created associated_ipaddress2 = PublicIPAddress.create( - self.userapiclient, - services=self.services["network"], - networkid=network.id - ) + self.userapiclient, + services=self.services["network"], + networkid=network.id + ) self.assertIsNotNone( - associated_ipaddress2, - "Failed to Associate IP Address" - ) + associated_ipaddress2, + "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( - 2, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 2, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Launching a Virtual Machine vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network created" + ) # Enabling static Nat for Ip Address associated StaticNATRule.enable( - self.userapiclient, - ipaddressid=associated_ipaddress2.ipaddress.id, - virtualmachineid=vm_created.id, - ) + self.userapiclient, + ipaddressid=associated_ipaddress2.ipaddress.id, + virtualmachineid=vm_created.id, + ) # Listing Ip Address by id list_ipaddress = PublicIPAddress.list( - self.userapiclient, - id=associated_ipaddress2.ipaddress.id, - listall=self.services["listall"] - ) + self.userapiclient, + id=associated_ipaddress2.ipaddress.id, + listall=self.services["listall"] + ) status = validateList(list_ipaddress) self.assertEquals( - PASS, - status[0], - "Failed to List IP Address" - ) + PASS, + status[0], + "Failed to List IP Address" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddress), - "Failed to List IP Address" - ) + 1, + len(list_ipaddress), + "Failed to List IP Address" + ) self.assertEquals( - True, - list_ipaddress[0].isstaticnat, - "Failed to Enable Static Nat" - ) + True, + list_ipaddress[0].isstaticnat, + "Failed to Enable Static Nat" + ) # Listing IP Forwarding Rules list_ipfwdrule_before = StaticNATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress2.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress2.ipaddress.id + ) # Verifying no IP Forwarding Rules are listed self.assertIsNone( - list_ipfwdrule_before, - "IP Forwardign Rule listed for newly enabled StaticNat IP" - ) + list_ipfwdrule_before, + "IP Forwardign Rule listed for newly enabled StaticNat IP" + ) # Creating IP Forwardign Rule ipfwd_rule = StaticNATRule.createIpForwardingRule( - self.userapiclient, - startport='80', - endport='89', - protocol='tcp', - ipaddressid=associated_ipaddress2.ipaddress.id, - openfirewall=False - ) + self.userapiclient, + startport='80', + endport='89', + protocol='tcp', + ipaddressid=associated_ipaddress2.ipaddress.id, + openfirewall=False + ) self.assertIsNotNone( - ipfwd_rule, - "Failed to create IP Forwarding Rule" - ) + ipfwd_rule, + "Failed to create IP Forwarding Rule" + ) # Listing IP Forwarding Rules list_ipfwdrule_after = StaticNATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress2.ipaddress.id - ) + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress2.ipaddress.id + ) status = validateList(list_ipfwdrule_after) self.assertEquals( - PASS, - status[0], - "Failed to List IP Forwarding Rule after Creation" - ) + PASS, + status[0], + "Failed to List IP Forwarding Rule after Creation" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipfwdrule_after), - "Failed to List IP Forwarding Rule after Creation" - ) + 1, + len(list_ipfwdrule_after), + "Failed to List IP Forwarding Rule after Creation" + ) # Deleting IP Forwarding Rule ipfwd_rule.delete(self.userapiclient) # Listing IP Forwarding Rules list_ipfwdrule_after = StaticNATRule.list( - self.userapiclient, - listall=self.services["listall"], - ipaddressid=associated_ipaddress2.ipaddress.id - ) - # Verifying no IP Forwarding Rules are listed + self.userapiclient, + listall=self.services["listall"], + ipaddressid=associated_ipaddress2.ipaddress.id + ) + # Verifying no IP Forwarding Rules are listed self.assertIsNone( - list_ipfwdrule_after, - "IP Forwardign Rule listed after deletion" - ) + list_ipfwdrule_after, + "IP Forwardign Rule listed after deletion" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -3369,7 +3426,8 @@ class TestIpAddresses(cloudstackTestCase): """ @summary: Test to list, create and update Autoscale Policy @Steps: - Step1: Creating a Network Offering for Supported Service LB with Netscaler + Step1: Creating a Network Offering for Supported + Service LB with Netscaler Step2: Create a Network using Network Offering created in Step1 Step3: Launching a VM using Network created in Step2 Step4: Associating IP Address for Network created in Step2 @@ -3389,254 +3447,254 @@ class TestIpAddresses(cloudstackTestCase): Step18: Verifying Autoscale policy is updated with condition2 """ if self.hypervisor.lower() == 'kvm': - raise unittest.SkipTest("ScaleVM is not supported on KVM. Hence, skipping the test") + raise unittest.SkipTest( + "ScaleVM is not supported on KVM. Hence, skipping the test") list_physical_networks = PhysicalNetwork.list( - self.apiClient, - zoneid=self.zone.id - ) - physical_networks_size = 0 - if list_physical_networks is not None: - physical_networks_size = len(list_physical_networks) - + self.apiClient, + zoneid=self.zone.id + ) run_flag = False for i in range(0, len(list_physical_networks)): list_network_serviceprovider = NetworkServiceProvider.list( - self.apiClient, - physicalnetworkid=list_physical_networks[i].id - ) + self.apiClient, + physicalnetworkid=list_physical_networks[i].id + ) for j in range(0, len(list_network_serviceprovider)): - if((list_network_serviceprovider[j].name == 'Netscaler') and (list_network_serviceprovider[j].state == 'Enabled')): + if((list_network_serviceprovider[j].name == 'Netscaler') and + (list_network_serviceprovider[j].state == 'Enabled')): run_flag = True break - if(run_flag == False): - self.debug("Netscaler is not enabled and auto scale VM is applicable only for Netscaler") + if not run_flag: + self.debug( + "Netscaler is not enabled and auto scale VM is\ + applicable only for Netscaler") else: # Listing Network Offerings list_nwoff_before = 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 + ) # Creating Network Offerign with LB as Netscalar nwoff_created = NetworkOffering.create( - self.apiClient, - self.services["nw_off_isolated_netscaler"] - ) + self.apiClient, + self.services["nw_off_isolated_netscaler"] + ) self.assertIsNotNone( - nwoff_created, - "Failed to Create Network Offering with LB sercvice for Netscaler" - ) + nwoff_created, + "Failed to Create Network Offering with\ + LB sercvice for Netscaler") # Enable Network offering nwoff_created.update(self.apiClient, state='Enabled') # Listing Network Offerings again list_nwoff_after = 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 + ) self.assertEquals( - len(list_nwoff_before) + 1, - len(list_nwoff_after), - "Failed to create Network Offering" - ) + len(list_nwoff_before) + 1, + len(list_nwoff_after), + "Failed to create Network Offering" + ) # Creating a Network Using the Network Offering network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=nwoff_created.id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=nwoff_created.id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) self.cleanup.append(nwoff_created) # Launching a Virtual Machine vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network 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], - "IP Addresses Association Failed while launching a VM" - ) + PASS, + status[0], + "IP Addresses Association Failed while launching a VM" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_before), - "IP Addresses Association Failed while launching a VM" - ) + 1, + len(list_ipaddresses_before), + "IP Addresses Association Failed while launching a VM" + ) # 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( - 2, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 2, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing Counters list_counters = Autoscale.listCounters( - self.userapiclient, - ) + self.userapiclient, + ) status = validateList(list_counters) self.assertEquals( - PASS, - status[0], - "Failed to list counters" - ) + PASS, + status[0], + "Failed to list counters" + ) # Listing Conditions list_conditions_before = Autoscale.listConditions( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) self.assertIsNone( - list_conditions_before, - "Listed Conditions for newly created user" - ) + list_conditions_before, + "Listed Conditions for newly created user" + ) # Creating first Condition condition_created1 = Autoscale.createCondition( - self.userapiclient, - counterid=list_counters[0].id, - relationaloperator='GT', - threshold='1000' - ) + self.userapiclient, + counterid=list_counters[0].id, + relationaloperator='GT', + threshold='1000' + ) self.assertIsNotNone( - condition_created1, - "Failed to create Condition" - ) + condition_created1, + "Failed to create Condition" + ) # Creating second Condition condition_created2 = Autoscale.createCondition( - self.userapiclient, - counterid=list_counters[0].id, - relationaloperator='GT', - threshold='1500' - ) + self.userapiclient, + counterid=list_counters[0].id, + relationaloperator='GT', + threshold='1500' + ) self.assertIsNotNone( - condition_created2, - "Failed to create Condition" - ) + condition_created2, + "Failed to create Condition" + ) # Listing Conditions again list_conditions_after = Autoscale.listConditions( - self.userapiclient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.userapiclient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) status = validateList(list_conditions_after) self.assertEquals( - PASS, - status[0], - "Failed to list Conditions after creation" - ) + PASS, + status[0], + "Failed to list Conditions after creation" + ) # Listing Autoscale policies list_autoscalepolicies_before = Autoscale.listAutoscalePolicies( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) # Verifying no Autoscale policies are listed self.assertIsNone( - list_autoscalepolicies_before, - "Autoscale policies listed" - ) + list_autoscalepolicies_before, + "Autoscale policies listed" + ) # Creating Autoscale Policy autoscalepolicy_created = Autoscale.createAutoscalePolicy( - self.userapiclient, - action='scaleup', - conditionids=condition_created1.id, - duration='100', - quiettime='100' - ) + self.userapiclient, + action='scaleup', + conditionids=condition_created1.id, + duration='100', + quiettime='100' + ) self.assertIsNotNone( - autoscalepolicy_created, - "Failed to create Autoscale VM Policy" - ) + autoscalepolicy_created, + "Failed to create Autoscale VM Policy" + ) # Verifying autoscalepolicy is created using condition1 self.assertEquals( - condition_created1.id, - autoscalepolicy_created.conditions[0].id, - "Autoscale Policy not created by given condition" - ) + condition_created1.id, + autoscalepolicy_created.conditions[0].id, + "Autoscale Policy not created by given condition" + ) # Listing Autoscale policies list_autoscalepolicies_after = Autoscale.listAutoscalePolicies( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_autoscalepolicies_after) self.assertEquals( - PASS, - status[0], - "Failed to list Autoscale Policy after creation" - ) + PASS, + status[0], + "Failed to list Autoscale Policy after creation" + ) self.assertEquals( - 1, - len(list_autoscalepolicies_after), - "Autoscale Policies count is not matching" - ) + 1, + len(list_autoscalepolicies_after), + "Autoscale Policies count is not matching" + ) # Updating Autoscale Policy autoscalepolicy_updated = Autoscale.updateAutoscalePolicy( - self.userapiclient, - id=autoscalepolicy_created.id, - conditionids=condition_created2.id, - duration='100', - quiettime='100' - ) + self.userapiclient, + id=autoscalepolicy_created.id, + conditionids=condition_created2.id, + duration='100', + quiettime='100' + ) self.assertIsNotNone( - autoscalepolicy_updated, - "Failed to update Autoscale Policy" - ) + autoscalepolicy_updated, + "Failed to update Autoscale Policy" + ) # Verifying the Autoscale Policy is updated self.assertEquals( - condition_created2.id, - autoscalepolicy_updated.conditions[0].id, - "Autoscale Policy not updated to given condition" - ) + condition_created2.id, + autoscalepolicy_updated.conditions[0].id, + "Autoscale Policy not updated to given condition" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -3647,316 +3705,324 @@ class TestIpAddresses(cloudstackTestCase): """ @summary: Test to list, create and update Autoscale VM Profiles @Steps: - Step1: Creating a Network Offering for Supported Service LB with Netscaler + Step1: Creating a Network Offering for Supported Service LB with + Netscaler Step2: Create a Network using Network Offering created in Step1 Step3: Launching a VM using Network created in Step2 Step4: Associating IP Address for Network created in Step2 Step5: Listing Available Service Offerings Step6: Listing all types of templates - Step7: Verifying only featured templates are listed for newly created user + Step7: Verifying only featured templates are listed for + newly created user Step8: Listing autoscale vm profiles Step9: Verifying no Autoscale VM Profiles are listed Step10: Creating a Autoscale VM Profile Step11: Listing Autoscale VM Profile Step12: Verifying 1 Autoscale VM Profile is listed Step13: Listing Autoscale VM Profile by id - Step14: Verifying details of the created autoscale vm profile are matching with listed autoscal vm profile + Step14: Verifying details of the created autoscale + vm profile are matching with listed autoscal vm profile Step15: Updating Autoscale VM profile with destroy vm grace period Step16: Verifying that Autoscale VM is updated """ if self.hypervisor.lower() == 'kvm': - raise unittest.SkipTest("ScaleVM is not supported on KVM. Hence, skipping the test") + raise unittest.SkipTest( + "ScaleVM is not supported on KVM. Hence, skipping the test") list_physical_networks = PhysicalNetwork.list( - self.apiClient, - zoneid=self.zone.id - ) - physical_networks_size = 0 - if list_physical_networks is not None: - physical_networks_size = len(list_physical_networks) + self.apiClient, + zoneid=self.zone.id + ) run_flag = False for i in range(0, len(list_physical_networks)): list_network_serviceprovider = NetworkServiceProvider.list( - self.apiClient, - physicalnetworkid=list_physical_networks[i].id - ) + self.apiClient, + physicalnetworkid=list_physical_networks[i].id + ) for j in range(0, len(list_network_serviceprovider)): - if((list_network_serviceprovider[j].name == 'Netscaler') and (list_network_serviceprovider[j].state == 'Enabled')): + if((list_network_serviceprovider[j].name == 'Netscaler') and + (list_network_serviceprovider[j].state == 'Enabled')): run_flag = True break - if(run_flag == False): - self.debug("Netscaler is not enabled and auto scale VM is applicable only for Netscaler") + if not run_flag: + self.debug( + "Netscaler is not enabled and auto scale VM\ + is applicable only for Netscaler") else: # Listing Network Offerings list_nwoff_before = 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 + ) # Creating Network Offerign with LB as Netscalar nwoff_created = NetworkOffering.create( - self.apiClient, - self.services["nw_off_isolated_netscaler"] - ) + self.apiClient, + self.services["nw_off_isolated_netscaler"] + ) self.assertIsNotNone( - nwoff_created, - "Failed to Create Network Offering with LB sercvice for Netscaler" - ) + nwoff_created, + "Failed to Create Network Offering with\ + LB sercvice for Netscaler") # Enable Network offering nwoff_created.update(self.apiClient, state='Enabled') # Listing Network Offerings again list_nwoff_after = 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 + ) self.assertEquals( - len(list_nwoff_before) + 1, - len(list_nwoff_after), - "Failed to create Network Offering" - ) + len(list_nwoff_before) + 1, + len(list_nwoff_after), + "Failed to create Network Offering" + ) # Creating a Network Using the Network Offering network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=nwoff_created.id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=nwoff_created.id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) self.cleanup.append(nwoff_created) # Launching a Virtual Machine vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network 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], - "IP Addresses Association Failed while launching a VM" - ) + PASS, + status[0], + "IP Addresses Association Failed while launching a VM" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_before), - "IP Addresses Association Failed while launching a VM" - ) + 1, + len(list_ipaddresses_before), + "IP Addresses Association Failed while launching a VM" + ) # 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( - 2, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 2, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing Service Offerings list_service_offerings = ServiceOffering.list( - self.userapiclient, - listall=self.services["listall"], - issystem='false' - ) + self.userapiclient, + listall=self.services["listall"], + issystem='false' + ) status = validateList(list_service_offerings) self.assertEquals( - PASS, - status[0], - "Failed to list Service Offerings" - ) + PASS, + status[0], + "Failed to list Service Offerings" + ) # Listing Users list_users = User.list( - self.apiClient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.apiClient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) status = validateList(list_users) self.assertEquals( - PASS, - status[0], - "Failed to list Users" - ) + PASS, + status[0], + "Failed to list Users" + ) # Listing Featured Templates list_templates_featured = Template.list( - self.userapiclient, - listall=self.services["listall"], - templatefilter="featured", - zoneid=self.zone.id - ) + self.userapiclient, + listall=self.services["listall"], + templatefilter="featured", + zoneid=self.zone.id + ) status = validateList(list_templates_featured) self.assertEquals( - PASS, - status[0], - "Failed to list Featured Templates" - ) + PASS, + status[0], + "Failed to list Featured Templates" + ) # Listing Community Templates list_templates_community = Template.list( - self.userapiclient, - listall=self.services["listall"], - templatefilter="community", - zoneid=self.zone.id - ) + self.userapiclient, + listall=self.services["listall"], + templatefilter="community", + zoneid=self.zone.id + ) self.assertIsNone( - list_templates_community, - "Community Templates listed for newly created User" - ) + list_templates_community, + "Community Templates listed for newly created User" + ) # Listing selfexecutable Templates list_templates_selfexecutable = Template.list( - self.userapiclient, - listall=self.services["listall"], - templatefilter="selfexecutable", - zoneid=self.zone.id - ) + self.userapiclient, + listall=self.services["listall"], + templatefilter="selfexecutable", + zoneid=self.zone.id + ) self.assertIsNone( - list_templates_selfexecutable, - "Self Executable Templates listed for newly created User" - ) + list_templates_selfexecutable, + "Self Executable Templates listed for newly created User" + ) # Listing Autoscale VM Profiles - list_autoscalevm_profiles_before = Autoscale.listAutoscaleVmPofiles( - self.userapiclient, - listall=self.services["listall"] - ) + list_autoscalevm_profiles_before =\ + Autoscale.listAutoscaleVmPofiles( + self.userapiclient, + listall=self.services["listall"] + ) self.assertIsNone( - list_autoscalevm_profiles_before, - "Autoscale VM Profiles listed" - ) + list_autoscalevm_profiles_before, + "Autoscale VM Profiles listed" + ) # Creating Autoscale VM Profile - counterparam = { "snmpcommunity": "public", "snmpport": "161"} + counterparam = {"snmpcommunity": "public", "snmpport": "161"} autoscalevm_profile = Autoscale.createAutoscaleVmProfile( - self.userapiclient, - serviceofferingid=list_service_offerings[0].id, - zoneid=self.zone.id, - templateid=list_templates_featured[0].id, - autoscaleuserid=list_users[0].id, - destroyvmgraceperiod='100', - counterparam=counterparam - ) + self.userapiclient, + serviceofferingid=list_service_offerings[0].id, + zoneid=self.zone.id, + templateid=list_templates_featured[0].id, + autoscaleuserid=list_users[0].id, + destroyvmgraceperiod='100', + counterparam=counterparam + ) self.assertIsNotNone( - autoscalevm_profile, - "Failed to create Autoscale VM Profile" - ) + autoscalevm_profile, + "Failed to create Autoscale VM Profile" + ) # Listing Autoscale VM Profiles list_autoscalevm_profiles_after = Autoscale.listAutoscaleVmPofiles( - self.userapiclient, - listall=self.services["listall"] - ) + self.userapiclient, + listall=self.services["listall"] + ) status = validateList(list_autoscalevm_profiles_after) self.assertEquals( - PASS, - status[0], - "Failed to list Autoscale VM Profile after creation" - ) + PASS, + status[0], + "Failed to list Autoscale VM Profile after creation" + ) # Verifying only 1 autoscale vm profile is created self.assertEquals( - 1, - len(list_autoscalevm_profiles_after), - "Count of Autoscale VM profiles listed is not matching" - ) + 1, + len(list_autoscalevm_profiles_after), + "Count of Autoscale VM profiles listed is not matching" + ) # Listing the Autoscale VM Profile by id list_autoscalvmprofile = Autoscale.listAutoscaleVmPofiles( - self.userapiclient, - listall=self.services["listall"], - id=autoscalevm_profile.id - ) + self.userapiclient, + listall=self.services["listall"], + id=autoscalevm_profile.id + ) status = validateList(list_autoscalvmprofile) self.assertEquals( - PASS, - status[0], - "Failed to list Autoscale VM Profile by Id after creation" - ) + PASS, + status[0], + "Failed to list Autoscale VM Profile by Id after creation" + ) # Verifying details of the listed Autoscale VM Profile # Creating expected and actual values dictionaries expected_dict = { - "id":autoscalevm_profile.id, - "account":self.account.name, - "domainid":self.domain.id, - "autoscaleuserid":list_users[0].id, - "serviceofferingid":list_service_offerings[0].id, - "zoneid":self.zone.id, - "templateid":list_templates_featured[0].id, - "destroyvmgraceperiod":autoscalevm_profile.destroyvmgraceperiod - } + "id": autoscalevm_profile.id, + "account": self.account.name, + "domainid": self.domain.id, + "autoscaleuserid": list_users[0].id, + "serviceofferingid": list_service_offerings[0].id, + "zoneid": self.zone.id, + "templateid": list_templates_featured[0].id, + "destroyvmgraceperiod": + autoscalevm_profile.destroyvmgraceperiod} actual_dict = { - "id":list_autoscalvmprofile[0].id, - "account":list_autoscalvmprofile[0].account, - "domainid":list_autoscalvmprofile[0].domainid, - "autoscaleuserid":list_autoscalvmprofile[0].autoscaleuserid, - "serviceofferingid":list_autoscalvmprofile[0].serviceofferingid, - "zoneid":list_autoscalvmprofile[0].zoneid, - "templateid":list_autoscalvmprofile[0].templateid, - "destroyvmgraceperiod":list_autoscalvmprofile[0].destroyvmgraceperiod - } + "id": list_autoscalvmprofile[0].id, + "account": list_autoscalvmprofile[0].account, + "domainid": list_autoscalvmprofile[0].domainid, + "autoscaleuserid": + list_autoscalvmprofile[0].autoscaleuserid, + "serviceofferingid": + list_autoscalvmprofile[0].serviceofferingid, + "zoneid": list_autoscalvmprofile[0].zoneid, + "templateid": list_autoscalvmprofile[0].templateid, + "destroyvmgraceperiod": + list_autoscalvmprofile[0].destroyvmgraceperiod} autoscalevm_profile_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - autoscalevm_profile_status, - "Created Autoscale VM Profile details are not as expected" - ) + True, + autoscalevm_profile_status, + "Created Autoscale VM Profile details are not as expected" + ) # Updating destroyvmgrageperiod for created Autoscale VM Profile autoscalevm_profile_updated = Autoscale.updateAutoscaleVMProfile( - self.userapiclient, - id=autoscalevm_profile.id, - autoscaleuserid=list_users[0].id, - destroyvmgraceperiod='200', - templateid=list_templates_featured[0].id, - ) + self.userapiclient, + id=autoscalevm_profile.id, + autoscaleuserid=list_users[0].id, + destroyvmgraceperiod='200', + templateid=list_templates_featured[0].id, + ) self.assertIsNotNone( - autoscalevm_profile_updated, - "Failed to update Autoscale VM Profile" - ) - # Verifyign that Destroy VM Graceperiod is updated in autoscale VM Profile + autoscalevm_profile_updated, + "Failed to update Autoscale VM Profile" + ) + # Verifyign that Destroy VM Graceperiod is updated in autoscale VM + # Profile self.assertEquals( - 200, - autoscalevm_profile_updated.destroyvmgraceperiod, - "Failed to update destroy vm grace period" - ) + 200, + autoscalevm_profile_updated.destroyvmgraceperiod, + "Failed to update destroy vm grace period" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account) @@ -3964,10 +4030,12 @@ class TestIpAddresses(cloudstackTestCase): @attr(tags=["advanced"], required_hardware="true") def test_19_create_update_autoscalevmgroup(self): - """ - @summary: Test to list, create, update, enable, disable Autoscale VM Profiles + """ + @summary: Test to list, create, update, enable,\ + disable Autoscale VM Profiles @Steps: - Step1: Creating a Network Offering for Supported Service LB with Netscaler + Step1: Creating a Network Offering for Supported Service LB with + Netscaler Step2: Create a Network using Network Offering created in Step1 Step3: Launching a VM using Network created in Step2 Step4: Associating IP Address for Network created in Step2 @@ -3975,333 +4043,336 @@ class TestIpAddresses(cloudstackTestCase): Step6: Creating Scaledown condition and scaledown policy Step7: Creating Autoscale VM profile Step8: Creating Load Balancer Rule - Step9: Listing Autoscale Vm groups and verifying no Autoscale VM groups are listed + Step9: Listing Autoscale Vm groups and verifying no Autoscale VM groups + are listed Step10: Creating Autoscale VM Group and verifying it was created - Step11: Listing Autoscale Vm groups and verifying 1 Autoscale VM groups is listed + Step11: Listing Autoscale Vm groups and verifying 1 Autoscale VM groups + is listed Step12: Disabling Autoscale VM group and verifying it was disabled Step13: Updating Autoscale VM group and verifying it was updated Step14: Enabling Autoscale VM group and verifying it was enabled """ if self.hypervisor.lower() == 'kvm': - raise unittest.SkipTest("ScaleVM is not supported on KVM. Hence, skipping the test") + raise unittest.SkipTest( + "ScaleVM is not supported on KVM. Hence, skipping the test") list_physical_networks = PhysicalNetwork.list( - self.apiClient, - zoneid=self.zone.id - ) - physical_networks_size = 0 - if list_physical_networks is not None: - physical_networks_size = len(list_physical_networks) + self.apiClient, + zoneid=self.zone.id + ) run_flag = False for i in range(0, len(list_physical_networks)): list_network_serviceprovider = NetworkServiceProvider.list( - self.apiClient, - physicalnetworkid=list_physical_networks[i].id - ) + self.apiClient, + physicalnetworkid=list_physical_networks[i].id + ) for j in range(0, len(list_network_serviceprovider)): - if((list_network_serviceprovider[j].name == 'Netscaler') and (list_network_serviceprovider[j].state == 'Enabled')): + if((list_network_serviceprovider[j].name == 'Netscaler') and + (list_network_serviceprovider[j].state == 'Enabled')): run_flag = True break - if(run_flag == False): - self.debug("Netscaler is not enabled and auto scale VM is applicable only for Netscaler") + if not run_flag: + self.debug( + "Netscaler is not enabled and auto scale VM is\ + applicable only for Netscaler") else: # Listing Network Offerings list_nwoff_before = 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 + ) # Creating Network Offerign with LB as Netscalar nwoff_created = NetworkOffering.create( - self.apiClient, - self.services["nw_off_isolated_netscaler"] - ) + self.apiClient, + self.services["nw_off_isolated_netscaler"] + ) self.assertIsNotNone( - nwoff_created, - "Failed to Create Network Offering with LB sercvice for Netscaler" - ) + nwoff_created, + "Failed to Create Network Offering with\ + LB sercvice for Netscaler") # Enable Network offering nwoff_created.update(self.apiClient, state='Enabled') # Listing Network Offerings again list_nwoff_after = 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 + ) self.assertEquals( - len(list_nwoff_before) + 1, - len(list_nwoff_after), - "Failed to create Network Offering" - ) + len(list_nwoff_before) + 1, + len(list_nwoff_after), + "Failed to create Network Offering" + ) # Creating a Network Using the Network Offering network = Network.create( - self.userapiclient, - self.services["network"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=nwoff_created.id, - zoneid=self.zone.id - ) + self.userapiclient, + self.services["network"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=nwoff_created.id, + zoneid=self.zone.id + ) self.assertIsNotNone( - network, - "Network creation failed" - ) + network, + "Network creation failed" + ) self.cleanup.append(network) # self.cleanup.append(nwoff_created) # Launching a Virtual Machine vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - networkids=network.id, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + networkids=network.id, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "Failed to launch a VM under network created" - ) + vm_created, + "Failed to launch a VM under network 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], - "IP Addresses Association Failed while launching a VM" - ) + PASS, + status[0], + "IP Addresses Association Failed while launching a VM" + ) # Verifying the length of the list is 1 self.assertEqual( - 1, - len(list_ipaddresses_before), - "IP Addresses Association Failed while launching a VM" - ) + 1, + len(list_ipaddresses_before), + "IP Addresses Association Failed while launching a VM" + ) # 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( - 2, - len(list_ipaddresses_after), - "Number of IP Addresses associated are not matching expected" - ) + 2, + len(list_ipaddresses_after), + "Number of IP Addresses associated are not matching expected" + ) # Listing Users list_users = User.list( - self.apiClient, - listall=self.services["listall"], - account=self.account.name, - domainid=self.domain.id - ) + self.apiClient, + listall=self.services["listall"], + account=self.account.name, + domainid=self.domain.id + ) status = validateList(list_users) self.assertEquals( - PASS, - status[0], - "Failed to list Users" - ) + PASS, + status[0], + "Failed to list Users" + ) # Listing counters list_counters = Autoscale.listCounters(self.userapiclient) status = validateList(list_counters) self.assertEquals( - PASS, - status[0], - "Failed to list Counters" - ) + PASS, + status[0], + "Failed to list Counters" + ) # Create Condition for scaleup Vm Policy condition_scaleup = Autoscale.createCondition( - self.userapiclient, - counterid=list_counters[0].id, - relationaloperator='GT', - threshold='40' - ) + self.userapiclient, + counterid=list_counters[0].id, + relationaloperator='GT', + threshold='40' + ) self.assertIsNotNone( - condition_scaleup, - "Failed to create Scaleup Condition" - ) + condition_scaleup, + "Failed to create Scaleup Condition" + ) # Creating scaleup Vm Policy scaleup_policy = Autoscale.createAutoscalePolicy( - self.userapiclient, - action='scaleup', - conditionids=condition_scaleup.id, - duration='40', - quiettime='300' - ) + self.userapiclient, + action='scaleup', + conditionids=condition_scaleup.id, + duration='40', + quiettime='300' + ) self.assertIsNotNone( - scaleup_policy, - "Failed to create Scaleup VM Policy" - ) + scaleup_policy, + "Failed to create Scaleup VM Policy" + ) # Create Condition for scaledown Vm Policy condition_scaledown = Autoscale.createCondition( - self.userapiclient, - counterid=list_counters[0].id, - relationaloperator='GT', - threshold='10' - ) + self.userapiclient, + counterid=list_counters[0].id, + relationaloperator='GT', + threshold='10' + ) self.assertIsNotNone( - condition_scaledown, - "Failed to create Scaledown Condition" - ) + condition_scaledown, + "Failed to create Scaledown Condition" + ) # Creating scaledown Vm Policy scaledown_policy = Autoscale.createAutoscalePolicy( - self.userapiclient, - action='scaledown', - conditionids=condition_scaledown.id, - duration='40', - quiettime='300' - ) + self.userapiclient, + action='scaledown', + conditionids=condition_scaledown.id, + duration='40', + quiettime='300' + ) self.assertIsNotNone( - scaledown_policy, - "Failed to create Scaledown VM Policy" - ) - counterparam = { "snmpcommunity": "public", "snmpport": "161"} + scaledown_policy, + "Failed to create Scaledown VM Policy" + ) + counterparam = {"snmpcommunity": "public", "snmpport": "161"} # Create Autoscale VM Profile vmprofile = Autoscale.createAutoscaleVmProfile( - self.userapiclient, - serviceofferingid=self.service_offering.id, - zoneid=self.zone.id, - templateid=self.template.id, - autoscaleuserid=list_users[0].id, - destroyvmgraceperiod='30', - counterparam=counterparam - ) + self.userapiclient, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id, + templateid=self.template.id, + autoscaleuserid=list_users[0].id, + destroyvmgraceperiod='30', + counterparam=counterparam + ) self.assertIsNotNone( - vmprofile, - "Failed to create Autoscale Vm Profile" - ) + vmprofile, + "Failed to create Autoscale Vm Profile" + ) self.services["lbrule"]["openfirewall"] = False # Creating Load Balancer Rule lbrule = LoadBalancerRule.create( - self.userapiclient, - self.services["lbrule"], - ipaddressid=associated_ipaddress.ipaddress.id, - accountid=self.account.name, - networkid=network.id, - domainid=self.domain.id - ) + self.userapiclient, + self.services["lbrule"], + ipaddressid=associated_ipaddress.ipaddress.id, + accountid=self.account.name, + networkid=network.id, + domainid=self.domain.id + ) self.assertIsNotNone( - lbrule, - "Failed to create Load Balancer Rule" - ) + lbrule, + "Failed to create Load Balancer Rule" + ) # Listing Autoscale VM Groups list_vmgroup_before = Autoscale.listAutoscaleVmGroup( - self.userapiclient, - listall=self.services["listall"], - lbruleid=lbrule.id - ) + self.userapiclient, + listall=self.services["listall"], + lbruleid=lbrule.id + ) # Verifying No Autoscale VM Groups are listed self.assertIsNone( - list_vmgroup_before, - "Listed Autoscale VM Groups for newly created LB Rule" - ) + list_vmgroup_before, + "Listed Autoscale VM Groups for newly created LB Rule" + ) # Creating Autoscale VM Group vmgroup = Autoscale.createAutoscaleVmGroup( - self.userapiclient, - lbruleid=lbrule.id, - minmembers='3', - maxmembers='10', - scaledownpolicyids=scaledown_policy.id, - scaleuppolicyids=scaleup_policy.id, - vmprofileid=vmprofile.id, - interval='30' - ) + self.userapiclient, + lbruleid=lbrule.id, + minmembers='3', + maxmembers='10', + scaledownpolicyids=scaledown_policy.id, + scaleuppolicyids=scaleup_policy.id, + vmprofileid=vmprofile.id, + interval='30' + ) self.assertIsNotNone( - vmgroup, - "Failed to create Autoscale VM Group" - ) + vmgroup, + "Failed to create Autoscale VM Group" + ) # Listing Autoscale VM Groups list_vmgroup_after = Autoscale.listAutoscaleVmGroup( - self.userapiclient, - listall=self.services["listall"], - lbruleid=lbrule.id - ) + self.userapiclient, + listall=self.services["listall"], + lbruleid=lbrule.id + ) status = validateList(list_vmgroup_after) self.assertEquals( - PASS, - status[0], - "Failed to list Autoscale VM group after creation" - ) + PASS, + status[0], + "Failed to list Autoscale VM group after creation" + ) # Verifying only 1 Autoscale VM group is listed self.assertEquals( - 1, - len(list_vmgroup_after), - "Autoscale VM group list count is not matching" - ) + 1, + len(list_vmgroup_after), + "Autoscale VM group list count is not matching" + ) # Disabling Autoscale VM group vmgroup_disabled = Autoscale.disableAutoscaleVmGroup( - self.userapiclient, - id=vmgroup.id - ) + self.userapiclient, + id=vmgroup.id + ) self.assertIsNotNone( - vmgroup_disabled, - "Failed to disable Autoscale VM group" - ) + vmgroup_disabled, + "Failed to disable Autoscale VM group" + ) # Verifyign the state of the VM Group afte renabling self.assertEquals( - "disabled", - vmgroup_disabled.state, - "Disabled VM Group state is not matching" - ) + "disabled", + vmgroup_disabled.state, + "Disabled VM Group state is not matching" + ) # Updating Autoscale VM Group vmgroup_updated = Autoscale.updateAutoscaleVMGroup( - self.userapiclient, - id=vmgroup.id, - minmembers='3', - maxmembers='10', - scaledownpolicyids=scaledown_policy.id, - scaleuppolicyids=scaleup_policy.id, - interval='40' - ) + self.userapiclient, + id=vmgroup.id, + minmembers='3', + maxmembers='10', + scaledownpolicyids=scaledown_policy.id, + scaleuppolicyids=scaleup_policy.id, + interval='40' + ) self.assertIsNotNone( - vmgroup_updated, - "Failed to update Autoscale VM group" - ) + vmgroup_updated, + "Failed to update Autoscale VM group" + ) self.assertEquals( - 40, - vmgroup_updated.interval, - "Updated Autoscale VM group interval value is not matching" - ) + 40, + vmgroup_updated.interval, + "Updated Autoscale VM group interval value is not matching" + ) # Enabling Autoscale VM group vmgroup_enabled = Autoscale.enableAutoscaleVmGroup( - self.userapiclient, - id=vmgroup.id - ) + self.userapiclient, + id=vmgroup.id + ) self.assertIsNotNone( - vmgroup_enabled, - "Failed to enable Autoscale VM group" - ) + vmgroup_enabled, + "Failed to enable Autoscale VM group" + ) # Verifyign the state of the VM Group afte renabling self.assertEquals( - "enabled", - vmgroup_enabled.state, - "Enabled VM Group state is not matching" - ) + "enabled", + vmgroup_enabled.state, + "Enabled VM Group state is not matching" + ) # Destroying the VM vm_created.delete(self.apiClient) self.cleanup.append(self.account)