@require_context
@require_volume_exists
def volume_glance_metadata_create(context, volume_id, key, value, session=None):
 if (session is None):
  session = get_session()
 with session.begin():
  rows = session.query(models.VolumeGlanceMetadata).filter_by(volume_id=volume_id).filter_by(key=key).filter_by(deleted=False).all()
  if (len(rows) > 0):
   raise exception.GlanceMetadataExists(key=key, volume_id=volume_id)
  vol_glance_metadata = models.VolumeGlanceMetadata()
  vol_glance_metadata.volume_id = volume_id
  vol_glance_metadata.key = key
  vol_glance_metadata.value = value
  vol_glance_metadata.save(session=session)
 return

@ require_context @ require_volume_exists def volume_glance_metadata_create ( context , volume_id , key , value , session = None ) : if ( session is None ) : session = get_session ( ) with session . begin ( ) : rows = session . query ( models . VolumeGlanceMetadata ) . filter_by ( volume_id = volume_id ) . filter_by ( key = key ) . filter_by ( deleted = False ) . all ( ) if ( len ( rows ) > 0 ) : raise exception . GlanceMetadataExists ( key = key , volume_id = volume_id ) vol_glance_metadata = models . VolumeGlanceMetadata ( ) vol_glance_metadata . volume_id = volume_id vol_glance_metadata . key = key vol_glance_metadata . value = value vol_glance_metadata . save ( session = session ) return
update the glance metadata for the specified volume .