Commit 51631df2 authored by Rene Hadler's avatar Rene Hadler

pve6-installer: Add support for LXC container import

parent 6e5f618a
......@@ -14,7 +14,7 @@ import subprocess
import requests
# Globale Variablen
VERSION = "0.9.5"
VERSION = "1.0.0"
TITLE = "iteas Proxmox Installer " + VERSION
CHECK_INTERNET_IP = "77.235.68.39"
VM_TEMPLATE_CIFS_SHARE = "//srv-backup01.iteas.at/archiv-replica"
......@@ -209,6 +209,7 @@ class Installer():
self.mgmt_ip = ""
self.backuppc = False
self.vm_import = []
self.lxc_import = []
self.share_clients = []
self.proxy = True
self.desktop = "kein"
......@@ -241,6 +242,10 @@ class Installer():
"129": {"name": "Ubuntu Server Standard", "template": True},
"101": {"name": "Ubuntu Server StyrionLDAP", "template": True}
}
self.LXC_IMPORTS = {
"500": {"name": "Samba Backupassist mit ADS Anbindung", "template": True, "search": "samba-backupassist_mit_ADS-Anbindung"},
"501": {"name": "Samba Backupassist ohne ADS Anbindung", "template": True, "search": "samba-backupassist_ohne_ADS-Anbindung"},
}
self.PUPPETS = {
"kein": "Nein",
"generic": "Generische Installation",
......@@ -268,6 +273,7 @@ class Installer():
"Proxmox-Umgebung", self.ENVIRONMENTS[self.environment],
"Proxmox-Lizenz", "Keine" if self.license == "" else self.license,
"VM-Template-Import", ",".join([self.VM_IMPORTS[x]["name"] for x in self.vm_import]) if len(self.vm_import) > 0 else "Keine",
"LXC-Template-Import", ",".join([self.LXC_IMPORTS[x]["name"] for x in self.lxc_import]) if len(self.lxc_import) > 0 else "Keine",
"Freigabe-Clients", ",".join([x for x in self.share_clients]) if len(self.share_clients) > 0 else "Alle",
"Mgmt-IP", "Keine" if self.mgmt_ip == "" else self.mgmt_ip,
"apt-Proxy", "Nein" if self.proxy == False else "Ja",
......@@ -312,6 +318,9 @@ class Installer():
elif step1_val[1] == "VM-Template-Import":
self.step1_vmtemplateimport()
elif step1_val[1] == "LXC-Template-Import":
self.step1_lxctemplateimport()
elif step1_val[1] == "Internet":
check_internet()
self.step1()
......@@ -463,6 +472,23 @@ class Installer():
self.step1()
def step1_lxctemplateimport(self):
list = []
for key, val in self.LXC_IMPORTS.items():
list += [key, val["name"], "ON" if key in self.lxc_import else "OFF"]
retval = gui_checklist_box("Schritt 1: LXC-Template-Import", "Waehlen sie die LXC Container die importiert werden sollen", list)
# Abbrechen
if retval[0] == 1 or retval[0] == 255:
self.step1()
return
self.lxc_import = []
for val in retval[1]:
self.lxc_import += [val]
self.step1()
def step1_shareclients(self):
retval = gui_input_box("Schritt 1: Freigabe-Clients", "Geben Sie die Clients/Netze an, die Zugriffe auf die Freigaben am Proxmox Host haben sollen. Mehrere Eintraege muessen durch Leerzeichen getrennt sein.", " ".join(self.share_clients))
# Abbrechen
......@@ -573,6 +599,7 @@ class Installer():
cifscnt += 1
if cifstest == 0:
# Import selected VMs
for vm_id in self.vm_import:
(ret, filename) = run_cmd_stdout("ls -t /mnt/dump/vzdump-qemu-%s*vma* | head -n1" % vm_id, argShell=True)
if filename != "":
......@@ -580,6 +607,14 @@ class Installer():
if self.VM_IMPORTS[vm_id]["template"] == True:
run_cmd("qm template %s" % vm_id)
# Import selected LXCs
for vm_id in self.lxc_import:
(ret, filename) = run_cmd_stdout("ls -t /mnt/template/cache/%s* | head -n1" % self.LXC_IMPORTS[vm_id]["search"], argShell=True)
if filename != "":
run_cmd("pct restore %s %s --storage %s" % (vm_id, filename.strip(), storage))
if self.VM_IMPORTS[vm_id]["template"] == True:
run_cmd("qm template %s" % vm_id)
run_cmd('umount /mnt')
else:
gui_message_box("Installer", "CIFS konnte nicht gemounted werden (Passwort falsch?), VMs werden nicht importiert!")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment