Example #1
0
File: virt.py Project: hfm/maglica
def test_get_domains():
    virt = Virt()
    virt.hosts[0]["conn"].defineXML(xml)
    dom = virt.get_inactive_domain("test2")
    domains = virt.get_domains()
    eq_(domains[0]["name"], "test")
    eq_(domains[1]["name"], "test2")
Example #2
0
File: vm.py Project: hfm/maglica
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,
    })
Example #3
0
File: virt.py Project: hfm/maglica
def test_get_inactive_domain():
    virt = Virt()
    virt.hosts[0]["conn"].defineXML(xml)
    dom = virt.get_inactive_domain("test2")
    eq_(dom["name"], "test2")
    eq_(dom["host"], "test")
    eq_(dom["state"], "shut off")
Example #4
0
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,
    })