[openstack] change upload to add a description string providing the mercurial repo and revision used to create it\n (similar to what is done for aws)
--- a/_modules/openstack_client.py Wed Nov 27 16:22:39 2013 +0100
+++ b/_modules/openstack_client.py Wed Nov 27 20:00:28 2013 +0100
@@ -75,7 +75,7 @@
print output_add
return True
-def upload_to_glance(path):
+def upload_to_glance(path, description=''):
log.info('will now try to upload to glance server')
ami_name = __salt__['grains.get']('ami.name')
if not ami_name:
@@ -97,9 +97,14 @@
if ok_for_image:
o_path = _find_objects(path,'.img')
if len(o_path) == 1:
- image_id = __salt__['openstack_client.upload_file'](
- o_path[0], 'ami', 'kernel_id=' + object_id['kernel'] +
- ' ramdisk_id=' + object_id['ramdisk'], image_name=ami_name)
+ other_params = 'kernel_id=%s ramdisk_id=%s' % (object_id['kernel'],
+ object_id['ramdisk'])
+ if description:
+ other_params += ' description="%s"' % description.replace('"',"'")
+ image_id = __salt__['openstack_client.upload_file'](o_path[0],
+ 'ami',
+ other_params=other_params,
+ image_name=ami_name)
return image_id
return False
--- a/ami_post/upload.sls Wed Nov 27 16:22:39 2013 +0100
+++ b/ami_post/upload.sls Wed Nov 27 20:00:28 2013 +0100
@@ -2,6 +2,9 @@
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 %}
- path: /mnt/output
- require:
- tmp_state.resized: resize_variation