def _set_properties_for_image(context, image_ref, properties, purge_props=False, session=None):
 orig_properties = {}
 for prop_ref in image_ref.properties:
  orig_properties[prop_ref.name] = prop_ref
 for (name, value) in properties.iteritems():
  prop_values = {'image_id': image_ref.id, 'name': name, 'value': value}
  if (name in orig_properties):
   prop_ref = orig_properties[name]
   _image_property_update(context, prop_ref, prop_values, session=session)
  else:
   image_property_create(context, prop_values, session=session)
 if purge_props:
  for key in orig_properties.keys():
   if (key not in properties):
    prop_ref = orig_properties[key]
    image_property_delete(context, prop_ref, session=session)

def _set_properties_for_image ( context , image_ref , properties , purge_props = False , session = None ) : orig_properties = { } for prop_ref in image_ref . properties : orig_properties [ prop_ref . name ] = prop_ref for ( name , value ) in properties . iteritems ( ) : prop_values = { 'image_id' : image_ref . id , 'name' : name , 'value' : value } if ( name in orig_properties ) : prop_ref = orig_properties [ name ] _image_property_update ( context , prop_ref , prop_values , session = session ) else : image_property_create ( context , prop_values , session = session ) if purge_props : for key in orig_properties . keys ( ) : if ( key not in properties ) : prop_ref = orig_properties [ key ] image_property_delete ( context , prop_ref , session = session )
create or update a set of image_properties for a given image .