def create_image_metadata(data):
 disk_format = data['disk_format']
 if (disk_format in ('ami', 'aki', 'ari')):
  container_format = disk_format
 elif (disk_format == 'docker'):
  disk_format = 'raw'
  container_format = 'docker'
 else:
  container_format = 'bare'
 meta = {'protected': data['protected'], 'disk_format': disk_format, 'container_format': container_format, 'min_disk': (data['minimum_disk'] or 0), 'min_ram': (data['minimum_ram'] or 0), 'name': data['name']}
 is_public = data.get('is_public', data.get('public', False))
 properties = {}
 if data.get('description'):
  properties['description'] = data['description']
 if data.get('kernel'):
  properties['kernel_id'] = data['kernel']
 if data.get('ramdisk'):
  properties['ramdisk_id'] = data['ramdisk']
 if data.get('architecture'):
  properties['architecture'] = data['architecture']
 if (api.glance.VERSIONS.active < 2):
  meta.update({'is_public': is_public, 'properties': properties})
 else:
  meta['visibility'] = ('public' if is_public else 'private')
  meta.update(properties)
 return meta

def create_image_metadata ( data ) : disk_format = data [ 'disk_format' ] if ( disk_format in ( 'ami' , 'aki' , 'ari' ) ) : container_format = disk_format elif ( disk_format == 'docker' ) : disk_format = 'raw' container_format = 'docker' else : container_format = 'bare' meta = { 'protected' : data [ 'protected' ] , 'disk_format' : disk_format , 'container_format' : container_format , 'min_disk' : ( data [ 'minimum_disk' ] or 0 ) , 'min_ram' : ( data [ 'minimum_ram' ] or 0 ) , 'name' : data [ 'name' ] } is_public = data . get ( 'is_public' , data . get ( 'public' , False ) ) properties = { } if data . get ( 'description' ) : properties [ 'description' ] = data [ 'description' ] if data . get ( 'kernel' ) : properties [ 'kernel_id' ] = data [ 'kernel' ] if data . get ( 'ramdisk' ) : properties [ 'ramdisk_id' ] = data [ 'ramdisk' ] if data . get ( 'architecture' ) : properties [ 'architecture' ] = data [ 'architecture' ] if ( api . glance . VERSIONS . active < 2 ) : meta . update ( { 'is_public' : is_public , 'properties' : properties } ) else : meta [ 'visibility' ] = ( 'public' if is_public else 'private' ) meta . update ( properties ) return meta
use the given dict of image form data to generate the metadata used for creating the image in glance .