Exemplo n.º 1
0
def get_vm_state(dom):
    prc = ConfigParser.RawConfigParser()
    prc.read('defConfig.ini')
    states = dict(prc.items('STATESMAP'))
    name = dom.name()
    key_state = str(queries.get_vm_state(name))
    state = states[key_state]
    return "VM %s state: %s".format(name, state)
Exemplo n.º 2
0
def get_vm_state(dom):
    prc = ConfigParser.RawConfigParser()
    prc.read('defConfig.ini')
    states = dict(prc.items('STATESMAP'))
    name = dom.name()
    key_state = str(queries.get_vm_state(name))
    state =  states[key_state]
    return "VM %s state: %s".format(name, state)
Exemplo n.º 3
0
def delete(dom):
    """Delete given libvirt domain"""
    name = dom.name()
    if queries.get_vm_state(name) == 1:
        dom.destroy()
    dom.undefine()
    queries.delete_vm(name)
    res = 'VM {} was destroyed'.format(name)
    return res
Exemplo n.º 4
0
def delete(dom):
    """Delete given libvirt domain"""
    name = dom.name()
    if queries.get_vm_state(name) == 1:
        dom.destroy()
    dom.undefine()
    queries.delete_vm(name)
    res = 'VM {} was destroyed'.format(name)
    return res
Exemplo n.º 5
0
def reboot(dom):
    """Reboot given libvirt domain"""
    name = dom.name()
    if queries.get_vm_state(name) == 1:
        dom.reboot(0)
    else:
        logger = logging.getLogger('manageVM.processing')
        logger.warning('Attempt to reboot unactive domain')
    res = 'VM {} rebooted'.format(name)
    return res
Exemplo n.º 6
0
def reboot(dom):
    """Reboot given libvirt domain"""
    name = dom.name()
    if queries.get_vm_state(name) == 1:
        dom.reboot(0)        
    else:
        logger = logging.getLogger('manageVM.processing')
        logger.warning('Attempt to reboot unactive domain')
    res = 'VM {} rebooted'.format(name)
    return res
Exemplo n.º 7
0
def get_vm_state(name, **kwargs):
    """Load from DB code of state of VM and return state"""
    dom = defineDomain(name)
    prc = ConfigParser.RawConfigParser()
    prc.read('defConfig.ini')
    states = dict(prc.items('STATESMAP'))
    name = dom.name()
    key_state = str(queries.get_vm_state(name))
    state = states[key_state]
    return "VM %s state: %s".format(name, state)
Exemplo n.º 8
0
def get_vm_state(name, **kwargs):
    """Load from DB code of state of VM and return state"""
    dom = defineDomain(name)
    prc = ConfigParser.RawConfigParser()
    prc.read('defConfig.ini')
    states = dict(prc.items('STATESMAP'))
    name = dom.name()
    key_state = str(queries.get_vm_state(name))
    state = states[key_state]
    return "VM %s state: %s".format(name, state)
Exemplo n.º 9
0
def powerOff(dom):
    """PowerOff given libvirt domain"""
    name = dom.name()
    if queries.get_vm_state(name) == 1:
        dom.destroy()
        queries.update_vm_state(name, 5)
    else:
        logger = logging.getLogger('manageVM.processing')
        logger.warning('Attempt to power off unactive domain')
    res = 'VM {} powered off'.format(name)
    return res
Exemplo n.º 10
0
def powerOff(dom):
    """PowerOff given libvirt domain"""
    name = dom.name()
    if queries.get_vm_state(name) == 1:
        dom.destroy()
        queries.update_vm_state(name, 5)       
    else:
        logger = logging.getLogger('manageVM.processing')
        logger.warning('Attempt to power off unactive domain')    
    res = 'VM {} powered off'.format(name)
    return res
Exemplo n.º 11
0
def powerOff(name, **kwargs):
    """PowerOff given libvirt domain"""
    dom = defineDomain(name)
    if queries.get_vm_state(name) == 1:
        dom.destroy()
        queries.update_vm_state(name, 5)
    else:
        logger = logging.getLogger('manageVM.compute')
        logger.warning('Attempt to power off unactive domain')
    res = 'VM {} powered off'.format(name)
    return res
Exemplo n.º 12
0
def powerOff(name, **kwargs):
    """PowerOff given libvirt domain"""
    dom = defineDomain(name)
    if queries.get_vm_state(name) == 1:
        dom.destroy()
        queries.update_vm_state(name, 5)       
    else:
        logger = logging.getLogger('manageVM.compute')
        logger.warning('Attempt to power off unactive domain')
    res = 'VM {} powered off'.format(name)
    return res
Exemplo n.º 13
0
def delete(name, **kwargs):
    """Delete given libvirt domain"""
    dom = defineDomain(name)
    if queries.get_vm_state(name) == 1:
        dom.destroy()
    mac = getMAC(name)
    queries.unAssignIP(mac)
    queries.delete_vm(name)
    manageBridges.delConfHost(mac)  # send
    res = 'VM {} was destroyed'.format(name)
    dom.undefine()
    return res
Exemplo n.º 14
0
def delete(name, **kwargs):
    """Delete given libvirt domain"""
    dom = defineDomain(name)
    if queries.get_vm_state(name) == 1:
        dom.destroy()
    mac = getMAC(name)
    queries.unAssignIP(mac)
    queries.delete_vm(name)
    manageBridges.delConfHost(mac)      # send
    res = 'VM {} was destroyed'.format(name)
    dom.undefine()
    return res