当前位置: 首页>>代码示例>>Python>>正文


Python VmSnapshot.deleteVMSnapshot方法代码示例

本文整理汇总了Python中marvin.lib.base.VmSnapshot.deleteVMSnapshot方法的典型用法代码示例。如果您正苦于以下问题:Python VmSnapshot.deleteVMSnapshot方法的具体用法?Python VmSnapshot.deleteVMSnapshot怎么用?Python VmSnapshot.deleteVMSnapshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin.lib.base.VmSnapshot的用法示例。


在下文中一共展示了VmSnapshot.deleteVMSnapshot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_03_delete_vm_snapshots

# 需要导入模块: from marvin.lib.base import VmSnapshot [as 别名]
# 或者: from marvin.lib.base.VmSnapshot import deleteVMSnapshot [as 别名]
    def test_03_delete_vm_snapshots(self):
        """Test to delete vm snapshots
        """

        list_snapshot_response = VmSnapshot.list(self.apiclient, vmid=self.virtual_machine.id, listall=True)

        self.assertEqual(
            isinstance(list_snapshot_response, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertNotEqual(
            list_snapshot_response,
            None,
            "Check if snapshot exists in ListSnapshot"
        )
        VmSnapshot.deleteVMSnapshot(self.apiclient, list_snapshot_response[0].id)

        time.sleep(self.services["sleep"] * 3)

        list_snapshot_response = VmSnapshot.list(self.apiclient, vmid=self.virtual_machine.id, listall=True)

        self.assertEqual(
            list_snapshot_response,
            None,
            "Check list vm snapshot has be deleted"
        )
开发者ID:KarlHarrisSungardAS,项目名称:cloudstack,代码行数:29,代码来源:test_vm_snapshots.py

示例2: test_02_take_VM_snapshot_with_data_disk

# 需要导入模块: from marvin.lib.base import VmSnapshot [as 别名]
# 或者: from marvin.lib.base.VmSnapshot import deleteVMSnapshot [as 别名]

#.........这里部分代码省略.........
            root_volume_vdis_after_create.base_vdi["uuid"],
            root_volume_vdis_after_revert.base_vdi["uuid"],
            TestVMSnapshots._base_vdis_should_be_the_same_err_msg
        )

        data_volume_path_3 = self._get_path(data_volume_id)

        self.assertNotEqual(
            data_volume_path_1,
            data_volume_path_3,
            TestVMSnapshots._path_should_have_changed_err_msg
        )

        data_volume_xen_vdis = self.xen_session.xenapi.SR.get_VDIs(data_volume_xen_sr)

        self._check_list(data_volume_xen_vdis, 3, TestVMSnapshots._should_be_three_vdis_err_msg)

        data_volume_vdis_after_revert = self._get_vdis(data_volume_xen_vdis)

        self.assertNotEqual(
            data_volume_vdis_after_create.active_vdi["uuid"],
            data_volume_vdis_after_revert.active_vdi["uuid"],
            TestVMSnapshots._active_vdis_should_not_be_the_same_err_msg
        )

        self.assertEqual(
            data_volume_vdis_after_create.snapshot_vdi["uuid"],
            data_volume_vdis_after_revert.snapshot_vdi["uuid"],
            TestVMSnapshots._snapshot_vdis_should_be_the_same_err_msg
        )

        self.assertEqual(
            data_volume_vdis_after_create.base_vdi["uuid"],
            data_volume_vdis_after_revert.base_vdi["uuid"],
            TestVMSnapshots._base_vdis_should_be_the_same_err_msg
        )

        #######################################
        #######################################
        ##### STEP 3: Delete VM snapshot  #####
        #######################################
        #######################################
        VmSnapshot.deleteVMSnapshot(self.apiClient, vmsnapshotid=vm_snapshot.id)

        list_vm_snapshots = VmSnapshot.list(self.apiClient, listAll="true")

        self.assertEqual(
            list_vm_snapshots,
            None,
            TestVMSnapshots._should_be_no_vm_snapshots_err_msg
        )

        root_volume_path_4 = self._get_path(root_volume_id)

        self.assertEqual(
            root_volume_path_3,
            root_volume_path_4,
            TestVMSnapshots._path_should_not_have_changed_err_msg
        )

        root_volume_xen_vdis = self.xen_session.xenapi.SR.get_VDIs(root_volume_xen_sr)

        self._check_list(root_volume_xen_vdis, 1, TestVMSnapshots._should_only_be_one_vdi_err_msg)

        root_volume_vdis_after_delete = self._get_vdis(root_volume_xen_vdis, True)

        self.assertEqual(
            root_volume_vdis_after_revert.active_vdi["uuid"],
            root_volume_vdis_after_delete.active_vdi["uuid"],
            TestVMSnapshots._active_vdis_should_be_the_same_err_msg
        )

        data_volume_path_4 = self._get_path(data_volume_id)

        self.assertEqual(
            data_volume_path_3,
            data_volume_path_4,
            TestVMSnapshots._path_should_not_have_changed_err_msg
        )

        data_volume_xen_vdis = self.xen_session.xenapi.SR.get_VDIs(data_volume_xen_sr)

        self._check_list(data_volume_xen_vdis, 1, TestVMSnapshots._should_only_be_one_vdi_err_msg)

        data_volume_vdis_after_delete = self._get_vdis(data_volume_xen_vdis, True)

        self.assertEqual(
            data_volume_vdis_after_revert.active_vdi["uuid"],
            data_volume_vdis_after_delete.active_vdi["uuid"],
            TestVMSnapshots._active_vdis_should_be_the_same_err_msg
        )

        #######################################
        #######################################
        #####      STEP 4: Start VM       #####
        #######################################
        #######################################
        self.virtual_machine.detach_volume(self.apiClient, data_volume)

        self.virtual_machine.start(self.apiClient)
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:104,代码来源:TestVMSnapshots.py

示例3: test_01_take_VM_snapshot

# 需要导入模块: from marvin.lib.base import VmSnapshot [as 别名]
# 或者: from marvin.lib.base.VmSnapshot import deleteVMSnapshot [as 别名]

#.........这里部分代码省略.........
        xen_vdis = self.xen_session.xenapi.SR.get_VDIs(xen_sr)

        self._check_list(xen_vdis, 3, TestVMSnapshots._should_be_three_vdis_err_msg)

        vdis_after_create = self._get_vdis(xen_vdis)

        vdiSnapshotOf = self.xen_session.xenapi.VDI.get_record(vdis_after_create.snapshot_vdi["snapshot_of"])

        self.assertEqual(
            vdiSnapshotOf["uuid"],
            vdis_after_create.active_vdi["uuid"],
            TestVMSnapshots._snapshot_parent_not_correct_err_msg
        )

        #######################################
        #######################################
        ###  STEP 2: Revert VM to Snapshot  ###
        #######################################
        #######################################
        self.virtual_machine.stop(self.apiClient)

        VmSnapshot.revertToSnapshot(self.apiClient, vmsnapshotid=vm_snapshot.id)

        list_vm_snapshots = VmSnapshot.list(self.apiClient, listAll="true")

        self._check_list(list_vm_snapshots, 1, TestVMSnapshots._should_only_be_one_vm_snapshot_err_msg)

        root_volume_path_3 = self._get_path(volume_id)

        self.assertNotEqual(
            root_volume_path_1,
            root_volume_path_3,
            TestVMSnapshots._path_should_have_changed_err_msg
        )

        xen_vdis = self.xen_session.xenapi.SR.get_VDIs(xen_sr)

        self._check_list(xen_vdis, 3, TestVMSnapshots._should_be_three_vdis_err_msg)

        vdis_after_revert = self._get_vdis(xen_vdis)

        self.assertNotEqual(
            vdis_after_create.active_vdi["uuid"],
            vdis_after_revert.active_vdi["uuid"],
            TestVMSnapshots._active_vdis_should_not_be_the_same_err_msg
        )

        self.assertEqual(
            vdis_after_create.snapshot_vdi["uuid"],
            vdis_after_revert.snapshot_vdi["uuid"],
            TestVMSnapshots._snapshot_vdis_should_be_the_same_err_msg
        )

        self.assertEqual(
            vdis_after_create.base_vdi["uuid"],
            vdis_after_revert.base_vdi["uuid"],
            TestVMSnapshots._base_vdis_should_be_the_same_err_msg
        )

        #######################################
        #######################################
        ##### STEP 3: Delete VM snapshot  #####
        #######################################
        #######################################
        VmSnapshot.deleteVMSnapshot(self.apiClient, vmsnapshotid=vm_snapshot.id)

        list_vm_snapshots = VmSnapshot.list(self.apiClient, listAll="true")

        self.assertEqual(
            list_vm_snapshots,
            None,
            TestVMSnapshots._should_be_no_vm_snapshots_err_msg
        )

        root_volume_path_4 = self._get_path(volume_id)

        self.assertEqual(
            root_volume_path_3,
            root_volume_path_4,
            TestVMSnapshots._path_should_not_have_changed_err_msg
        )

        xen_vdis = self.xen_session.xenapi.SR.get_VDIs(xen_sr)

        self._check_list(xen_vdis, 1, TestVMSnapshots._should_only_be_one_vdi_err_msg)

        vdis_after_delete = self._get_vdis(xen_vdis, True)

        self.assertEqual(
            vdis_after_revert.active_vdi["uuid"],
            vdis_after_delete.active_vdi["uuid"],
            TestVMSnapshots._active_vdis_should_be_the_same_err_msg
        )

        #######################################
        #######################################
        #####      STEP 4: Start VM       #####
        #######################################
        #######################################
        self.virtual_machine.start(self.apiClient)
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:104,代码来源:TestVMSnapshots.py

示例4: test_03_list_vm_snapshots_pagination

# 需要导入模块: from marvin.lib.base import VmSnapshot [as 别名]
# 或者: from marvin.lib.base.VmSnapshot import deleteVMSnapshot [as 别名]
    def test_03_list_vm_snapshots_pagination(self):
        """
        @Desc: Test to List VM Snapshots pagination
        @Steps:
        Step1: Listing all the VM snapshots for a user
        Step2: Verifying that list size is 0
        Step3: Creating (page size + 1) number of VM snapshots
        Step4: Listing all the VM snapshots again for a user
        Step5: Verifying that list size is (page size + 1)
        Step6: Listing all the VM snapshots in page1
        Step7: Verifying that list size is (page size)
        Step8: Listing all the VM snapshots in page2
        Step9: Verifying that list size is 1
        Step10: Deleting the VM 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 ['kvm', 'hyperv']:
            raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
        # Listing all the VM snapshots for a User
        list_vm_snaps_before = VmSnapshot.list(
                                               self.userapiclient,
                                               listall=self.services["listall"]
                                               )
        # Verifying list size is 0
        self.assertIsNone(
                          list_vm_snaps_before,
                          "VM snapshots exists for newly created user"
                          )
        # Creating pagesize + 1 number of VM snapshots
        for i in range(0, (self.services["pagesize"] + 1)):
            snapshot_created = VmSnapshot.create(
                                                 self.userapiclient,
                                                 self.virtual_machine.id,
                                                 )
            self.assertIsNotNone(
                                 snapshot_created,
                                 "Snapshot creation failed"
                                 )

        # Listing all the VM snapshots for user again
        list_vm_snaps_after = VmSnapshot.list(
                                              self.userapiclient,
                                              listall=self.services["listall"]
                                              )
        status = validateList(list_vm_snaps_after)
        self.assertEquals(
                          PASS,
                          status[0],
                          "VM snapshot creation failed"
                          )
        # Verifying that list size is pagesize + 1
        self.assertEquals(
                          self.services["pagesize"] + 1,
                          len(list_vm_snaps_after),
                          "Failed to create pagesize + 1 number of VM snapshots"
                          )
        # Listing all the VM snapshots in page 1
        list_vm_snaps_page1 = VmSnapshot.list(
                                              self.userapiclient,
                                              listall=self.services["listall"],
                                              page=1,
                                              pagesize=self.services["pagesize"]
                                              )
        status = validateList(list_vm_snaps_page1)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Failed to list vm snapshots in page 1"
                          )
        # Verifying the list size to be equal to pagesize
        self.assertEquals(
                          self.services["pagesize"],
                          len(list_vm_snaps_page1),
                          "Size of vm snapshots in page 1 is not matching"
                          )
        # Listing all the vm snapshots in page 2
        list_vm_snaps_page2 = VmSnapshot.list(
                                              self.userapiclient,
                                              listall=self.services["listall"],
                                              page=2,
                                              pagesize=self.services["pagesize"]
                                              )
        status = validateList(list_vm_snaps_page2)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Failed to list vm snapshots in page 2"
                          )
        # Verifying the list size to be equal to pagesize
        self.assertEquals(
                          1,
                          len(list_vm_snaps_page2),
                          "Size of vm snapshots in page 2 is not matching"
                          )
        # Deleting the vm snapshot present in page 2
        VmSnapshot.deleteVMSnapshot(
                                    self.userapiclient,
                                    snapshot_created.id
                                    )
#.........这里部分代码省略.........
开发者ID:Skotha,项目名称:cloudstack,代码行数:103,代码来源:test_escalations_snapshots.py


注:本文中的marvin.lib.base.VmSnapshot.deleteVMSnapshot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。