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