do not use a variable to store variation address (closes #613090)
authorPaul Tonelli <paul.tonelli@logilab.fr>
Thu, 09 Jan 2014 12:49:11 +0100
changeset 192 702c422f2cc8
parent 191 d5616a52f5fb
child 193 918f0ec4d4f5
do not use a variable to store variation address (closes #613090)
ami_post/upload.sls
ami_pre/files.sls
--- a/ami_post/upload.sls	Wed Nov 27 20:00:28 2013 +0100
+++ b/ami_post/upload.sls	Thu Jan 09 12:49:11 2014 +0100
@@ -1,10 +1,12 @@
+{% set address_variation =  grains.get('ami.hg_address_variation', 'http://hg.logilab.org/users/ptonelli/salt-ami-cloud-builder/variation') %}
+{% set rev_variation = grains.get('ami.hg_rev_variation', salt['cmd.run']('hg identify --id ' + address_variation)) %}
+{% set description = "%s/file/%s/" % (address_variation, rev_variation) %}
+
 {% if 'keystone.user' in grains %}
 upload_variant:
     module.run:
         - name: openstack_client.upload_to_glance
-{% if 'ami.hg_rev_variation' in grains and 'ami.hg_address_variation' in grains %}
-        - description: {{ grains['ami.hg_address_variation'] }}/file/{{ grains['ami.hg_rev_variation'] }}/
-{% endif %}
+        - description: {{ description }}
         - path: /mnt/output
         - require:
             - tmp_state.resized: resize_variation
@@ -63,9 +65,7 @@
 {% if 'ami.size' in grains %}
         - size: {{grains['ami.size']}}
 {% endif %}
-{% if 'ami.hg_rev_variation' in grains and 'ami.hg_address_variation' in grains %}
-        - description: {{ grains['ami.hg_address_variation'] }}/file/{{ grains['ami.hg_rev_variation'] }}/
-{% endif %}
+        - description: {{ description }}
         - require:
             - tmp_state.resized: resize_variation
             - cmd.run: space_remove_pk
--- a/ami_pre/files.sls	Wed Nov 27 20:00:28 2013 +0100
+++ b/ami_pre/files.sls	Thu Jan 09 12:49:11 2014 +0100
@@ -5,7 +5,6 @@
         - require:
             - mount.mounted: mounted_variation
 
-
 {% if 'ami.salt_install_script' in grains %}
 /mnt/variation/tmp/salt_install:
   file.managed:
@@ -23,11 +22,12 @@
       - tmp_state.local_managed: resolv.conf
 {% endif %}
 
-
-{% if 'ami.hg_address_variation' in grains %}
 hg_variation:
     hg.latest:
         - name: {{ grains['ami.hg_address_variation'] }}
+{% else %}
+        - name: {{ 'http://hg.logilab.org/users/ptonelli/salt-ami-cloud-builder/variation' }} 
+{% endif %}
 {% if 'ami.hg_rev_variation' in grains %}
         - rev: {{ grains['ami.hg_rev_variation'] }}
 {% endif %}
@@ -37,12 +37,3 @@
 {% endif %}
 
 
-{% if 'ami.hg_rev_variation' not in grains %}
-ami.hg_rev_variation:
-  grains.present:
-{% if 'ami.hg_address_variation' in grains %}
-    - value: {{ salt['cmd.run']('hg identify --id ' + grains['ami.hg_address_variation']) }} 
-{% else %}
-    - value: {{ salt['cmd.run']('hg identify --id ' + default_address) }} 
-{% endif %}
-{% endif %}