code cleaning
authorPaul Tonelli <paul.tonelli@logilab.fr>
Tue, 05 Mar 2013 14:39:46 +0100
changeset 19 4229d57223fe
parent 18 4239da26bf7c
child 20 b72d3743bad6
code cleaning
_modules/openstack_client.py
_modules/vm_create.py
--- a/_modules/openstack_client.py	Tue Mar 05 14:39:30 2013 +0100
+++ b/_modules/openstack_client.py	Tue Mar 05 14:39:46 2013 +0100
@@ -52,10 +52,10 @@
 
 def delete_image(id_image):
     '''
-    delete image from glance 
-     
+    delete image from glance
+
     CLI Example::
-      
+
         salt '*'  openstack_client.delete_image\
                 00000000-0000-0000-0000-000000000000
     '''
@@ -77,14 +77,14 @@
 #            print i + " : " + pillars_val[i]
 #    return True
 
-def upload_to_glance(path, filename, disk_format, other_params, 
+def upload_to_glance(path, filename, disk_format, other_params,
         image_name=None):
     g_client = _auth_glance()
     if image_name == None:
         image_name = filename.replace(".img","")
     #glance upload initrd, kernel and get ids
     print "sending "+ disk_format + " to glance"
-    output_add = __salt__['cmd.run']("glance add is_public=false disk_format=" 
+    output_add = __salt__['cmd.run']("glance add is_public=false disk_format="
             + disk_format + " container_format=" + disk_format + " name=\""
             + image_name + "\" " + other_params + " < " + path + "/" + filename)
     id_image = output_add.split("ID: ")[1].split('\n')[0]
@@ -143,7 +143,7 @@
     '''
 
     nt_ks = _auth_nova()
-    matching_instances = [machine for machine in nt_ks.servers.list() 
+    matching_instances = [machine for machine in nt_ks.servers.list()
             if item.nk.servers.list()[0].human_id == human_id]
     if len(matching_instances) == 1:
         machine = matching_instances[0]
--- a/_modules/vm_create.py	Tue Mar 05 14:39:30 2013 +0100
+++ b/_modules/vm_create.py	Tue Mar 05 14:39:46 2013 +0100
@@ -182,6 +182,7 @@
     image_dirname = DEFAULT_MOUNT_DIR
     ### Exec pre state here ###
     #update_image(path + '/' + image_dirname)
+    log.info(__salt__['state.sls']('ami_creator_pre')
     #variate_image(path + '/' + image_dirname, variation_filename)
     #kernel_name, ramdisk_name = get_initrd_kernel(path, image_dirname)
     kernel_name = "vmlinuz_" + DEFAULT_MOUNT_DIR
@@ -189,6 +190,7 @@
     #clean_images(path,image_dirname)
     #umount_images(path)
     #resize_and_check(path, image_name)
+    log.info(__salt__['state.sls']('ami_creator_post')
     if bool(upload_to_glance):
         log.info('will now upload to glance server')
         id_kernel = __salt__['openstack_client.upload_to_glance'](