Merge "Add copyright header to patch files"
[armband.git] / patches / fuel-library / multiarch-fuel / 0003-build_image.pp-Extract-cluster_arch-from-URI.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Wed, 15 Mar 2017 23:44:32 +0100
11 Subject: [PATCH] build_image.pp: Extract cluster_arch from "/" URI
12
13 Since target image building was moved from nailgun to puppet, we
14 need to determine the "target_arch" value differently.
15
16 One way to go is to extract it from the root disk image URI, which
17 is constructed based on static fixture data in nailgun.
18
19 This change relies on the following:
20 - image_data contains "/", with a properly arch-qualified URI;
21 - image_data "/" URI arch uses the same format as "target_arch"
22   (in this case "arm64" instead of "aarch64" or other variations);
23
24 While at it, increase task timeout from 1800s to 3600s.
25
26 NOTE: Unlike the previous approach, this method does not rely on any
27 other nailgun changes (i.e. adding the "arch" field to the database
28 model), but only on `fa_build_image --target_arch=...` support.
29
30 JIRA: https://jira.opnfv.org/browse/ARMBAND-240
31
32 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
33 ---
34  deployment/puppet/osnailyfacter/manifests/provision/build_image.pp | 7 +++++--
35  1 file changed, 5 insertions(+), 2 deletions(-)
36
37 diff --git a/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp b/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp
38 index 3f90aec..c1b8fbe 100644
39 --- a/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp
40 +++ b/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp
41 @@ -8,6 +8,9 @@ class osnailyfacter::provision::build_image(
42      $data = loadyaml($data_file)
43    }
44    $cluster_id = $data['cluster']['id']
45 +  $root_img_uri_split = split($data['image_data']['/']['uri'], '_')
46 +  $root_img_suffix_split = split($root_img_uri_split[-1], '[.]')
47 +  $cluster_arch = $root_img_suffix_split[0]
48
49    if $data['ironic']['enabled'] == 'true' {
50      $ironic_packages = [
51 @@ -50,9 +53,9 @@ class osnailyfacter::provision::build_image(
52      $extra_params = '--data_driver nailgun_build_image'
53
54      exec { 'generate_image_with_fuel':
55 -      command => "fa_build_image ${build_dir} ${log_params} ${extra_params} --input_data_file ${data_file}",
56 +      command => "fa_build_image ${build_dir} ${log_params} ${extra_params} --target_arch=${cluster_arch} --input_data_file ${data_file}",
57        path    => ['/bin', '/usr/bin'],
58 -      timeout => 1800,
59 +      timeout => 3600,
60        unless  => "test -e /var/www/nailgun/bootstrap/ironic/${cluster_id}/vmlinuz",
61      }
62    }