O'Reilly logo

KVM Virtualization Cookbook by Konstantin Ivanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

There's more...

The full code implementation follows:

import libvirtfrom bottle import run, request, get, post, HTTPResponsedef libvirtConnect():  try:    conn = libvirt.open('qemu:///system')  except libvirt.libvirtError:    conn = None  return conndef getLibvirtInstances():  conn = libvirtConnect()  if conn == None:    return HTTPResponse(status=500, body='Error listing instances\n')  else:    try:      instances = conn.listDefinedDomains()      return instances    except libvirt.libvirtError:      return HTTPResponse(status=500, body='Error listing instances\n')def defineKVMInstance(template):  conn = libvirtConnect()  if conn == None:    return HTTPResponse(status=500, body='Error defining instance\n')  else:    try:      conn.defineXML(template) return HTTPResponse(status=200, body='Instance ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required