예제 #1
0
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)
        self.log.warn(
            "Deprecated, prefer using 'openio rdir assignments rawx'.")

        all_rawx, all_rdir = \
            self.app.client_manager.volume.rdir_lb.get_assignments(
                    'rawx', connection_timeout=30.0, read_timeout=90.0)

        results = list()
        if not parsed_args.aggregated:
            columns, results = _format_assignments(all_rawx, 'Rawx')
        else:
            dummy_rdir = {"addr": "n/a", "tags": {}}
            rdir_by_id = dict()
            for rawx in all_rawx:
                rdir = rawx.get('rdir', dummy_rdir)
                rdir_id = rdir['tags'].get('tag.service_id') or rdir['addr']
                rdir_by_id[rdir_id] = rdir
                managed_rawx = rdir.get('managed_rawx') or list()
                rawx_id = rawx['tags'].get('tag.service_id') or rawx['addr']
                managed_rawx.append(rawx_id)
                rdir['managed_rawx'] = managed_rawx
            for rdir in all_rdir:
                rdir_id = rdir['tags'].get('tag.service_id') or rdir['addr']
                if rdir_id not in rdir_by_id:
                    rdir['managed_rawx'] = list()
                    rdir_by_id[rdir_id] = rdir
            for addr, rdir in iteritems(rdir_by_id):
                results.append((addr, len(rdir['managed_rawx']),
                                ' '.join(rdir['managed_rawx'])))
            results.sort()
            columns = ('Rdir', 'Number of bases', 'Bases')
        return columns, results
예제 #2
0
    def take_action(self, parsed_args):
        self.log.debug('take_action(%s)', parsed_args)
        self.log.warn("Deprecated, prefer using 'openio rdir bootstrap rawx'.")

        try:
            all_rawx = self.app.client_manager.volume.rdir_lb.assign_all_rawx(
                parsed_args.max_per_rdir,
                connection_timeout=30.0,
                read_timeout=90.0)
        except OioException as exc:
            self.success = False
            self.log.warn("Failed to assign all rawx: %s", exc)
            all_rawx, _ = \
                self.app.client_manager.volume.rdir_lb.get_assignments(
                        'rawx', connection_timeout=30.0, read_timeout=90.0)

        columns, results = _format_assignments(all_rawx, 'Rawx')
        return columns, results