prepare vm.py for dominique

This commit is contained in:
Nico Schottelius 2020-01-23 21:20:16 +01:00
parent 550937630c
commit b5409552d8

View file

@ -32,7 +32,7 @@ class VM(object):
self.config = config
self.db = DB(config, prefix="/vm")
#TODO: Select generic
#TODO: Select generic
self.hackprefix="/home/nico/vcs/uncloud/uncloud/hack/hackcloud" #TODO: Should be removed midterm
self.qemu="/usr/bin/qemu-system-x86_64" #TODO: should be in config
self.accel="kvm" #TODO: should be config
@ -60,7 +60,9 @@ class VM(object):
self.vm['cores'] = 2
self.vm['os_image'] = os.path.join(self.hackprefix, "alpine-virt-3.11.2-x86_64.iso")
self.mac=MAC(self.config).get_next()
self.mac=MAC(self.config)
self.mac.create()
self.vm['ifname'] = "uc{}".format(self.mac.to_str_format())
self.vm['commandline' ] = [ "sudo",
"{}".format(self.qemu),
@ -74,6 +76,8 @@ class VM(object):
"-device", "virtio-net-pci,netdev=netmain,id=net0,mac={}".format(self.mac)
]
# TODO: Add ip link command afterwards (rouxdo)
self.db.set(str(self.vm['uuid']),
self.vm,
as_json=True)