1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., Enea AB and others.
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
13 MaaS configuration fails until all required artifacts are in place,
14 including bootloaders and target images.
16 Hack around this by forcing an explicit artifact sync.
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.
22 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
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
29 diff --git a/maas/files/maas-artifact-sync.sh b/maas/files/maas-artifact-sync.sh
31 index 0000000..1715c51
33 +++ b/maas/files/maas-artifact-sync.sh
35 +{%- from "maas/map.jinja" import region with context %}
38 + local total_attempts=$1; shift
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}"
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
59 @@ -161,11 +161,19 @@ maas_login_admin:
63 +maas_force_artifact_sync:
65 + - name: salt://maas/files/maas-artifact-sync.sh
69 + - cmd: maas_login_admin
73 - name: maas.process_maas_config
75 - - cmd: maas_login_admin
76 + - cmd: maas_force_artifact_sync
77 {%- if grains.get('kitchen-test') %}