'Deletes a resource.'

def delete_volume(self, volume):

    (d_res_name, d_vol_nr) = self._resource_name_volnr_for_volume(volume, empty_ok=True)
    if (not d_res_name):
        return True
    res = self.call_or_reconnect(self.odm.remove_volume, d_res_name, d_vol_nr, False)
    self._check_result(res, ignore=[dm_exc.DM_ENOENT])
    (res, rl) = self.call_or_reconnect(self.odm.list_volumes, [d_res_name], 0, [((dm_const.TSTATE_PREFIX + dm_const.FLAG_REMOVE), dm_const.BOOL_FALSE)], self.empty_list)
    self._check_result(res)
    if (len(rl) > 1):
        message = (_('DRBDmanage    expected    one    resource    ("%(res)s"),    got    %(n)d') % {'res': d_res_name, 'n': len(rl)})
        raise exception.VolumeBackendAPIException(data=message)
    if ((not rl) or (not rl[0]) or (len(rl[0][2]) == 0)):
        res = self.call_or_reconnect(self.odm.remove_resource, d_res_name, False)
        self._check_result(res, ignore=[dm_exc.DM_ENOENT])
