[patch] Drop upstream reclass formula patches
[fuel.git] / mcp / patches / 0003-maas-region-force-artifact-download.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., 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: Sat, 5 Aug 2017 02:03:01 +0200
11 Subject: [PATCH] maas: region: force artifact download
12
13 MaaS configuration fails until all required artifacts are in place,
14 including bootloaders and target images.
15
16 Hack around this by forcing an explicit artifact sync.
17
18 NOTE: This is probably achievable through existing maas salt custom
19 module (py) and/or minor rework on that.
20 This fixup should be temporary at best.
21
22 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
23 ---
24  maas/files/maas-artifact-sync.sh | 20 ++++++++++++++++++++
25  maas/region.sls                  | 10 +++++++++-
26  2 files changed, 29 insertions(+), 1 deletion(-)
27  create mode 100644 maas/files/maas-artifact-sync.sh
28
29 diff --git a/maas/files/maas-artifact-sync.sh b/maas/files/maas-artifact-sync.sh
30 new file mode 100644
31 index 0000000..1715c51
32 --- /dev/null
33 +++ b/maas/files/maas-artifact-sync.sh
34 @@ -0,0 +1,20 @@
35 +{%- from "maas/map.jinja" import region with context %}
36 +#!/bin/bash
37 +function wait_for {
38 +  local total_attempts=$1; shift
39 +  local cmdstr=$@
40 +  local sleep_time=10
41 +  echo -e "\n[NOTE] Waiting for cmd to return success: ${cmdstr}\n"
42 +  for attempt in $(seq "${total_attempts}"); do
43 +    eval "${cmdstr}" && break || true
44 +    echo -n '.'; sleep "${sleep_time}"
45 +  done
46 +}
47 +maas login {{ region.admin.username }} \
48 +  http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < \
49 +  /var/lib/maas/.maas_credentials || exit 1
50 +# wait max 5 min for service up, 15 min image download, 5 min region to rack sync
51 +wait_for 30 "maas opnfv boot-resources import"
52 +wait_for 90 "! maas opnfv boot-resources is-importing | grep -q 'true'"
53 +maas opnfv rack-controllers import-boot-images || exit 3
54 +wait_for 30 "true {%- for arch in region.opnfv_arches.split(' ') %} && test -d /var/lib/maas/boot-resources/current/ubuntu/{{ arch }}{%- endfor %}"
55 diff --git a/maas/region.sls b/maas/region.sls
56 index aed295d..d6d28bb 100644
57 --- a/maas/region.sls
58 +++ b/maas/region.sls
59 @@ -161,11 +161,19 @@ maas_login_admin:
60    - onlyif: /bin/false
61    {%- endif %}
62
63 +maas_force_artifact_sync:
64 +  cmd.script:
65 +  - name: salt://maas/files/maas-artifact-sync.sh
66 +  - template: jinja
67 +  - shell: /bin/bash
68 +  - require:
69 +    - cmd: maas_login_admin
70 +
71  maas_config:
72    module.run:
73    - name: maas.process_maas_config
74    - require:
75 -    - cmd: maas_login_admin
76 +    - cmd: maas_force_artifact_sync
77    {%- if grains.get('kitchen-test') %}
78    - onlyif: /bin/false
79    {%- endif %}