bug corrections and renamed initrd to ramdisk and vmlinuz to kernel when possible
authorPaul Tonelli <paul.tonelli@logilab.fr>
Tue, 12 Mar 2013 17:31:13 +0100
changeset 69 03a191bfee6f
parent 68 601c145e6326
child 70 afe92adc13cc
bug corrections and renamed initrd to ramdisk and vmlinuz to kernel when possible
_modules/vm_create.py
ami_creator_post.sls
readme.txt
--- a/_modules/vm_create.py	Tue Mar 12 16:32:57 2013 +0100
+++ b/_modules/vm_create.py	Tue Mar 12 17:31:13 2013 +0100
@@ -68,25 +68,26 @@
 def upload_to_glance(path):
     log.info('will now try to upload to glance server')
     object_id = {}
-    object_types = {'kernel':'aki','initrd':'ari'}
+    object_types = {'kernel':'aki','ramdisk':'ari'}
     ok_for_image = True
     for o_type in object_types:
-        object_id[o_type] = __salt__['grains.item'](+'_id')
+        object_id[o_type] = __salt__['grains.item'](o_type + '_id')
         if object_id[o_type]:
             object_id[o_type] = object_id[o_type].values()[0]
         else:
-            o_path = _find_objects(path, object_types[o_type])
+            o_path = _find_objects(path, o_type)
             if len(o_path) == 1:
                 object_id[o_type] = __salt__['openstack_client.upload_to_glance'](
                         o_path[0], object_types[o_type], '')
             else:
+                log.error('no ' + object_types[o_type] + ' found in ' + path)
                 ok_for_image = False
     if ok_for_image:
-        o_path = _find_objects(path, object_types['.img'])
+        o_path = _find_objects(path,'.img')
         if len(o_path) == 1:
             image_id = __salt__['openstack_client.upload_to_glance'](
                  o_path[0], 'ami', 'kernel_id=' + object_id['kernel'] +
-                 ' ramdisk_id=' + object_id['initrd'])
+                 ' ramdisk_id=' + object_id['ramdisk'])
         return image_id
     return False
 
@@ -100,5 +101,5 @@
 def _find_objects(path, substring):
     object_names = [element for element in listdir(path)
             if substring in element]
-    return object_names
+    return [path + '/' + element for element in object_names]
 
--- a/ami_creator_post.sls	Tue Mar 12 16:32:57 2013 +0100
+++ b/ami_creator_post.sls	Tue Mar 12 17:31:13 2013 +0100
@@ -43,14 +43,14 @@
 {% for file in salt['file.find'](chroot + '/boot/', iname='vmlinuz*') %}
 kernel:
     tmp_state.local_managed:
-        - name: /mnt/vmlinuz_variation
+        - name: /mnt/kernel_variation
         - source: {{ file }}
 {% endfor %}
 
 {% for file in salt['file.find'](chroot + '/boot/', iname='initrd*') %}
 initrd:
     tmp_state.local_managed:
-        - name: /mnt/initrd_variation
+        - name: /mnt/ramdisk_variation
         - source: {{ file }}
 {% endfor %}
 
--- a/readme.txt	Tue Mar 12 16:32:57 2013 +0100
+++ b/readme.txt	Tue Mar 12 17:31:13 2013 +0100
@@ -27,12 +27,12 @@
 keystone.password: ptonelli
 keystone.tenant: ptonelli
 keystone.tenant_id: 7050e8e884414ef985826434c52d93f3
-keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
+keystone.auth_url: 'http://control.openstack.logilab.fr:5000/v2.0'
 keystone.insecure: False   #(optional)
 
 ### only if you know what you are doing ! ###
 kernel_id:a5b900bd-c009-40b2-a763-32b32996b1ee
-ramdisk_id:b953e40a-2605-402b-8663-c8556a5899f2
+initrd_id:b953e40a-2605-402b-8663-c8556a5899f2
 
 ====== END ========
 
@@ -43,10 +43,10 @@
 include your credentials by downloading and running openrc.sh):
 
 glance add is_public=false disk_format=aki container_format=aki \
-name=variation-kernel < vmlinuz_variation
+name=variation_kernel < kernel_variation
 
 glance add is_public=false disk_format=ari container_format=ari \
-name=variation-ramdisk < initrd_variation
+name=variation_ramdisk < ramdisk_variation
 
 glance add disk_format=ami container_format=ami name="variation-amd64" \
 kernel_id=278de93c-5276-410f-a221-667cc1443cf8 \