1 From 2a9e72d95200161ec27e8f199a76c6ec1f88bff1 Mon Sep 17 00:00:00 2001
2 From: Josep Puigdemont <josep.puigdemont@enea.com>
3 Date: Fri, 20 May 2016 10:23:45 +0200
4 Subject: [PATCH] virtual_fuel: prepare class to allow multiple bridges
6 The VirtualFuel class has now two new methods:
8 del_vm_nics: Deletes all interfaces from the VM.
10 add_vm_nic: Adds a NIC to the VM, attached to the specified bridge.
12 The following method has been deleted:
14 set_vm_nic: implemented with the two new methods
16 Apart from the deleted method, no functionality has been changed.
18 This is just a small but necessary step towards adding support for
19 configuring more than one NIC in the fuel VM.
21 Change-Id: I9f02c8163dfb9768510e78d5d5e77a0bb43306fb
22 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
24 deploy/environments/virtual_fuel.py | 21 +++++++++++++--------
25 1 file changed, 13 insertions(+), 8 deletions(-)
27 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
28 index 2fac98b..5a86c97 100644
29 --- a/deploy/environments/virtual_fuel.py
30 +++ b/deploy/environments/virtual_fuel.py
31 @@ -67,22 +67,25 @@ class VirtualFuel(ExecutionEnvironment):
32 with open(self.temp_vm_file, "wc") as f:
33 self.vm_xml.write(f, pretty_print=True, xml_declaration=True)
35 - def set_vm_nic(self):
36 + def del_vm_nics(self):
37 interfaces = self.vm_xml.xpath('/domain/devices/interface')
38 for interface in interfaces:
39 interface.getparent().remove(interface)
41 + def add_vm_nic(self, bridge):
42 interface = etree.Element('interface')
43 interface.set('type', 'bridge')
44 source = etree.SubElement(interface, 'source')
45 - source.set('bridge', self.pxe_bridge)
46 + source.set('bridge', bridge)
47 model = etree.SubElement(interface, 'model')
48 model.set('type', 'virtio')
50 devices = self.vm_xml.xpath('/domain/devices')
53 device.append(interface)
55 - self.update_vm_template_file()
59 def create_volume(self, pool, name, su, img_type='qcow2'):
60 log('Creating image using Libvirt volumes in pool %s, name: %s' %
61 @@ -121,11 +124,13 @@ class VirtualFuel(ExecutionEnvironment):
62 disk_size = disk_sizes['fuel']
63 disk_path = self.create_image(disk_path, disk_size)
65 - temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
66 - exec_cmd('cp %s %s' % (self.vm_template, temp_vm_file))
69 + self.add_vm_nic(self.pxe_bridge)
70 + self.update_vm_template_file()
72 vm_definition_overwrite = self.dha.get_vm_definition('fuel')
73 - self.define_vm(self.vm_name, temp_vm_file, disk_path,
75 + self.define_vm(self.vm_name, self.temp_vm_file, disk_path,
76 vm_definition_overwrite)
78 def setup_environment(self):