本文整理汇总了Python中marvin.lib.base.StoragePool.list方法的典型用法代码示例。如果您正苦于以下问题:Python StoragePool.list方法的具体用法?Python StoragePool.list怎么用?Python StoragePool.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.StoragePool
的用法示例。
在下文中一共展示了StoragePool.list方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def setUpClass(cls):
testClient = super(TestAttachDataDiskOnCWPS, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
cls.hypervisor = cls.testClient.getHypervisorInfo()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls._cleanup = []
cls.template = get_template(
cls.apiclient,
cls.zone.id,
cls.testdata["ostype"])
cls.skiptest = False
try:
cls.pools = StoragePool.list(
cls.apiclient,
zoneid=cls.zone.id,
scope="CLUSTER")
except Exception as e:
cls.skiptest = True
return
try:
# Create an account
cls.account = Account.create(
cls.apiclient,
cls.testdata["account"],
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)
# Create user api client of the account
cls.userapiclient = testClient.getUserApiClient(
UserName=cls.account.name,
DomainName=cls.account.domain
)
# Create Service offering
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.testdata["service_offering"],
)
cls._cleanup.append(cls.service_offering)
# Create Disk offering
cls.disk_offering = DiskOffering.create(
cls.apiclient,
cls.testdata["disk_offering"],
custom=True,
tags=CLUSTERTAG1,
)
cls._cleanup.append(cls.disk_offering)
except Exception as e:
cls.tearDownClass()
raise e
return
示例2: setUpClass
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def setUpClass(cls):
testClient = super(TestVolumes, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()
cls._cleanup = []
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.hypervisor = testClient.getHypervisorInfo()
cls.invalidStoragePoolType = False
cls.disk_offering = DiskOffering.create(cls.apiclient, cls.services["disk_offering"])
cls.resized_disk_offering = DiskOffering.create(cls.apiclient, cls.services["resized_disk_offering"])
cls.custom_resized_disk_offering = DiskOffering.create(
cls.apiclient, cls.services["resized_disk_offering"], custom=True
)
template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"])
if template == FAILED:
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
cls.services["template"] = template.id
cls.services["diskofferingid"] = cls.disk_offering.id
cls.services["resizeddiskofferingid"] = cls.resized_disk_offering.id
cls.services["customresizeddiskofferingid"] = cls.custom_resized_disk_offering.id
# Create VMs, VMs etc
cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id)
cls.service_offering = ServiceOffering.create(cls.apiclient, cls.services["service_offerings"]["tiny"])
cls.virtual_machine = VirtualMachine.create(
cls.apiclient,
cls.services,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id,
mode=cls.services["mode"],
)
pools = StoragePool.list(cls.apiclient)
# cls.assertEqual(
# validateList(pools)[0],
# PASS,
# "storage pool list validation failed")
cls.volume = Volume.create(cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid)
cls._cleanup = [
cls.resized_disk_offering,
cls.custom_resized_disk_offering,
cls.service_offering,
cls.disk_offering,
cls.volume,
cls.account,
]
示例3: test_05_storage_pools
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_05_storage_pools(self):
"""Check the status of Storage pools"""
# Validate the following
# 1. List storage pools for the zone
# 2. Check state is "enabled" or not
storage_pools = StoragePool.list(
self.apiclient,
zoneid=self.zone.id,
listall=True
)
self.assertEqual(
isinstance(storage_pools, list),
True,
"Check if listStoragePools returns a valid response"
)
for storage_pool in storage_pools:
self.assertEqual(
storage_pool.state,
'Up',
"storage pool should be in Up state and running"
)
return
示例4: test_01_recover_VM
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_01_recover_VM(self):
""" Test Restore VM on VMWare
1. Deploy a VM without datadisk
2. Restore the VM
3. Verify that VM comes up in Running state
"""
try:
self.pools = StoragePool.list(
self.apiclient,
zoneid=self.zone.id,
scope="CLUSTER")
status = validateList(self.pools)
# Step 3
self.assertEqual(
status[0],
PASS,
"Check: Failed to list cluster wide storage pools")
if len(self.pools) < 2:
self.skipTest("There must be at atleast two cluster wide\
storage pools available in the setup")
except Exception as e:
self.skipTest(e)
# Adding tags to Storage Pools
cluster_no = 1
StoragePool.update(
self.apiclient,
id=self.pools[0].id,
tags=[CLUSTERTAG1[:-1] + repr(cluster_no)])
self.vm = VirtualMachine.create(
self.apiclient,
self.testdata["small"],
accountid=self.account.name,
templateid=self.template.id,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_cwps.id,
zoneid=self.zone.id,
)
# Step 2
volumes_root_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm.id,
type=ROOT,
listall=True
)
root_volume = volumes_root_list[0]
# Restore VM till its ROOT disk is recreated on onother Primary Storage
while True:
self.vm.restore(self.apiclient)
volumes_root_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm.id,
type=ROOT,
listall=True
)
root_volume = volumes_root_list[0]
if root_volume.storage != self.pools[0].name:
break
# Step 3
vm_list = list_virtual_machines(
self.apiclient,
id=self.vm.id)
state = vm_list[0].state
i = 0
while(state != "Running"):
vm_list = list_virtual_machines(
self.apiclient,
id=self.vm.id)
time.sleep(10)
i = i + 1
state = vm_list[0].state
if i >= 10:
self.fail("Restore VM Failed")
break
return
示例5: setUpClass
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def setUpClass(cls):
try:
cls._cleanup = []
cls.testClient = super(
testHaPoolMaintenance,
cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig()
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(
cls.api_client,
cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services['mode'] = cls.zone.networktype
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.clusterWithSufficientPool = None
cls.listResponse = None
clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id)
if not validateList(clusters)[0]:
cls.debug(
"check list cluster response for zone id %s" %
cls.zone.id)
cls.listResponse = True
return
for cluster in clusters:
cls.pool = StoragePool.list(cls.api_client,
clusterid=cluster.id,
keyword="NetworkFilesystem"
)
if not validateList(cls.pool)[0]:
cls.debug(
"check list cluster response for zone id %s" %
cls.zone.id)
cls.listResponse = True
return
if len(cls.pool) >= 2:
cls.clusterWithSufficientPool = cluster
break
if not cls.clusterWithSufficientPool:
return
cls.services["service_offerings"][
"tiny"]["offerha"] = "True"
cls.services_off = ServiceOffering.create(
cls.api_client,
cls.services["service_offerings"]["tiny"])
cls._cleanup.append(cls.services_off)
except Exception as e:
cls.tearDownClass()
raise Exception("Warning: Exception in setup : %s" % e)
return
示例6: test_08_resize_volume
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_08_resize_volume(self):
"""Test resize a volume"""
# Verify the size is the new size is what we wanted it to be.
self.debug(
"Attaching volume (ID: %s) to VM (ID: %s)" % (
self.volume.id,
self.virtual_machine.id
))
self.virtual_machine.attach_volume(self.apiClient, self.volume)
self.attached = True
hosts = Host.list(self.apiClient, id=self.virtual_machine.hostid)
self.assertTrue(isinstance(hosts, list))
self.assertTrue(len(hosts) > 0)
self.debug("Found %s host" % hosts[0].hypervisor)
if hosts[0].hypervisor == "XenServer":
self.virtual_machine.stop(self.apiClient)
elif hosts[0].hypervisor.lower() in ("vmware", "hyperv"):
self.skipTest("Resize Volume is unsupported on VmWare and Hyper-V")
# resize the data disk
self.debug("Resize Volume ID: %s" % self.volume.id)
self.services["disk_offering"]["disksize"] = 20
disk_offering_20_GB = DiskOffering.create(
self.apiclient,
self.services["disk_offering"]
)
self.cleanup.append(disk_offering_20_GB)
cmd = resizeVolume.resizeVolumeCmd()
cmd.id = self.volume.id
cmd.diskofferingid = disk_offering_20_GB.id
self.apiClient.resizeVolume(cmd)
count = 0
success = False
while count < 3:
list_volume_response = Volume.list(
self.apiClient,
id=self.volume.id,
type='DATADISK'
)
for vol in list_volume_response:
if vol.id == self.volume.id and int(vol.size) == (int(disk_offering_20_GB.disksize) * (1024** 3)) and vol.state == 'Ready':
success = True
if success:
break
else:
time.sleep(10)
count += 1
self.assertEqual(
success,
True,
"Check if the data volume resized appropriately"
)
can_shrink = False
list_volume_response = Volume.list(
self.apiClient,
id=self.volume.id,
type='DATADISK'
)
storage_pool_id = [x.storageid for x in list_volume_response if x.id == self.volume.id][0]
storage = StoragePool.list(self.apiclient, id=storage_pool_id)[0]
# At present only CLVM supports shrinking volumes
if storage.type.lower() == "clvm":
can_shrink = True
if can_shrink:
self.services["disk_offering"]["disksize"] = 10
disk_offering_10_GB = DiskOffering.create(
self.apiclient,
self.services["disk_offering"]
)
self.cleanup.append(disk_offering_10_GB)
cmd = resizeVolume.resizeVolumeCmd()
cmd.id = self.volume.id
cmd.diskofferingid = disk_offering_10_GB.id
cmd.shrinkok = "true"
self.apiClient.resizeVolume(cmd)
count = 0
success = False
while count < 3:
list_volume_response = Volume.list(
self.apiClient,
id=self.volume.id
)
for vol in list_volume_response:
if vol.id == self.volume.id and int(vol.size) == (int(disk_offering_10_GB.disksize) * (1024 ** 3)) and vol.state == 'Ready':
success = True
if success:
break
#.........这里部分代码省略.........
示例7: setUpClass
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def setUpClass(cls):
testClient = super(TestVolumes, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.hypervisor = testClient.getHypervisorInfo()
#for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
if cls.hypervisor.lower() == 'lxc':
if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
raise unittest.SkipTest("RBD storage type is required for data volumes for LXC")
cls.disk_offering = DiskOffering.create(
cls.apiclient,
cls.services["disk_offering"]
)
cls.resized_disk_offering = DiskOffering.create(
cls.apiclient,
cls.services["resized_disk_offering"]
)
cls.custom_resized_disk_offering = DiskOffering.create(
cls.apiclient,
cls.services["resized_disk_offering"],
custom=True
)
template = get_template(
cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
if template == FAILED:
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
cls.services["template"] = template.id
cls.services["diskofferingid"] = cls.disk_offering.id
cls.services['resizeddiskofferingid'] = cls.resized_disk_offering.id
cls.services['customresizeddiskofferingid'] = cls.custom_resized_disk_offering.id
# Create VMs, VMs etc
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.services["service_offerings"]
)
cls.virtual_machine = VirtualMachine.create(
cls.apiclient,
cls.services,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id,
mode=cls.services["mode"]
)
pools = StoragePool.list(cls.apiclient)
# cls.assertEqual(
# validateList(pools)[0],
# PASS,
# "storage pool list validation failed")
if cls.hypervisor.lower() == 'lxc' and cls.storage_pools.type.lower() != 'rbd':
raise unittest.SkipTest("Snapshots not supported on Hyper-V or LXC")
cls.volume = Volume.create(
cls.apiclient,
cls.services,
account=cls.account.name,
domainid=cls.account.domainid
)
cls._cleanup = [
cls.resized_disk_offering,
cls.custom_resized_disk_offering,
cls.service_offering,
cls.disk_offering,
cls.volume,
cls.account
]
示例8: setUpClass
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def setUpClass(cls):
testClient = super(TestPathVolume, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
#Get Zone,Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient)
cls.testdata["mode"] = cls.zone.networktype
cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"])
cls.testdata["template"]["ostypeid"] = cls.template.ostypeid
if cls.template == FAILED:
cls.fail("get_template() failed to return template with description %s" % cls.testdata["ostype"])
cls._cleanup = []
try:
cls.account = Account.create(cls.apiclient,
cls.testdata["account"],
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)
#createa two service offerings
cls.service_offering_1 = ServiceOffering.create(cls.apiclient, cls.testdata["service_offerings"]["small"])
cls._cleanup.append(cls.service_offering_1)
# Create Disk offerings
cls.disk_offering_1 = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
cls._cleanup.append(cls.disk_offering_1)
#check if zone wide storage is enable
cls.list_storage = StoragePool.list(cls.apiclient,
scope="ZONE"
)
if cls.list_storage:
cls.zone_wide_storage = cls.list_storage[0]
cls.debug("zone wide storage id is %s" % cls.zone_wide_storage.id)
cls.testdata["tags"] = "zp"
update1 = StoragePool.update(cls.apiclient,
id=cls.zone_wide_storage.id,
tags=cls.testdata["tags"]
)
cls.debug("Storage %s pool tag%s" % (cls.zone_wide_storage.id, update1.tags))
cls.testdata["service_offerings"]["tags"] = "zp"
cls.tagged_so = ServiceOffering.create(cls.apiclient, cls.testdata["service_offerings"])
cls.testdata["service_offerings"]["tags"] = " "
cls._cleanup.append(cls.tagged_so)
#create tagged disk offerings
cls.testdata["disk_offering"]["tags"] = "zp"
cls.disk_offering_tagged = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
cls._cleanup.append(cls.disk_offering_tagged)
else:
cls.debug("No zone wide storage found")
#check if local storage is enable
if cls.zone.localstorageenabled:
cls.testdata["disk_offering"]["tags"] = " "
cls.testdata["service_offerings"]["storagetype"] = 'local'
cls.service_offering_2 = ServiceOffering.create(cls.apiclient, cls.testdata["service_offerings"])
cls._cleanup.append(cls.service_offering_2)
#craete a compute offering with local storage
cls.testdata["disk_offering"]["storagetype"] = 'local'
cls.disk_offering_local = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
cls._cleanup.append(cls.disk_offering_local)
cls.testdata["disk_offering"]["storagetype"] = ' '
else:
cls.debug("No local storage found")
cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name,
DomainName=cls.account.domain
)
#Check if login is successful with new account
response = User.login(cls.userapiclient,
username=cls.account.name,
password=cls.testdata["account"]["password"]
)
assert response.sessionkey is not None
#response should have non null value
except Exception as e:
cls.tearDownClass()
raise e
return
示例9: test_01_positive_test_1
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_01_positive_test_1(self):
"""
positive test for volume life cycle
# 1. Deploy a vm [vm1] with shared storage and data disk
# 2. Deploy a vm [vm2]with shared storage without data disk
# 3.
# 4. Create a new volume and attache to vm2
# 5. Detach data disk from vm1 and download it
# Variance(1-9)
# 6. Upload volume by providing url of downloaded volume in step 5
# 7. Attach the volume to a different vm - vm2
# 8. Try to delete an attached volume
# 9. Create template from root volume of VM1
# 10. Create new VM using the template created in step 9
# 11. Delete the template
# 12. Detach the disk from VM2 and re-attach the disk to VM1
# 13.
# 14.
# 15.Migrate volume(detached) and then attach to a vm and live-migrate
# 16.Upload volume of size smaller than storage.max.volume.upload.size(leaving the negative case)
# 17.NA
# 18.
# 19.NA
# 20.Detach data disks from VM2 and delete volume
"""
# 1. Deploy a vm [vm1] with shared storage and data disk
self.virtual_machine_1 = VirtualMachine.create(self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_1.id,
zoneid=self.zone.id,
diskofferingid=self.disk_offering_1.id,
mode=self.testdata["mode"]
)
verify_vm(self, self.virtual_machine_1.id)
# List data volume for vm1
list_volume = Volume.list(self.userapiclient,
virtualmachineid=self.virtual_machine_1.id,
type='DATADISK'
)
self.assertEqual(validateList(list_volume)[0], PASS, "Check List volume response for vm id %s" % self.virtual_machine_1.id)
list_data_volume_for_vm1 = list_volume[0]
self.assertEqual(len(list_volume), 1, "There is no data disk attached to vm id:%s" % self.virtual_machine_1.id)
self.assertEqual(list_data_volume_for_vm1.virtualmachineid, str(self.virtual_machine_1.id), "Check if volume state (attached) is reflected")
# 2. Deploy a vm [vm2]with shared storage without data disk
self.virtual_machine_2 = VirtualMachine.create(self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_1.id,
zoneid=self.zone.id,
mode=self.testdata["mode"]
)
verify_vm(self, self.virtual_machine_2.id)
#4. Create a new volume and attache to vm2
self.volume = Volume.create(self.userapiclient,
services=self.testdata["volume"],
diskofferingid=self.disk_offering_1.id,
zoneid=self.zone.id
)
list_data_volume = Volume.list(self.userapiclient,
id=self.volume.id
)
self.assertEqual(validateList(list_data_volume)[0], PASS, "Check List volume response for volume %s" % self.volume.id)
self.assertEqual(list_data_volume[0].id, self.volume.id, "check list volume response for volume id: %s" % self.volume.id)
self.debug("volume id %s got created successfully" % list_data_volume[0].id)
# Attach volume to vm2
self.virtual_machine_2.attach_volume(self.userapiclient,
self.volume
)
verify_attach_volume(self, self.virtual_machine_2.id, self.volume.id)
#Variance
if self.zone.localstorageenabled:
# V1.Create vm3 with local storage offering
self.virtual_machine_local_3=VirtualMachine.create(self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_2.id,
zoneid=self.zone.id,
mode=self.testdata["mode"]
)
verify_vm(self, self.virtual_machine_local_3.id)
# V2.create two data disk on local storage
self.local_volumes = []
for i in range(2):
local_volume = Volume.create(self.userapiclient,
services=self.testdata["volume"],
diskofferingid=self.disk_offering_local.id,
zoneid=self.zone.id
#.........这里部分代码省略.........
示例10: list_ssvms
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
print "Disable zone"
zoneCmd = updateZone.updateZoneCmd()
zoneCmd.id = zone.id
zoneCmd.allocationstate = 'Disabled'
apiClient.updateZone(zoneCmd)
ssvms = list_ssvms(apiClient)
if ssvms:
for ssvm in ssvms:
print "ssvm name={}, id={}".format(ssvm.name, ssvm.id)
print "Destroy SSVM"
cmd = destroySystemVm.destroySystemVmCmd()
cmd.id = ssvm.id
apiClient.destroySystemVm(cmd)
storages = StoragePool.list(apiClient)
if storages:
for storage in storages:
print "storage name={}, id={}".format(storage.name, storage.id)
if storage.state == 'Maintenance':
print "delete StoragePool"
cmd = deleteStoragePool.deleteStoragePoolCmd()
cmd.id = storage.id
cmd.forced = 'True'
apiClient.deleteStoragePool(cmd)
else:
print "Delete StoragePool"
s = StoragePool(tmp_dict)
s.id = storage.id
s.forced = 'True'
s.delete(apiClient)
示例11: setUpClass
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def setUpClass(cls):
testClient = super(TestConcurrentSnapshots, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
cls.hypervisor = cls.testClient.getHypervisorInfo()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.template = get_template(
cls.apiclient,
cls.zone.id,
cls.testdata["ostype"])
cls._cleanup = []
cls.vm_pool = []
cls.snapshotSupported = True
if cls.hypervisor.lower() in ["hyperv", "lxc"]:
cls.snapshotSupported = False
return
# Set sleep time as per Snapshot Recurring Policy - HOURLY
cls.sleep_time_for_hourly_policy = 60 * 60 * 1
cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
try:
# Create an account
cls.account = Account.create(
cls.apiclient,
cls.testdata["account"],
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)
# Create user api client of the account
cls.userapiclient = testClient.getUserApiClient(
UserName=cls.account.name,
DomainName=cls.account.domain
)
# Create Service offering
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.testdata["service_offering"],
)
cls._cleanup.append(cls.service_offering)
for i in range(4):
cls.vm = VirtualMachine.create(
cls.apiclient,
cls.testdata["small"],
templateid=cls.template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id,
zoneid=cls.zone.id,
mode=cls.zone.networktype
)
cls.vm_pool.append(cls.vm)
cls._cleanup.append(cls.vm)
cls.checksum_pool = []
cls.root_pool = []
cls.snapshot_pool = []
cls.rec_policy_pool = []
for vm in cls.vm_pool:
root_volumes = list_volumes(
cls.apiclient,
virtualmachineid=vm.id,
type='ROOT',
listall=True
)
checksum_root = createChecksum(
cls.testdata,
vm,
root_volumes[0],
"rootdiskdevice")
cls.checksum_pool.append(checksum_root)
cls.root_pool.append(root_volumes[0])
try:
cls.pools = StoragePool.list(cls.apiclient, zoneid=cls.zone.id)
except Exception as e:
raise unittest.SkipTest(e)
except Exception as e:
cls.tearDownClass()
raise e
return
示例12: test_local_storage_data_disk_tag
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_local_storage_data_disk_tag(self):
"""
@Desc: Test whether tags are honoured while creating
data disks on local storage
@Steps:
This test needs multiple local storages
Step1: create a tag 'loc' on the local storage
Step2: create a disk offering with this storage tag 'loc'
Step3: create a VM and create disk by selecting the disk offering
created in step2
step4: check whether the data disk created in step3 is created on
local storage with tag 'loc'
"""
if not self.zone.localstorageenabled:
self.skipTest('Local storage is not enable for this '
'zone. skipping')
local_storages = StoragePool.list(self.apiClient,
zoneid=self.zone.id,
scope='HOST')
self.assertEqual(
isinstance(local_storages, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
local_storages,
None,
"Check if local storage pools exists in ListStoragePools"
)
cmd = updateStoragePool.updateStoragePoolCmd()
cmd.zoneid = self.zone.id
cmd.tags = 'loc'
cmd.id = local_storages[0].id
self.apiClient.updateStoragePool(cmd)
self.services["disk_offering"]["storagetype"] = 'local'
self.services["disk_offering"]["tags"] = 'loc'
disk_offering = DiskOffering.create(
self.apiClient,
self.services["disk_offering"]
)
self.services["virtual_machine"]["zoneid"] = self.zone.id
self.services["virtual_machine"]["template"] = self.template.id
# Step3: Verifying that VM creation is successful
virtual_machine = VirtualMachine.create(
self.apiClient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
mode=self.services["mode"]
)
self.cleanup.append(virtual_machine)
self.cleanup.append(disk_offering)
# Verify VM state
self.assertEqual(
virtual_machine.state,
'Running',
"Check VM state is Running or not"
)
self.volume = Volume.create(
self.apiClient,
self.services["volume"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
diskofferingid=disk_offering.id
)
virtual_machine.attach_volume(self.apiClient, self.volume)
self.attached = True
list_volume_response = Volume.list(
self.apiClient,
id=self.volume.id
)
self.assertEqual(
isinstance(list_volume_response, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
list_volume_response,
None,
"Check if volume exists in ListVolumes"
)
volume = list_volume_response[0]
self.assertNotEqual(
volume.virtualmachineid,
None,
"Check if volume state (attached) is reflected"
)
storage_pool = StoragePool.list(self.apiClient, id=volume.storageid)
self.assertEqual(
volume.storagetype,
'local',
"Check list storage pool response has local as storage type"
#.........这里部分代码省略.........
示例13: test_09_stop_vm_migrate_vol
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_09_stop_vm_migrate_vol(self):
"""Test Stopped Virtual Machine's ROOT volume migration
"""
# Validate the following:
# 1. deploy Vm with startvm=true
# 2. Should not be able to login to the VM.
# 3. listVM command should return the deployed VM.State of this VM
# should be "Running".
# 4. Stop the vm
# 5.list primary storages in the cluster , should be more than one
# 6.Migrate voluem to another available primary storage
clusters = Cluster.list(self.apiclient, zoneid=self.zone.id)
self.assertEqual(isinstance(clusters, list), True, "Check list response returns a valid list")
i = 0
for cluster in clusters:
storage_pools = StoragePool.list(self.apiclient, clusterid=cluster.id)
if len(storage_pools) > 1:
self.cluster_id = cluster.id
i += 1
break
if i == 0:
self.skipTest("No cluster with more than one primary storage pool to perform migrate volume test")
hosts = Host.list(self.apiclient, clusterid=self.cluster_id)
self.assertEqual(isinstance(hosts, list), True, "Check list response returns a valid list")
host = hosts[0]
self.debug("Deploying instance on host: %s" % host.id)
self.debug("Deploying instance in the account: %s" % self.account.name)
self.virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
diskofferingid=self.disk_offering.id,
hostid=host.id,
mode=self.zone.networktype,
)
response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
self.assertEqual(response[0], PASS, response[1])
try:
self.virtual_machine.stop(self.apiclient)
except Exception as e:
self.fail("failed to stop instance: %s" % e)
volumes = Volume.list(self.apiclient, virtualmachineid=self.virtual_machine.id, type="ROOT", listall=True)
self.assertEqual(isinstance(volumes, list), True, "Check volume list response returns a valid list")
vol_response = volumes[0]
# get the storage name in which volume is stored
storage_name = vol_response.storage
storage_pools = StoragePool.list(self.apiclient, clusterid=self.cluster_id)
# Get storage pool to migrate volume
for spool in storage_pools:
if spool.name == storage_name:
continue
else:
self.storage_id = spool.id
self.storage_name = spool.name
break
self.debug("Migrating volume to storage pool: %s" % self.storage_name)
Volume.migrate(self.apiclient, storageid=self.storage_id, volumeid=vol_response.id)
volume = Volume.list(self.apiclient, virtualmachineid=self.virtual_machine.id, type="ROOT", listall=True)
self.assertEqual(volume[0].storage, self.storage_name, "Check volume migration response")
return
示例14: test_01_multiple_snapshot_in_zwps
# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import list [as 别名]
def test_01_multiple_snapshot_in_zwps(self):
""" Test multiple volume snapshot in zwps
# 1. Verify if setup has a ZWPS and 2 CWPS
# 2. Deploy a VM with data disk in ZWPS
# 1. Verify ROOT and DATA Disk of the VM is in ZWPS.
# 2. Take a snapshot of VM.
# 3. Create Multiple Snapshots till operation fails.
"""
try:
self.pools = StoragePool.list(self.apiclient, zoneid=self.zone.id)
status = validateList(self.pools)
self.assertEqual(
status[0],
PASS,
"Check: Failed to list storage pools due to %s" %
status[2])
zonepoolList = list(storagePool for storagePool in self.pools
if storagePool.scope == "ZONE")
if len(zonepoolList) < 1:
self.skipTest("There must be at least one zone wide\
storage pools available in the setup")
if len(list(storagePool for storagePool in self.pools
if storagePool.scope == "CLUSTER")) < 2:
self.skipTest("There must be at atleast two cluster wide\
storage pools available in the setup")
except Exception as e:
self.skipTest(e)
# Adding tags to Storage Pools
zone_no = 1
StoragePool.update(
self.apiclient,
id=zonepoolList[0].id,
tags=[ZONETAG1[:-1] + repr(zone_no)])
self.vm_zwps = VirtualMachine.create(
self.apiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_zwps.id,
diskofferingid=self.disk_offering_zwps.id,
zoneid=self.zone.id,
)
self.cleanup.append(self.vm_zwps)
# Step 1
volumes_root_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm_zwps.id,
type=ROOT,
listall=True
)
status = validateList(volumes_root_list)
self.assertEqual(
status[0],
PASS,
"Check: Failed to list root vloume due to %s" %
status[2])
root_volume = volumes_root_list[0]
if root_volume.storage != zonepoolList[0].name:
self.fail("Root Volume not in Zone-Wide Storage Pool !")
volumes_data_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm_zwps.id,
type=DATA,
listall=True
)
status = validateList(volumes_data_list)
self.assertEqual(
status[0],
PASS,
"Check: Failed to list data vloume due to %s" %
status[2])
data_volume = volumes_data_list[0]
if data_volume.storage != zonepoolList[0].name:
self.fail("Data Volume not in Zone-Wide Storage Pool !")
# Step 2
self.vm_zwps.stop(self.apiclient)
self.debug(
"Creation of Snapshot of Data Volume after VM is stopped.....")
Snapshot.create(
self.apiclient,
data_volume.id)
#.........这里部分代码省略.........