Esempio n. 1
0
File: vm.py Progetto: mattmb/spoke
def power_modify(vm_name, state):
    from spoke.lib.vm_power import SpokeVMPowerXen
    vmp = SpokeVMPowerXen(hv_uri, vm_name)
    try:
        result = vmp.modify(state)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result    
Esempio n. 2
0
def power_modify(vm_name, state):
    try:
        conf = _spoke_config(_salt_config('config'))
        hv_uri = conf.get('VM', 'hv_uri')
        vmp = SpokeVMPowerXen(hv_uri, vm_name)
        result = vmp.modify(state)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Esempio n. 3
0
    if request['action'] == 'search':
        try:
            mc.data = vmp.get()
        except error.SpokeError, e:
            mc.fail(e.msg, e.exit_code)        
    elif request['action'] == 'on':
        try:
            mc.data = vmp.create()
        except error.SpokeError, e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'off':
        try:
            mc.data = vmp.delete()
        except error.SpokeError, e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'forceoff':
        try:
            mc.data = vmp.delete(force=True)
        except error.SpokeError, e:
            mc.fail(e.msg, e.exit_code)
    elif request['action'] == 'reboot':
        try:
            mc.data = vmp.modify(vm_power_state='reboot')
        except error.SpokeError, e:
            mc.fail(e.msg, e.exit_code)
    else:
        msg = "Unknown action: " + request['action']
        mc.fail(msg, 2)
    log.info('Result via Mcollective: %s' % mc.data)
    sys.exit(0)