Added tag to created vm

This commit is contained in:
Gonzalo Martinez 2024-08-27 16:36:30 -03:00
parent db1f56d58c
commit e21df4e0f5

View File

@ -25,12 +25,14 @@ def importTemplate(name, storage, id):
file = f"/tmp/{file}" file = f"/tmp/{file}"
print(f"Importing {file} to {storage} with id {id}") print(f"Importing {file} to {storage} with id {id}")
templateName = os.path.basename(file).split(".")[0] templateName = os.path.basename(file).split(".")[0]
os.popen(f'qm create {id} --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci --name "{templateName}" | cut -d"." -f1').read() os.popen(f'qm create {id} --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci --name "{templateName}" --tag temlate').read()
os.popen(f'qm set {id} --scsi0 {storage}:0,import-from={file}').read() os.popen(f'qm set {id} --scsi0 {storage}:0,import-from={file}').read()
os.popen(f'qm set {id} --ide2 {storage}:cloudinit').read() os.popen(f'qm set {id} --ide2 {storage}:cloudinit').read()
os.popen(f'qm set {id} --boot order=scsi0').read() os.popen(f'qm set {id} --boot order=scsi0').read()
os.popen(f'qm set {id} --serial0 socket --vga serial0').read() os.popen(f'qm set {id} --serial0 socket --vga serial0').read()
os.popen(f'qm template {id}').read() os.popen(f'qm template {id}').read()
# add a tag to the vm
def generateMenuOptions(): def generateMenuOptions():
ImagesList = getImagesList() ImagesList = getImagesList()