http://git-wip-us.apache.org/repos/asf/cloudstack/blob/46802557/test/integration/component/test_escalations_instances.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_escalations_instances.py b/test/integration/component/test_escalations_instances.py index 1aaa688..7e4cfe6 100644 --- a/test/integration/component/test_escalations_instances.py +++ b/test/integration/component/test_escalations_instances.py @@ -16,17 +16,28 @@ # under the License. # Import Local Modules -from marvin.cloudstackTestCase import * -from marvin.cloudstackException import * -from marvin.cloudstackAPI import * -from marvin.sshClient import SshClient -from marvin.lib.utils import * -from marvin.lib.base import * -from marvin.lib.common import * +from marvin.cloudstackTestCase import cloudstackTestCase, unittest +from marvin.lib.utils import cleanup_resources, validateList +from marvin.lib.base import (Account, + ServiceOffering, + NetworkOffering, + Network, + VirtualMachine, + SecurityGroup, + DiskOffering, + Resources, + Iso, + Configurations, + SSHKeyPair, + Volume, + VmSnapshot, + Zone) +from marvin.lib.common import (get_zone, + get_template, + get_domain) from marvin.codes import PASS from nose.plugins.attrib import attr -from time import sleep -# from ctypes.wintypes import BOOLEAN + class TestListInstances(cloudstackTestCase): @@ -40,19 +51,23 @@ class TestListInstances(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' cls.services["disk_offering"]["storagetype"] = 'local' else: cls.storagetype = 'shared' - cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared' + cls.services["service_offerings"][ + "tiny"]["storagetype"] = 'shared' cls.services["disk_offering"]["storagetype"] = 'shared' cls.services['mode'] = cls.zone.networktype @@ -62,32 +77,13 @@ class TestListInstances(cloudstackTestCase): cls.services["custom_volume"]["zoneid"] = cls.zone.id # Creating Disk offering, Service Offering and Account cls.disk_offering = DiskOffering.create( - cls.api_client, - cls.services["disk_offering"] - ) + cls.api_client, + cls.services["disk_offering"] + ) cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offerings"]["tiny"] - ) - cls.account = Account.create( - cls.api_client, - cls.services["account"], - domainid=cls.domain.id - ) - # Getting authentication for user in newly created Account - cls.user = cls.account.user[0] - cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name) - # Updating resource Limits - for i in range(0, 12): - Resources.updateLimit( - cls.api_client, - account=cls.account.name, - domainid=cls.domain.id, - max=-1, - resourcetype=i - ) - - cls._cleanup.append(cls.account) + cls.api_client, + cls.services["service_offerings"]["tiny"] + ) cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.disk_offering) except Exception as e: @@ -98,7 +94,27 @@ class TestListInstances(cloudstackTestCase): def setUp(self): self.apiClient = self.testClient.getApiClient() - self.cleanup = [] + self.account = Account.create( + 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) + # Updating resource Limits + for i in range(0, 12): + Resources.updateLimit( + self.api_client, + account=self.account.name, + domainid=self.domain.id, + max=-1, + resourcetype=i + ) + + self.cleanup = [self.account, ] def tearDown(self): # Clean up, terminate the created resources @@ -115,14 +131,15 @@ class TestListInstances(cloudstackTestCase): return def __verify_values(self, expected_vals, actual_vals): - """ + """ @Desc: Function to verify expected and actual values @Steps: 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 """ @@ -139,24 +156,26 @@ class TestListInstances(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", "basic"], required_hardware="false") def test_01_list_instances_pagination(self): - """ + """ @Desc: Test List Instances pagination @Steps: Step1: Listing all the Instances for a user Step2: Verifying listed Instances for account created at class level - Step3: If number of volumes is less than (page size + 1), then creating them + Step3: If number of volumes is less than + (page size + 1), then creating them Step4: Listing all the volumes again after creation of volumes Step5: Verifying the length of the volumes is (page size + 1) Step6: Listing all the volumes in page1 - Step7: Verifying that the length of the volumes in page 1 is (page size) + Step7: Verifying that the length of the volumes in page 1 is + (page size) Step8: Listing all the volumes in page2 Step9: Verifying that the length of the volumes in page 2 is 1 Step10: Deleting the volume present in page 2 @@ -164,124 +183,128 @@ class TestListInstances(cloudstackTestCase): Step12: Verifying that there are no volumes present in page 2 """ # Listing all the instances for a user - list_instances_before = VirtualMachine.list(self.userapiclient, listall=self.services["listall"]) + list_instances_before = VirtualMachine.list( + self.userapiclient, + listall=self.services["listall"]) # Verifying listed instances for account created at class level self.assertIsNone( - list_instances_before, - "Virtual Machine already exists for newly created user" - ) - # If number of instances are less than (pagesize + 1), then creating them + list_instances_before, + "Virtual Machine already exists for newly created user" + ) + # If number of instances are less than (pagesize + 1), then creating + # them for i in range(0, (self.services["pagesize"] + 1)): vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - if(i < (self.services["pagesize"])): - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) self.assertEqual( - self.services["virtual_machine"]["displayname"], - vm_created.displayname, - "Newly created VM name and the test data VM name are not matching" - ) + self.services["virtual_machine"]["displayname"], + vm_created.displayname, + "Newly created VM name and the test data VM name\ + are not matching") # Listing all the instances again after creating VM's - list_instances_after = VirtualMachine.list(self.userapiclient, listall=self.services["listall"]) + list_instances_after = VirtualMachine.list( + self.userapiclient, + listall=self.services["listall"]) status = validateList(list_instances_after) self.assertEquals( - PASS, - status[0], - "Listing of instances after creation failed" - ) + PASS, + status[0], + "Listing of instances after creation failed" + ) # Verifying the length of the instances is (page size + 1) self.assertEqual( - len(list_instances_after), - (self.services["pagesize"] + 1), - "Number of instances created is not matching as expected" - ) + len(list_instances_after), + (self.services["pagesize"] + 1), + "Number of instances created is not matching as expected" + ) # Listing all the volumes in page1 list_instances_page1 = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid + ) status = validateList(list_instances_page1) self.assertEquals( - PASS, - status[0], - "Listing of instances in page1 failed" - ) + PASS, + status[0], + "Listing of instances in page1 failed" + ) # Verifying that the length of the instances in page 1 is (page size) self.assertEqual( - self.services["pagesize"], - len(list_instances_page1), - "List VM response is not matching with the page size length for page 1" - ) + self.services["pagesize"], + len(list_instances_page1), + "List VM response is not matching with the page size\ + length for page 1") # Listing all the VM's in page2 list_instances_page2 = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=2, - pagesize=self.services["pagesize"], - domainid=self.account.domainid - ) + self.userapiclient, + listall=self.services["listall"], + page=2, + pagesize=self.services["pagesize"], + domainid=self.account.domainid + ) status = validateList(list_instances_page2) self.assertEquals( - PASS, - status[0], - "Listing of instances in page2 failed" - ) + PASS, + status[0], + "Listing of instances in page2 failed" + ) # Verifying that the length of the VM's in page 2 is 1 self.assertEqual( - 1, - len(list_instances_page2), - "List VM response is not matching with the page size length for page 2" - ) + 1, + len(list_instances_page2), + "List VM response is not matching with the\ + page size length for page 2" + ) instance_page2 = list_instances_page2[0] # Verifying that the VM on page 2 is not present in page1 for i in range(0, len(list_instances_page1)): instance_page1 = list_instances_page1[i] self.assertNotEquals( - instance_page2.id, - instance_page1.id, - "VM listed in page 2 is also listed in page 1" - ) + instance_page2.id, + instance_page1.id, + "VM listed in page 2 is also listed in page 1" + ) # Deleting a single VM - VirtualMachine.delete(vm_created, self.userapiclient, expunge=True) + VirtualMachine.delete(vm_created, self.apiClient, expunge=True) # Listing the VM's in page 2 list_instance_response = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=2, - pagesize=self.services["pagesize"], - domainid=self.account.domainid - ) + self.userapiclient, + listall=self.services["listall"], + page=2, + pagesize=self.services["pagesize"], + domainid=self.account.domainid + ) # verifying that VM does not exists on page 2 self.assertEqual( - list_instance_response, - None, - "VM was not deleted" - ) + list_instance_response, + None, + "VM was not deleted" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") def test_02_list_Running_vm(self): - """ + """ @Desc: Test List Running VM's @Steps: Step1: Listing all the Running VMs for a user @@ -289,90 +312,90 @@ class TestListInstances(cloudstackTestCase): Step3: Deploying a VM Step4: Listing all the Running VMs for a user again Step5: Verifying that the size of the list is increased by 1 - Step6: Verifying that the details of the Running VM listed are same as the VM deployed in Step3 + Step6: Verifying that the details of the Running VM listed are + same as the VM deployed in Step3 """ # Listing all the Running VM's for a User list_running_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Running" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Running" + ) self.assertIsNone( - list_running_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_running_vms_before, + "Virtual Machine already exists for newly created user" + ) # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) # Listing all the Running VM's for a User list_running_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Running" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Running" + ) status = validateList(list_running_vms_after) self.assertEquals( - PASS, - status[0], - "Newly created VM is not in Running state" - ) + PASS, + status[0], + "Newly created VM is not in Running state" + ) # Verifying list size is 1 self.assertEquals( - 1, - len(list_running_vms_after), - "Running VM list count is not matching" - ) + 1, + len(list_running_vms_after), + "Running VM list count is not matching" + ) running_vm = list_running_vms_after[0] # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":"Running", - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": "Running", + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":running_vm.id, - "name":running_vm.name, - "displayname":running_vm.displayname, - "state":running_vm.state, - "zoneid":running_vm.zoneid, - "account":running_vm.account, - "template":running_vm.templateid - } + "id": running_vm.id, + "name": running_vm.name, + "displayname": running_vm.displayname, + "state": running_vm.state, + "zoneid": running_vm.zoneid, + "account": running_vm.account, + "template": running_vm.templateid + } running_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - running_vm_status, - "Listed Running VM details are not as expected" - ) + True, + running_vm_status, + "Listed Running VM details are not as expected" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") def test_03_list_Stopped_vm(self): - """ + """ @Desc: Test List Stopped VM's @Steps: Step1: Listing all the Stopped VMs for a user @@ -381,86 +404,86 @@ class TestListInstances(cloudstackTestCase): Step4: Stopping the VM deployed in step3 Step5: Listing all the Stopped VMs for a user again Step6: Verifying that the size of the list is increased by 1 - Step7: Verifying that the details of the Stopped VM listed are same as the VM stopped in Step4 + Step7: Verifying that the details of the Stopped VM listed are + same as the VM stopped in Step4 """ # Listing all the Stopped VM's for a User list_stopped_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Stopped" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Stopped" + ) self.assertIsNone( - list_stopped_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_stopped_vms_before, + "Virtual Machine already exists for newly created user" + ) # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) # Stopping the VM VirtualMachine.stop(vm_created, self.userapiclient) # Listing all the Stopped VM's for a User list_stopped_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Stopped" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Stopped" + ) status = validateList(list_stopped_vms_after) self.assertEquals( - PASS, - status[0], - "Stopped VM is not in Stopped state" - ) + PASS, + status[0], + "Stopped VM is not in Stopped state" + ) # Verifying list size is 1 self.assertEquals( - 1, - len(list_stopped_vms_after), - "Stopped VM list count is not matching" - ) + 1, + len(list_stopped_vms_after), + "Stopped VM list count is not matching" + ) stopped_vm = list_stopped_vms_after[0] # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":"Stopped", - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": "Stopped", + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":stopped_vm.id, - "name":stopped_vm.name, - "displayname":stopped_vm.displayname, - "state":stopped_vm.state, - "zoneid":stopped_vm.zoneid, - "account":stopped_vm.account, - "template":stopped_vm.templateid - } + "id": stopped_vm.id, + "name": stopped_vm.name, + "displayname": stopped_vm.displayname, + "state": stopped_vm.state, + "zoneid": stopped_vm.zoneid, + "account": stopped_vm.account, + "template": stopped_vm.templateid + } stopped_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - stopped_vm_status, - "Listed Stopped VM details are not as expected" - ) + True, + stopped_vm_status, + "Listed Stopped VM details are not as expected" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") @@ -476,99 +499,100 @@ class TestListInstances(cloudstackTestCase): Step6: Verifying that destroyed VM is not listed for User Step7: Listing all the destroyed VMs as admin Step8: Verifying that the size of the list is 1 - Step9: Verifying that the details of the Destroyed VM listed are same as the VM destroyed in Step4 + Step9: Verifying that the details of the Destroyed VM listed + are same as the VM destroyed in Step4 """ # Listing all the Destroyed VM's for a User list_destroyed_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Destroyed" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Destroyed" + ) self.assertIsNone( - list_destroyed_vms_before, - "Virtual Machine in Destroyed state already exists for newly created user" - ) + list_destroyed_vms_before, + "Virtual Machine in Destroyed state already exists\ + for newly created user") # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) + vm_created, + "VM creation failed" + ) # Destroying the VM VirtualMachine.delete(vm_created, self.userapiclient, expunge=False) # Listing all the Destroyed VM's for a User list_destroyed_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Destroyed" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Destroyed" + ) self.assertIsNone( - list_destroyed_vms_after, - "Destroyed VM is not in destroyed state" - ) + list_destroyed_vms_after, + "Destroyed VM is not in destroyed state" + ) # Listing destroyed VMs as admin user list_destroyed_vms_admin = VirtualMachine.list( - self.apiClient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - state="Destroyed", - id=vm_created.id - ) + self.apiClient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + state="Destroyed", + id=vm_created.id + ) status = validateList(list_destroyed_vms_admin) self.assertEquals( - PASS, - status[0], - "Destroyed VM is not in Destroyed state" - ) + PASS, + status[0], + "Destroyed VM is not in Destroyed state" + ) # Verifying that the length of the destroyed VMs list should be 1 self.assertEquals( - 1, - len(list_destroyed_vms_admin), - "Destroyed VM list count is not matching" - ) + 1, + len(list_destroyed_vms_admin), + "Destroyed VM list count is not matching" + ) destroyed_vm = list_destroyed_vms_admin[0] # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":"Destroyed", - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": "Destroyed", + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":destroyed_vm.id, - "name":destroyed_vm.name, - "displayname":destroyed_vm.displayname, - "state":destroyed_vm.state, - "zoneid":destroyed_vm.zoneid, - "account":destroyed_vm.account, - "template":destroyed_vm.templateid - } + "id": destroyed_vm.id, + "name": destroyed_vm.name, + "displayname": destroyed_vm.displayname, + "state": destroyed_vm.state, + "zoneid": destroyed_vm.zoneid, + "account": destroyed_vm.account, + "template": destroyed_vm.templateid + } destroyed_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - destroyed_vm_status, - "Listed Destroyed VM details are not as expected" - ) + True, + destroyed_vm_status, + "Listed Destroyed VM details are not as expected" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") @@ -582,95 +606,95 @@ class TestListInstances(cloudstackTestCase): Step4: Listing all the VMs for a user again Step5: Verifying that the size of the list is increased by 1 Step6: List a VM by specifying the Id if the VM deployed in Step3 - Step7: Verifying that the details of the Listed VM are same as the VM deployed in Step3 + Step7: Verifying that the details of the Listed VM are same as + the VM deployed in Step3 """ # Listing all the VM's for a User list_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - account=self.account.name - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + account=self.account.name + ) self.assertIsNone( - list_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_vms_before, + "Virtual Machine already exists for newly created user" + ) # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) # Listing all the VM's for a User list_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - account=self.account.name - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + account=self.account.name + ) status = validateList(list_vms_after) self.assertEquals( - PASS, - status[0], - "Listing of VM after creation failed" - ) + PASS, + status[0], + "Listing of VM after creation failed" + ) self.assertEquals( - 1, - len(list_vms_after), - "VM list count is not matching" - ) + 1, + len(list_vms_after), + "VM list count is not matching" + ) # Listing a VM by Id list_vm_byid = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - id=vm_created.id - ) + self.userapiclient, + listall=self.services["listall"], + id=vm_created.id + ) status = validateList(list_vm_byid) self.assertEquals( - PASS, - status[0], - "Listing of VM by Id failed" - ) + PASS, + status[0], + "Listing of VM by Id failed" + ) listed_vm = list_vm_byid[0] # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":vm_created.state, - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": vm_created.state, + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":listed_vm.id, - "name":listed_vm.name, - "displayname":listed_vm.displayname, - "state":listed_vm.state, - "zoneid":listed_vm.zoneid, - "account":listed_vm.account, - "template":listed_vm.templateid - } + "id": listed_vm.id, + "name": listed_vm.name, + "displayname": listed_vm.displayname, + "state": listed_vm.state, + "zoneid": listed_vm.zoneid, + "account": listed_vm.account, + "template": listed_vm.templateid + } list_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - list_vm_status, - "Listed VM by Id details are not as expected" - ) + True, + list_vm_status, + "Listed VM by Id details are not as expected" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") @@ -683,134 +707,136 @@ class TestListInstances(cloudstackTestCase): Step3: Deploying a 2 VM's Step4: Listing all the VMs for a user again Step5: Verifying that list size is increased by 2 - Step6: Listing the VM by specifying complete name of VM-1 created in step3 + Step6: Listing the VM by specifying complete name of + VM-1 created in step3 Step7: Verifying that the size of the list is 1 - Step8: Verifying that the details of the listed VM are same as the VM-1 created in step3 + Step8: Verifying that the details of the listed VM are same as the + VM-1 created in step3 Step9: Listing the VM by specifying the partial name of VM Step10: Verifying that the size of the list is 2 """ # Listing all the VM's for a User list_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + ) self.assertIsNone( - list_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_vms_before, + "Virtual Machine already exists for newly created user" + ) vms = {} for i in range(0, 2): # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) vms.update({i: vm_created}) # Listing all the VM's for a User list_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + ) status = validateList(list_vms_after) self.assertEquals( - PASS, - status[0], - "VM's creation failed" - ) + PASS, + status[0], + "VM's creation failed" + ) self.assertEquals( - 2, - len(list_vms_after), - "VM's list count is not matching" - ) + 2, + len(list_vms_after), + "VM's list count is not matching" + ) # Listing the VM by complete name list_vm_byfullname = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - name=vms[0].name - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + name=vms[0].name + ) status = validateList(list_vm_byfullname) self.assertEquals( - PASS, - status[0], - "Failed to list VM by Name" - ) + PASS, + status[0], + "Failed to list VM by Name" + ) # Verifying that the size of the list is 1 self.assertEquals( - 1, - len(list_vm_byfullname), - "VM list by full name count is not matching" - ) - # Verifying that the details of the listed VM are same as the VM created above + 1, + len(list_vm_byfullname), + "VM list by full name count is not matching" + ) + # Verifying that the details of the listed VM are same + # as the VM created above # Creating expected and actual values dictionaries expected_dict = { - "id":vms[0].id, - "name":vms[0].name, - "displayname":vms[0].displayname, - "state":vms[0].state, - "zoneid":vms[0].zoneid, - "account":vms[0].account, - "template":vms[0].templateid - } + "id": vms[0].id, + "name": vms[0].name, + "displayname": vms[0].displayname, + "state": vms[0].state, + "zoneid": vms[0].zoneid, + "account": vms[0].account, + "template": vms[0].templateid + } actual_dict = { - "id":list_vm_byfullname[0].id, - "name":list_vm_byfullname[0].name, - "displayname":list_vm_byfullname[0].displayname, - "state":list_vm_byfullname[0].state, - "zoneid":list_vm_byfullname[0].zoneid, - "account":list_vm_byfullname[0].account, - "template":list_vm_byfullname[0].templateid - } + "id": list_vm_byfullname[0].id, + "name": list_vm_byfullname[0].name, + "displayname": list_vm_byfullname[0].displayname, + "state": list_vm_byfullname[0].state, + "zoneid": list_vm_byfullname[0].zoneid, + "account": list_vm_byfullname[0].account, + "template": list_vm_byfullname[0].templateid + } list_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - list_vm_status, - "Listed VM details are not as expected" - ) + True, + list_vm_status, + "Listed VM details are not as expected" + ) # Listing the VM by partial name list_vm_bypartialname = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - domainid=self.account.domainid, - name=vms[0].name[:1] - ) + self.userapiclient, + listall=self.services["listall"], + domainid=self.account.domainid, + name=vms[0].name[:1] + ) status = validateList(list_vm_bypartialname) self.assertEquals( - PASS, - status[0], - "Failed to list VM by Name" - ) + PASS, + status[0], + "Failed to list VM by Name" + ) # Verifying that the size of the list is 2 self.assertEquals( - 2, - len(list_vm_bypartialname), - "VM list by full name count is not matching" - ) + 2, + len(list_vm_bypartialname), + "VM list by full name count is not matching" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") def test_07_list_vm_by_name_state(self): - """ + """ @Desc: Test List VM's by Name and State @Steps: Step1: Listing all the VMs for a user @@ -818,143 +844,147 @@ class TestListInstances(cloudstackTestCase): Step3: Deploying a VM Step4: Listing all the VMs for a user again Step5: Verifying that list size is increased by 1 - Step6: Listing the VM by specifying name of VM created in step3 and state as Running (matching name and state) + Step6: Listing the VM by specifying name of VM created in step3 and + state as Running (matching name and state) Step7: Verifying that the size of the list is 1 - Step8: Verifying that the details of the listed VM are same as the VM created in step3 - Step9: Listing the VM by specifying name of VM created in step3 and state as Stopped (non matching state) + Step8: Verifying that the details of the listed VM are same as + the VM created in step3 + Step9: Listing the VM by specifying name of VM created in step3 + and state as Stopped (non matching state) Step10: Verifying that the size of the list is 0 - Step11: Listing the VM by specifying non matching name and state as Running (non matching name) + Step11: Listing the VM by specifying non matching name and + state as Running (non matching name) Step12: Verifying that the size of the list is 0 """ # Listing all the VM's for a User list_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + ) self.assertIsNone( - list_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_vms_before, + "Virtual Machine already exists for newly created user" + ) # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) # Listing all the VM's for a User list_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + ) status = validateList(list_vms_after) self.assertEquals( - PASS, - status[0], - "VM's creation failed" - ) + PASS, + status[0], + "VM's creation failed" + ) self.assertEquals( - 1, - len(list_vms_after), - "VM's list count is not matching" - ) + 1, + len(list_vms_after), + "VM's list count is not matching" + ) # Listing the VM by matching Name and State list_running_vm = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - name=vm_created.name, - state="Running" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + name=vm_created.name, + state="Running" + ) status = validateList(list_running_vm) self.assertEquals( - PASS, - status[0], - "List VM by name and state failed" - ) + PASS, + status[0], + "List VM by name and state failed" + ) # Verifying that the size of the list is 1 self.assertEquals( - 1, - len(list_running_vm), - "Count of VM list by name and state is not matching" - ) - # Verifying that the details of the listed VM are same as the VM created above + 1, + len(list_running_vm), + "Count of VM list by name and state is not matching" + ) + # Verifying that the details of the listed VM are same + # as the VM created above # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":"Running", - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": "Running", + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":list_running_vm[0].id, - "name":list_running_vm[0].name, - "displayname":list_running_vm[0].displayname, - "state":list_running_vm[0].state, - "zoneid":list_running_vm[0].zoneid, - "account":list_running_vm[0].account, - "template":list_running_vm[0].templateid - } + "id": list_running_vm[0].id, + "name": list_running_vm[0].name, + "displayname": list_running_vm[0].displayname, + "state": list_running_vm[0].state, + "zoneid": list_running_vm[0].zoneid, + "account": list_running_vm[0].account, + "template": list_running_vm[0].templateid + } list_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - list_vm_status, - "Listed VM details are not as expected" - ) + True, + list_vm_status, + "Listed VM details are not as expected" + ) # Listing the VM by matching name and non matching state list_running_vm = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - name=vm_created.name, - state="Stopped" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + name=vm_created.name, + state="Stopped" + ) self.assertIsNone( - list_running_vm, - "Listed VM with non matching state" - ) + list_running_vm, + "Listed VM with non matching state" + ) # Listing the VM by non matching name and matching state list_running_vm = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - name="name", - state="Running" - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + name="name", + state="Running" + ) self.assertIsNone( - list_running_vm, - "Listed VM with non matching name" - ) + list_running_vm, + "Listed VM with non matching name" + ) return @attr(tags=["advanced", "basic"], required_hardware="false") def test_08_list_vm_by_zone(self): - """ - @Desc: Test List VM by Zone. + """ + @Desc: Test List VM by Zone. This test case is applicable for a setup having multiple zones. @Steps: Step1: Listing all the zones @@ -966,7 +996,8 @@ class TestListInstances(cloudstackTestCase): Step6: Deploying a VM Step7: Listing all the VMs for a user again for matching zone Step8: Verifying that the size of the list is 1 - Step9: Verifying that the details of the Listed VM are same as the VM deployed in Step6 + Step9: Verifying that the details of the Listed VM are same + as the VM deployed in Step6 Step10: Listing all the VMs for a user again for non-matching zone Step11: Verifying that the size of the list is 0 """ @@ -974,10 +1005,10 @@ class TestListInstances(cloudstackTestCase): zones_list = Zone.list(self.apiClient) status = validateList(zones_list) self.assertEquals( - PASS, - status[0], - "zones not available in the given setup" - ) + PASS, + status[0], + "zones not available in the given setup" + ) current_zone = self.services["virtual_machine"]["zoneid"] current_template = self.services["virtual_machine"]["template"] # Checking if there are multiple zones in the setup. @@ -986,114 +1017,114 @@ class TestListInstances(cloudstackTestCase): else: # Getting the template available under the zone template = get_template( - self.apiClient, - zones_list[0].id, - self.services["ostype"] - ) + self.apiClient, + zones_list[0].id, + self.services["ostype"] + ) self.assertIsNotNone( - template, - "Template not found for zone" - ) + template, + "Template not found for zone" + ) self.services["virtual_machine"]["zoneid"] = zones_list[0].id self.services["virtual_machine"]["template"] = template.id # Listing all the VM's for a User list_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - zoneid=zones_list[0].id - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + zoneid=zones_list[0].id + ) self.assertIsNone( - list_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_vms_before, + "Virtual Machine already exists for newly created user" + ) # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) # Listing all the VMs for a user again for matching zone list_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - zoneid=zones_list[0].id - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + zoneid=zones_list[0].id + ) status = validateList(list_vms_after) self.assertEquals( - PASS, - status[0], - "VM creation failed" - ) + PASS, + status[0], + "VM creation failed" + ) # Verifying that the size of the list is 1 self.assertEquals( - 1, - len(list_vms_after), - "VM list count is not matching" - ) + 1, + len(list_vms_after), + "VM list count is not matching" + ) listed_vm = list_vms_after[0] - # Verifying that the details of the Listed VM are same as the VM deployed above + # Verifying that the details of the Listed VM are + # same as the VM deployed above # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":vm_created.state, - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": vm_created.state, + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":listed_vm.id, - "name":listed_vm.name, - "displayname":listed_vm.displayname, - "state":listed_vm.state, - "zoneid":listed_vm.zoneid, - "account":listed_vm.account, - "template":listed_vm.templateid - } + "id": listed_vm.id, + "name": listed_vm.name, + "displayname": listed_vm.displayname, + "state": listed_vm.state, + "zoneid": listed_vm.zoneid, + "account": listed_vm.account, + "template": listed_vm.templateid + } list_vm_status = self.__verify_values( - expected_dict, - actual_dict - ) + expected_dict, + actual_dict + ) self.assertEqual( - True, - list_vm_status, - "Listed VM by Id details are not as expected" - ) + True, + list_vm_status, + "Listed VM by Id details are not as expected" + ) # Listing all the VMs for a user again for non-matching zone list_vms = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - zoneid=zones_list[1].id - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + zoneid=zones_list[1].id + ) self.assertIsNone( - list_vms, - "VM's listed for non matching zone" - ) + list_vms, + "VM's listed for non matching zone" + ) self.services["virtual_machine"]["zoneid"] = current_zone self.services["virtual_machine"]["template"] = current_template return @attr(tags=["advanced", "basic"], required_hardware="false") def test_09_list_vm_by_zone_name(self): - """ - @Desc: Test List VM by Zone. + """ + @Desc: Test List VM by Zone. This test case is applicable for a setup having multiple zones. @Steps: Step1: Listing all the zones @@ -1105,22 +1136,26 @@ class TestListInstances(cloudstackTestCase): Step6: Deploying a VM Step7: Listing all the VMs for a user again Step8: Verifying that list size is increased by 1 - Step9: Listing the VM by specifying name of VM created in step6 and matching zone (matching name and zone) + Step9: Listing the VM by specifying name of VM created in step6 + and matching zone (matching name and zone) Step10: Verifying that the size of the list is 1 - Step11: Verifying that the details of the listed VM are same as the VM created in step3 - Step12: Listing the VM by specifying name of VM created in step6 and non matching zone (non matching zone) + Step11: Verifying that the details of the listed VM are same + as the VM created in step3 + Step12: Listing the VM by specifying name of VM created in step6 + and non matching zone (non matching zone) Step13: Verifying that the size of the list is 0 - Step14: Listing the VM by specifying non matching name and matching zone (non matching name) + Step14: Listing the VM by specifying non matching name and + matching zone (non matching name) Step15: Verifying that the size of the list is 0 """ # Listing all the zones available zones_list = Zone.list(self.apiClient) status = validateList(zones_list) self.assertEquals( - PASS, - status[0], - "zones not available in the given setup" - ) + PASS, + status[0], + "zones not available in the given setup" + ) current_zone = self.services["virtual_machine"]["zoneid"] current_template = self.services["virtual_machine"]["template"] # Checking if there are multiple zones in the setup. @@ -1129,343 +1164,353 @@ class TestListInstances(cloudstackTestCase): else: # Getting the template available under the zone template = get_template( - self.apiClient, - zones_list[0].id, - self.services["ostype"] - ) + self.apiClient, + zones_list[0].id, + self.services["ostype"] + ) self.assertIsNotNone( - template, - "Template not found for zone" - ) + template, + "Template not found for zone" + ) self.services["virtual_machine"]["zoneid"] = zones_list[0].id self.services["virtual_machine"]["template"] = template.id # Listing all the VM's for a User list_vms_before = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - zoneid=zones_list[0].id, - account=self.account.name - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + zoneid=zones_list[0].id, + account=self.account.name + ) self.assertIsNone( - list_vms_before, - "Virtual Machine already exists for newly created user" - ) + list_vms_before, + "Virtual Machine already exists for newly created user" + ) # Deploying a VM vm_created = VirtualMachine.create( - self.userapiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id, - ) + self.userapiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + ) self.assertIsNotNone( - vm_created, - "VM creation failed" - ) - self.cleanup.append(vm_created) + vm_created, + "VM creation failed" + ) # Listing all the VMs for a user again for matching zone list_vms_after = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - zoneid=zones_list[0].id, - account=self.account.name - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + zoneid=zones_list[0].id, + account=self.account.name + ) status = validateList(list_vms_after) self.assertEquals( - PASS, - status[0], - "VM creation failed" - ) + PASS, + status[0], + "VM creation failed" + ) # Verifying that the size of the list is 1 self.assertEquals( - 1, - len(list_vms_after), - "VM list count is not matching" - ) - # Listing the VM by specifying name of VM created in above and matching zone + 1, + len(list_vms_after), + "VM list count is not matching" + ) + # Listing the VM by specifying name of VM created in above and + # matching zone list_vms = VirtualMachine.list( - self.userapiclient, - listall=self.services["listall"], - page=1, - pagesize=self.services["pagesize"], - domainid=self.account.domainid, - zoneid=zones_list[0].id, - name=vm_created.name - ) + self.userapiclient, + listall=self.services["listall"], + page=1, + pagesize=self.services["pagesize"], + domainid=self.account.domainid, + zoneid=zones_list[0].id, + name=vm_created.name + ) status = validateList(list_vms) self.assertEquals( - PASS, - status[0], - "Listing VM's by name and zone failed" - ) + PASS, + status[0], + "Listing VM's by name and zone failed" + ) # Verifying Verifying that the size of the list is 1 self.assertEquals( - 1, - len(list_vms), - "Count of listed VM's by name and zone is not as expected" - ) + 1, + len(list_vms), + "Count of listed VM's by name and zone is not as expected" + ) listed_vm = list_vms[0] - # Verifying that the details of the Listed VM are same as the VM deployed above + # Verifying that the details of the Listed VM are same + # as the VM deployed above # Creating expected and actual values dictionaries expected_dict = { - "id":vm_created.id, - "name":vm_created.name, - "displayname":vm_created.displayname, - "state":vm_created.state, - "zoneid":vm_created.zoneid, - "account":vm_created.account, - "template":vm_created.templateid - } + "id": vm_created.id, + "name": vm_created.name, + "displayname": vm_created.displayname, + "state": vm_created.state, + "zoneid": vm_created.zoneid, + "account": vm_created.account, + "template": vm_created.templateid + } actual_dict = { - "id":listed_vm.id, - "name":listed_vm.name, - "displayname":listed_vm.displayname, - "state":listed_vm.state, - "zoneid":listed_vm.zoneid, - "account":listed_vm.account, - "template":listed_vm.templateid - } + "id": listed_vm.id, + "name": listed_vm.name, + "displayname": listed_vm.displayname, + "state": listed_vm.state, + "zoneid": listed_vm.zoneid, + "account": listed_vm.account, + "template": listed_vm
<TRUNCATED>