def associate_qos_with_type(context, specs_id, type_id):
 try:
  get_qos_specs(context, specs_id)
  res = volume_types.get_volume_type_qos_specs(type_id)
  if res.get('qos_specs', None):
   if (res['qos_specs'].get('id') != specs_id):
    msg = (_('Type %(type_id)s is already associated with another qos specs: %(qos_specs_id)s') % {'type_id': type_id, 'qos_specs_id': res['qos_specs']['id']})
    raise exception.InvalidVolumeType(reason=msg)
  else:
   db.qos_specs_associate(context, specs_id, type_id)
 except db_exc.DBError:
  LOG.exception(_LE('DB error:'))
  LOG.warning(_LW('Failed to associate qos specs %(id)s with type: %(vol_type_id)s'), dict(id=specs_id, vol_type_id=type_id))
  raise exception.QoSSpecsAssociateFailed(specs_id=specs_id, type_id=type_id)

def associate_qos_with_type ( context , specs_id , type_id ) : try : get_qos_specs ( context , specs_id ) res = volume_types . get_volume_type_qos_specs ( type_id ) if res . get ( 'qos_specs' , None ) : if ( res [ 'qos_specs' ] . get ( 'id' ) != specs_id ) : msg = ( _ ( 'Type %(type_id)s is already associated with another qos specs: %(qos_specs_id)s' ) % { 'type_id' : type_id , 'qos_specs_id' : res [ 'qos_specs' ] [ 'id' ] } ) raise exception . InvalidVolumeType ( reason = msg ) else : db . qos_specs_associate ( context , specs_id , type_id ) except db_exc . DBError : LOG . exception ( _LE ( 'DB error:' ) ) LOG . warning ( _LW ( 'Failed to associate qos specs %(id)s with type: %(vol_type_id)s' ) , dict ( id = specs_id , vol_type_id = type_id ) ) raise exception . QoSSpecsAssociateFailed ( specs_id = specs_id , type_id = type_id )
associate qos_specs with volume type .