Exemple #1
0
    def take_action(self, parsed_args):
        from oio.common.easy_value import convert_size
        self.log.debug('take_action(%s)', parsed_args)

        account = self.app.client_manager.account
        self.take_action_container(parsed_args)
        # The command is named 'show' but we must call
        # container_get_properties() because container_show() does
        # not return system properties (and we need them).
        data = self.app.client_manager.storage.container_get_properties(
            account,
            parsed_args.container,
            cid=parsed_args.cid,
            admin_mode=True)
        sys = data['system']
        ctime = float(sys[M2_PROP_CTIME]) / 1000000.
        bytes_usage = sys.get(M2_PROP_USAGE, 0)
        objects = sys.get(M2_PROP_OBJECTS, 0)
        damaged_objects = sys.get(M2_PROP_DAMAGED_OBJECTS, 0)
        missing_chunks = sys.get(M2_PROP_MISSING_CHUNKS, 0)
        if parsed_args.formatter == 'table':
            ctime = int(ctime)
            bytes_usage = convert_size(int(bytes_usage), unit="B")
            objects = convert_size(int(objects))
        info = {
            'account': sys['sys.account'],
            'base_name': sys['sys.name'],
            'container': sys['sys.user.name'],
            'ctime': ctime,
            'bytes_usage': bytes_usage,
            'quota': sys.get(M2_PROP_QUOTA, "Namespace default"),
            'objects': objects,
            'damaged_objects': damaged_objects,
            'missing_chunks': missing_chunks,
            'storage_policy': sys.get(M2_PROP_STORAGE_POLICY,
                                      "Namespace default"),
            'max_versions': sys.get(M2_PROP_VERSIONING_POLICY,
                                    "Namespace default"),
            'status': OIO_DB_STATUS_NAME.get(sys.get('sys.status'), "Unknown"),
        }

        for k in ('stats.page_count', 'stats.freelist_count',
                  'stats.page_size'):
            info[k] = sys.get(k)
        wasted = (float_value(info['stats.freelist_count'], 0) /
                  float_value(info['stats.page_count'], 1))
        wasted_bytes = (int_value(info['stats.freelist_count'], 0) *
                        int_value(info['stats.page_size'], 0))
        info['stats.space_wasted'] = "%5.2f%% (est. %s)" % \
            (wasted * 100, convert_size(wasted_bytes))

        bucket = sys.get(M2_PROP_BUCKET_NAME, None)
        if bucket is not None:
            info['bucket'] = bucket
        delete_exceeding = sys.get(M2_PROP_DEL_EXC_VERSIONS, None)
        if delete_exceeding is not None:
            info['delete_exceeding_versions'] = delete_exceeding != '0'
        for k, v in iteritems(data['properties']):
            info['meta.' + k] = v
        return list(zip(*sorted(info.items())))
Exemple #2
0
    def _test_create_with_status(self, status=None):
        def _status(_data):
            return _data['system']['sys.status']

        params = self.param_ref(self.ref)
        headers = {}
        headers['x-oio-action-mode'] = 'autocreate'
        headers['Content-Type'] = 'application/json'
        if status:
            data = ('{"properties":{},' +
                    '"system":{"sys.status": "%d"}}' % status)
        else:
            data = None
            status = OIO_DB_ENABLED

        resp = self.request('POST', self.url_container('create'),
                            params=params,
                            data=data,
                            headers=headers)
        self.assertEqual(resp.status, 201)

        resp = self.request('POST', self.url_container('get_properties'),
                            params=params)
        data = self.json_loads(resp.data)
        self.assertEqual(OIO_DB_STATUS_NAME.get(_status(data), "Unknown"),
                         OIO_DB_STATUS_NAME[status])
Exemple #3
0
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)

        account = self.app.client_manager.account
        self.take_action_container(parsed_args)
        # The command is named 'show' but we must call
        # container_get_properties() because container_show() does
        # not return system properties (and we need them).
        data = self.app.client_manager.storage.container_get_properties(
            account,
            parsed_args.container,
            cid=parsed_args.cid
        )

        sys = data['system']
        ctime = float(sys['sys.m2.ctime']) / 1000000.
        bytes_usage = sys.get('sys.m2.usage', 0)
        objects = sys.get('sys.m2.objects', 0)
        damaged_objects = sys.get('sys.m2.objects.damaged', 0)
        missing_chunks = sys.get('sys.m2.chunks.missing', 0)
        if parsed_args.formatter == 'table':
            from oio.common.easy_value import convert_size

            ctime = int(ctime)
            bytes_usage = convert_size(int(bytes_usage), unit="B")
            objects = convert_size(int(objects))
        info = {
            'account': sys['sys.account'],
            'base_name': sys['sys.name'],
            'container': sys['sys.user.name'],
            'ctime': ctime,
            'bytes_usage': bytes_usage,
            'quota': sys.get('sys.m2.quota', "Namespace default"),
            'objects': objects,
            'damaged_objects': damaged_objects,
            'missing_chunks': missing_chunks,
            'storage_policy': sys.get('sys.m2.policy.storage',
                                      "Namespace default"),
            'max_versions': sys.get('sys.m2.policy.version',
                                    "Namespace default"),
            'status': OIO_DB_STATUS_NAME.get(sys.get('sys.status'), "Unknown"),
        }
        delete_exceeding = sys.get('sys.m2.policy.version.delete_exceeding',
                                   None)
        if delete_exceeding is not None:
            info['delete_exceeding_versions'] = delete_exceeding != '0'
        for k, v in data['properties'].iteritems():
            info['meta.' + k] = v
        return zip(*sorted(info.iteritems()))
Exemple #4
0
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)

        account = self.app.client_manager.account
        container = parsed_args.container

        data = self.app.client_manager.storage.container_get_properties(
            account, container)

        data_dir = self.app.client_manager.storage.directory.list(
            account, container)

        info = {
            'account':
            data['system']['sys.account'],
            'base_name':
            data['system']['sys.name'],
            'name':
            data['system']['sys.user.name'],
            'meta0':
            list(),
            'meta1':
            list(),
            'meta2':
            list(),
            'status':
            OIO_DB_STATUS_NAME.get(data['system'].get('sys.status'),
                                   "Unknown"),
        }

        for d in data_dir['srv']:
            if d['type'] == 'meta2':
                info['meta2'].append(d['host'])

        for d in data_dir['dir']:
            if d['type'] == 'meta0':
                info['meta0'].append(d['host'])
            if d['type'] == 'meta1':
                info['meta1'].append(d['host'])

        for stype in ["meta0", "meta1", "meta2"]:
            info[stype] = ', '.join(info[stype])
        return list(zip(*sorted(info.items())))
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)
        self.take_action_container(parsed_args)

        account = self.app.client_manager.account
        container = parsed_args.container
        cid = parsed_args.cid
        m2_sys = self.app.client_manager.storage.container_get_properties(
            account, container, cid=cid)['system']

        data_dir = self.app.client_manager.storage.directory.list(account,
                                                                  container,
                                                                  cid=cid)

        info = {
            'account': m2_sys['sys.account'],
            'base_name': m2_sys['sys.name'],
            'name': m2_sys['sys.user.name'],
            'meta0': list(),
            'meta1': list(),
            'meta2': list(),
            'meta2.sys.peers': list(),
            'status': OIO_DB_STATUS_NAME.get(m2_sys.get('sys.status'),
                                             "Unknown"),
        }

        for d in data_dir['srv']:
            if d['type'] == 'meta2':
                info['meta2'].append(d['host'])

        for peer in m2_sys.get('sys.peers', 'Unknown').split(','):
            info['meta2.sys.peers'].append(peer)

        for d in data_dir['dir']:
            if d['type'] == 'meta0':
                info['meta0'].append(d['host'])
            if d['type'] == 'meta1':
                info['meta1'].append(d['host'])

        for stype in ["meta0", "meta1", "meta2", 'meta2.sys.peers']:
            info[stype] = ', '.join(info[stype])
        return list(zip(*sorted(info.items())))