本文整理汇总了Python中marvin.lib.base.Snapshot.list方法的典型用法代码示例。如果您正苦于以下问题:Python Snapshot.list方法的具体用法?Python Snapshot.list怎么用?Python Snapshot.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Snapshot
的用法示例。
在下文中一共展示了Snapshot.list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_list_snapshots
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_03_list_snapshots(self):
"""Test listing Snapshots using 'ids' parameter
"""
list_snapshot_response = Snapshot.list(
self.apiclient,
ids=[self.snapshot_1.id, self.snapshot_2.id, self.snapshot_3.id],
listAll=True
)
self.assertEqual(
isinstance(list_snapshot_response, list),
True,
"ListSnapshots response was not a valid list"
)
self.assertEqual(
len(list_snapshot_response),
3,
"ListSnapshots response expected 3 Snapshots, received %s" % len(list_snapshot_response)
)
#PLEASE UNCOMMENT ONCE VM SNAPSHOT DELAY BUG AFTER VM CREATION IS FIXED
#@attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
#def test_04_list_vm_snapshots(self):
"""Test listing VMSnapshots using 'vmsnapshotids' parameter
"""
"""list_vm_snapshot_response = VmSnapshot.list(
示例2: createSnapshotFromVirtualMachineVolume
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def createSnapshotFromVirtualMachineVolume(apiclient, account, vmid):
"""Create snapshot from volume"""
try:
volumes = Volume.list(apiclient, account=account.name, domainid=account.domainid, virtualmachineid=vmid)
validationresult = validateList(volumes)
assert validateList(volumes)[0] == PASS, "List volumes should return a valid response"
snapshot = Snapshot.create(apiclient, volume_id=volumes[0].id, account=account.name, domainid=account.domainid)
snapshots = Snapshot.list(apiclient, id=snapshot.id, listall=True)
validationresult = validateList(snapshots)
assert validationresult[0] == PASS, "List snapshot should return a valid list"
except Exception as e:
return [FAIL, e]
return [PASS, snapshot]
示例3: test_06_create_snapshots_in_project
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_06_create_snapshots_in_project(self):
"""Test create snapshots in project
"""
# Validate the following
# 1. Create a project
# 2. Add some snapshots to the project
# 3. Verify snapshot created inside project can only be used in inside
# the project
self.debug("Deploying VM for Project: %s" % self.project.id)
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
serviceofferingid=self.service_offering.id,
projectid=self.project.id,
)
self.cleanup.append(virtual_machine_1)
# Verify VM state
self.assertEqual(virtual_machine_1.state, "Running", "Check VM state is Running or not")
# Get the Root disk of VM
volumes = list_volumes(self.apiclient, projectid=self.project.id, type="ROOT", listall=True)
self.assertEqual(isinstance(volumes, list), True, "Check for list volume response return valid data")
self.debug("Creating snapshot from volume: %s" % volumes[0].id)
# Create a snapshot from the ROOTDISK
snapshot = Snapshot.create(self.apiclient, volumes[0].id, projectid=self.project.id)
self.cleanup.append(snapshot)
# Verify Snapshot state
self.assertEqual(
snapshot.state in ["BackedUp", "CreatedOnPrimary", "Allocated"],
True,
"Check Snapshot state is in one of the mentioned possible states, \
It is currently: %s"
% snapshot.state,
)
snapshots = Snapshot.list(self.apiclient, account=self.account.name, domainid=self.account.domainid)
self.assertEqual(snapshots, None, "Snapshots should not be available outside the project")
return
示例4: test_04_reoccuring_snapshot_rules
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_04_reoccuring_snapshot_rules(self):
"""
1) Create a VM using the Service offering IsVolatile enabled
2) Apply a recurring snapshot rule on the Volume.
3) After a couple of snapshots are taken reboot the VM.
Verify the following conditions
1) New root disk should be formed
2) The recurring snapshot rule should be deleted
"""
self.hypervisor = self.testClient.getHypervisorInfo()
vms = VirtualMachine.list(
self.apiclient,
id=self.vm_with_reset.id,
listall=True
)
vm_list_validation_result = validateList(vms)
self.assertEqual(vm_list_validation_result[0], PASS, "vm list validation failed due to %s" %
vm_list_validation_result[2])
vm_with_reset = vm_list_validation_result[1]
vm_with_reset_root_disk_id = self.get_root_device_uuid_for_vm(
vm_with_reset.id,
vm_with_reset.rootdeviceid
)
self.debug("Creating recurring snapshot policy for root disk on vm created with IsVolatile=True")
self.debug("Snapshot Policy - Type : %s Scheduled Hours : %s" %(
self.services["recurring_snapshot"]["intervaltype"],
self.services["recurring_snapshot"]["schedule"]))
recurring_snapshot = SnapshotPolicy.create(
self.apiclient,
vm_with_reset_root_disk_id,
self.services["recurring_snapshot"]
)
#ListSnapshotPolicy should return newly created policy
list_snapshots_policy = SnapshotPolicy.list(
self.apiclient,
id=recurring_snapshot.id,
volumeid=vm_with_reset_root_disk_id
)
snapshot_list_validation_result = validateList(list_snapshots_policy)
self.assertEqual(snapshot_list_validation_result[0], PASS, "snapshot list validation failed due to %s" %
snapshot_list_validation_result[2])
snapshots_policy = snapshot_list_validation_result[1]
self.assertEqual(
snapshots_policy.id,
recurring_snapshot.id,
"Check recurring snapshot id in list resources call"
)
self.assertEqual(
snapshots_policy.maxsnaps,
self.services["recurring_snapshot"]["maxsnaps"],
"Check interval type in list resources call"
)
sleep_seconds = (self.services["recurring_snapshot"]["schedule"]) * 3600 + 600
sleep_minutes = sleep_seconds/60
self.debug("Sleeping for %s minutes till the volume is snapshoted" %sleep_minutes)
time.sleep(sleep_seconds)
retriesCount = self.services["retriesCount"]
while True:
snapshots = Snapshot.list(
self.apiclient,
volumeid=vm_with_reset_root_disk_id,
intervaltype=\
self.services["recurring_snapshot"]["intervaltype"],
snapshottype=RECURRING,
listall=True
)
snapshot_list_validation_result = validateList(snapshots)
if snapshot_list_validation_result[0] == PASS:
break
elif retriesCount == 0:
self.fail("Failed to get snapshots list")
time.sleep(60)
retriesCount = retriesCount - 1
# rebooting the vm with isVolatile = True
try:
self.vm_with_reset.reboot(self.apiclient)
except Exception as e:
self.fail("Failed to reboot the virtual machine. Error: %s" % e)
# Check if the the root disk was destroyed and recreated for isVolatile=True
self.debug("Checking whether root disk of VM with isVolatile=True was destroyed")
vms = VirtualMachine.list(
self.apiclient,
#.........这里部分代码省略.........
示例5: test_01_storage_snapshots_limits
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_01_storage_snapshots_limits(self):
""" Storage and Snapshot Limit
1. Create Snapshot of ROOT disk.
2. Verify the Secondary Storage value
is increased by the size of snapshot.
3. Delete Snaphshot.
4. Verify the Secondary
Storage value is decreased by the size of snapshot.
5. Set the Snapshot limit of Account.
6. Create Snasphots till limit is reached.
7. Create Snapshot of ROOT Volume.
Creation should fail.
8. Delete few Snapshots.
9. Create Snapshot again.
Creation should succeed.
"""
# Get ROOT Volume
root_volumes_list = Volume.list(
self.userapiclient,
virtualmachineid=self.vm.id,
type='ROOT'
)
status = validateList(root_volumes_list)
self.assertEqual(status[0], PASS, "ROOT Volume List Validation Failed")
root_volume = root_volumes_list[0]
self.data_volume_created = Volume.create(
self.userapiclient,
self.testdata["volume"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
diskofferingid=self.disk_offering.id
)
self.cleanup.append(self.data_volume_created)
data_volumes_list = Volume.list(
self.userapiclient,
id=self.data_volume_created.id
)
status = validateList(data_volumes_list)
self.assertEqual(status[0], PASS, "DATA Volume List Validation Failed")
self.data_volume = data_volumes_list[0]
self.vm.attach_volume(
self.userapiclient,
self.data_volume
)
# Get Secondary Storage Value from Database
qryresult_before_snapshot = self.dbclient.execute(
" select id, account_name, secondaryStorageTotal\
from account_view where account_name = '%s';" %
self.account.name)
status = validateList(qryresult_before_snapshot)
self.assertEqual(
status[0],
PASS,
"Check sql query to return SecondaryStorageTotal of account")
secStorageBeforeSnapshot = qryresult_before_snapshot[0][2]
# Step 1
snapshot = Snapshot.create(
self.userapiclient,
root_volume.id)
snapshots_list = Snapshot.list(self.userapiclient,
id=snapshot.id)
status = validateList(snapshots_list)
self.assertEqual(status[0], PASS, "Snapshots List Validation Failed")
# Verify Snapshot state
self.assertEqual(
snapshots_list[0].state.lower() in [
BACKED_UP,
],
True,
"Snapshot state is not as expected. It is %s" %
snapshots_list[0].state
)
# Step 2
qryresult_after_snapshot = self.dbclient.execute(
" select id, account_name, secondaryStorageTotal\
from account_view where account_name = '%s';" %
self.account.name)
status = validateList(qryresult_after_snapshot)
self.assertEqual(
status[0],
PASS,
#.........这里部分代码省略.........
示例6: test_03_reuse_template_name
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_03_reuse_template_name(self):
"""TS_BUG_011-Test Reusing deleted template name
"""
# Validate the following
# 1. Deploy VM using default template, small service offering
# and small data disk offering.
# 2. Perform snapshot on the root disk of this VM.
# 3. Create a template from snapshot.
# 4. Delete the template and create a new template with same name
# 5. Template should be created succesfully
# Create a snapshot from the ROOTDISK
snapshot = Snapshot.create(
self.apiclient,
self.volume.id,
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created snapshot with ID: %s" % snapshot.id)
snapshots = Snapshot.list(
self.apiclient,
id=snapshot.id
)
self.assertEqual(
isinstance(snapshots, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
snapshots,
None,
"Check if result exists in list snapshots call"
)
self.assertEqual(
snapshots[0].id,
snapshot.id,
"Check snapshot id in list resources call"
)
# Generate template from the snapshot
template = Template.create_from_snapshot(
self.apiclient,
snapshot,
self.services["template"],
random_name=False
)
self.debug("Created template from snapshot: %s" % template.id)
templates = Template.list(
self.apiclient,
templatefilter=\
self.services["template"]["templatefilter"],
id=template.id
)
self.assertEqual(
isinstance(templates, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
templates,
None,
"Check if result exists in list item call"
)
self.assertEqual(
templates[0].isready,
True,
"Check new template state in list templates call"
)
self.debug("Deleting template: %s" % template.id)
template.delete(self.apiclient)
# Wait for some time to ensure template state is reflected in other calls
time.sleep(self.services["sleep"])
# Generate template from the snapshot
self.debug("Creating template from snapshot: %s with same name" %
template.id)
template = Template.create_from_snapshot(
self.apiclient,
snapshot,
self.services["template"],
random_name=False
)
templates = Template.list(
self.apiclient,
templatefilter=\
self.services["template"]["templatefilter"],
id=template.id
)
self.assertEqual(
isinstance(templates, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
#.........这里部分代码省略.........
示例7: test_02_check_size_snapshotTemplate
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_02_check_size_snapshotTemplate(self):
"""TS_BUG_010-Test check size of snapshot and template
"""
# Validate the following
# 1. Deploy VM using default template, small service offering
# and small data disk offering.
# 2. Perform snapshot on the root disk of this VM.
# 3. Create a template from snapshot.
# 4. Check the size of snapshot and template
# Create a snapshot from the ROOTDISK
snapshot = Snapshot.create(
self.apiclient,
self.volume.id,
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created snapshot with ID: %s" % snapshot.id)
snapshots = Snapshot.list(
self.apiclient,
id=snapshot.id
)
self.assertEqual(
isinstance(snapshots, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
snapshots,
None,
"Check if result exists in list snapshots call"
)
self.assertEqual(
snapshots[0].id,
snapshot.id,
"Check snapshot id in list resources call"
)
# Generate template from the snapshot
template = Template.create_from_snapshot(
self.apiclient,
snapshot,
self.services["template"]
)
self.cleanup.append(template)
self.debug("Created template from snapshot with ID: %s" % template.id)
templates = Template.list(
self.apiclient,
templatefilter=\
self.services["template"]["templatefilter"],
id=template.id
)
self.assertEqual(
isinstance(templates, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
templates,
None,
"Check if result exists in list item call"
)
self.assertEqual(
templates[0].isready,
True,
"Check new template state in list templates call"
)
# check size of template with that of snapshot
self.assertEqual(
templates[0].size,
self.volume.size,
"Derived template size (%s) does not match snapshot size (%s)" % (templates[0].size, self.volume.size)
)
return
示例8: test_02_list_volume_snapshots_byid
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_02_list_volume_snapshots_byid(self):
"""
@Desc: Test to List Volume Snapshots by Id
@Steps:
Step1: Listing all the volume snapshots for a user
Step2: Verifying that list size is 0
Step3: Creating a volume snapshot
Step4: Listing all the volume snapshots again for a user
Step5: Verifying that list size is 1
Step6: Listing all the volume snapshots by specifying snapshot id
Step7: Verifying that list size is 1
Step8: Verifying details of the listed volume snapshot
"""
if self.hypervisor.lower() in ['hyperv']:
raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
# Listing all the volume snapshots for a User
list_vol_snaps_before = Snapshot.list(
self.userapiclient,
listall=self.services["listall"]
)
# Verifying list size is 0
self.assertIsNone(
list_vol_snaps_before,
"Volume snapshots exists for newly created user"
)
# Listing the root volumes available for the user
volumes_list = Volume.list(
self.userapiclient,
listall=self.services["listall"]
)
status = validateList(volumes_list)
self.assertEquals(
PASS,
status[0],
"Root volume did not get created while deploying a VM"
)
# Verifying list size to be 1
self.assertEquals(
1,
len(volumes_list),
"More than 1 root volume created for deployed VM"
)
root_volume = volumes_list[0]
# Creating a volume snapshot
snapshot_created = Snapshot.create(
self.userapiclient,
root_volume.id,
)
self.assertIsNotNone(
snapshot_created,
"Snapshot creation failed"
)
self.cleanup.append(snapshot_created)
# Listing all the volume snapshots for user again
list_vol_snaps_after = Snapshot.list(
self.userapiclient,
listall=self.services["listall"]
)
status = validateList(list_vol_snaps_after)
self.assertEquals(
PASS,
status[0],
"Volume snapshot creation failed"
)
# Verifying that list size is 1
self.assertEquals(
1,
len(list_vol_snaps_after),
"Failed to create Volume snapshot"
)
# Listing volume snapshot by id
list_vol_snapshot = Snapshot.list(
self.userapiclient,
listall=self.services["listall"],
id=snapshot_created.id
)
status = validateList(list_vol_snapshot)
self.assertEquals(
PASS,
status[0],
"Failed to list Volume snapshot by Id"
)
# Verifying that list size is 1
self.assertEquals(
1,
len(list_vol_snapshot),
"Size of the list volume snapshot by Id is not matching"
)
# Verifying details of the listed snapshot to be same as snapshot created above
# Creating expected and actual values dictionaries
expected_dict = {
"id":snapshot_created.id,
"name":snapshot_created.name,
"state":snapshot_created.state,
"intervaltype":snapshot_created.intervaltype,
"account":snapshot_created.account,
"domain":snapshot_created.domainid,
"volume":snapshot_created.volumeid
}
actual_dict = {
#.........这里部分代码省略.........
示例9: test_01_list_volume_snapshots_pagination
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_01_list_volume_snapshots_pagination(self):
"""
@Desc: Test to List Volume Snapshots pagination
@steps:
Step1: Listing all the volume snapshots for a user
Step2: Verifying that list size is 0
Step3: Creating (page size + 1) number of volume snapshots
Step4: Listing all the volume snapshots again for a user
Step5: Verifying that list size is (page size + 1)
Step6: Listing all the volume snapshots in page1
Step7: Verifying that list size is (page size)
Step8: Listing all the volume snapshots in page2
Step9: Verifying that list size is 1
Step10: Deleting the volume snapshot present in page 2
Step11: Listing all the volume snapshots in page2
Step12: Verifying that list size is 0
"""
if self.hypervisor.lower() in ['hyperv']:
raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
# Listing all the volume snapshots for a User
list_vol_snaps_before = Snapshot.list(
self.userapiclient,
listall=self.services["listall"]
)
# Verifying list size is 0
self.assertIsNone(
list_vol_snaps_before,
"Volume snapshots exists for newly created user"
)
# Listing the root volumes available for the user
volumes_list = Volume.list(
self.userapiclient,
listall=self.services["listall"]
)
status = validateList(volumes_list)
self.assertEquals(
PASS,
status[0],
"Root volume did not get created while deploying a VM"
)
# Verifying list size to be 1
self.assertEquals(
1,
len(volumes_list),
"More than 1 root volume created for deployed VM"
)
root_volume = volumes_list[0]
# Creating pagesize + 1 number of volume snapshots
for i in range(0, (self.services["pagesize"] + 1)):
snapshot_created = Snapshot.create(
self.userapiclient,
root_volume.id,
)
self.assertIsNotNone(
snapshot_created,
"Snapshot creation failed"
)
self.cleanup.append(snapshot_created)
# Listing all the volume snapshots for user again
list_vol_snaps_after = Snapshot.list(
self.userapiclient,
listall=self.services["listall"]
)
status = validateList(list_vol_snaps_after)
self.assertEquals(
PASS,
status[0],
"Volume snapshot creation failed"
)
# Verifying that list size is pagesize + 1
self.assertEquals(
self.services["pagesize"] + 1,
len(list_vol_snaps_after),
"Failed to create pagesize + 1 number of Volume snapshots"
)
# Listing all the volume snapshots in page 1
list_vol_snaps_page1 = Snapshot.list(
self.userapiclient,
listall=self.services["listall"],
page=1,
pagesize=self.services["pagesize"]
)
status = validateList(list_vol_snaps_page1)
self.assertEquals(
PASS,
status[0],
"Failed to list volume snapshots in page 1"
)
# Verifying the list size to be equal to pagesize
self.assertEquals(
self.services["pagesize"],
len(list_vol_snaps_page1),
"Size of volume snapshots in page 1 is not matching"
)
# Listing all the volume snapshots in page 2
list_vol_snaps_page2 = Snapshot.list(
self.userapiclient,
listall=self.services["listall"],
page=2,
#.........这里部分代码省略.........
示例10: test_01_volume_snapshot
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_01_volume_snapshot(self):
""" Test Volume (root) Snapshot
# 1. Deploy a VM on primary storage and .
# 2. Take snapshot on root disk
# 3. Verify the snapshot's entry in the "snapshots" table
and presence of the corresponding
snapshot on the Secondary Storage
# 4. Create Template from the Snapshot and Deploy a
VM using the Template
# 5. Log in to the VM from template and make verify
the contents of the ROOT disk matches with the snapshot.
# 6. Delete Snapshot and Deploy a Linux VM from the
Template and verify the successful deployment of the VM.
# 7. Create multiple snapshots on the same volume and
Check the integrity of all the snapshots by creating
a template from the snapshot and deploying a Vm from it
and delete one of the snapshots
# 8. Verify that the original checksum matches with the checksum
of VM's created from remaning snapshots
# 9. Make verify the contents of the ROOT disk
matches with the snapshot
# 10.Verify that Snapshot of both DATA and ROOT volume should
succeed when snapshot of Data disk of a VM is taken
when snapshot of ROOT volume of VM is in progress
# 11.Create snapshot of data disk and verify the original checksum
matches with the volume created from snapshot
# 12.Verify that volume's state should not change when snapshot of
a DATA volume is taken that is attached to a VM
# 13.Verify that volume's state should not change when snapshot of
a DATA volume is taken that is not attached to a VM
# 14.Verify that create Snapshot with quiescevm=True should succeed
# 15.revertSnapshot() to revert VM to a specified
Volume snapshot for root volume
"""
# Step 1
# Get ROOT Volume Id
root_volumes_cluster_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm_1.id,
type='ROOT',
listall=True
)
root_volume_cluster = root_volumes_cluster_list[0]
disk_volumes_cluster_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm_1.id,
type='DATADISK',
listall=True
)
data_disk = disk_volumes_cluster_list[0]
root_vol_state = root_volume_cluster.state
ckecksum_random_root_cluster = createChecksum(
service=self.testdata,
virtual_machine=self.vm_1,
disk=root_volume_cluster,
disk_type="rootdiskdevice")
self.vm_1.stop(self.apiclient)
root_vol_snap = Snapshot.create(
self.apiclient,
root_volume_cluster.id)
self.assertEqual(
root_vol_snap.state,
"BackedUp",
"Check if the snapshot state is correct "
)
self.assertEqual(
root_vol_state,
root_volume_cluster.state,
"Check if volume state has changed"
)
self.vm_1.start(self.apiclient)
# Step 2
snapshot_list = list_snapshots(
self.apiclient,
id=root_vol_snap.id
)
self.assertNotEqual(
snapshot_list,
None,
"Check if result exists in list item call"
)
self.assertEqual(
snapshot_list[0].id,
root_vol_snap.id,
"Check resource id in list resources call"
)
self.assertTrue(
is_snapshot_on_nfs(
#.........这里部分代码省略.........
示例11: test_01_volume_snapshot
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_01_volume_snapshot(self):
""" Test Volume (root) Snapshot
# 1. Create Hourly, Daily,Weekly recurring snapshot policy for ROOT disk and
Verify the presence of the corresponding snapshots on the Secondary Storage
# 2. Delete the snapshot policy and verify the entry as Destroyed in snapshot_schedule
# 3. Verify that maxsnaps should not consider manual snapshots for deletion
# 4. Snapshot policy should reflect the correct timezone
# 5. Verify that listSnapshotPolicies() should return all snapshot policies
that belong to the account (both manual and recurring snapshots)
# 6. Verify that listSnapshotPolicies() should not return snapshot
policies that have been deleted
# 7. Verify that snapshot should not be created for VM in Destroyed state
# 8. Verify that snapshot should get created after resuming the VM
# 9. Verify that All the recurring policies associated with the VM should be
deleted after VM get destroyed.
"""
# Step 1
self.testdata["recurring_snapshot"]["intervaltype"] = 'HOURLY'
recurring_snapshot = SnapshotPolicy.create(
self.apiclient,
self.volume[0].id,
self.testdata["recurring_snapshot"]
)
# ListSnapshotPolicy should return newly created policy
list_snapshots_policy = list_snapshot_policy(
self.apiclient,
id=recurring_snapshot.id,
volumeid=self.volume[0].id
)
list_validation = validateList(list_snapshots_policy)
self.assertEqual(
list_validation[0],
PASS,
"snapshot list validation failed due to %s" %
list_validation[2])
timeout = self.testdata["timeout"]
while True:
snapshots = list_snapshots(
self.apiclient,
volumeid=self.volume[0].id,
intervaltype=self.testdata[
"recurring_snapshot"]["intervaltype"],
snapshottype='RECURRING',
listall=True
)
if isinstance(snapshots, list):
break
elif timeout == 0:
raise Exception("List snapshots API call failed.")
for snapshot in snapshots:
self.assertEqual(
self.dbclient.execute(
"select type_description from snapshots where name='%s'" %
snapshot.name)[0][0],
"HOURLY"
)
time.sleep(180)
for snapshot in snapshots:
self.assertTrue(
is_snapshot_on_nfs(
self.apiclient,
self.dbclient,
self.config,
self.zone.id,
snapshot.id))
recurring_snapshot.delete(self.apiclient)
self.assertEqual(
self.dbclient.execute(
"select * from snapshot_policy where uuid='%s'" %
recurring_snapshot.id),
[]
)
self.testdata["recurring_snapshot"]["intervaltype"] = 'DAILY'
self.testdata["recurring_snapshot"]["schedule"] = '00:00'
recurring_snapshot_daily = SnapshotPolicy.create(
self.apiclient,
self.volume[0].id,
self.testdata["recurring_snapshot"]
)
list_snapshots_policy_daily = list_snapshot_policy(
self.apiclient,
id=recurring_snapshot_daily.id,
volumeid=self.volume[0].id
)
list_validation = validateList(list_snapshots_policy_daily)
self.assertEqual(
#.........这里部分代码省略.........
示例12: test_01_verify_events_table
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_01_verify_events_table(self):
""" Test events table
# 1. Deploy a VM.
# 2. Take VM snapshot.
# 3. Verify that events table records UUID of the volume in descrption
instead of volume ID
"""
# Step 1
# Create VM
vm = VirtualMachine.create(
self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
volumes_list = list_volumes(
self.apiclient,
virtualmachineid=vm.id,
type='ROOT',
listall=True
)
volume_list_validation = validateList(volumes_list)
self.assertEqual(
volume_list_validation[0],
PASS,
"volume list validation failed due to %s" %
volume_list_validation[2]
)
root_volume = volumes_list[0]
# Step 2
# Create snapshot of root volume
snapshot = Snapshot.create(
self.apiclient,
root_volume.id)
snapshots_list = Snapshot.list(self.userapiclient,
id=snapshot.id)
status = validateList(snapshots_list)
self.assertEqual(status[0], PASS, "Snapshots List Validation Failed")
self.assertEqual(
snapshot.state,
"BackedUp",
"Check if snapshot gets created properly"
)
# Step 3
qresultset = self.dbclient.execute(
"select description from event where type='SNAPSHOT.CREATE' AND \
description like '%%%s%%'" % root_volume.id)
event_validation_result = validateList(qresultset)
self.assertEqual(
event_validation_result[0],
PASS,
"event list validation failed due to %s" %
event_validation_result[2]
)
self.assertNotEqual(
len(qresultset),
0,
"Check if events table records UUID of the volume"
)
return
示例13: test_02_list_snapshots_with_removed_data_store
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_02_list_snapshots_with_removed_data_store(self):
"""Test listing volume snapshots with removed data stores
"""
# 1 - Create new volume -> V
# 2 - Create new Primary Storage -> PS
# 3 - Attach and detach volume V from vm
# 4 - Migrate volume V to PS
# 5 - Take volume V snapshot -> S
# 6 - List snapshot and verify it gets properly listed although Primary Storage was removed
# Create new volume
vol = Volume.create(
self.apiclient,
self.services["volume"],
diskofferingid=self.disk_offering.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
)
self.cleanup.append(vol)
self.assertIsNotNone(vol, "Failed to create volume")
vol_res = Volume.list(
self.apiclient,
id=vol.id
)
self.assertEqual(
validateList(vol_res)[0],
PASS,
"Invalid response returned for list volumes")
vol_uuid = vol_res[0].id
# Create new Primary Storage
clusters = list_clusters(
self.apiclient,
zoneid=self.zone.id
)
assert isinstance(clusters,list) and len(clusters)>0
storage = StoragePool.create(self.apiclient,
self.services["nfs2"],
clusterid=clusters[0].id,
zoneid=self.zone.id,
podid=self.pod.id
)
self.cleanup.append(self.virtual_machine_with_disk)
self.cleanup.append(storage)
self.assertEqual(
storage.state,
'Up',
"Check primary storage state"
)
self.assertEqual(
storage.type,
'NetworkFilesystem',
"Check storage pool type"
)
storage_pools_response = list_storage_pools(self.apiclient,
id=storage.id)
self.assertEqual(
isinstance(storage_pools_response, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
len(storage_pools_response),
0,
"Check list Hosts response"
)
storage_response = storage_pools_response[0]
self.assertEqual(
storage_response.id,
storage.id,
"Check storage pool ID"
)
self.assertEqual(
storage.type,
storage_response.type,
"Check storage pool type "
)
# Attach created volume to vm, then detach it to be able to migrate it
self.virtual_machine_with_disk.stop(self.apiclient)
self.virtual_machine_with_disk.attach_volume(
self.apiclient,
vol
)
self.virtual_machine_with_disk.detach_volume(
self.apiclient,
vol
)
# Migrate volume to new Primary Storage
Volume.migrate(self.apiclient,
storageid=storage.id,
volumeid=vol.id
)
volume_response = list_volumes(
#.........这里部分代码省略.........
示例14: test_01_delta_snapshots
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import list [as 别名]
def test_01_delta_snapshots(self):
""" Delta Snapshots
1. Create file on ROOT disk of deployed VM.
2. Create Snapshot of ROOT disk.
3. Verify secondary storage count.
4. Check integrity of Full Snapshot.
5. Delete delta snaphshot and check integrity of\
remaining snapshots.
6. Delete full snapshot and verify it is deleted from\
secondary storage.
"""
checksum_created = []
full_snapshot_count = 0
delta_snapshot_count = 0
# Mulitply delta max value by 2 to set loop counter
# to create 2 Snapshot chains
snapshot_loop_count = int(self.delta_max) * 2
# Get ROOT Volume
root_volumes_list = list_volumes(
self.apiclient,
virtualmachineid=self.vm.id,
type=ROOT,
listall=True
)
status = validateList(root_volumes_list)
self.assertEqual(
status[0],
PASS,
"Check listVolumes response for ROOT Disk")
root_volume = root_volumes_list[0]
# Get Secondary Storage Value from Database
qryresult_before_snapshot = self.dbclient.execute(
" select id, account_name, secondaryStorageTotal\
from account_view where account_name = '%s';" %
self.account.name)
self.assertNotEqual(
len(qryresult_before_snapshot),
0,
"Check sql query to return SecondaryStorageTotal of account")
storage_qry_result_old = qryresult_before_snapshot[0]
secondary_storage_old = storage_qry_result_old[2]
# Create Snapshots
for i in range(snapshot_loop_count):
# Step 1
checksum_root = createChecksum(
self.testdata,
self.vm,
root_volume,
"rootdiskdevice")
time.sleep(30)
checksum_created.append(checksum_root)
# Step 2
root_vol_snapshot = Snapshot.create(
self.apiclient,
root_volume.id)
self.snapshots_created.append(root_vol_snapshot)
snapshots_list = Snapshot.list(self.apiclient,
id=root_vol_snapshot.id)
status = validateList(snapshots_list)
self.assertEqual(status[0], PASS, "Check listSnapshots response")
# Verify Snapshot state
self.assertEqual(
snapshots_list[0].state.lower() in [
BACKED_UP,
],
True,
"Snapshot state is not as expected. It is %s" %
snapshots_list[0].state
)
self.assertEqual(
snapshots_list[0].volumeid,
root_volume.id,
"Snapshot volume id is not matching with the vm's volume id")
# Step 3
qryresult_after_snapshot = self.dbclient.execute(
" select id, account_name, secondaryStorageTotal\
from account_view where account_name = '%s';" %
self.account.name)
self.assertNotEqual(
len(qryresult_after_snapshot),
0,
#.........这里部分代码省略.........
示例15: test_01_multiple_snapshot_in_zwps
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot 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)
#.........这里部分代码省略.........