summaryrefslogtreecommitdiffstats
path: root/deploy/environments
diff options
context:
space:
mode:
authorJosep Puigdemont <josep.puigdemont@enea.com>2016-05-20 10:23:45 +0200
committerJosep Puigdemont <josep.puigdemont@enea.com>2016-06-17 10:24:58 +0200
commit2a9e72d95200161ec27e8f199a76c6ec1f88bff1 (patch)
tree3e640cb4dcc8842b4bcabcd04b4ae85543e2f948 /deploy/environments
parentdc7f16e0fa9545021b2673e18eff421221ba06c0 (diff)
virtual_fuel: prepare class to allow multiple bridges
The VirtualFuel class has now two new methods: del_vm_nics: Deletes all interfaces from the VM. add_vm_nic: Adds a NIC to the VM, attached to the specified bridge. The following method has been deleted: set_vm_nic: implemented with the two new methods Apart from the deleted method, no functionality has been changed. This is just a small but necessary step towards adding support for configuring more than one NIC in the fuel VM. Change-Id: I9f02c8163dfb9768510e78d5d5e77a0bb43306fb Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
Diffstat (limited to 'deploy/environments')
-rw-r--r--deploy/environments/virtual_fuel.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
index 2fac98b25..5a86c9711 100644
--- a/deploy/environments/virtual_fuel.py
+++ b/deploy/environments/virtual_fuel.py
@@ -67,22 +67,25 @@ class VirtualFuel(ExecutionEnvironment):
with open(self.temp_vm_file, "wc") as f:
self.vm_xml.write(f, pretty_print=True, xml_declaration=True)
- def set_vm_nic(self):
+ def del_vm_nics(self):
interfaces = self.vm_xml.xpath('/domain/devices/interface')
for interface in interfaces:
interface.getparent().remove(interface)
+
+ def add_vm_nic(self, bridge):
interface = etree.Element('interface')
interface.set('type', 'bridge')
source = etree.SubElement(interface, 'source')
- source.set('bridge', self.pxe_bridge)
+ source.set('bridge', bridge)
model = etree.SubElement(interface, 'model')
model.set('type', 'virtio')
+
devices = self.vm_xml.xpath('/domain/devices')
if devices:
device = devices[0]
device.append(interface)
-
- self.update_vm_template_file()
+ else:
+ err('No devices!')
def create_volume(self, pool, name, su, img_type='qcow2'):
log('Creating image using Libvirt volumes in pool %s, name: %s' %
@@ -121,11 +124,13 @@ class VirtualFuel(ExecutionEnvironment):
disk_size = disk_sizes['fuel']
disk_path = self.create_image(disk_path, disk_size)
- temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
- exec_cmd('cp %s %s' % (self.vm_template, temp_vm_file))
- self.set_vm_nic()
+ self.del_vm_nics()
+ self.add_vm_nic(self.pxe_bridge)
+ self.update_vm_template_file()
+
vm_definition_overwrite = self.dha.get_vm_definition('fuel')
- self.define_vm(self.vm_name, temp_vm_file, disk_path,
+
+ self.define_vm(self.vm_name, self.temp_vm_file, disk_path,
vm_definition_overwrite)
def setup_environment(self):