Identify jump host bridges based on IDF / PDF nets
[fuel.git] / mcp / patches / 0003-maas-region-force-artifact-download.patch
1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Sat, 5 Aug 2017 02:03:01 +0200
3 Subject: [PATCH] maas: region: force artifact download
4
5 MaaS configuration fails until all required artifacts are in place,
6 including bootloaders and target images.
7
8 Hack around this by forcing an explicit artifact sync.
9
10 NOTE: This is probably achievable through existing maas salt custom
11 module (py) and/or minor rework on that.
12 This fixup should be temporary at best.
13
14 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
15 ---
16
17 diff --git a/maas/region.sls b/maas/region.sls
18 --- a/maas/region.sls
19 +++ b/maas/region.sls
20 @@ -109,11 +109,19 @@
21    cmd.run:
22    - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
23
24 +maas_force_artifact_sync:
25 +  cmd.script:
26 +  - name: salt://maas/files/maas-artifact-sync.sh
27 +  - template: jinja
28 +  - shell: /bin/bash
29 +  - require:
30 +    - cmd: maas_login_admin
31 +
32  maas_config:
33    module.run:
34    - name: maas.process_maas_config
35    - require:
36 -    - cmd: maas_login_admin
37 +    - cmd: maas_force_artifact_sync
38
39  maas_commissioning_scripts:
40    module.run:
41 diff --git a/maas/files/maas-artifact-sync.sh b/maas/files/maas-artifact-sync.sh
42 new file mode 100644
43 --- /dev/null
44 +++ b/maas/files/maas-artifact-sync.sh
45 @@ -0,0 +1,21 @@
46 +{%- from "maas/map.jinja" import region with context %}
47 +#!/bin/bash
48 +function wait_for {
49 +  local total_attempts=$1; shift
50 +  local cmdstr=$@
51 +  local sleep_time=10
52 +  echo -e "\n[NOTE] Waiting for cmd to return success: ${cmdstr}\n"
53 +  for attempt in $(seq "${total_attempts}"); do
54 +    eval "${cmdstr}" && break || true
55 +    echo -n '.'; sleep "${sleep_time}"
56 +  done
57 +}
58 +maas login {{ region.admin.username }} \
59 +  http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < \
60 +  /var/lib/maas/.maas_credentials || exit 1
61 +# wait max 15 min for service up / image download, 5 min region to rack sync
62 +wait_for 90 "grep -qzE '(Unable to probe for DHCP servers|DHCP probe complete).*Rack controller' /var/log/maas/rackd.log"
63 +maas opnfv boot-resources import || exit 2
64 +wait_for 90 "! maas opnfv boot-resources is-importing | grep -q 'true'"
65 +maas opnfv rack-controllers import-boot-images || exit 3
66 +wait_for 30 "test -d /var/lib/maas/boot-resources/current/ubuntu/amd64"