def _add_inventory_to_provider(conn, rp, inv_list, to_add):
 for rc_id in to_add:
  rc_str = _RC_CACHE.string_from_id(rc_id)
  inv_record = inv_list.find(rc_str)
  if (inv_record.capacity <= 0):
   raise exception.InvalidInventoryCapacity(resource_class=rc_str, resource_provider=rp.uuid)
  ins_stmt = _INV_TBL.insert().values(resource_provider_id=rp.id, resource_class_id=rc_id, total=inv_record.total, reserved=inv_record.reserved, min_unit=inv_record.min_unit, max_unit=inv_record.max_unit, step_size=inv_record.step_size, allocation_ratio=inv_record.allocation_ratio)
  conn.execute(ins_stmt)

def _add_inventory_to_provider ( conn , rp , inv_list , to_add ) : for rc_id in to_add : rc_str = _RC_CACHE . string_from_id ( rc_id ) inv_record = inv_list . find ( rc_str ) if ( inv_record . capacity <= 0 ) : raise exception . InvalidInventoryCapacity ( resource_class = rc_str , resource_provider = rp . uuid ) ins_stmt = _INV_TBL . insert ( ) . values ( resource_provider_id = rp . id , resource_class_id = rc_id , total = inv_record . total , reserved = inv_record . reserved , min_unit = inv_record . min_unit , max_unit = inv_record . max_unit , step_size = inv_record . step_size , allocation_ratio = inv_record . allocation_ratio ) conn . execute ( ins_stmt )
inserts new inventory records for the supplied resource provider .