Browse Source

topologies: handle `enable_v4` attribute for links

master
Théophile Bastian 2 years ago
parent
commit
458dc08d9c
  1. 10
      README.md
  2. 4
      lxc_net/container.py
  3. 3
      lxc_net/network.py
  4. 4
      lxc_net/parse_network.py

10
README.md

@ -64,6 +64,7 @@ looking like this: @@ -64,6 +64,7 @@ looking like this:
---
links:
- domains: ['a', 'b']
enable_v4: false
- domains: ['b', 'c']
domains:
b:
@ -75,8 +76,13 @@ attribute, the list of domains (containers) connected to it. A domain is @@ -75,8 +76,13 @@ attribute, the list of domains (containers) connected to it. A domain is
described by an arbitrary name. Domains will be spawned (and indexed) in
alphabetical order.
The valid options for links are:
* `enable_v4`: boolean, specifies whether the NICs connected to this link have
an IPv4 address.
A `domains` root element is optional, and may be used to specify
domain-specific options.
The valid options are:
* `enable_v4`: boolean, specifies whether the domain has an IPv4 address.
The valid options for domains are:
* `enable_v4`: boolean, specifies whether the domain has IPv4 addresses on its
NICs.

4
lxc_net/container.py

@ -174,7 +174,9 @@ class Container(util.LibvirtObject): @@ -174,7 +174,9 @@ class Container(util.LibvirtObject):
for net in self.networks:
net_config = net_config_templ.inst(
mac=util.MACAddress(net.id, self.id),
ipv4=util.Addrv4(net.id, self.id) if self.enable_v4 else None,
ipv4=util.Addrv4(net.id, self.id)
if self.enable_v4 and net.enable_v4
else None,
ipv6=util.Addrv6(net.id, self.id),
)
net_config_path = net_conf_dir / "11-{link:02d}-{name}.network".format(

3
lxc_net/network.py

@ -12,13 +12,14 @@ class Network(util.LibvirtObject): @@ -12,13 +12,14 @@ class Network(util.LibvirtObject):
def __str__(self):
return "This network is already instanciated"
def __init__(self, conn, name=None):
def __init__(self, conn, name=None, enable_v4=True):
super().__init__(conn)
if not name:
name = str(self.id)
self.name = settings.PREFIX + "_link_" + name
self.enable_v4 = enable_v4
self.bridge_id = settings.NETWORK_ID * 0xFF + self.id
self.bridge_mac = util.MACAddress(self.id, None)
self.ipv4 = util.Addrv4(self.id, None, host_address=True)

4
lxc_net/parse_network.py

@ -214,7 +214,9 @@ class YamlTopology(Topology): @@ -214,7 +214,9 @@ class YamlTopology(Topology):
"a 'domains' attribute is mandatory for each link"
)
cur_link = network.Network(self.conn)
cur_link = network.Network(
self.conn, enable_v4=link_conf.get("enable_v4", True),
)
self.links.append(cur_link)
for dom in link_conf["domains"]:

Loading…
Cancel
Save