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


Python VirtualMachine.stop方法代码示例

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


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

示例1: test_02_template_permissions

# 需要导入模块: from marvin.lib.base import VirtualMachine [as 别名]
# 或者: from marvin.lib.base.VirtualMachine import stop [as 别名]
    def test_02_template_permissions(self):
        """
        @Desc: Test to create Public Template by registering or by snapshot and volume when
        Global parameter 'allow.public.user.template' is set to  False
        @steps:
        1.Set Global parameter 'allow.public.user.template' as False. Restart Management server
        2. Create a domain
        3. Create a domain admin and a domain user
        4. Create a vm as domain user
        5. take snapshot of root disk as user vm
        6. try to create public template from snapshot . It should fail
        7. stop the VM
        8. take the public template from volume. it should fail
        9. register a public template as a domain user . it should fail
        10. create a VM  as domain admin
        11. create a snapshot of root disk as domain admin
        12 create a public template of the snapshot .it should fail
        13. Register a public template as domain admin. it should fail
        14 Stop the vm as domain admin
        15. Create a template from volume as domain admin . it should fail

        """
        self.updateConfigurAndRestart("allow.public.user.templates", "false")
        
        user_account = Account.create(
            self.apiclient,
            self.testdata["account2"],
            admin=False,
            domainid=self.domain.id
        )
        admin_user = self.account.user[0]
        self.admin_api_client = self.testClient.getUserApiClient(
            admin_user.username,
            self.domain.name)
        user = user_account.user[0]
        self.user_api_client = self.testClient.getUserApiClient(
            user.username,
            self.domain.name)

        self.testdata["templates"]["ispublic"] = True
        # Register new public template as domain user
        # Exception should be raised for registering public template
        try:
            template = Template.register(
                self.user_api_client,
                self.testdata["templates"],
                zoneid=self.zone.id,
                account=user_account.name,
                domainid=user_account.domainid,
                hypervisor=self.hypervisor
            )
            self.updateConfigurAndRestart("allow.public.user.templates", "true")
            self.fail("Template creation passed for user")
        except CloudstackAPIException  as e:
            self.assertRaises("Exception Raised : %s" % e)
        # Register new public template as domain admin
        # Exception should be raised for registering public template
        try:
            template = Template.register(
                self.admin_api_client,
                self.testdata["templates"],
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.account.domainid,
                hypervisor=self.hypervisor
            )
            self.updateConfigurAndRestart("allow.public.user.templates", "true")
            self.fail("Template creation passed for domain admin")
        except CloudstackAPIException  as e:
            self.assertRaises("Exception Raised : %s" % e)

        user_vm_created = VirtualMachine.create(
            self.user_api_client,
            self.testdata["virtual_machine"],
            accountid=user_account.name,
            domainid=user_account.domainid,
            serviceofferingid=self.service_offering.id,
        )
        self.assertIsNotNone(user_vm_created,
                             "VM creation failed"
        )
        # Get the Root disk of VM
        volume = list_volumes(
            self.user_api_client,
            virtualmachineid=user_vm_created.id,
            type='ROOT',
            listall=True
        )
        snapshot_created = Snapshot.create(
            self.user_api_client,
            volume[0].id,
            account=user_account.name,
            domainid=user_account.domainid
        )
        self.assertIsNotNone(
            snapshot_created,
            "Snapshot creation failed"
        )
        self.debug("Creating a template from snapshot: %s" % snapshot_created.id)
        #
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:103,代码来源:test_escalation_templates.py


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