Public
Snippet $3 authored by Matthew Monaco

nova-spice

Edited
nova-spice
#!/usr/bin/env python2

from __future__ import print_function

import sys
import os
from   os import environ as env
from   novaclient.v1_1.client import Client as NovaClient
from   novaclient import utils

nova = NovaClient(
    env["OS_USERNAME"],
    env["OS_PASSWORD"],
    env["OS_TENANT_NAME"],
    env["OS_AUTH_URL"],
    service_type="compute")

name    = sys.argv[1]
server  = utils.find_resource(nova.servers, name)
host    = server._info["OS-EXT-SRV-ATTR:hypervisor_hostname"]
uuid    = server.id

cmd = (
    "virt-manager", "-c", "qemu+ssh://root@%s/system"%(host), "--show-domain-console", uuid
)

print(*cmd)
os.execlp(cmd[0], *cmd)