'Deletes all inventory records for a resource provider with the
supplied UUID.
First attempt to DELETE the inventory using microversion 1.5. If
this results in a 406, fail over to a PUT.'

@safe_connect
def _delete_inventory(self, rp_uuid):

    curr = self._get_inventory_and_update_provider_generation(rp_uuid)
    if (not curr.get('inventories', {})):
        msg = 'No    inventory    to    delete    from    resource    provider    %s.'
        LOG.debug(msg, rp_uuid)
        return
    msg = _LI('Compute    node    %s    reported    no    inventory    but    previous    inventory    was    detected.    Deleting    existing    inventory    records.')
    LOG.info(msg, rp_uuid)
    url = ('/resource_providers/%s/inventories' % rp_uuid)
    r = self.delete(url, version='1.5')
    placement_req_id = get_placement_request_id(r)
    cur_rp_gen = self._resource_providers[rp_uuid]['generation']
    msg_args = {'rp_uuid': rp_uuid, 'placement_req_id': placement_req_id}
    if (r.status_code == 406):
        LOG.debug('Falling    back    to    placement    API    microversion    1.0    for    deleting    all    inventory    for    a    resource    provider.')
        payload = {'resource_provider_generation': cur_rp_gen, 'inventories': {}}
        r = self.put(url, payload)
        placement_req_id = get_placement_request_id(r)
        msg_args['placement_req_id'] = placement_req_id
        if (r.status_code == 200):
            updated_inv = r.json()
            new_gen = updated_inv['resource_provider_generation']
            self._resource_providers[rp_uuid]['generation'] = new_gen
            msg_args['generation'] = new_gen
            LOG.info(_LI('[%(placement_req_id)s]    Deleted    all    inventory    for    resource    provider    %(rp_uuid)s    at    generation    %(generation)i.'), msg_args)
            return
    if (r.status_code == 204):
        self._resource_providers[rp_uuid]['generation'] = (cur_rp_gen + 1)
        LOG.info(_LI('[%(placement_req_id)s]    Deleted    all    inventory    for    resource    provider    %(rp_uuid)s.'), msg_args)
        return
    elif (r.status_code == 404):
        LOG.debug('[%(placement_req_id)s]    Resource    provider    %(rp_uuid)s    deleted    by    another    thread    when    trying    to    delete    inventory.    Ignoring.', msg_args)
        self._resource_providers.pop(rp_uuid, None)
        self._provider_aggregate_map.pop(rp_uuid, None)
        return
    elif (r.status_code == 409):
        rc_str = _extract_inventory_in_use(r.text)
        if (rc_str is not None):
            msg = _LW('[%(placement_req_id)s]    We    cannot    delete    inventory    %(rc_str)s    for    resource    provider    %(rp_uuid)s    because    the    inventory    is    in    use.')
            msg_args['rc_str'] = rc_str
            LOG.warning(msg, msg_args)
            return
    msg = _LE('[%(placement_req_id)s]    Failed    to    delete    inventory    for    resource    provider    %(rp_uuid)s.    Got    error    response:    %(err)s.')
    msg_args['err'] = r.text
    LOG.error(msg, msg_args)
