[maas] Make boot-source-selection ops idempotent 95/56695/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 26 Apr 2018 17:25:21 +0000 (19:25 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 26 Apr 2018 17:59:31 +0000 (17:59 +0000)
- add `unless` clause;
- instead of adding a new boot sources, update the existing one,
  assuming standard MaaS installation (always updates id '1');

Change-Id: I2db92a3b14d0588095c69545cbb6977ca109613e
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
(cherry picked from commit d7ab894b988d8dd6fe49714e0d8d6077e08ebb16)

mcp/patches/0016-Set-boot-source-selections.patch

index 73bdc90..ff52681 100644 (file)
@@ -13,18 +13,18 @@ Subject: [PATCH] Set boot source selections
 Change-Id: I8dc738b3e6e6f1bfcc1348873f162651aff8bbdf
 
 diff --git a/maas/region.sls b/maas/region.sls
-index 39844bd..e231795 100644
 --- a/maas/region.sls
 +++ b/maas/region.sls
-@@ -171,6 +171,12 @@ maas_login_admin:
+@@ -171,6 +171,13 @@ maas_login_admin:
    cmd.run:
    - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
 
 +boot_source_selections:
 +  cmd.run:
-+  - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv boot-source-selections create 1 os='ubuntu' release='{{ region.maas_config.default_distro_series }}' arches='{{ pillar._param.opnfv_maas_node01_architecture.split('/')[0] }}' subarches='*' labels='*'"
++  - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv boot-source-selection update 1 1 release='{{ region.maas_config.default_distro_series }}'"
 +  - require:
 +    - cmd: maas_login_admin
++  - unless: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv boot-source-selections read 1 | grep -q {{ region.maas_config.default_distro_series }}"
 +
  maas_force_artifact_sync:
    cmd.script: