update code to use new get function from salt #bf057b8f584bbcaf6adbcbce197cae6c74dae4a6
authorPaul Tonelli <paul.tonelli@logilab.fr>
Thu, 18 Apr 2013 11:46:37 +0200
changeset 115 063b9cbe5aa1
parent 114 79ef182dcc5e
child 116 41ee6c1162be
update code to use new get function from salt #bf057b8f584bbcaf6adbcbce197cae6c74dae4a6 (grains.items outputed a dict after salt update #4cdc6708f3128fb584e64e6d196b9990bd643169) needs salt > 0.13
_modules/openstack_client.py
_modules/vm_create.py
--- a/_modules/openstack_client.py	Mon Apr 15 14:54:19 2013 +0200
+++ b/_modules/openstack_client.py	Thu Apr 18 11:46:37 2013 +0200
@@ -27,13 +27,12 @@
     to use glance with cmd.run
     '''
     if id_elements == None:
-        print __salt__['grains.item']('keystone.auth_url')
-        id_elements={
-                'OS_AUTH_URL': __salt__['grains.item']('keystone.auth_url'),
-                'OS_TENANT_ID': __salt__['grains.item']('keystone.tenant_id'),
-                'OS_TENANT_NAME': __salt__['grains.item']('keystone.tenant'),
-                'OS_USERNAME': __salt__['grains.item']('keystone.user'),
-                'OS_PASSWORD': __salt__['grains.item']('keystone.password')
+        id_elements = {
+                'OS_AUTH_URL': __salt__['grains.get']('keystone.auth_url'),
+                'OS_TENANT_ID': __salt__['grains.get']('keystone.tenant_id'),
+                'OS_TENANT_NAME': __salt__['grains.get']('keystone.tenant'),
+                'OS_USERNAME': __salt__['grains.get']('keystone.user'),
+                'OS_PASSWORD': __salt__['grains.get']('keystone.password')
                 }
         for key in id_elements:
             if force_update or key not in environ:
--- a/_modules/vm_create.py	Mon Apr 15 14:54:19 2013 +0200
+++ b/_modules/vm_create.py	Thu Apr 18 11:46:37 2013 +0200
@@ -47,14 +47,14 @@
 
 def upload_to_glance(path):
     log.info('will now try to upload to glance server')
-    ami_name = __salt__['grains.item']('ami.name')
+    ami_name = __salt__['grains.get']('ami.name')
     if not ami_name:
         ami_name = "variation"
     object_id = {}
     object_types = {'kernel':'aki','ramdisk':'ari'}
     ok_for_image = True
     for o_type in object_types:
-        object_id[o_type] = __salt__['grains.item'](o_type + '_id')
+        object_id[o_type] = __salt__['grains.get'](o_type + '_id')
         if object_id[o_type]:
             object_id[o_type] = object_id[o_type].values()[0]
         else: