1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 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>
25 diff --git a/maas/region.sls b/maas/region.sls
30 - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
32 +maas_force_artifact_sync:
34 + - name: salt://maas/files/maas-artifact-sync.sh
38 + - cmd: maas_login_admin
42 - name: maas.process_maas_config
44 - - cmd: maas_login_admin
45 + - cmd: maas_force_artifact_sync
47 maas_commissioning_scripts:
49 diff --git a/maas/files/maas-artifact-sync.sh b/maas/files/maas-artifact-sync.sh
52 +++ b/maas/files/maas-artifact-sync.sh
54 +{%- from "maas/map.jinja" import region with context %}
57 + local total_attempts=$1; shift
60 + echo -e "\n[NOTE] Waiting for cmd to return success: ${cmdstr}\n"
61 + for attempt in $(seq "${total_attempts}"); do
62 + eval "${cmdstr}" && break || true
63 + echo -n '.'; sleep "${sleep_time}"
66 +maas login {{ region.admin.username }} \
67 + http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < \
68 + /var/lib/maas/.maas_credentials || exit 1
69 +# wait max 5 min for service up, 15 min image download, 5 min region to rack sync
70 +wait_for 30 "grep -qzE '(Unable to probe for DHCP servers|DHCP probe complete).*Rack controller' /var/log/maas/rackd.log"
71 +maas opnfv boot-resources import || exit 2
72 +wait_for 90 "! maas opnfv boot-resources is-importing | grep -q 'true'"
73 +maas opnfv rack-controllers import-boot-images || exit 3
74 +wait_for 30 "test -d /var/lib/maas/boot-resources/current/ubuntu/amd64"