diff --git a/SWSCloudNode/qemu/__init__.py b/SWSCloudNode/qemu/__init__.py index 16a9546..a72a19a 100644 --- a/SWSCloudNode/qemu/__init__.py +++ b/SWSCloudNode/qemu/__init__.py @@ -123,7 +123,7 @@ class QEMU: return True - def create(self, cores, memory, storage, hostname, ip, dns1, dns2, password, os_name, os_suite): + def create(self, cores, memory, storage, swap, hostname, ip, dns1, dns2, password, os_name, os_suite): """ функция создания виртуальной машины """ @@ -144,6 +144,14 @@ class QEMU: os.popen("cp /etc/vmbuilder/qemu/* /var/lib/qemu/images/%s/templates/qemu" % hostname) # generate partition file + #Open new data file + f = open("/var/lib/qemu/images/%s/partition" % hostname, "w") + f.write("root %s\n" % storage) + if swap > 0: + f.write("---\n" % swap) + f.write("swap %s\n" % swap) + f.close() + os.popen("cp vm/storage/%s.partition /var/lib/qemu/images/%s/partition" % (storage, hostname), "r") os.popen("cp vm/firstboot.sh /var/lib/qemu/images/%s/boot.sh" % hostname, "r")