'Update the inventory for this resource provider if needed.
:param rp_uuid: The resource provider UUID for the operation
:param inv_data: The new inventory for the resource provider
:returns: True if the inventory was updated (or did not need to be),
False otherwise.'

def _update_inventory_attempt(self, rp_uuid, inv_data):

    curr = self._get_inventory_and_update_provider_generation(rp_uuid)
    if (inv_data == curr.get('inventories', {})):
        return True
    cur_rp_gen = self._resource_providers[rp_uuid]['generation']
    payload = {'resource_provider_generation': cur_rp_gen, 'inventories': inv_data}
    url = ('/resource_providers/%s/inventories' % rp_uuid)
    result = self.put(url, payload)
    if (result.status_code == 409):
        LOG.info(_LI('[%(placement_req_id)s]    Inventory    update    conflict    for    %(resource_provider_uuid)s    with    generation    ID    %(generation_id)s'), {'placement_req_id': get_placement_request_id(result), 'resource_provider_uuid': rp_uuid, 'generation_id': cur_rp_gen})
        match = _RE_INV_IN_USE.search(result.text)
        if match:
            rc = match.group(1)
            raise exception.InventoryInUse(resource_classes=rc, resource_provider=rp_uuid)
        del self._resource_providers[rp_uuid]
        self._ensure_resource_provider(rp_uuid)
        return False
    elif (not result):
        placement_req_id = get_placement_request_id(result)
        LOG.warning(_LW('[%(placement_req_id)s]    Failed    to    update    inventory    for    resource    provider    %(uuid)s:    %(status)i    %(text)s'), {'placement_req_id': placement_req_id, 'uuid': rp_uuid, 'status': result.status_code, 'text': result.text})
        LOG.debug('[%(placement_req_id)s]    Failed    inventory    update    request    for    resource    provider    %(uuid)s    with    body:    %(payload)s', {'placement_req_id': placement_req_id, 'uuid': rp_uuid, 'payload': payload})
        return False
    if (result.status_code != 200):
        placement_req_id = get_placement_request_id(result)
        LOG.info(_LI('[%(placement_req_id)s]    Received    unexpected    response    code    %(code)i    while    trying    to    update    inventory    for    resource    provider    %(uuid)s:    %(text)s'), {'placement_req_id': placement_req_id, 'uuid': rp_uuid, 'code': result.status_code, 'text': result.text})
        return False
    updated_inventories_result = result.json()
    new_gen = updated_inventories_result['resource_provider_generation']
    self._resource_providers[rp_uuid]['generation'] = new_gen
    LOG.debug('Updated    inventory    for    %s    at    generation    %i', rp_uuid, new_gen)
    return True
