Container: allow disabling IPv4 on a container
This commit is contained in:
parent
82dcc54c71
commit
be299901e9
1 changed files with 12 additions and 2 deletions
|
@ -129,7 +129,16 @@ class Container(util.LibvirtObject):
|
|||
def __str__(self):
|
||||
return "This container is already instanciated"
|
||||
|
||||
def __init__(self, conn, networks, name=None, mem=int(1e6)):
|
||||
def __init__(self, conn, networks, name=None, mem=int(1e6), enable_v4=True):
|
||||
""" Parameters:
|
||||
* conn: connection to libvirt,
|
||||
* networks: iterable of Network instances this container is connected to,
|
||||
* name: name of the container. Defaults to something id-based.
|
||||
* mem: KiB of memory available to this container,
|
||||
* enable_v4: is IPv4 enabled for this container? Defaults to True. If False,
|
||||
this container won't be given an IPv4 address.
|
||||
"""
|
||||
|
||||
super().__init__(conn)
|
||||
|
||||
if not name:
|
||||
|
@ -138,6 +147,7 @@ class Container(util.LibvirtObject):
|
|||
|
||||
self.networks = networks
|
||||
self.mem = mem
|
||||
self.enable_v4 = enable_v4
|
||||
|
||||
self.overlay_root = None
|
||||
|
||||
|
@ -159,7 +169,7 @@ 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),
|
||||
ipv4=util.Addrv4(net.id, self.id) if self.enable_v4 else None,
|
||||
ipv6=util.Addrv6(net.id, self.id),
|
||||
)
|
||||
net_config_path = net_conf_dir / "11-{link:02d}-{name}.network".format(
|
||||
|
|
Loading…
Reference in a new issue