def test_03_delete_iso(self): """Test delete ISO """ # Validate the following: # 1. UI should not show the deleted ISP # 2. database (vm_template table) should not contain deleted ISO self.debug("Deleting ISO with ID: %s" % self.iso_1.id) self.iso_1.delete(self.apiclient) # Sleep to ensure that ISO state is reflected in other calls time.sleep(self.services["sleep"]) # ListIsos to verify deleted ISO is properly deleted list_iso_response = list_isos( self.apiclient, id=self.iso_1.id ) self.assertEqual( list_iso_response, None, "Check if ISO exists in ListIsos" ) return
def test_02_edit_iso(self): """Test Edit ISO """ # Validate the following: # 1. UI should show the edited values for ISO # 2. database (vm_template table) should have updated values # Generate random values for updating ISO name and Display text new_displayText = random_gen() new_name = random_gen() self.debug("Updating ISO permissions for ISO: %s" % self.iso_1.id) cmd = updateIso.updateIsoCmd() # Assign new values to attributes cmd.id = self.iso_1.id cmd.displaytext = new_displayText cmd.name = new_name cmd.bootable = self.services["bootable"] cmd.passwordenabled = self.services["passwordenabled"] self.apiclient.updateIso(cmd) # Check whether attributes are updated in ISO using listIsos list_iso_response = list_isos( self.apiclient, id=self.iso_1.id ) self.assertEqual( isinstance(list_iso_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_iso_response), 0, "Check template available in List ISOs" ) iso_response = list_iso_response[0] self.assertEqual( iso_response.displaytext, new_displayText, "Check display text of updated ISO" ) self.assertEqual( iso_response.bootable, self.services["bootable"], "Check if image is bootable of updated ISO" ) self.assertEqual( iso_response.ostypeid, self.services["ostypeid"], "Check OSTypeID of updated ISO" ) return
def get_iso_details(self, isoname): # ListIsos to list default ISOS (VM and xen tools) list_default_iso_response = list_isos(self.apiclient, name=isoname, account="system", isready="true") status = validateList(list_default_iso_response) self.assertEqual(PASS, status[0], "Check if ISO exists in ListIsos")
def test_03_attach_ISO_in_RHEL7OSVM(self): """ @desc:Incorrect guest os mapping in vmware for Rhel7. Add a valid RHEL7 URL to execute this test case Step1 :Register an RHEL 7 template Step2 :Launch a VM Step3: Try to attach VMware Tools ISO Step4: Verify VMware tools ISO attached correctly """ self.hypervisor = str(get_hypervisor_type(self.api_client)).lower() if self.hypervisor != "vmware": self.skipTest("This test can be run only on vmware") self.services["Rhel7template"][ "url"] = "http://10.147.28.7/templates/rhel71.ova", template = Template.register(self.userapiclient, self.services["Rhel7template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor) self.debug("Registered a template with format {} and id {}".format( self.services["Rhel7template"]["format"], template.id)) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create(self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=template.id, zoneid=self.zone.id) self.cleanup.append(vm) response = VirtualMachine.list(self.userapiclient, id=vm.id) status = validateList(response) self.assertEqual(status[0], PASS, "list vm response returned invalid list") list_default_iso_response = list_isos(self.api_client, name="vmware-tools.iso", account="system", isready="true") status = validateList(list_default_iso_response) self.assertEqual(PASS, status[0], "ISO list is empty") self.debug("Registered a ISO with name {}".format( list_default_iso_response[0].name)) try: vm.attach_iso(self.userapiclient, list_default_iso_response[0]) except CloudstackAPIException as e: self.fail("Attached ISO failed : %s" % e) response = VirtualMachine.list(self.userapiclient, id=vm.id) status = validateList(response) self.assertEqual(status[0], PASS, "list vm response returned invalid list") attachedIsoName = response[0].isoname self.assertEqual(attachedIsoName, "vmware-tools.iso", "vmware-tools.iso not attached") return
def test_01_create_iso(self): """Test create public & private ISO """ # Validate the following: # 1. database (vm_template table) should be # updated with newly created ISO # 2. UI should show the newly added ISO # 3. listIsos API should show the newly added ISO iso = Iso.create( self.apiclient, self.services["iso2"], account=self.account.name, domainid=self.account.domainid ) self.debug("ISO created with ID: %s" % iso.id) try: iso.download(self.apiclient) except Exception as e: self.fail("Exception while downloading ISO %s: %s" % (iso.id, e)) list_iso_response = list_isos( self.apiclient, id=iso.id ) self.assertEqual( isinstance(list_iso_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_iso_response), 0, "Check template available in List ISOs" ) iso_response = list_iso_response[0] self.assertEqual( iso_response.displaytext, self.services["iso2"]["displaytext"], "Check display text of newly created ISO" ) self.assertEqual( iso_response.zoneid, self.services["iso2"]["zoneid"], "Check zone ID of newly created ISO" ) return
def get_iso_details(self, isoname): # ListIsos to list default ISOS (VM and xen tools) list_default_iso_response = list_isos( self.apiclient, name=isoname, isready="true" ) self.assertEqual( list_default_iso_response, None, "Check if ISO exists in ListIsos" )
def test_05_iso_permissions(self): """Update & Test for ISO permissions""" # validate the following # 1. listIsos returns valid permissions set for ISO # 2. permission changes should be reflected in vm_template # table in database self.debug("Updating permissions for ISO: %s" % self.iso_2.id) cmd = updateIsoPermissions.updateIsoPermissionsCmd() cmd.id = self.iso_2.id # Update ISO permissions cmd.isfeatured = self.services["isfeatured"] cmd.ispublic = self.services["ispublic"] cmd.isextractable = self.services["isextractable"] self.apiclient.updateIsoPermissions(cmd) # Verify ListIsos have updated permissions for the ISO for normal user list_iso_response = list_isos( self.apiclient, id=self.iso_2.id, account=self.account.name, domainid=self.account.domainid ) self.assertEqual( isinstance(list_iso_response, list), True, "Check list response returns a valid list" ) iso_response = list_iso_response[0] self.assertEqual( iso_response.id, self.iso_2.id, "Check ISO ID" ) self.assertEqual( iso_response.ispublic, self.services["ispublic"], "Check ispublic permission of ISO" ) self.assertEqual( iso_response.isfeatured, self.services["isfeatured"], "Check isfeatured permission of ISO" ) return
def get_iso_details(self, isoname): # ListIsos to list default ISOS (VM and xen tools) list_default_iso_response = list_isos( self.apiclient, name=isoname, account="system", isready="true" ) status = validateList(list_default_iso_response) self.assertEquals( PASS, status[0], "Check if ISO exists in ListIsos")
def test_06_copy_iso(self): """Test for copy ISO from one zone to another""" # Validate the following # 1. copy ISO should be successful and secondary storage # should contain new copied ISO. if len(self.zones) <= 1: self.skipTest( "Not enough zones available to perform copy template") self.services["destzoneid"] = filter( lambda z: z.id != self.zone.id, self.zones)[0].id self.debug("Copy ISO from %s to %s" % ( self.zone.id, self.services["destzoneid"] )) cmd = copyIso.copyIsoCmd() cmd.id = self.iso_2.id cmd.destzoneid = self.services["destzoneid"] cmd.sourcezoneid = self.zone.id self.apiclient.copyIso(cmd) # Verify ISO is copied to another zone using ListIsos list_iso_response = list_isos( self.apiclient, id=self.iso_2.id, zoneid=self.services["destzoneid"] ) self.assertEqual( isinstance(list_iso_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_iso_response), 0, "Check template extracted in List ISO" ) iso_response = list_iso_response[0] self.assertEqual( iso_response.id, self.iso_2.id, "Check ID of the downloaded ISO" ) self.assertEqual( iso_response.zoneid, self.services["destzoneid"], "Check zone ID of the copied ISO" ) self.debug("Cleanup copied ISO: %s" % iso_response.id) # Cleanup- Delete the copied ISO timeout = self.services["timeout"] while True: time.sleep(self.services["sleep"]) list_iso_response = list_isos( self.apiclient, id=self.iso_2.id, zoneid=self.services["destzoneid"] ) self.assertEqual( isinstance(list_iso_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_iso_response), 0, "Check template extracted in List ISO" ) iso_response = list_iso_response[0] if iso_response.isready: break if timeout == 0: raise Exception( "Failed to download copied iso(ID: %s)" % iso_response.id) timeout = timeout - 1 cmd = deleteIso.deleteIsoCmd() cmd.id = iso_response.id cmd.zoneid = self.services["destzoneid"] self.apiclient.deleteIso(cmd) return
def test3_attach_ISO_in_RHEL7OSVM(self): """ @desc:Incorrect guest os mapping in vmware for Rhel7. Add a valid RHEL7 URL to execute this test case Step1 :Register an RHEL 7 template Step2 :Launch a VM Step3: Try to attach VMware Tools ISO Step4: Verify VMware tools ISO attached correctly """ self.hypervisor = str(get_hypervisor_type(self.api_client)).lower() if self.hypervisor != "vmware": self.skipTest("This test can be run only on vmware") self.services["Rhel7template"]["url"]="http://10.147.28.7/templates/rhel71.ova", template = Template.register( self.userapiclient, self.services["Rhel7template"], zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, hypervisor=self.hypervisor ) self.debug( "Registered a template with format {} and id {}".format( self.services["Rhel7template"]["format"],template.id) ) template.download(self.userapiclient) self.cleanup.append(template) vm = VirtualMachine.create( self.userapiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=template.id, zoneid=self.zone.id ) self.cleanup.append(vm) response = VirtualMachine.list(self.userapiclient,id=vm.id) status = validateList(response) self.assertEqual(status[0],PASS,"list vm response returned invalid list") list_default_iso_response = list_isos( self.api_client, name="vmware-tools.iso", account="system", isready="true" ) status = validateList(list_default_iso_response) self.assertEquals( PASS, status[0], "ISO list is empty") self.debug( "Registered a ISO with name {}".format(list_default_iso_response[0].name)) try: vm.attach_iso(self.userapiclient,list_default_iso_response[0]) except CloudstackAPIException as e: self.fail("Attached ISO failed : %s" % e) response = VirtualMachine.list(self.userapiclient, id=vm.id) status = validateList(response) self.assertEqual(status[0], PASS,"list vm response returned invalid list") attachedIsoName=response[0].isoname; self.assertEqual(attachedIsoName, "vmware-tools.iso", "vmware-tools.iso not attached") return