Esempio n. 1
0
async def vm_set_memory(cluster_id: str, vm_uuid: str, args: MemoryArgs):
    """ Set VM Memory (needs troubleshooting) """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.set_memory(args.memory)}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 2
0
async def vm_power_suspend(cluster_id: str, vm_uuid: str):
    """ Suspend the VM """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.suspend()}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 3
0
async def vm_set_vCPU_inurl(cluster_id: str, vm_uuid: str, vCPU_count: int):
    """ Set VM vCPU count """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.set_vCPUs(vCPU_count)}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 4
0
async def instance_set_description_inurl(cluster_id: str, vm_uuid: str, new_description: str):
    """ Set Instance (VM/Template) Description """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.set_description(new_description)}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 5
0
async def instance_set_name(cluster_id: str, vm_uuid: str, args: NameArgs):
    """ Set Instance (VM/Template) Name """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.set_name(args.name)}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 6
0
async def vm_delete(cluster_id: str, vm_uuid: str):
    """ Delete VM """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.delete()}
    else:
        ret = {"success": False}

    XenVm.remove_orphaned(cluster_id)

    session.xenapi.session.logout()
    return ret
Esempio n. 7
0
async def vm_power_restart(cluster_id: str, vm_uuid: str):
    """ Restart VM, can return false if the system does not support ACPI shutdown.
        System powerstate must be checked beforehand """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        ret = {"success": _vm.reboot()}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 8
0
async def vm_start(cluster_id: str, vm_uuid: str):
    """ Start the VM
        System powerstate must be checked beforehand """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if XenVm is not None:
        ret = {"success": _vm.start()}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, _vm)

    session.xenapi.session.logout()
    return ret
Esempio n. 9
0
async def instance_clone_inurl(cluster_id: str, vm_uuid: str, clone_name: str):
    """ Clone Instance (VM/Template) """
    session = create_session(cluster_id)
    _vm: VM = VM.get_by_uuid(session, vm_uuid)
    if _vm is not None:
        newVM = _vm.clone(clone_name)
        if newVM is not None:
            ret = {"success": True, "data": newVM.serialize()}
        else:
            ret = {"success": False}
    else:
        ret = {"success": False}

    XenVm.update(cluster_id, newVM)

    session.xenapi.session.logout()
    return ret