Rebase: deploy related patch series. 65/15165/2
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 31 May 2016 20:34:54 +0000 (22:34 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Sat, 4 Jun 2016 16:04:52 +0000 (16:04 +0000)
After change "common.py: catch stderr in exec_cmd" [1] and other
unrelated changes were merged upstream,
we need to rebase the complete deploy related series.

While we're at it, re-export Fuel@OPNFV patches in Armband.

[1] https://gerrit.opnfv.org/gerrit/#/c/14561/

Change-Id: Icbc8261c2e24e4b29e8f5f2bc83db6829219129a

28 files changed:
patches/opnfv-fuel/0001-common.py-allow-specifying-number-of-attempts-in-exe.patch [moved from patches/opnfv-fuel/0021-common.py-allow-specifying-number-of-attempts-in-exe.patch with 91% similarity]
patches/opnfv-fuel/0002-ipmi_adapter-simplify-retry-if-command-fails.patch [moved from patches/opnfv-fuel/0022-ipmi_adapter-simplify-retry-if-command-fails.patch with 94% similarity]
patches/opnfv-fuel/0003-VirtualFuel-Add-temp_dir-and-vm_name-attributes.patch [moved from patches/opnfv-fuel/0013-VirtualFuel-Add-temp_dir-and-vm_name-attributes.patch with 100% similarity]
patches/opnfv-fuel/0004-virtual_fuel-factor-out-image-creation-into-a-method.patch [moved from patches/opnfv-fuel/0014-virtual_fuel-factor-out-image-creation-into-a-method.patch with 100% similarity]
patches/opnfv-fuel/0005-virtual_fuel-make-vm_template-an-attribute.patch [moved from patches/opnfv-fuel/0017-virtual_fuel-make-vm_template-an-attibute.patch with 57% similarity]
patches/opnfv-fuel/0006-virtual_fuel-initial-support-for-remote-libvirt.patch [moved from patches/opnfv-fuel/0015-virtual_fuel-initial-support-for-libvirt-volumes.patch with 61% similarity]
patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch [moved from patches/opnfv-fuel/0018-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch with 56% similarity]
patches/opnfv-fuel/0008-virtual_fuel-prepare-class-to-allow-multiple-bridges.patch [new file with mode: 0644]
patches/opnfv-fuel/0009-deploy.py-add-multiple-bridges-support.patch [moved from patches/opnfv-fuel/0023-deploy.py-add-multiple-bridges-support.patch with 85% similarity]
patches/opnfv-fuel/0010-deploy.sh-allow-specifying-several-bridges.patch [moved from patches/opnfv-fuel/0024-deploy.sh-allow-specifying-several-bridges.patch with 97% similarity]
patches/opnfv-fuel/0011-deploy.sh-accept-a-timeout-flag-T.patch [moved from patches/opnfv-fuel/0026-deploy.sh-accept-a-timeout-flag-T.patch with 95% similarity]
patches/opnfv-fuel/0012-Fuel-VM-for-the-Enea-Armband-lab.patch [moved from patches/opnfv-fuel/0025-Fuel-VM-for-the-Enea-Armband-lab.patch with 100% similarity]
patches/opnfv-fuel/0013-transplant-Generate-extra-interfaces-config-file.patch [moved from patches/opnfv-fuel/0019-transplant-Generate-extra-interfaces-config-file.patch with 100% similarity]
patches/opnfv-fuel/0014-deploy.sh-no-need-to-set-umask-0000.patch [moved from patches/opnfv-fuel/0020-deploy.sh-no-need-to-set-umask-0000.patch with 88% similarity]
patches/opnfv-fuel/0015-Remove-check-for-root.patch [moved from patches/opnfv-fuel/0016-Remove-check-for-root.patch with 85% similarity]
patches/opnfv-fuel/0016-Allow-customizing-Fuel-commit.patch [moved from patches/opnfv-fuel/0001-Allow-customizing-Fuel-commit.patch with 94% similarity]
patches/opnfv-fuel/0017-Allow-customizing-java-and-fuel-mirror-URLs.patch [moved from patches/opnfv-fuel/0002-Allow-customizing-java-and-fuel-mirror-URLs.patch with 100% similarity]
patches/opnfv-fuel/0018-deploy-reap.py-Dump-extra-interfaces-information.patch [moved from patches/opnfv-fuel/0027-deploy-reap.py-Dump-extra-interfaces-information.patch with 98% similarity]
patches/opnfv-fuel/0019-deploy-ipmi-adapter-Add-port-config-support.patch [moved from patches/opnfv-fuel/0030-deploy-ipmi-adapter-Add-port-config-support.patch with 99% similarity]
patches/opnfv-fuel/0020-Add-arm64-deb-repositories-setup.patch [moved from patches/opnfv-fuel/0003-Add-arm64-deb-repositories-setup.patch with 98% similarity]
patches/opnfv-fuel/0021-Build-bootstrap-image-for-arm64.patch [moved from patches/opnfv-fuel/0004-Build-bootstrap-image-for-arm64.patch with 85% similarity]
patches/opnfv-fuel/0022-bootstrap-Use-public-Ubuntu-ports-mirrors.patch [moved from patches/opnfv-fuel/0005-bootstrap-Use-public-Ubuntu-ports-mirrors.patch with 100% similarity]
patches/opnfv-fuel/0023-bootstrap-Add-armband-rtc-efi-fix-package.patch [moved from patches/opnfv-fuel/0006-bootstrap-Add-armband-rtc-efi-fix-package.patch with 100% similarity]
patches/opnfv-fuel/0024-Allow-customizing-fuel-plugin-opendaylight.patch [moved from patches/opnfv-fuel/0007-Allow-customizing-fuel-plugin-opendaylight.patch with 100% similarity]
patches/opnfv-fuel/0025-f_repobuild-Makefile-Use-python-debian-from-pip.patch [moved from patches/opnfv-fuel/0009-f_repobuild-Makefile-Use-python-debian-from-pip.patch with 100% similarity]
patches/opnfv-fuel/0026-f_repobuild-Repeat-mirror-build-up-to-ten-times.patch [moved from patches/opnfv-fuel/0028-f_repobuild-Repeat-mirror-build-up-to-ten-times.patch with 100% similarity]
patches/opnfv-fuel/0027-UX-Update-bootstrap-target-build-time-estimate.patch [moved from patches/opnfv-fuel/0029-UX-Update-bootstrap-target-build-time-estimate.patch with 94% similarity]
patches/opnfv-fuel/0028-bootstrap-Add-lshw-package.patch [moved from patches/opnfv-fuel/0031-bootstrap-Add-lshw-package.patch with 100% similarity]

@@ -8,8 +8,8 @@ until it succeeds. One example of this are the ipmitool commands, which
 may fail temorarily on some targets if they get too many requests
 simultaneously.
 
-In this patch two new optional parameters are introduced to the function
-signature, which do not break backward compatibility:
+In this patch three new optional parameters are introduced to the
+function signature, which do not break backward compatibility:
   attempts: which indicates how many times the command should be run if
             it returns a non-zero value*, and defaults to 1 (as today).
   delay:    which indicates the delay in seconds between attempts, and
@@ -18,8 +18,8 @@ signature, which do not break backward compatibility:
             command if set to True.
 
 * It may be desirable to add yet another parameter to indicate what
-  return value should be considered an error, but zero for now seems a
-  reasonable default
+  return value should be considered an error, but non-zero for now
+  seems a reasonable default.
 
 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
 ---
@@ -2,7 +2,7 @@ From: Josep Puigdemont <josep.puigdemont@enea.com>
 Date: Fri, 6 May 2016 12:09:58 +0200
 Subject: [PATCH] ipmi_adapter: simplify, retry if command fails
 
-The method get_node_state has been added to the The IpmiAdapter class.
+The method get_node_state has been added to the the IpmiAdapter class.
 
 In addition, now the power on/off methods will try several times to
 perform their IPMI command before giving up, instead of bailing out at
@@ -11,18 +11,15 @@ the first error.
 After the power on/off command is completed, the method will wait until
 the node is in the desired state.
 
-FIXME: a command could potentially take several minutes if the defaults
-are used; each IPMI command can take 1 minutes, and there can be three
+NOTE: a command could potentially take several minutes if the defaults
+are used; each IPMI command can take up to 1 minute, and there can be 3
 commands issued per operation, one of them may be retried 20 times with
-the current defaults. Ideally we would use eventlet or something alike
-to allow each command a limited time to execute:
+the current defaults. Ideally we would use eventlet or something similar
+to allow each command a limited time to execute, instead:
+
     with eventlet.timeout.Timeout(seconds) as t:
         power_on/off_command
 
-FIXME: There is a potential dead-lock situation by issuing the command
-and then checking the status, as someone could have intervened in
-between the two commands.
-
 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
 ---
  deploy/dha_adapters/ipmi_adapter.py | 101 +++++++++++++++---------------------
@@ -1,17 +1,17 @@
 From: Josep Puigdemont <josep.puigdemont@enea.com>
 Date: Wed, 4 May 2016 14:27:23 +0200
-Subject: [PATCH] virtual_fuel: make vm_template an attibute
+Subject: [PATCH] virtual_fuel: make vm_template an attribute
 
 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
 ---
- deploy/environments/virtual_fuel.py | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
+ deploy/environments/virtual_fuel.py | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
 
 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
-index f07207f..92a234c 100644
+index 82c4e47..ac5fc53 100644
 --- a/deploy/environments/virtual_fuel.py
 +++ b/deploy/environments/virtual_fuel.py
-@@ -46,6 +46,10 @@ class VirtualFuel(ExecutionEnvironment):
+@@ -28,6 +28,10 @@ class VirtualFuel(ExecutionEnvironment):
          self.temp_dir = tempfile.mkdtemp()
          self.vm_name = self.dha.get_node_property(self.fuel_node_id,
                                                    'libvirtName')
@@ -22,8 +22,19 @@ index f07207f..92a234c 100644
  
      def __del__(self):
          delete(self.temp_dir)
-@@ -106,7 +110,7 @@ class VirtualFuel(ExecutionEnvironment):
-         disk_path = self.create_image(disk_path, disk_size)
+@@ -55,18 +59,13 @@ class VirtualFuel(ExecutionEnvironment):
+         exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
+     def create_vm(self):
+-        vm_template = '%s/%s' % (self.root_dir,
+-                                 self.dha.get_node_property(
+-                                     self.fuel_node_id, 'libvirtTemplate'))
+-        check_file_exists(vm_template)
+-
+         disk_path = '%s/%s.raw' % (self.storage_dir, self.vm_name)
+         disk_sizes = self.dha.get_disks()
+         disk_size = disk_sizes['fuel']
+         self.create_image(disk_path, disk_size)
  
          temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
 -        exec_cmd('cp %s %s' % (vm_template, temp_vm_file))
@@ -1,44 +1,66 @@
 From: Josep Puigdemont <josep.puigdemont@enea.com>
 Date: Wed, 4 May 2016 14:27:23 +0200
-Subject: [PATCH] virtual_fuel: initial support for libvirt volumes
+Subject: [PATCH] virtual_fuel: initial support for remote libvirt
 
-This patch introduces the ability to create volumes on the libvirt host
-where the Fuel VM is being deployed. For now a default pool is used,
-but the idea is to allow this to be configured.
+With this patch it should be possible to create a fuel VM on a remote
+libvirt server by properly defining the LIBVIRT_DEFAULT_URI [1]
+environment variable. If the variable is not defined, then there should
+be no percievable change in behaviour for the script.
+
+This patch introduces the ability to create volumes (images) on a
+remote libvirt host where the Fuel VM is to be deployed. For now
+the volumes are created by default in a pool named jenkins, but
+the idea is to allow this to be configured, probably in the POD's
+DHA file.
 
 Since all virsh commands honor LIBVIRT_DEFAULT_URI, we use this
 environment variable to detect wheter we should create a volume or not.
-The rationale being that this environment variable will only be set if
-the user wants to do the VM deployment on a remote libvirt host.
+The rationale being that the variable will only be set if the user wants
+to to do the VM deployment on a remote libvirt host.
+
+We need to create a volume because we can not rely on being able to
+access the remote server's file system directly.
+
+The images are then transferred to the libvirt host using virsh
+commands. All this could also be done using scp and a user directory
+on the host machine, but using pools allows us to take advantage of
+libvirt's policies and file permissions.
 
-All this could also be done using scp and a user directory on the host
-machine, but using pools allows us to take advantage of libvirt's
-policies and file permissions.
+CHANGE: when LIBVIRT_DEFAULT_URI is defined, the script will not check
+for the presence of the required PXE bridge. This will still be checked
+when the Fuel VM is started and the bridge not found, but this happens
+at a later point than it does today.
 
 CHANGE: before this patch, the file system image was named like the VM:
 vm_name.raw. This patch introduces a change and adds a timestamp suffix
 to the image: vm_name-timestamp.raw. This is so to avoid collisions with
-an image with the same name on the remote pool. It may also be useful to
-keep around old images for later testing, while the VM definition can
-likely be the same.
+an image with the same name on the remote pool (two PODs may be using
+the same pool). It may also be useful to keep around old file system
+images.
+
+FIXME: This patch requires a pool named "jenkins" in the remote libvirt
+server, and it will fail if it is not present. This should be
+configurable.
+
+Notice though that we can still define LIBVIRT_DEFAULT_URI as
+"qemu:///system" to create the Fuel VM on the local host.
 
-FIXME: This patch will use a pool called "jenkins" in the libvirt
-server, and it will fail if it is not present. This is a requirement
-that should be amended in the future, and properly documented.
+[1] https://libvirt.org/remote.html#Remote_URI_reference
 
+Change-Id: I40925ed31337d3ad9cf505f284f5c3d14e9129a0
 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
 ---
  deploy/deploy.py                       |  5 +++
- deploy/dha_adapters/libvirt_adapter.py | 28 +++++++++++++++++
- deploy/environments/virtual_fuel.py    | 57 +++++++++++++++++++++++++++++-----
+ deploy/dha_adapters/libvirt_adapter.py | 31 +++++++++++++++++++
+ deploy/environments/virtual_fuel.py    | 56 ++++++++++++++++++++++++++++++++--
  deploy/install_fuel_master.py          |  8 +++--
- 4 files changed, 88 insertions(+), 10 deletions(-)
+ 4 files changed, 95 insertions(+), 5 deletions(-)
 
 diff --git a/deploy/deploy.py b/deploy/deploy.py
-index f86f2be..265e888 100755
+index 742e76b..179ee7b 100755
 --- a/deploy/deploy.py
 +++ b/deploy/deploy.py
-@@ -243,6 +243,11 @@ class AutoDeploy(object):
+@@ -245,6 +245,11 @@ class AutoDeploy(object):
  
  
  def check_bridge(pxe_bridge, dha_path):
@@ -51,7 +73,7 @@ index f86f2be..265e888 100755
          dha_struct = yaml.load(yaml_file)
      if dha_struct['adapter'] != 'libvirt':
 diff --git a/deploy/dha_adapters/libvirt_adapter.py b/deploy/dha_adapters/libvirt_adapter.py
-index 85913ac..8f3042c 100644
+index 85913ac..466f134 100644
 --- a/deploy/dha_adapters/libvirt_adapter.py
 +++ b/deploy/dha_adapters/libvirt_adapter.py
 @@ -11,6 +11,7 @@
@@ -62,21 +84,23 @@ index 85913ac..8f3042c 100644
  
  from common import (
      log,
-@@ -23,6 +24,13 @@ DEV = {'pxe': 'network',
+@@ -23,6 +24,15 @@ DEV = {'pxe': 'network',
         'disk': 'hd',
         'iso': 'cdrom'}
  
-+vol_xml_template = '''<volume type='file'>
-+  <name>%s</name>
-+  <capacity unit='%s'>%s</capacity>
++VOL_XML_TEMPLATE = '''<volume type='file'>
++  <name>{name}</name>
++  <capacity unit='{unit}'>{size!s}</capacity>
 +  <target>
-+    <format type='%s'/>
++    <format type='{format_type}'/>
 +  </target>
 +</volume>'''
++
++DEFAULT_POOL = 'jenkins'
  
  class LibvirtAdapter(HardwareAdapter):
  
-@@ -140,3 +148,23 @@ class LibvirtAdapter(HardwareAdapter):
+@@ -140,3 +150,24 @@ class LibvirtAdapter(HardwareAdapter):
  
      def get_virt_net_conf_dir(self):
          return self.dha_struct['virtNetConfDir']
@@ -84,13 +108,14 @@ index 85913ac..8f3042c 100644
 +    def upload_iso(self, iso_file):
 +        size = os.path.getsize(iso_file)
 +        vol_name = os.path.basename(iso_file)
-+        vol_xml = vol_xml_template % (vol_name, 'bytes', str(size), 'raw')
++        vol_xml = VOL_XML_TEMPLATE.format(name=vol_name, unit='bytes',
++                                          size=size, format_type='raw')
 +        fd, fname = tempfile.mkstemp(text=True, suffix='deploy')
 +        os.write(fd, vol_xml)
 +        os.close(fd)
 +
 +        log(vol_xml)
-+        pool = 'jenkins' # FIXME
++        pool = DEFAULT_POOL # FIXME
 +        exec_cmd('virsh vol-create --pool %s %s' % (pool, fname))
 +        vol_path = exec_cmd('virsh vol-path --pool %s %s' % (pool, vol_name))
 +
@@ -101,15 +126,16 @@ index 85913ac..8f3042c 100644
 +
 +        return vol_path
 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
-index 82c4e47..56d6f98 100644
+index ac5fc53..f9f9f7a 100644
 --- a/deploy/environments/virtual_fuel.py
 +++ b/deploy/environments/virtual_fuel.py
-@@ -11,14 +11,33 @@
+@@ -11,14 +11,36 @@
  from lxml import etree
  from execution_environment import ExecutionEnvironment
  import tempfile
 +import os
 +import re
++import time
  
  from common import (
      exec_cmd,
@@ -119,14 +145,16 @@ index 82c4e47..56d6f98 100644
 +    log,
  )
  
-+vol_xml_template = '''<volume type='file'>
-+  <name>%s</name>
-+  <capacity unit='%s'>%s</capacity>
++VOL_XML_TEMPLATE = '''<volume type='file'>
++  <name>{name}</name>
++  <capacity unit='{unit}'>{size!s}</capacity>
 +  <target>
-+    <format type='%s'/>
++    <format type='{format_type}'/>
 +  </target>
 +</volume>'''
 +
++DEFAULT_POOL = 'jenkins'
++
 +def get_size_and_unit(s):
 +    p = re.compile('^(\d+)\s*(\D+)')
 +    m = p.match(s)
@@ -138,7 +166,7 @@ index 82c4e47..56d6f98 100644
  
  class VirtualFuel(ExecutionEnvironment):
  
-@@ -51,19 +70,41 @@ class VirtualFuel(ExecutionEnvironment):
+@@ -55,14 +77,42 @@ class VirtualFuel(ExecutionEnvironment):
          with open(temp_vm_file, 'w') as f:
              vm_xml.write(f, pretty_print=True, xml_declaration=True)
  
@@ -149,7 +177,8 @@ index 82c4e47..56d6f98 100644
 +        if size == None:
 +            err('Could not determine size and unit of %s' % s)
 +
-+        vol_xml = vol_xml_template % (name, unit, str(size), img_type)
++        vol_xml = VOL_XML_TEMPLATE.format(name=name, unit=unit, size=size,
++                                          format_type=img_type)
 +        fname = os.path.join(self.temp_dir, '%s_vol.xml' % name)
 +        with file(fname, 'w') as f:
 +            f.write(vol_xml)
@@ -166,19 +195,14 @@ index 82c4e47..56d6f98 100644
 +        if os.environ.get('LIBVIRT_DEFAULT_URI') == None:
 +            exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
 +        else:
-+            pool = 'jenkins' # FIXME
++            pool = DEFAULT_POOL # FIXME
 +            name = os.path.basename(disk_path)
 +            disk_path = self.create_volume(pool, name, disk_size)
--    def create_vm(self):
--        vm_template = '%s/%s' % (self.root_dir,
--                                 self.dha.get_node_property(
--                                     self.fuel_node_id, 'libvirtTemplate'))
--        check_file_exists(vm_template)
++
 +        return disk_path
  
+     def create_vm(self):
 -        disk_path = '%s/%s.raw' % (self.storage_dir, self.vm_name)
-+    def create_vm(self):
 +        stamp = time.strftime("%Y%m%d%H%M%S")
 +        disk_path = '%s/%s-%s.raw' % (self.storage_dir, self.vm_name, stamp)
          disk_sizes = self.dha.get_disks()
@@ -187,9 +211,9 @@ index 82c4e47..56d6f98 100644
 +        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' % (vm_template, temp_vm_file))
+         exec_cmd('cp %s %s' % (self.vm_template, temp_vm_file))
 diff --git a/deploy/install_fuel_master.py b/deploy/install_fuel_master.py
-index 4f6a052..1c1bf05 100644
+index 631bf99..5adccef 100644
 --- a/deploy/install_fuel_master.py
 +++ b/deploy/install_fuel_master.py
 @@ -54,8 +54,12 @@ class InstallFuelMaster(object):
@@ -1,41 +1,24 @@
 From: Josep Puigdemont <josep.puigdemont@enea.com>
-Date: Wed, 4 May 2016 14:27:23 +0200
+Date: Fri, 20 May 2016 10:05:11 +0200
 Subject: [PATCH] virtual_fuel: add XML tree as attribute of VirtualFuel
 
 Now the VM XML definition tree is an attribute of the object, this way
-it can be used by all methods without having to re-read the file from
-the file.
+it can be used by all methods without having to re-read the file.
 
 Methods added:
 update_vm_template_file: Flushes the contents of the in-memory XML
     representation of the VM to the backing file.
 
-del_vm_nics: Deletes all interfaces from the VM
-
-add_vm_nic: Adds a new NIC to the VM, it now takes the name of the
-    bridge as a parameter.
-
-Add a function to flush the contents of the in-memory XML representation
-to the file update_vm_template_file
-
 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
 ---
- deploy/environments/virtual_fuel.py | 37 +++++++++++++++++++++++++------------
- 1 file changed, 25 insertions(+), 12 deletions(-)
+ deploy/environments/virtual_fuel.py | 21 ++++++++++++++-------
+ 1 file changed, 14 insertions(+), 7 deletions(-)
 
 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
-index 92a234c..b68577e 100644
+index f9f9f7a..7dc9720 100644
 --- a/deploy/environments/virtual_fuel.py
 +++ b/deploy/environments/virtual_fuel.py
-@@ -13,6 +13,7 @@ from execution_environment import ExecutionEnvironment
- import tempfile
- import os
- import re
-+import time
- from common import (
-     exec_cmd,
-@@ -50,28 +51,38 @@ class VirtualFuel(ExecutionEnvironment):
+@@ -54,14 +54,21 @@ class VirtualFuel(ExecutionEnvironment):
                                        self.dha.get_node_property(
                                            self.fuel_node_id, 'libvirtTemplate'))
          check_file_exists(self.vm_template)
@@ -56,47 +39,24 @@ index 92a234c..b68577e 100644
 +        with open(self.temp_vm_file, "wc") as f:
 +            self.vm_xml.write(f, pretty_print=True, xml_declaration=True)
 +
-+    def del_vm_nics(self):
++    def set_vm_nic(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)
+@@ -70,12 +77,12 @@ class VirtualFuel(ExecutionEnvironment):
+         source.set('bridge', self.pxe_bridge)
          model = etree.SubElement(interface, 'model')
          model.set('type', 'virtio')
 -        devices = vm_xml.xpath('/domain/devices')
-+
 +        devices = self.vm_xml.xpath('/domain/devices')
          if devices:
              device = devices[0]
              device.append(interface)
 -        with open(temp_vm_file, 'w') as f:
 -            vm_xml.write(f, pretty_print=True, xml_declaration=True)
-+        else:
-+            err('No devices!')
++
++        self.update_vm_template_file()
  
      def create_volume(self, pool, name, su, img_type='qcow2'):
          log('Creating image using Libvirt volumes in pool %s, name: %s' %
-@@ -109,11 +120,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(temp_vm_file)
-+        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):
diff --git a/patches/opnfv-fuel/0008-virtual_fuel-prepare-class-to-allow-multiple-bridges.patch b/patches/opnfv-fuel/0008-virtual_fuel-prepare-class-to-allow-multiple-bridges.patch
new file mode 100644 (file)
index 0000000..f2e21e2
--- /dev/null
@@ -0,0 +1,75 @@
+From: Josep Puigdemont <josep.puigdemont@enea.com>
+Date: Fri, 20 May 2016 10:23:45 +0200
+Subject: [PATCH] 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 supporting
+more than one bridge in the fuel VM.
+
+Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
+---
+ deploy/environments/virtual_fuel.py | 21 +++++++++++++--------
+ 1 file changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
+index 7dc9720..5a86c97 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(temp_vm_file)
++        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):
@@ -19,10 +19,10 @@ Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
  2 files changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/deploy/deploy.py b/deploy/deploy.py
-index ff4582a..041ba2f 100755
+index 179ee7b..9db1754 100755
 --- a/deploy/deploy.py
 +++ b/deploy/deploy.py
-@@ -312,8 +312,8 @@ def parse_arguments():
+@@ -316,8 +316,8 @@ def parse_arguments():
      parser.add_argument('-s', dest='storage_dir', action='store',
                          default='%s/images' % CWD,
                          help='Storage Directory [default: images]')
@@ -33,17 +33,18 @@ index ff4582a..041ba2f 100755
                          help='Linux Bridge for booting up the Fuel Master VM '
                               '[default: pxebr]')
      parser.add_argument('-p', dest='fuel_plugins_dir', action='store',
-@@ -332,6 +332,9 @@ def parse_arguments():
-     args = parser.parse_args()
-     log(args)
+@@ -333,6 +333,9 @@ def parse_arguments():
+                         action='store_true', default=False,
+                         help=('Do not launch environment deployment'))
  
 +    if not args.pxe_bridge:
 +        args.pxe_bridge = ['pxebr']
 +
-     check_file_exists(args.dha_file)
+     args = parser.parse_args()
+     log(args)
  
-     if not args.cleanup_only:
-@@ -343,6 +346,7 @@ def parse_arguments():
+@@ -348,7 +351,8 @@ def parse_arguments():
+         check_file_exists(iso_abs_path)
          log('Using image directory: %s' % args.storage_dir)
          create_dir_if_not_exists(args.storage_dir)
 -        check_bridge(args.pxe_bridge, args.dha_file)
@@ -53,10 +54,10 @@ index ff4582a..041ba2f 100755
      kwargs = {'no_fuel': args.no_fuel, 'fuel_only': args.fuel_only,
                'no_health_check': args.no_health_check,
 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
-index b68577e..6b673d0 100644
+index 5a86c97..b1a76e4 100644
 --- a/deploy/environments/virtual_fuel.py
 +++ b/deploy/environments/virtual_fuel.py
-@@ -121,7 +121,8 @@ class VirtualFuel(ExecutionEnvironment):
+@@ -125,7 +125,8 @@ class VirtualFuel(ExecutionEnvironment):
          disk_path = self.create_image(disk_path, disk_size)
  
          self.del_vm_nics()
@@ -17,7 +17,7 @@ Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
  1 file changed, 7 insertions(+), 4 deletions(-)
 
 diff --git a/ci/deploy.sh b/ci/deploy.sh
-index 34ecc57..c9b836b 100755
+index dc13f1c..3a95327 100755
 --- a/ci/deploy.sh
 +++ b/ci/deploy.sh
 @@ -57,7 +57,10 @@ and provides a fairly simple mechanism to execute a deployment.
@@ -32,7 +32,7 @@ index 34ecc57..c9b836b 100755
  -d Dry-run - Produces deploy config files (config/dea.yaml and
     config/dha.yaml), but does not execute deploy
  -f Deploy on existing Fuel master
-@@ -130,9 +133,9 @@ do
+@@ -133,9 +136,9 @@ do
              fi
              ;;
          B)
@@ -8,7 +8,7 @@ Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
  1 file changed, 15 insertions(+), 4 deletions(-)
 
 diff --git a/ci/deploy.sh b/ci/deploy.sh
-index c9b836b..5f06a19 100755
+index 3a95327..a8b3015 100755
 --- a/ci/deploy.sh
 +++ b/ci/deploy.sh
 @@ -29,7 +29,7 @@ cat << EOF
@@ -37,7 +37,7 @@ index c9b836b..5f06a19 100755
  -i .iso image to be deployed (needs to be provided in a URI
     style, it can be a local resource: file:// or a remote resource http(s)://)
  
-@@ -111,6 +114,11 @@ FUEL_CREATION_ONLY=''
+@@ -114,6 +117,11 @@ FUEL_CREATION_ONLY=''
  NO_DEPLOY_ENVIRONMENT=''
  STORAGE_DIR=''
  DRY_RUN=0
@@ -49,7 +49,7 @@ index c9b836b..5f06a19 100755
  #
  # END of variables to customize
  ############################################################################
-@@ -118,7 +126,7 @@ DRY_RUN=0
+@@ -121,7 +129,7 @@ DRY_RUN=0
  ############################################################################
  # BEGIN of main
  #
@@ -58,7 +58,7 @@ index c9b836b..5f06a19 100755
  do
      case $OPTION in
          b)
-@@ -166,6 +174,9 @@ do
+@@ -169,6 +177,9 @@ do
                  STORAGE_DIR="-s ${OPTARG}"
              fi
              ;;
@@ -68,7 +68,7 @@ index c9b836b..5f06a19 100755
          i)
              ISO=${OPTARG}
              if [[ ! $ISO == file://* ]] && \
-@@ -227,8 +238,8 @@ if [ $DRY_RUN -eq 0 ]; then
+@@ -238,8 +249,8 @@ if [ $DRY_RUN -eq 0 ]; then
          ISO=${SCRIPT_PATH}/ISO/image.iso
      fi
      # Start deployment
@@ -8,10 +8,10 @@ Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
  1 file changed, 6 deletions(-)
 
 diff --git a/ci/deploy.sh b/ci/deploy.sh
-index 343d499..34ecc57 100755
+index a8b3015..cd7f652 100755
 --- a/ci/deploy.sh
 +++ b/ci/deploy.sh
-@@ -76,9 +76,6 @@ Input parameters to the build script is:
+@@ -82,9 +82,6 @@ Input parameters to the build script is:
  -i .iso image to be deployed (needs to be provided in a URI
     style, it can be a local resource: file:// or a remote resource http(s)://)
  
@@ -21,7 +21,7 @@ index 343d499..34ecc57 100755
  Examples:
  sudo `basename $0` -b file:///home/jenkins/lab-config -l lf -p pod1 -s ha_odl-l3_heat_ceilometer -i file:///home/jenkins/myiso.iso
  EOF
-@@ -207,9 +204,6 @@ fi
+@@ -226,9 +223,6 @@ fi
  # Enable the automatic exit trap
  trap do_exit SIGINT SIGTERM EXIT
  
@@ -2,6 +2,7 @@ From: Josep Puigdemont <josep.puigdemont@enea.com>
 Date: Wed, 4 May 2016 14:27:23 +0200
 Subject: [PATCH] Remove check for root
 
+Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
 ---
  ci/deploy.sh                        | 5 -----
  deploy/deploy-config.py             | 1 -
@@ -10,10 +11,10 @@ Subject: [PATCH] Remove check for root
  4 files changed, 10 deletions(-)
 
 diff --git a/ci/deploy.sh b/ci/deploy.sh
-index dc13f1c..343d499 100755
+index cd7f652..5f06a19 100755
 --- a/ci/deploy.sh
 +++ b/ci/deploy.sh
-@@ -193,11 +193,6 @@ do
+@@ -204,11 +204,6 @@ do
      esac
  done
  
@@ -38,7 +39,7 @@ index 65d51b2..88a1111 100644
  )
  
 diff --git a/deploy/deploy.py b/deploy/deploy.py
-index 265e888..ff4582a 100755
+index 9db1754..ca092f5 100755
 --- a/deploy/deploy.py
 +++ b/deploy/deploy.py
 @@ -32,7 +32,6 @@ from common import (
@@ -49,7 +50,7 @@ index 265e888..ff4582a 100755
      ArgParser,
  )
  
-@@ -230,7 +229,6 @@ class AutoDeploy(object):
+@@ -232,7 +231,6 @@ class AutoDeploy(object):
          return 0
  
      def run(self):
@@ -58,10 +59,10 @@ index 265e888..ff4582a 100755
              self.cleanup_execution_environment()
          else:
 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
-index 56d6f98..f07207f 100644
+index b1a76e4..4ff68f6 100644
 --- a/deploy/environments/virtual_fuel.py
 +++ b/deploy/environments/virtual_fuel.py
-@@ -17,7 +17,6 @@ import re
+@@ -18,7 +18,6 @@ import time
  from common import (
      exec_cmd,
      check_file_exists,
@@ -69,7 +70,7 @@ index 56d6f98..f07207f 100644
      delete,
      log,
  )
-@@ -114,7 +113,6 @@ class VirtualFuel(ExecutionEnvironment):
+@@ -135,7 +134,6 @@ class VirtualFuel(ExecutionEnvironment):
                         vm_definition_overwrite)
  
      def setup_environment(self):
@@ -7,7 +7,7 @@ Subject: [PATCH] Allow customizing Fuel commit
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/build/config.mk b/build/config.mk
-index 667575c..30d9ccc 100644
+index 23bda18..af63fcd 100644
 --- a/build/config.mk
 +++ b/build/config.mk
 @@ -9,7 +9,7 @@
@@ -37,7 +37,7 @@ Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
  1 file changed, 34 insertions(+)
 
 diff --git a/deploy/reap.py b/deploy/reap.py
-index bf64d40..6feaf17 100755
+index 1262d4c..1f1b8ad 100644
 --- a/deploy/reap.py
 +++ b/deploy/reap.py
 @@ -15,6 +15,8 @@ import yaml
@@ -49,7 +49,7 @@ index bf64d40..6feaf17 100755
  
  from common import (
      N,
-@@ -245,6 +247,38 @@ class Reap(object):
+@@ -246,6 +248,38 @@ class Reap(object):
              if key not in ['ipaddress', 'netmask',
                             'dhcp_pool_start', 'dhcp_pool_end']:
                  del fuel['ADMIN_NETWORK'][key]
@@ -60,7 +60,7 @@ index 283bd57..f4f2e6a 100644
  
      def get_node_pxe_mac(self, node_id):
 diff --git a/deploy/reap.py b/deploy/reap.py
-index 6feaf17..9933d1d 100755
+index 1f1b8ad..d5386aa 100644
 --- a/deploy/reap.py
 +++ b/deploy/reap.py
 @@ -59,6 +59,8 @@ adapter:
@@ -3,13 +3,13 @@ Date: Wed, 24 Feb 2016 20:04:03 +0100
 Subject: [PATCH] Add arm64 deb repositories setup
 
 ---
- build/f_isoroot/f_kscfg/ks.cfg            |  1 +
+ build/f_isoroot/f_kscfg/ks.cfg.patch      | 10 ++++++++++
  build/install/apt-ftparchive-deb.conf     |  8 +++++++-
  build/install/apt-ftparchive-release.conf |  2 +-
  build/install/apt-ftparchive-udeb.conf    |  7 ++++++-
  build/install/install.sh                  | 22 ++++++++++++++++++----
  build/install/uninstall.sh                | 18 ++++++++++--------
- 6 files changed, 43 insertions(+), 15 deletions(-)
+ 6 files changed, 52 insertions(+), 15 deletions(-)
 
 diff --git a/build/f_isoroot/f_kscfg/ks.cfg.patch b/build/f_isoroot/f_kscfg/ks.cfg.patch
 index a6840e4..e1ae8fc 100644
@@ -6,9 +6,11 @@ For now the arch is hardcoded for simplicity. We should detect this
 but how? If we're multi-arch then one bootstrap image should be built
 per supported arch. This requires Fuel refactoring.
 ---
- build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ build/bootstrap_admin_node.sh.patch | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
 
+diff --git a/build/bootstrap_admin_node.sh.patch b/build/bootstrap_admin_node.sh.patch
+index aeef3f7..c66b497 100644
 --- a/build/bootstrap_admin_node.sh.patch
 +++ b/build/bootstrap_admin_node.sh.patch
 @@ -53,6 +53,23 @@
@@ -8,8 +8,8 @@ introduced by using qemu-user-static.
 
 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
 ---
- build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh | 9 ++++++---
- 1 file changed, 6 insertions(+), 3 deletions(-)
+ build/bootstrap_admin_node.sh.patch | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
 
 diff --git a/build/bootstrap_admin_node.sh.patch b/build/bootstrap_admin_node.sh.patch
 index c66b497..46b53e6 100644