From 9a5b6a996d07b06bdbba5ce4aad0f36a751bb04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Tue, 8 Mar 2022 15:21:14 +0100 Subject: [PATCH] Use name from topology in container name --- lxc_net/parse_network.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lxc_net/parse_network.py b/lxc_net/parse_network.py index 58f3b3f..fdb4882 100644 --- a/lxc_net/parse_network.py +++ b/lxc_net/parse_network.py @@ -35,7 +35,7 @@ def requires_id_in_link_range(func): class Topology: - """ A generic network topology """ + """A generic network topology""" class InvalidConfiguration(Exception): def __init__(self, reason): @@ -58,9 +58,9 @@ class Topology: @requires_parsed @requires_id_in_link_range def net_setstate_single(self, link_id, state, verbose=False, verbose_inline=False): - """ Start or stop a single network. - * `net_id`: the link to be affected - * `verbose`: if true, prints progress + """Start or stop a single network. + * `net_id`: the link to be affected + * `verbose`: if true, prints progress """ link = self.links[link_id] @@ -91,9 +91,9 @@ class Topology: @requires_parsed @requires_id_in_dom_range def dom_setstate_single(self, dom_id, state, verbose=False, verbose_inline=False): - """ Start or stop a single domain. - * `dom_id`: the domain to be affected - * `verbose`: if true, prints progress + """Start or stop a single domain. + * `dom_id`: the domain to be affected + * `verbose`: if true, prints progress """ dom = self.domains[dom_id] @@ -135,8 +135,8 @@ class Topology: @requires_parsed def net_setstate(self, state, verbose=False): - """ Start or stop the networks. - * `verbose`: if true, prints progress + """Start or stop the networks. + * `verbose`: if true, prints progress """ if verbose: @@ -151,8 +151,8 @@ class Topology: @requires_parsed def dom_setstate(self, state, verbose=False): - """ Start or stop the domains. - * `verbose`: if true, prints progress + """Start or stop the domains. + * `verbose`: if true, prints progress """ if verbose: @@ -188,9 +188,9 @@ del requires_parsed class YamlTopology(Topology): - """ Parse a YAML description of a network topology. The networks' links and domains + """Parse a YAML description of a network topology. The networks' links and domains are contained in the `links` and `domains` attributes, but their `create` methods - are not called. """ + are not called.""" def __init__(self, path, conn): super().__init__(conn) @@ -215,7 +215,8 @@ class YamlTopology(Topology): ) cur_link = network.Network( - self.conn, enable_v4=link_conf.get("enable_v4", True), + self.conn, + enable_v4=link_conf.get("enable_v4", True), ) self.links.append(cur_link) @@ -246,6 +247,7 @@ class YamlTopology(Topology): self.conn, dom_descr[dom]["links"], enable_v4=dom_descr[dom].get("enable_v4", True), + name=dom, ) for dom in sorted_dom_names ]