From 0f4faf2e5d6deab14591f89eb899526139f8b4ca Mon Sep 17 00:00:00 2001 From: braniz Date: Thu, 16 Nov 2023 11:13:02 +0100 Subject: [PATCH] =?UTF-8?q?Bridge=20CheckBox=20Erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- create.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/create.py b/create.py index 8fda4c2..d69303c 100644 --- a/create.py +++ b/create.py @@ -14,6 +14,9 @@ class LxcLauncherGUI: self.num_hosts_var = tk.StringVar() self.num_hosts_var.set("1") # Standardwert auf 1 setzen + # Neue Variable für bridgeprofil Checkbox + self.bridgeprofile_checkbox_var = tk.BooleanVar() + self.create_widgets() def create_widgets(self): @@ -51,21 +54,25 @@ class LxcLauncherGUI: protection_checkbox = ttk.Checkbutton(self.root, text="Protection", variable=self.protection_checkbox_var) protection_checkbox.grid(row=3, column=1, padx=10, pady=10, sticky="w") + # Checkbox für bridgeprofil + bridgeprofile_checkbox = ttk.Checkbutton(self.root, text="Bridgeprofil", variable=self.bridgeprofile_checkbox_var) + bridgeprofile_checkbox.grid(row=4, column=0, padx=10, pady=10, sticky="w") + # Button zum Starten launch_button = ttk.Button(self.root, text="Starten", command=self.launch_lxc) - launch_button.grid(row=4, column=0, padx=10, pady=10, sticky="w") + launch_button.grid(row=5, column=0, padx=10, pady=10, sticky="w") # Button für Weitere Hosts hosts_button = ttk.Button(self.root, text="Weitere Hosts", command=self.show_hosts) - hosts_button.grid(row=4, column=1, padx=10, pady=10, sticky="w") + hosts_button.grid(row=5, column=1, padx=10, pady=10, sticky="w") # Button zum Beenden exit_button = ttk.Button(self.root, text="Beenden", command=self.root.destroy) - exit_button.grid(row=5, column=0, columnspan=4, padx=10, pady=10, sticky="w") + exit_button.grid(row=6, column=0, columnspan=4, padx=10, pady=10, sticky="w") # Label für das Ergebnis self.result_label = ttk.Label(self.root, text="") - self.result_label.grid(row=6, column=0, columnspan=4, padx=10, pady=10, sticky="w") + self.result_label.grid(row=7, column=0, columnspan=4, padx=10, pady=10, sticky="w") def show_error_message(self, message): messagebox.showerror("Fehler", message) @@ -98,7 +105,13 @@ class LxcLauncherGUI: nesting_option = "true" if self.nesting_checkbox_var.get() else "false" protection_option = "true" if self.protection_checkbox_var.get() else "false" + bridgeprofile_option = "true" if self.bridgeprofile_checkbox_var.get() else "false" + + # Anpassung des Befehls für bridgeprofil + #launch_command = f"lxc launch images:{selected_image} {host_name} -c security.nesting={nesting_option} -c security.protection.delete={protection_option} -p bridgeprofile={bridgeprofile_option}" launch_command = f"lxc launch images:{selected_image} {host_name} -c security.nesting={nesting_option} -c security.protection.delete={protection_option}" + if self.bridgeprofile_checkbox_var.get(): + launch_command += " -p default -p bridgeprofile" process = Popen(launch_command, shell=True, stdout=PIPE, stderr=PIPE) output, error = process.communicate() @@ -118,9 +131,9 @@ class LxcLauncherGUI: # Reset der Auswahl self.selected_image.set("") # Zurücksetzen des Auswahlmenüs self.host_name_var.set("") # Zurücksetzen des Hostnamen-Eingabefelds - self.num_hosts_var.set("") # Zurücksetzen des Felds für die Anzahl der Hosts self.nesting_checkbox_var.set(False) # Zurücksetzen der Nesting-Checkbox self.protection_checkbox_var.set(False) # Zurücksetzen der Protection-Checkbox + self.bridgeprofile_checkbox_var.set(False) # Zurücksetzen der Bridgeprofil-Checkbox if __name__ == "__main__": root = tk.Tk()