Skip to content

Commit e2d99c3

Browse files
author
Complete and Absolute Nonsense
committed
Implement isolated network ports
Requires Ubuntu 22.04 (or more specifically, LibVirt 6.1+)
1 parent cfddf60 commit e2d99c3

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

cloudvirt/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ def _parse_vmspec(self):
138138
except KeyError:
139139
pass
140140

141+
try:
142+
if vmspec_yaml["isolated_port"] is None:
143+
self.logger.error("isolated_port cannot be specified then left blank")
144+
145+
if type(vmspec_yaml["isolated_port"]).__name__ != "bool":
146+
self.logger.error("isolated port should be a bool.")
147+
148+
self.vmspec.isolated_port = vmspec_yaml["isolated_port"]
149+
except KeyError:
150+
pass
151+
141152
def _parse_userspec(self):
142153
# - - load yaml - - #
143154
if not self.userspec_file:

cloudvirt/driver.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ def _gen_dom(self):
346346
ET.SubElement(domxml_dev_iface, "mac", {"address": self.vmspec.mac_addr})
347347
ET.SubElement(domxml_dev_iface, "model", {"type": "virtio"})
348348

349+
if self.vmspec.isolated_port is not None:
350+
isolated_opt = "no"
351+
if self.vmspec.isolated_port is True:
352+
isolated_opt = "yes"
353+
ET.SubElement(domxml_dev_iface, "port", {"isolated": isolated_opt})
354+
349355
ET.SubElement(domxml_dev, "serial", {"type": "pty"})
350356

351357
domxml = ET.tostring(domxml_root, encoding="unicode")

cloudvirt/spec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self):
1111
self.ip = None
1212
self.gateway = None
1313
self.bridge_pfxlen = None
14+
self.isolated_port = None
1415

1516
# storage
1617
self.vol_pool = None

0 commit comments

Comments
 (0)