• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python base.Snapshot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createSnapshot

 def createSnapshot(self, volumeid):
     try:
         Snapshot.create(
             self.apiclient,
             volumeid
         )
     except Exception as e:
         self.debug("Exception occured: %s" % e)
         self.exceptionOccured = True
开发者ID:ZhangQingcheng,项目名称:cloudstack,代码行数:9,代码来源:test_concurrent_snapshots_limit.py


示例2: test_validateState_fails_after_retry_limit

    def test_validateState_fails_after_retry_limit(self):
        retries = 3
        timeout = 2
        api_client = MockApiClient(retries, 'initial state', 'final state')
        snapshot = Snapshot({'id': 'snapshot_id'})
        state = snapshot.validateState(api_client, 'final state', timeout=timeout, interval=1)

        self.assertEqual(state, [FAIL, 'Snapshot state not transited to final state, operation timed out'])
        self.assertEqual(retries, api_client.retry_counter)
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:9,代码来源:test_base.py


示例3: test_validateState_succeeds_at_retry_limit

    def test_validateState_succeeds_at_retry_limit(self):
        retries = 3
        timeout = 3
        api_client = MockApiClient(retries, 'initial state', 'final state')
        snapshot = Snapshot({'id': 'snapshot_id'})
        state = snapshot.validateState(api_client, 'final state', timeout=timeout, interval=1)

        self.assertEqual(state, [PASS, None])
        self.assertEqual(retries, api_client.retry_counter)
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:9,代码来源:test_base.py


示例4: test_01_check_revert_snapshot

    def test_01_check_revert_snapshot(self):
        """ Test revert snapshot on XenServer

        # 1. Deploy a VM.
        # 2. Take VM snapshot.
        # 3. Verify that volume snapshot fails with error 
                can not create volume snapshot for VM with VM-snapshot

        """
        # Step 1
        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_cluster_list = list_volumes(
                self.apiclient,
                virtualmachineid=vm.id,
                type='ROOT',
                listall=True
                )

        volume_list_validation = validateList(volumes_cluster_list)

	self.assertEqual(
                volume_list_validation[0],
                PASS,
                "Event list validation failed due to %s" %
		volume_list_validation[2]
            )
 
        root_volume = volumes_cluster_list[0]
        
        #Step 2
        vm_snap = VmSnapshot.create(self.apiclient,
                vm.id)

	self.assertEqual(
			vm_snap.state,
			"Ready",
			"Check the snapshot of vm is ready!"
			)


        #Step 3
        with self.assertRaises(Exception):
            Snapshot.create(
                    self.apiclient,
                    root_volume.id)

        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:55,代码来源:testpath_revert_snap.py


示例5: test_05_snapshots_per_project

    def test_05_snapshots_per_project(self):
        """Test Snapshot limit per project
        """
        # Validate the following
        # 1. set max no of snapshots per project to 1.
        # 2. Create one snapshot in the project. Snapshot should be
        #    successfully created
        # 5. Try to create another snapshot in this project. It should give
        #    user an appropriate error and an alert should be generated.

        if self.hypervisor.lower() in ["hyperv"]:
            raise self.skipTest("Snapshots feature is not supported on Hyper-V")
        self.debug("Updating snapshot resource limits for project: %s" % self.project.id)
        # Set usage_vm=1 for Account 1
        update_resource_limit(self.apiclient, 3, max=1, projectid=self.project.id)  # Snapshot

        self.debug("Deploying VM for account: %s" % self.account.name)
        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, virtualmachineid=virtual_machine_1.id, projectid=self.project.id, type="ROOT"
        )
        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_1 = Snapshot.create(self.apiclient, volumes[0].id, projectid=self.project.id)
        self.cleanup.append(snapshot_1)

        # list snapshots
        snapshots = list_snapshots(self.apiclient, projectid=self.project.id)

        self.debug("snapshots list: %s" % snapshots)

        self.assertEqual(validateList(snapshots)[0], PASS, "Snapshots list validation failed")
        self.assertEqual(len(snapshots), 1, "Snapshots list should have exactly one entity")

        # Exception should be raised for second snapshot
        with self.assertRaises(Exception):
            Snapshot.create(self.apiclient, volumes[0].id, projectid=self.project.id)
        return
开发者ID:vaddanak,项目名称:challenges,代码行数:51,代码来源:test_project_limits.py


示例6: createSnapshotFromVirtualMachineVolume

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]
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:14,代码来源:common.py


示例7: test_03_list_snapshots

    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(
开发者ID:Accelerite,项目名称:cloudstack,代码行数:25,代码来源:test_list_ids_parameter.py


示例8: test_01_test_vm_volume_snapshot

    def test_01_test_vm_volume_snapshot(self):
        """
        @Desc: Test that Volume snapshot for root volume is allowed
        when VM snapshot is present for the VM
        @Steps:
        1: Deploy a VM and create a VM snapshot for VM
        2: Try to create snapshot for the root volume of the VM,
        It should not fail
        """

        # Creating Virtual Machine
        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
        )

        VmSnapshot.create(
            self.apiclient,
            virtual_machine.id,
        )

        volumes = Volume.list(self.apiclient,
                              virtualmachineid=virtual_machine.id,
                              type="ROOT",
                              listall=True)

        self.assertEqual(validateList(volumes)[0], PASS,
                "Failed to get root volume of the VM")

        snapshot = Snapshot.create(
            self.apiclient,
            volumes[0].id,
            account=self.account.name,
            domainid=self.account.domainid
        )
        self.debug("Snapshot created: ID - %s" % snapshot.id)
        snapshots = list_snapshots(
            self.apiclient,
            id=snapshot.id
        )
        self.assertEqual(
            validateList(snapshots)[0],
            PASS,
            "Invalid snapshot list"
        )
        self.assertEqual(
            snapshots[0].id,
            snapshot.id,
            "Check resource id in list resources call"
        )
        return
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:54,代码来源:test_vm_snapshots.py


示例9: test_06_create_snapshots_in_project

    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
开发者ID:maksimov,项目名称:cloudstack,代码行数:41,代码来源:test_project_resources.py


示例10: test_02_snapshot_data_disk

    def test_02_snapshot_data_disk(self):
        """Test Snapshot Data Disk
        """
        if self.hypervisor.lower() in ['hyperv']:
            self.skipTest("Snapshots feature is not supported on Hyper-V")

        volume = list_volumes(
            self.apiclient,
            virtualmachineid=self.virtual_machine_with_disk.id,
            type='DATADISK',
            listall=True
        )
        self.assertEqual(
            isinstance(volume, list),
            True,
            "Check list response returns a valid list"
        )

        self.debug("Creating a Snapshot from data volume: %s" % volume[0].id)
        snapshot = Snapshot.create(
            self.apiclient,
            volume[0].id,
            account=self.account.name,
            domainid=self.account.domainid
        )
        snapshots = list_snapshots(
            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 item call"
        )
        self.assertEqual(
            snapshots[0].id,
            snapshot.id,
            "Check resource id in list resources call"
        )
        self.assertTrue(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                snapshot.id))
        return
开发者ID:vaddanak,项目名称:challenges,代码行数:52,代码来源:test_snapshots.py


示例11: test_01_test_vm_volume_snapshot

    def test_01_test_vm_volume_snapshot(self):
        """
        @Desc: Test that Volume snapshot for root volume is not allowed
        when VM snapshot is present for the VM
        @Steps:
        1: Deploy a VM and create a VM snapshot for VM
        2: Try to create snapshot for the root volume of the VM,
        It should expect Exception
        """

        # Creating Virtual Machine
        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
        )

        VmSnapshot.create(
            self.apiclient,
            virtual_machine.id,
        )

        volumes = Volume.list(self.apiclient,
                              virtualmachineid=virtual_machine.id,
                              type="ROOT",
                              listall=True)

        self.assertEqual(validateList(volumes)[0], PASS,
                "Failed to get root volume of the VM")

        volume = volumes[0]

        with self.assertRaises(Exception):
            Snapshot.create(self.apiclient,
                            volume_id=volume.id)

        return
开发者ID:milamberspace,项目名称:cloudstack,代码行数:39,代码来源:test_vm_snapshots.py


示例12: test_04_template_from_snapshot

    def test_04_template_from_snapshot(self):
        """Create Template from snapshot
        """

        # Validate the following
        # 2. Snapshot the Root disk
        # 3. Create Template from snapshot
        # 4. Deploy Virtual machine using this template
        # 5. VM should be in running state

        userapiclient = self.testClient.getUserApiClient(UserName=self.account.name, DomainName=self.account.domain)

        volumes = Volume.list(userapiclient, virtualmachineid=self.virtual_machine.id, type="ROOT", listall=True)
        volume = volumes[0]

        self.debug("Creating a snapshot from volume: %s" % volume.id)
        # Create a snapshot of volume
        snapshot = Snapshot.create(userapiclient, volume.id, account=self.account.name, domainid=self.account.domainid)
        self.debug("Creating a template from snapshot: %s" % snapshot.id)
        # Generate template from the snapshot
        template = Template.create_from_snapshot(userapiclient, snapshot, self.services["template"])
        self.cleanup.append(template)
        # Verify created template
        templates = Template.list(
            userapiclient, templatefilter=self.services["template"]["templatefilter"], id=template.id
        )
        self.assertNotEqual(templates, None, "Check if result exists in list item call")

        self.assertEqual(templates[0].id, template.id, "Check new template id in list resources call")
        self.debug("Deploying a VM from template: %s" % template.id)
        # Deploy new virtual machine using template
        virtual_machine = VirtualMachine.create(
            userapiclient,
            self.services["virtual_machine"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
        )
        self.cleanup.append(virtual_machine)

        vm_response = VirtualMachine.list(
            userapiclient, id=virtual_machine.id, account=self.account.name, domainid=self.account.domainid
        )
        self.assertEqual(isinstance(vm_response, list), True, "Check for list VM response return valid list")

        # Verify VM response to check whether VM deployment was successful
        self.assertNotEqual(len(vm_response), 0, "Check VMs available in List VMs response")
        vm = vm_response[0]
        self.assertEqual(vm.state, "Running", "Check the state of VM created from Template")
        return
开发者ID:MissionCriticalCloudOldRepos,项目名称:cosmic-core,代码行数:51,代码来源:test_templates.py


示例13: test_01_snapshot_data_disk

    def test_01_snapshot_data_disk(self):
        """Test Snapshot Data Disk
        """

        volume = list_volumes(
            self.apiclient,
            virtualmachineid=self.virtual_machine_with_disk.id,
            type='DATADISK',
            listall=True
        )
        self.assertEqual(
            isinstance(volume, list),
            True,
            "Check list response returns a valid list"
        )

        self.debug("Creating a Snapshot from data volume: %s" % volume[0].id)
        snapshot = Snapshot.create(
            self.apiclient,
            volume[0].id,
            account=self.account.name,
            domainid=self.account.domainid,
            asyncbackup=True
        )
        snapshots = list_snapshots(
            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 item call"
        )
        self.assertEqual(
            snapshots[0].id,
            snapshot.id,
            "Check resource id in list resources call"
        )
        self.assertEqual(
            snapshot.state,
            "BackingUp",
            "Check resource state in list resources call"
        )
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:49,代码来源:test_separate_backup_from_snapshot.py


示例14: CreateSnapshot

def CreateSnapshot(self, root_volume, is_recurring):
    """Create Snapshot"""
    if is_recurring:
        self.testdata["recurring_snapshot"]["intervaltype"] = 'HOURLY'
        self.testdata["recurring_snapshot"]["schedule"] = 1

        recurring_snapshot = SnapshotPolicy.create(
            self.apiclient,
            root_volume.id,
            self.testdata["recurring_snapshot"]
        )
        self.rec_policy_pool.append(recurring_snapshot)
    else:
        root_vol_snapshot = Snapshot.create(
            self.apiclient,
            root_volume.id)

        self.snapshot_pool.append(root_vol_snapshot)

    return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:20,代码来源:testpath_volume_cuncurrent_snapshots.py


示例15: create_vm

 def create_vm(self,
               account,
               domain,
               isRunning=False,
               project  =None,
               limit    =None,
               pfrule   =False,
               lbrule   =None,
               natrule  =None,
               volume   =None,
               snapshot =False):
     #TODO: Implemnt pfrule/lbrule/natrule
     self.debug("Deploying instance in the account: %s" % account.name)
     self.virtual_machine = VirtualMachine.create(self.apiclient,
                                                  self.services["virtual_machine"],
                                                  accountid=account.name,
                                                  domainid=domain.id,
                                                  serviceofferingid=self.service_offering.id,
                                                  mode=self.zone.networktype if pfrule else 'basic',
                                                  projectid=project.id if project else None)
     self.debug("Deployed instance in account: %s" % account.name)
     list_virtual_machines(self.apiclient,
                           id=self.virtual_machine.id)
     if snapshot:
        volumes = list_volumes(self.apiclient,
                               virtualmachineid=self.virtual_machine.id,
                               type='ROOT',
                               listall=True)
        self.snapshot = Snapshot.create(self.apiclient,
                                   volumes[0].id,
                                   account=account.name,
                                   domainid=account.domainid)
     if volume:
         self.virtual_machine.attach_volume(self.apiclient,
                                            volume)
     if not isRunning:
         self.virtual_machine.stop(self.apiclient)
     self.cleanup.append(self.virtual_machine)
开发者ID:PCextreme,项目名称:cloudstack,代码行数:38,代码来源:test_assign_vm.py


示例16: test_04_reoccuring_snapshot_rules

    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,
#.........这里部分代码省略.........
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:101,代码来源:test_base_image_updation.py


示例17: test_01_storage_snapshots_limits

    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,
#.........这里部分代码省略.........
开发者ID:franklouwers,项目名称:cloudstack,代码行数:101,代码来源:testpath_snapshot_limits.py


示例18: test_03_reuse_template_name

    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(
#.........这里部分代码省略.........
开发者ID:MountHuang,项目名称:cloudstack,代码行数:101,代码来源:test_blocker_bugs.py


示例19: test_02_check_size_snapshotTemplate

    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
开发者ID:MountHuang,项目名称:cloudstack,代码行数:78,代码来源:test_blocker_bugs.py


示例20: test_02_list_volume_snapshots_byid


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.StaticNATRule类代码示例发布时间:2022-05-27
下一篇:
Python base.ServiceOffering类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap