mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Interop API Additional scenarios
This commit is contained in:
parent
6db212d413
commit
d08d60b2f3
@ -56,6 +56,8 @@ from marvin.codes import FAILED, PASS
|
|||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
#Import System modules
|
#Import System modules
|
||||||
import time
|
import time
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
_multiprocess_shared_ = True
|
_multiprocess_shared_ = True
|
||||||
class TestXDCCPInterop(cloudstackTestCase):
|
class TestXDCCPInterop(cloudstackTestCase):
|
||||||
@ -65,7 +67,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
testClient = super(TestXDCCPInterop, cls).getClsTestClient()
|
testClient = super(TestXDCCPInterop, cls).getClsTestClient()
|
||||||
cls.apiclient = testClient.getApiClient()
|
cls.apiclient = testClient.getApiClient()
|
||||||
cls.services = testClient.getParsedTestDataConfig()
|
cls.services = testClient.getParsedTestDataConfig()
|
||||||
|
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
||||||
# Get Zone, Domain and templates
|
# Get Zone, Domain and templates
|
||||||
cls.domain = get_domain(cls.apiclient)
|
cls.domain = get_domain(cls.apiclient)
|
||||||
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
|
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
|
||||||
@ -106,7 +108,8 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cls.account = Account.create(
|
cls.account = Account.create(
|
||||||
cls.apiclient,
|
cls.apiclient,
|
||||||
cls.services["account"],
|
cls.services["account"],
|
||||||
domainid=cls.domain.id
|
domainid=cls.domain.id,
|
||||||
|
admin=False
|
||||||
)
|
)
|
||||||
cls.debug(cls.account.id)
|
cls.debug(cls.account.id)
|
||||||
|
|
||||||
@ -130,8 +133,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cls.services["interop"][cls.uploadtemplateformat],
|
cls.services["interop"][cls.uploadtemplateformat],
|
||||||
zoneid=cls.zone.id,
|
zoneid=cls.zone.id,
|
||||||
domainid=cls.account.domainid,
|
domainid=cls.account.domainid,
|
||||||
account=cls.account.name,
|
account=cls.account.name
|
||||||
isdynamicallyscalable="true"
|
|
||||||
)
|
)
|
||||||
timeout = cls.services["vgpu"]["timeout"]
|
timeout = cls.services["vgpu"]["timeout"]
|
||||||
|
|
||||||
@ -169,9 +171,13 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cls.services["medium"]["zoneid"] = cls.zone.id
|
cls.services["medium"]["zoneid"] = cls.zone.id
|
||||||
cls.services["medium"]["template"] = cls.template.id
|
cls.services["medium"]["template"] = cls.template.id
|
||||||
|
|
||||||
|
user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500))
|
||||||
|
cls.services["virtual_machine"]["userdata"] = user_data
|
||||||
|
|
||||||
|
|
||||||
# cls.services["large"]["zoneid"] = cls.zone.id
|
# cls.services["large"]["zoneid"] = cls.zone.id
|
||||||
# cls.services["large"]["template"] = cls.template.id
|
# cls.services["large"]["template"] = cls.template.id
|
||||||
"""
|
|
||||||
cls.virtual_machine = VirtualMachine.create(
|
cls.virtual_machine = VirtualMachine.create(
|
||||||
cls.apiclient,
|
cls.apiclient,
|
||||||
cls.services["medium"],
|
cls.services["medium"],
|
||||||
@ -181,7 +187,12 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
mode=cls.services['mode'],
|
mode=cls.services['mode'],
|
||||||
startvm="false"
|
startvm="false"
|
||||||
)
|
)
|
||||||
"""
|
cls.user_api_client = cls.testClient.getUserApiClient(
|
||||||
|
UserName=cls.account.name,
|
||||||
|
DomainName=cls.account.domain
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
cls.cleanup = [
|
cls.cleanup = [
|
||||||
cls.service_offering,
|
cls.service_offering,
|
||||||
cls.account
|
cls.account
|
||||||
@ -195,12 +206,12 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
#self.apiclient = self.testClient.getApiClient()
|
#self.user_api_client = self.testClient.getApiClient()
|
||||||
#self.dbclient = self.testClient.getDbConnection()
|
#self.dbclient = self.testClient.getDbConnection()
|
||||||
self.cleanup = []
|
self.cleanup = []
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_01_create_list_delete_security_group(self):
|
def test_01_create_list_delete_security_group(self):
|
||||||
"""
|
"""
|
||||||
Test Security Group Creation,List,Deletion on a Basic
|
Test Security Group Creation,List,Deletion on a Basic
|
||||||
@ -208,26 +219,26 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
if self.zone.networktype!="Basic":
|
if self.zone.networktype!="Basic":
|
||||||
self.skipTest("Security Group creation is applicable only with Basic zone setup. skipping")
|
self.skipTest("Security Group creation is applicable only with Basic zone setup. skipping")
|
||||||
|
|
||||||
sg=SecurityGroup.create(self.apiclient,
|
sg=SecurityGroup.create(self.user_api_client,
|
||||||
self.services("security_group")
|
self.services("security_group")
|
||||||
)
|
)
|
||||||
|
|
||||||
listsg=SecurityGroup.list(self.apiclient,id=sg.id)
|
listsg=SecurityGroup.list(self.user_api_client,id=sg.id)
|
||||||
|
|
||||||
if sg.name!=listsg[0].name:
|
if sg.name!=listsg[0].name:
|
||||||
self.fail("Security Group is not created with specified details")
|
self.fail("Security Group is not created with specified details")
|
||||||
|
|
||||||
sg.delete(self.apiclient)
|
sg.delete(self.user_api_client)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_01_list_all_regions_with_noparams(self):
|
def test_01_list_all_regions_with_noparams(self):
|
||||||
"""
|
"""
|
||||||
Test List Regions With No Parameters
|
Test List Regions With No Parameters
|
||||||
"""
|
"""
|
||||||
regionavailable="no"
|
regionavailable="no"
|
||||||
listregions=Region.list(self.apiclient)
|
listregions=Region.list(self.user_api_client)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
isinstance(listregions, list),
|
isinstance(listregions, list),
|
||||||
@ -242,14 +253,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
if regionavailable=="no":
|
if regionavailable=="no":
|
||||||
self.fail("There is no region created")
|
self.fail("There is no region created")
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_02_list_all_diskofferings_with_noparams(self):
|
def test_02_list_all_diskofferings_with_noparams(self):
|
||||||
"""
|
"""
|
||||||
Test List Disk Offerings with No Parameters
|
Test List Disk Offerings with No Parameters
|
||||||
"""
|
"""
|
||||||
|
|
||||||
diskofferingvailable=0
|
diskofferingvailable=0
|
||||||
listdiskofferings=DiskOffering.list(self.apiclient)
|
listdiskofferings=DiskOffering.list(self.user_api_client)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
isinstance(listdiskofferings, list),
|
isinstance(listdiskofferings, list),
|
||||||
@ -271,14 +282,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
self.fail("All the default disk offerings are not listed")
|
self.fail("All the default disk offerings are not listed")
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_03_list_all_Serviceofferings_with_noparams(self):
|
def test_03_list_all_Serviceofferings_with_noparams(self):
|
||||||
"""
|
"""
|
||||||
Test List Service Offerings with No Parameters
|
Test List Service Offerings with No Parameters
|
||||||
"""
|
"""
|
||||||
|
|
||||||
serviceofferingvailable=0
|
serviceofferingvailable=0
|
||||||
listserviceofferings=ServiceOffering.list(self.apiclient)
|
listserviceofferings=ServiceOffering.list(self.user_api_client)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
isinstance(listserviceofferings, list),
|
isinstance(listserviceofferings, list),
|
||||||
@ -296,14 +307,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
self.fail("All the default service offerings are not listed")
|
self.fail("All the default service offerings are not listed")
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="false")
|
||||||
def test_04_list_zones_with_no_params(self):
|
def test_04_list_zones_with_no_params(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Test list zones
|
Test list zones
|
||||||
"""
|
"""
|
||||||
zonesavailable=0
|
zonesavailable=0
|
||||||
listallzones=Zone.list(self.apiclient)
|
listallzones=Zone.list(self.user_api_client)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
isinstance(listallzones, list),
|
isinstance(listallzones, list),
|
||||||
@ -321,14 +332,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_05_validate_stopped_vm_deployment(self):
|
def test_05_validate_stopped_vm_deployment(self):
|
||||||
"""
|
"""
|
||||||
Test Deploy Virtual Machine in Stopped State
|
Test Deploy Virtual Machine in Stopped State
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -365,14 +376,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_06_attachvolume_to_a_stopped_vm(self):
|
def test_06_attachvolume_to_a_stopped_vm(self):
|
||||||
"""
|
"""
|
||||||
Test Attach Volume To A Stopped VM
|
Test Attach Volume To A Stopped VM
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -382,12 +393,12 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
msg="Check if VM is in Stopped state"
|
msg="Check if VM is in Stopped state"
|
||||||
)
|
)
|
||||||
custom_disk_offering=DiskOffering.list(
|
custom_disk_offering=DiskOffering.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
name="custom"
|
name="custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.__class__.volume = Volume.create(
|
self.__class__.volume = Volume.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["volume"],
|
self.services["volume"],
|
||||||
zoneid=self.zone.id,
|
zoneid=self.zone.id,
|
||||||
account=self.account.name,
|
account=self.account.name,
|
||||||
@ -398,7 +409,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
# Check List Volume response for newly created volume
|
# Check List Volume response for newly created volume
|
||||||
list_volume_response = Volume.list(
|
list_volume_response = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.volume.id
|
id=self.volume.id
|
||||||
)
|
)
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
@ -412,11 +423,11 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cmd.id = self.volume.id
|
cmd.id = self.volume.id
|
||||||
cmd.virtualmachineid = self.virtual_machine.id
|
cmd.virtualmachineid = self.virtual_machine.id
|
||||||
cmd.deviceid=1
|
cmd.deviceid=1
|
||||||
vol1=self.apiclient.attachVolume(cmd)
|
vol1=self.user_api_client.attachVolume(cmd)
|
||||||
|
|
||||||
# Check all volumes attached to same VM
|
# Check all volumes attached to same VM
|
||||||
list_volume_response = Volume.list(
|
list_volume_response = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
virtualmachineid=self.virtual_machine.id,
|
virtualmachineid=self.virtual_machine.id,
|
||||||
type='DATADISK',
|
type='DATADISK',
|
||||||
listall=True
|
listall=True
|
||||||
@ -437,14 +448,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_07_start_vm(self):
|
def test_07_start_vm(self):
|
||||||
"""
|
"""
|
||||||
Test Start Stopped Virtual Machine with volumes attached
|
Test Start Stopped Virtual Machine with volumes attached
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -453,12 +464,12 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
'Stopped',
|
'Stopped',
|
||||||
msg="Check if VM is in Stopped state before starting it"
|
msg="Check if VM is in Stopped state before starting it"
|
||||||
)
|
)
|
||||||
self.virtual_machine.start(self.apiclient)
|
self.virtual_machine.start(self.user_api_client)
|
||||||
|
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -485,7 +496,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_08_list_all_vms_with_zone_id(self):
|
def test_08_list_all_vms_with_zone_id(self):
|
||||||
"""
|
"""
|
||||||
Test list all vm's available with the zone id
|
Test list all vm's available with the zone id
|
||||||
@ -497,10 +508,10 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cmd.listall = True
|
cmd.listall = True
|
||||||
cmd.zoneid=self.zone.id
|
cmd.zoneid=self.zone.id
|
||||||
|
|
||||||
list_vm_response=self.apiclient.listVirtualMachines(cmd)
|
list_vm_response=self.user_api_client.listVirtualMachines(cmd)
|
||||||
"""
|
"""
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
zoneid=self.zone.id
|
zoneid=self.zone.id
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
@ -519,15 +530,15 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="false")
|
||||||
def test_09_reboot_vm(self):
|
def test_09_reboot_vm(self):
|
||||||
"""Test Reboot Virtual Machine
|
"""Test Reboot Virtual Machine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.virtual_machine.reboot(self.apiclient)
|
self.virtual_machine.reboot(self.user_api_client)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -550,27 +561,27 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_10_detach_volume(self):
|
def test_10_detach_volume(self):
|
||||||
"""
|
"""
|
||||||
Test Detach Volume
|
Test Detach Volume
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_volume_response1 = Volume.list(
|
list_volume_response1 = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.volume.id
|
id=self.volume.id
|
||||||
)
|
)
|
||||||
|
|
||||||
if list_volume_response1[0].virtualmachineid is None:
|
if list_volume_response1[0].virtualmachineid is None:
|
||||||
self.skipTest("Check if volume is attached to the VM before detach")
|
self.skipTest("Check if volume is attached to the VM before detach")
|
||||||
|
|
||||||
self.virtual_machine.detach_volume(self.apiclient, self.volume)
|
self.virtual_machine.detach_volume(self.user_api_client, self.volume)
|
||||||
|
|
||||||
# Sleep to ensure the current state will reflected in other calls
|
# Sleep to ensure the current state will reflected in other calls
|
||||||
time.sleep(self.services["sleep"])
|
time.sleep(self.services["sleep"])
|
||||||
|
|
||||||
list_volume_response = Volume.list(
|
list_volume_response = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.volume.id
|
id=self.volume.id
|
||||||
)
|
)
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
@ -604,7 +615,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
list_volume_response1 = Volume.list(
|
list_volume_response1 = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.volume.id
|
id=self.volume.id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -613,13 +624,13 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
cmd = deleteVolume.deleteVolumeCmd()
|
cmd = deleteVolume.deleteVolumeCmd()
|
||||||
cmd.id = self.volume.id
|
cmd.id = self.volume.id
|
||||||
self.apiclient.deleteVolume(cmd)
|
self.user_api_client.deleteVolume(cmd)
|
||||||
|
|
||||||
# Sleep to ensure the current state will reflected in other calls
|
# Sleep to ensure the current state will reflected in other calls
|
||||||
time.sleep(self.services["sleep"])
|
time.sleep(self.services["sleep"])
|
||||||
|
|
||||||
list_volume_response = Volume.list(
|
list_volume_response = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.volume.id,
|
id=self.volume.id,
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -630,14 +641,14 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_12_stop_vm_with_force_false(self):
|
def test_12_stop_vm_with_force_false(self):
|
||||||
"""
|
"""
|
||||||
Test Stop Virtual Machine
|
Test Stop Virtual Machine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -645,7 +656,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
self.skipTest("Check if VM is in Running state before stopping it")
|
self.skipTest("Check if VM is in Running state before stopping it")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.virtual_machine.stop(self.apiclient,forced="false")
|
self.virtual_machine.stop(self.user_api_client,forced="false")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail("Failed to stop VM: %s" % e)
|
self.fail("Failed to stop VM: %s" % e)
|
||||||
return
|
return
|
||||||
@ -653,16 +664,16 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="true")
|
||||||
def test_13_destroy_vm(self):
|
def test_13_destroy_vm(self):
|
||||||
"""
|
"""
|
||||||
Test destroy Virtual Machine
|
Test destroy Virtual Machine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.virtual_machine.delete(self.apiclient, expunge=False)
|
self.virtual_machine.delete(self.user_api_client, expunge=False)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -685,7 +696,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="false")
|
||||||
def test_14_restore_stopped_vm(self):
|
def test_14_restore_stopped_vm(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -693,11 +704,11 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
noffering=NetworkOffering.list(
|
noffering=NetworkOffering.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
||||||
)
|
)
|
||||||
vmnetwork=Network.create(
|
vmnetwork=Network.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["network"],
|
self.services["network"],
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
domainid=self.account.domainid,
|
domainid=self.account.domainid,
|
||||||
@ -706,7 +717,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
list_nw_response = Network.list(
|
list_nw_response = Network.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=vmnetwork.id
|
id=vmnetwork.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -715,7 +726,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"Check list response returns a valid networks list"
|
"Check list response returns a valid networks list"
|
||||||
)
|
)
|
||||||
restorevm = VirtualMachine.create(
|
restorevm = VirtualMachine.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["medium"],
|
self.services["medium"],
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
domainid=self.account.domainid,
|
domainid=self.account.domainid,
|
||||||
@ -727,7 +738,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=restorevm.id
|
id=restorevm.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -742,7 +753,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
newvolume = Volume.create(
|
newvolume = Volume.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["volume"],
|
self.services["volume"],
|
||||||
zoneid=self.zone.id,
|
zoneid=self.zone.id,
|
||||||
account=self.account.name,
|
account=self.account.name,
|
||||||
@ -756,16 +767,16 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cmd.id = newvolume.id
|
cmd.id = newvolume.id
|
||||||
cmd.virtualmachineid = restorevm.id
|
cmd.virtualmachineid = restorevm.id
|
||||||
cmd.deviceid=1
|
cmd.deviceid=1
|
||||||
vol1=self.apiclient.attachVolume(cmd)
|
vol1=self.user_api_client.attachVolume(cmd)
|
||||||
|
|
||||||
cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
|
cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
|
||||||
cmd.virtualmachineid=restorevm.id
|
cmd.virtualmachineid=restorevm.id
|
||||||
self.apiclient.restoreVirtualMachine(cmd)
|
self.user_api_client.restoreVirtualMachine(cmd)
|
||||||
|
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=restorevm.id
|
id=restorevm.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -786,10 +797,10 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"Check virtual machine is in Stopped state"
|
"Check virtual machine is in Stopped state"
|
||||||
)
|
)
|
||||||
|
|
||||||
restorevm.start(self.apiclient)
|
restorevm.start(self.user_api_client)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=restorevm.id
|
id=restorevm.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -813,13 +824,13 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
restorevm.delete(self.apiclient)
|
restorevm.delete(self.apiclient)
|
||||||
|
|
||||||
vmnetwork.delete(self.apiclient)
|
vmnetwork.delete(self.user_api_client)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
|
@attr(tags = ["devcloud", "advanced", "advancedns", "basic", "sg"], required_hardware="false")
|
||||||
def test_15_restore_vm_with_template_id(self):
|
def test_15_restore_vm_with_template_id(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -827,11 +838,11 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
noffering=NetworkOffering.list(
|
noffering=NetworkOffering.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
||||||
)
|
)
|
||||||
vm1network=Network.create(
|
vm1network=Network.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["network"],
|
self.services["network"],
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
domainid=self.account.domainid,
|
domainid=self.account.domainid,
|
||||||
@ -840,7 +851,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
list_nw_response = Network.list(
|
list_nw_response = Network.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=vm1network.id
|
id=vm1network.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -850,7 +861,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
restorevm = VirtualMachine.create(
|
restorevm = VirtualMachine.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["medium"],
|
self.services["medium"],
|
||||||
networkids=vm1network.id,
|
networkids=vm1network.id,
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
@ -864,7 +875,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=restorevm.id
|
id=restorevm.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -875,12 +886,12 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
|
|
||||||
custom_disk_offering=DiskOffering.list(
|
custom_disk_offering=DiskOffering.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
name="custom"
|
name="custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
newvolume = Volume.create(
|
newvolume = Volume.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["volume"],
|
self.services["volume"],
|
||||||
zoneid=self.zone.id,
|
zoneid=self.zone.id,
|
||||||
account=self.account.name,
|
account=self.account.name,
|
||||||
@ -894,17 +905,17 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
cmd.id = newvolume.id
|
cmd.id = newvolume.id
|
||||||
cmd.virtualmachineid = restorevm.id
|
cmd.virtualmachineid = restorevm.id
|
||||||
cmd.deviceid=1
|
cmd.deviceid=1
|
||||||
vol1=self.apiclient.attachVolume(cmd)
|
vol1=self.user_api_client.attachVolume(cmd)
|
||||||
|
|
||||||
cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
|
cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
|
||||||
cmd.virtualmachineid = restorevm.id
|
cmd.virtualmachineid = restorevm.id
|
||||||
cmd.templateid = self.xtemplate.id
|
cmd.templateid = self.xtemplate.id
|
||||||
self.apiclient.restoreVirtualMachine(cmd)
|
self.user_api_client.restoreVirtualMachine(cmd)
|
||||||
|
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|
||||||
list_vm_response = VirtualMachine.list(
|
list_vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=restorevm.id
|
id=restorevm.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -927,7 +938,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
restorevm.delete(self.apiclient)
|
restorevm.delete(self.apiclient)
|
||||||
|
|
||||||
vm1network.delete(self.apiclient)
|
vm1network.delete(self.user_api_client)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -939,11 +950,11 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
noffering=NetworkOffering.list(
|
noffering=NetworkOffering.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
||||||
)
|
)
|
||||||
vm2network=Network.create(
|
vm2network=Network.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["network"],
|
self.services["network"],
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
domainid=self.account.domainid,
|
domainid=self.account.domainid,
|
||||||
@ -952,7 +963,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
list_nw_response = Network.list(
|
list_nw_response = Network.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=vm2network.id
|
id=vm2network.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -962,7 +973,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
templatevm = VirtualMachine.create(
|
templatevm = VirtualMachine.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["medium"],
|
self.services["medium"],
|
||||||
templateid=self.template.id,
|
templateid=self.template.id,
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
@ -974,7 +985,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
vm_response = VirtualMachine.list(
|
vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=templatevm.id)
|
id=templatevm.id)
|
||||||
|
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
@ -989,10 +1000,10 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
"Check the state of VM created from Template"
|
"Check the state of VM created from Template"
|
||||||
)
|
)
|
||||||
|
|
||||||
templatevm.stop(self.apiclient,forced="false")
|
templatevm.stop(self.user_api_client,forced="false")
|
||||||
|
|
||||||
vm_response = VirtualMachine.list(
|
vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=templatevm.id)
|
id=templatevm.id)
|
||||||
|
|
||||||
vm = vm_response[0]
|
vm = vm_response[0]
|
||||||
@ -1003,7 +1014,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
list_volume_response = Volume.list(
|
list_volume_response = Volume.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
virtualmachineid=vm.id,
|
virtualmachineid=vm.id,
|
||||||
type="ROOT",
|
type="ROOT",
|
||||||
listall=True
|
listall=True
|
||||||
@ -1011,7 +1022,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
#Create template from Virtual machine and Volume ID
|
#Create template from Virtual machine and Volume ID
|
||||||
roottemplate = Template.create(
|
roottemplate = Template.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["interop"]["template"],
|
self.services["interop"]["template"],
|
||||||
volumeid=list_volume_response[0].id,
|
volumeid=list_volume_response[0].id,
|
||||||
account=self.account.name,
|
account=self.account.name,
|
||||||
@ -1021,7 +1032,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|
||||||
list_template_response = Template.list(
|
list_template_response = Template.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
templatefilter=\
|
templatefilter=\
|
||||||
self.services["templatefilter"],
|
self.services["templatefilter"],
|
||||||
id=roottemplate.id
|
id=roottemplate.id
|
||||||
@ -1042,36 +1053,31 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
template_response.displaytext,
|
template_response.displaytext,
|
||||||
self.services["template"]["displaytext"],
|
self.services["interop"]["template"]["displaytext"],
|
||||||
"Check display text of newly created template"
|
"Check display text of newly created template"
|
||||||
)
|
)
|
||||||
name = template_response.name
|
name = template_response.name
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name.count(self.services["template"]["name"]),
|
name.count(self.services["interop"]["template"]["name"]),
|
||||||
1,
|
1,
|
||||||
"Check name of newly created template"
|
"Check name of newly created template"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
|
||||||
template_response.ostypeid,
|
|
||||||
self.services["template"]["ostypeid"],
|
|
||||||
"Check osTypeID of newly created template"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
templatevm.delete(self.apiclient)
|
templatevm.delete(self.apiclient)
|
||||||
vm2network.delete(self.apiclient)
|
vm2network.delete(self.user_api_client)
|
||||||
|
|
||||||
vm3network=Network.create(
|
vm3network=Network.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["network"],
|
self.services["network"],
|
||||||
accountid=self.account.name,
|
accountid=self.account.name,
|
||||||
domainid=self.account.domainid,
|
domainid=self.account.domainid,
|
||||||
networkofferingid=noffering.id,
|
networkofferingid=noffering[0].id,
|
||||||
zoneid=self.zone.id
|
zoneid=self.zone.id
|
||||||
)
|
)
|
||||||
|
|
||||||
list_nw_response = Network.list(
|
list_nw_response = Network.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=vm3network.id
|
id=vm3network.id
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -1082,7 +1088,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
|
|
||||||
templatevm = VirtualMachine.create(
|
templatevm = VirtualMachine.create(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
self.services["medium"],
|
self.services["medium"],
|
||||||
templateid=roottemplate.id,
|
templateid=roottemplate.id,
|
||||||
networkids=vm3network.id,
|
networkids=vm3network.id,
|
||||||
@ -1094,7 +1100,7 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
vm_response = VirtualMachine.list(
|
vm_response = VirtualMachine.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
id=templatevm.id)
|
id=templatevm.id)
|
||||||
|
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
@ -1110,10 +1116,10 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Delete the template
|
# Delete the template
|
||||||
roottemplate.delete(self.apiclient)
|
roottemplate.delete(self.user_api_client)
|
||||||
|
|
||||||
list_template_response = Template.list(
|
list_template_response = Template.list(
|
||||||
self.apiclient,
|
self.user_api_client,
|
||||||
templatefilter=\
|
templatefilter=\
|
||||||
self.services["template"]["templatefilter"],
|
self.services["template"]["templatefilter"],
|
||||||
id=roottemplate.id,
|
id=roottemplate.id,
|
||||||
@ -1127,5 +1133,204 @@ class TestXDCCPInterop(cloudstackTestCase):
|
|||||||
|
|
||||||
templatevm.delete(self.apiclient)
|
templatevm.delete(self.apiclient)
|
||||||
|
|
||||||
vm3network.delete(self.apiclient)
|
vm3network.delete(self.user_api_client)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@attr(tags=["devcloud", "basic", "advanced", "post"], required_hardware="true")
|
||||||
|
def test_17_deployvm_userdata_post(self):
|
||||||
|
"""Test userdata as POST, size > 2k
|
||||||
|
"""
|
||||||
|
deployVmResponse = VirtualMachine.create(
|
||||||
|
self.user_api_client,
|
||||||
|
services=self.services["virtual_machine"],
|
||||||
|
accountid=self.account.name,
|
||||||
|
domainid=self.account.domainid,
|
||||||
|
serviceofferingid=self.service_offering.id,
|
||||||
|
templateid=self.template.id,
|
||||||
|
zoneid=self.zone.id,
|
||||||
|
method='POST'
|
||||||
|
)
|
||||||
|
vms = list_virtual_machines(
|
||||||
|
self.user_api_client,
|
||||||
|
account=self.account.name,
|
||||||
|
domainid=self.account.domainid,
|
||||||
|
id=deployVmResponse.id
|
||||||
|
)
|
||||||
|
self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name)
|
||||||
|
vm = vms[0]
|
||||||
|
self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test")
|
||||||
|
self.assert_(vm.state == "Running", "VM is not in Running state")
|
||||||
|
return
|
||||||
|
|
||||||
|
@attr(tags=["devcloud", "basic", "advanced"], required_hardware="true")
|
||||||
|
def test_18_deployvm_userdata(self):
|
||||||
|
"""Test userdata as GET, size > 2k
|
||||||
|
"""
|
||||||
|
deployVmResponse = VirtualMachine.create(
|
||||||
|
self.user_api_client,
|
||||||
|
services=self.services["virtual_machine"],
|
||||||
|
accountid=self.account.name,
|
||||||
|
domainid=self.account.domainid,
|
||||||
|
serviceofferingid=self.service_offering.id,
|
||||||
|
templateid=self.template.id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
vms = list_virtual_machines(
|
||||||
|
self.user_api_client,
|
||||||
|
account=self.account.name,
|
||||||
|
domainid=self.account.domainid,
|
||||||
|
id=deployVmResponse.id
|
||||||
|
)
|
||||||
|
self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name)
|
||||||
|
vm = vms[0]
|
||||||
|
self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test")
|
||||||
|
self.assert_(vm.state == "Running", "VM is not in Running state")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@attr(tags=["advanced", "basic"], required_hardware="false")
|
||||||
|
def test_19_template_tag(self):
|
||||||
|
""" Test creation, listing and deletion tag on templates
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self.hypervisor.lower() in ['lxc']:
|
||||||
|
self.skipTest("template creation from volume feature is not supported on %s" % self.hypervisor.lower())
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
noffering=NetworkOffering.list(
|
||||||
|
self.user_api_client,
|
||||||
|
name="DefaultIsolatedNetworkOfferingWithSourceNatService"
|
||||||
|
)
|
||||||
|
vm4network=Network.create(
|
||||||
|
self.user_api_client,
|
||||||
|
self.services["network"],
|
||||||
|
accountid=self.account.name,
|
||||||
|
domainid=self.account.domainid,
|
||||||
|
networkofferingid=noffering[0].id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
|
||||||
|
list_nw_response = Network.list(
|
||||||
|
self.user_api_client,
|
||||||
|
id=vm4network.id
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(list_nw_response, list),
|
||||||
|
True,
|
||||||
|
"Check list response returns a valid networks list"
|
||||||
|
)
|
||||||
|
|
||||||
|
vm_1 = VirtualMachine.create(
|
||||||
|
self.user_api_client,
|
||||||
|
self.services["medium"],
|
||||||
|
templateid=template.id,
|
||||||
|
networkids=vm4network.id,
|
||||||
|
serviceofferingid=self.service_offering.id,
|
||||||
|
accountid=self.account.name,
|
||||||
|
domainid=self.account.domainid,
|
||||||
|
mode=self.services['mode'],
|
||||||
|
startvm="true"
|
||||||
|
)
|
||||||
|
time.sleep(600)
|
||||||
|
self.debug("Stopping the virtual machine: %s" % vm_1.name)
|
||||||
|
# Stop virtual machine
|
||||||
|
vm_1.stop(self.user_api_client)
|
||||||
|
except Exception as e:
|
||||||
|
self.fail("Failed to stop VM: %s" % e)
|
||||||
|
|
||||||
|
timeout = self.services["timeout"]
|
||||||
|
while True:
|
||||||
|
list_volume = Volume.list(
|
||||||
|
self.user_api_client,
|
||||||
|
virtualmachineid=vm_1.id,
|
||||||
|
type='ROOT',
|
||||||
|
listall=True
|
||||||
|
)
|
||||||
|
if isinstance(list_volume, list):
|
||||||
|
break
|
||||||
|
elif timeout == 0:
|
||||||
|
raise Exception("List volumes failed.")
|
||||||
|
|
||||||
|
time.sleep(5)
|
||||||
|
timeout = timeout - 1
|
||||||
|
|
||||||
|
self.volume = list_volume[0]
|
||||||
|
|
||||||
|
self.debug("Creating template from ROOT disk of virtual machine: %s" %
|
||||||
|
vm_1.name)
|
||||||
|
# Create template from volume
|
||||||
|
template = Template.create(
|
||||||
|
self.user_api_client,
|
||||||
|
self.services["template"],
|
||||||
|
self.volume.id
|
||||||
|
)
|
||||||
|
self.cleanup.append(template)
|
||||||
|
self.debug("Created the template(%s). Now restarting the userVm: %s" %
|
||||||
|
(template.name, vm_1.name))
|
||||||
|
vm_1.start(self.user_api_client)
|
||||||
|
|
||||||
|
self.debug("Creating a tag for the template")
|
||||||
|
tag = Tag.create(
|
||||||
|
self.user_api_client,
|
||||||
|
resourceIds=template.id,
|
||||||
|
resourceType='Template',
|
||||||
|
tags={'OS': 'windows8'}
|
||||||
|
)
|
||||||
|
self.debug("Tag created: %s" % tag.__dict__)
|
||||||
|
|
||||||
|
tags = Tag.list(
|
||||||
|
self.user_api_client,
|
||||||
|
listall=True,
|
||||||
|
resourceType='Template',
|
||||||
|
key='OS',
|
||||||
|
value='windows8'
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(tags, list),
|
||||||
|
True,
|
||||||
|
"List tags should not return empty response"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
tags[0].value,
|
||||||
|
'windows8',
|
||||||
|
'The tag should have original value'
|
||||||
|
)
|
||||||
|
|
||||||
|
Template.list(
|
||||||
|
self.user_api_client,
|
||||||
|
templatefilter=self.services["template"]["templatefilter"],
|
||||||
|
listall=True,
|
||||||
|
key='OS',
|
||||||
|
value='windows8'
|
||||||
|
)
|
||||||
|
|
||||||
|
self.debug("Deleting the created tag..")
|
||||||
|
try:
|
||||||
|
tag.delete(
|
||||||
|
self.user_api_client,
|
||||||
|
resourceIds=template.id,
|
||||||
|
resourceType='Template',
|
||||||
|
tags={'OS': 'windows8'}
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
self.fail("Failed to delete the tag - %s" % e)
|
||||||
|
|
||||||
|
self.debug("Verifying if tag is actually deleted!")
|
||||||
|
tags = Tag.list(
|
||||||
|
self.user_api_client,
|
||||||
|
listall=True,
|
||||||
|
resourceType='Template',
|
||||||
|
key='OS',
|
||||||
|
value='windows8'
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
tags,
|
||||||
|
None,
|
||||||
|
"List tags should return empty response"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user