Python help
-
All I want to do is be able to send force shut offs
Am i able to get help here?
def force_shutdown_vm(vm_uuid): XO_URL = "https://192.168.100.30:2223/" username = "ThePlague" password = "NO" context = ssl._create_unverified_context() try: session = XenAPI.Session(XO_URL,ignore_ssl=True) session.set_ssl_context(context) session.xenapi.login_with_password(username,password) vm_ref = session.xenapi.VM.get_by_uuid(vm_uuid) session.xenapi.VM.Clean_shutdown(vm_ref) print("The VM Shutdown Successfully.") except Exception as e: print(f"Error: {e}") finally: session.xenapi.session.logout()
what am i doing wrong ahhahahahaha
-
Hi,
You are using the XAPI Python SDK, meant to be used against a host, not XO.
Two choices: keep using that but point it to the pool master directly OR use XO API instead (eg the REST API). I would advise for the option 2.
-
@olivierlambert How would I do that with the rest api?
-
Well, you gave such little details that I have no idea about how to answer your question.
If it's just sending a command to force shutdown a VM, you can just do this with the appropriate action in the REST API. See https://docs.xen-orchestra.com/restapi for more details