Source code for oio.cli.volume.client

# Copyright (C) 2015-2017 OpenIO SAS, as part of OpenIO SDS
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <>.

from logging import getLogger

LOG = getLogger(__name__)

API_NAME = 'volume'

[docs]class VolumeClientCli(object): def __init__(self, namespace, **kwargs): self.conf = {'namespace': namespace} self.conf.update(kwargs) self._rdir = None self._rdir_lb = None @property def volume(self): if not self._rdir: from oio.rdir.client import RdirClient self._rdir = RdirClient(self.conf) return self._rdir @property def rdir_lb(self): if not self._rdir_lb: from oio.rdir.client import RdirDispatcher self._rdir_lb = RdirDispatcher(self.conf) return self._rdir_lb
[docs] def volume_admin_show(self, volume): return self.volume.admin_show(volume)
[docs] def volume_admin_clear(self, volume, **kwargs): return self.volume.admin_clear(volume, **kwargs)
[docs] def volume_show(self, volume, **kwargs): from oio.common.json import json info = self.volume.status(volume, **kwargs) data = {} containers = info.get('container') data['chunk'] = info.get('chunk') for ct in containers: data['container.%s' % ct] = json.dumps(containers[ct]) return data
[docs] def volume_admin_lock(self, volume, key): return self.volume.admin_lock(volume, key)
[docs] def volume_admin_unlock(self, volume): return self.volume.admin_unlock(volume)
[docs] def volume_admin_incident(self, volume, date): return self.volume.admin_incident_set(volume, date)
[docs]def make_client(instance): """ Build a VolumeClientCli that will be added as "volume" field of `instance`. :param instance: an instance of ClientManager :returns: an instance of VolumeClientCli """ client = VolumeClientCli( **instance.cli_conf() ) return client