Пример #1
0
def serverInit():
    """"""
    # get cwd
    mod_vm.mod_info["path"] = os.getcwd()
    context = daemon.DaemonContext()
    with context:
        if os.path.exists("/var/run/rendervmd.pid"):
            try:
                pf = open("/var/run/rendervmd.pid", "r")
                pid = int(pf.read().strip())
                pf.close()
                if pid != None:
                    os.kill(pid, SIGTERM)
                    os.remove("/var/run/rendervmd.pid")
            except Exception:
                sys.stderr.write("error in vm daemon!")
        else:
            pf = open("/var/run/rendervmd.pid", "w+")
            pid = int(os.getpid())
            pf.write(str(pid))
            pf.close()
            # start Http Service
            mod_vm.mod_init()
            addr = ("localhost", 8001)
            server = HTTPServer(addr, RESTHandler)
            print "server is running..."
            server.serve_forever()
            context.__exit__()
            exit(0)
Пример #2
0
import os,sys
import libvirt
import mod_vm
import mod_config

mod_vm.mod_init()
conn=libvirt.open("qemu:///system")
vmconfig=mod_config.setName(mod_vm.config["Windows2k8"],"testname hello")
print vmconfig
dom=conn.createLinux(vmconfig,0)