Skip to content

Commit

Permalink
libvirt: use 8 random chars in network name
Browse files Browse the repository at this point in the history
1. prefix the network names passed to libvirt with 8 random chars
extracted from the per-prefix uuid.

2. Let libvirt generate the bridge name automatically in NAT network.

Signed-off-by: Nadav Goldin <[email protected]>
  • Loading branch information
nvgoldin committed Jul 1, 2017
1 parent ab3919a commit 6efafbe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lago/providers/libvirt/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def mapping(self):
return self._spec['mapping']

def _libvirt_name(self):
return self._env.prefixed_name(self.name(), max_length=15)
return self._env.prefixed_name(self.name())

def _libvirt_xml(self):
raise NotImplementedError(
Expand Down Expand Up @@ -177,7 +177,6 @@ def _libvirt_xml(self):

replacements = {
'@NAME@': self._libvirt_name(),
'@BR_NAME@': ('%s-nic' % self._libvirt_name())[:12],
'@GW_ADDR@': self.gw(),
'@SUBNET@': subnet
}
Expand Down
2 changes: 1 addition & 1 deletion lago/providers/libvirt/templates/net_nat_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='@BR_NAME@' stp='on' delay='0' />
<bridge stp='on' delay='0' />
<ip address='@GW_ADDR@' netmask='255.255.255.0' />
<ip family='ipv6' address='fd8f:1391:3a82:@SUBNET@::1' prefix='64' />
</network>
4 changes: 1 addition & 3 deletions lago/providers/libvirt/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,7 @@ def _libvirt_xml(self):
interface.append(
ET.Element(
'source',
network=self.vm.virt_env.prefixed_name(
dev_spec['net'], max_length=15
),
network=self.vm.virt_env.prefixed_name(dev_spec['net']),
),
)
interface.append(
Expand Down

0 comments on commit 6efafbe

Please sign in to comment.