本文整理汇总了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)
#
#.........这里部分代码省略.........