本文整理汇总了Python中maglica.virt.Virt.get_active_domain方法的典型用法代码示例。如果您正苦于以下问题:Python Virt.get_active_domain方法的具体用法?Python Virt.get_active_domain怎么用?Python Virt.get_active_domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maglica.virt.Virt
的用法示例。
在下文中一共展示了Virt.get_active_domain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove
# 需要导入模块: from maglica.virt import Virt [as 别名]
# 或者: from maglica.virt.Virt import get_active_domain [as 别名]
def remove(args):
options = {
"mandatory": ["name"],
"optional" : ["on"],
}
check_args(args, options)
name = args["name"]
virt = Virt(hosts())
dom = virt.get_inactive_domain(name)
if not dom:
(dom, host) = virt.get_active_domain(name)
if dom:
raise Exception("Active domain cannot be removed.Please stop it.")
else:
raise Exception("Domain not found.")
host = dom["host"]
if args.has_key("on"):
host = args["on"]
maglica.dispatcher.dispatch({
"type" : "vm",
"host" : host,
"action" : "remove",
"args" : args,
})
示例2: attach_disk
# 需要导入模块: from maglica.virt import Virt [as 别名]
# 或者: from maglica.virt.Virt import get_active_domain [as 别名]
def attach_disk(args):
options = {
"mandatory": ["name", "size"],
"optional" : [],
}
check_args(args, options)
size = args["size"]
if re.match(r'.+G$', size):
args["size"] = int(args["size"][:-1])
args["size"] = args["size"] * 1024 * 1024
elif re.match(r'.+M$', size):
args["size"] = int(args["size"][:-1])
args["size"] = args["size"] * 1024
elif re.match(r'.+K$', size):
args["size"] = int(args["size"][:-1])
if args["size"] > 100 * 1024 * 1024:
raise Exception("Size is too large.")
name = args["name"]
virt = Virt(hosts())
(dom, host) = virt.get_active_domain(name)
maglica.dispatcher.dispatch({
"type" : "vm",
"host" : host,
"action" : "attach_disk",
"args" : args,
})
示例3: test_get_active_domain
# 需要导入模块: from maglica.virt import Virt [as 别名]
# 或者: from maglica.virt.Virt import get_active_domain [as 别名]
def test_get_active_domain():
virt = Virt()
(dom, host) = virt.get_active_domain("test")
eq_(host, "test")
eq_(dom.name(), "test")
ok_(dom.isActive())