From 6efafbec96fc2f4d5b47035db2a38706ba41ecd8 Mon Sep 17 00:00:00 2001 From: Nadav Goldin Date: Wed, 28 Jun 2017 14:56:00 +0300 Subject: [PATCH] libvirt: use 8 random chars in network name 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 --- lago/providers/libvirt/network.py | 3 +-- lago/providers/libvirt/templates/net_nat_template.xml | 2 +- lago/providers/libvirt/vm.py | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lago/providers/libvirt/network.py b/lago/providers/libvirt/network.py index 9b6e1dcb..54bcec28 100644 --- a/lago/providers/libvirt/network.py +++ b/lago/providers/libvirt/network.py @@ -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( @@ -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 } diff --git a/lago/providers/libvirt/templates/net_nat_template.xml b/lago/providers/libvirt/templates/net_nat_template.xml index 0fb8ab59..f51298b5 100644 --- a/lago/providers/libvirt/templates/net_nat_template.xml +++ b/lago/providers/libvirt/templates/net_nat_template.xml @@ -5,7 +5,7 @@ - + diff --git a/lago/providers/libvirt/vm.py b/lago/providers/libvirt/vm.py index 283b976e..cb2b8ba0 100644 --- a/lago/providers/libvirt/vm.py +++ b/lago/providers/libvirt/vm.py @@ -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(