本文整理汇总了Python中marvin.lib.base.Snapshot.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Snapshot.delete方法的具体用法?Python Snapshot.delete怎么用?Python Snapshot.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Snapshot
的用法示例。
在下文中一共展示了Snapshot.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_01_list_volume_snapshots_pagination
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import delete [as 别名]
#.........这里部分代码省略.........
)
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,
pagesize=self.services["pagesize"]
)
status = validateList(list_vol_snaps_page2)
self.assertEquals(
PASS,
status[0],
"Failed to list volume snapshots in page 2"
)
# Verifying the list size to be equal to pagesize
self.assertEquals(
1,
len(list_vol_snaps_page2),
"Size of volume snapshots in page 2 is not matching"
)
# Deleting the volume snapshot present in page 2
Snapshot.delete(
snapshot_created,
self.userapiclient
)
self.cleanup.remove(snapshot_created)
# Listing all the snapshots in page 2 again
list_vol_snaps_page2 = Snapshot.list(
self.userapiclient,
listall=self.services["listall"],
page=2,
pagesize=self.services["pagesize"]
)
# Verifying that list size is 0
self.assertIsNone(
list_vol_snaps_page2,
"Volume snapshot not deleted from page 2"
)
return
示例2: test_01_delta_snapshots
# 需要导入模块: from marvin.lib.base import Snapshot [as 别名]
# 或者: from marvin.lib.base.Snapshot import delete [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,
#.........这里部分代码省略.........