From eb997864e2680686f22376e08b85de771efd0dfd Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Wed, 21 Jun 2023 12:19:14 +0200 Subject: [PATCH] dont crash if param is not set in config.json --- src/lxc/lxc.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lxc/lxc.py b/src/lxc/lxc.py index 68f0318..927faf9 100644 --- a/src/lxc/lxc.py +++ b/src/lxc/lxc.py @@ -16,31 +16,31 @@ class LXC(LinuxMachine): self.lxc_hostname = lxc_hostname self.os = os - self.os_name = os["name"] - self.os_release = os["release"] + self.os_name = os.get("name") + self.os_release = os.get("release") self.resources = resources - self.cpu = resources["cpu"] - self.memory = resources["memory"] - self.swap = resources["swap"] - self.disk = resources["disk"] - self.storage = resources["storage"] + self.cpu = resources.get("cpu") + self.memory = resources.get("memory") + self.swap = resources.get("swap") + self.disk = resources.get("disk") + self.storage = resources.get("storage") self.network = network - self.bridge = network["bridge"] - self.ipv4 = network["ipv4"] + self.bridge = network.get("bridge") + self.ipv4 = network.get("ip") self.ipv4_netmask = 0 - self.ipv6 = network["ipv6"] - self.mac = network["mac"] - self.gateway4 = network["gateway4"] - self.gateway6 = network["gateway6"] - self.vlan = network["vlan"] + self.ipv6 = network.get("ip6") + self.mac = network.get("hwaddr") + self.gateway4 = network.get("gw") + self.gateway6 = network.get("gw6") + self.vlan = network.get("trunks") self.options = options - self.privileged = options["privileged"] - self.start_on_boot = options["start_on_boot"] - self.startup_order = options["startup_order"] - self.password = options["password"] + self.privileged = options.get("privileged") + self.start_on_boot = options.get("start_on_boot") + self.startup_order = options.get("startup_order") + self.password = options.get("password") self.creation = creation self.deploy = deploy