@handle_db_data_error
@require_admin_context
def qos_specs_update(context, qos_specs_id, updates):
 session = get_session()
 with session.begin():
  _qos_specs_get_all_ref(context, qos_specs_id, session)
  specs = updates.get('specs', {})
  if ('consumer' in updates):
   specs = specs.copy()
   specs['consumer'] = updates['consumer']
  spec_ref = None
  for key in specs.keys():
   try:
    spec_ref = _qos_specs_get_item(context, qos_specs_id, key, session)
   except exception.QoSSpecsKeyNotFound:
    spec_ref = models.QualityOfServiceSpecs()
   id = None
   if spec_ref.get('id', None):
    id = spec_ref['id']
   else:
    id = str(uuid.uuid4())
   value = dict(id=id, key=key, value=specs[key], specs_id=qos_specs_id, deleted=False)
   LOG.debug('qos_specs_update() value: %s', value)
   spec_ref.update(value)
   spec_ref.save(session=session)
  return specs

@ handle_db_data_error @ require_admin_context def qos_specs_update ( context , qos_specs_id , updates ) : session = get_session ( ) with session . begin ( ) : _qos_specs_get_all_ref ( context , qos_specs_id , session ) specs = updates . get ( 'specs' , { } ) if ( 'consumer' in updates ) : specs = specs . copy ( ) specs [ 'consumer' ] = updates [ 'consumer' ] spec_ref = None for key in specs . keys ( ) : try : spec_ref = _qos_specs_get_item ( context , qos_specs_id , key , session ) except exception . QoSSpecsKeyNotFound : spec_ref = models . QualityOfServiceSpecs ( ) id = None if spec_ref . get ( 'id' , None ) : id = spec_ref [ 'id' ] else : id = str ( uuid . uuid4 ( ) ) value = dict ( id = id , key = key , value = specs [ key ] , specs_id = qos_specs_id , deleted = False ) LOG . debug ( 'qos_specs_update() value: %s' , value ) spec_ref . update ( value ) spec_ref . save ( session = session ) return specs
make updates to an existing qos specs .