def take_action(self, parsed_args):
     data = fc_client.get_request('/clusters/git-repos/')
     if parsed_args.env:
         data = [entry for entry in data
                 if entry['env_id'] == parsed_args.env]
     data = data_utils.get_display_data_multi(self.columns, data)
     return (self.columns, data)
    def take_action(self, parsed_args):
        env_id = parsed_args.env
        if not env_id:
            repo_id = parsed_args.repo
            repos = fc_client.get_request('/clusters/git-repos/')
            env_id = [repo['env_id'] for repo in repos
                      if repo['id'] == repo_id][0]

        env = Environment(env_id)
        # Due to how Nailgun handles such tasks, returned
        # one will not contain any deployment-related data.
        # So we'll have to fetch the last noop task with progress < 100
        env.redeploy_changes(noop_run=True)
        for retry in xrange(TASK_RETRIES):
            tasks = Task.get_all()
            try:
                task = filter(lambda t: t.data['status'] == 'running' and
                              t.data['name'] == 'dry_run_deployment',
                              tasks).pop()
                break
            except IndexError:
                time.sleep(TASK_RETRY_DELAY)
                continue
        data = {'task_id': task.id}
        data = data_utils.get_display_data_multi(self.columns, [data])
        return (self.columns, data)
    def take_action(self, args):
        data = self.client.get_filtered(
            cluster_id=args.env, node_ids=args.node,
            node_role=args.role, is_active=(not args.deleted))
        data = data_utils.get_display_data_multi(self.columns, data)

        return self.columns, data
 def take_action(self, parsed_args):
     result = self.get_client().get(self.get_base_url(parsed_args))
     try:
         data = data_utils.get_display_data_multi(self.columns, result)
         return self.columns, data
     except fc_error.BadDataException:
         return zip(*result.items())
    def take_action(self, parsed_args):
        task_id = parsed_args.task
        if not task_id:
            all_tasks = Task.get_all()
            env_tasks = filter(
                lambda t: t.data['cluster'] == parsed_args.env and
                t.data['name'] == 'dry_run_deployment',
                all_tasks)
            env_tasks.sort(key=lambda t: t.data['time_start'])
            fuel_task = env_tasks[-1]
        else:
            fuel_task = Task(task_id)

        history = fuel_task.connection.get_request(
            ('transactions/{tid}/'
             'deployment_history?include_summary=1').format(tid=fuel_task.id)
        )
        changes = []
        changed_tasks = filter(lambda t: t['status'] != 'skipped' and
                               t.get('summary', {}) and
                               t['summary']['resources']['out_of_sync'] > 0,
                               history)
        for task in changed_tasks:
            name = task['task_name']
            for item in task['summary']['raw_report']:
                if 'Would have triggered' not in item['message'] and \
                    'Finished catalog run' not in item['message']:
                    short_item = item['source'].replace('/Stage[main]/', '')
                    changes.append({'task_id': name,
                                    'resource': short_item,
                                    'node_id': task['node_id']})

        data = data_utils.get_display_data_multi(self.columns, changes)
        return (self.columns, data)
Beispiel #6
0
    def take_action(self, parsed_args):
        model, model_id = self.parse_model(parsed_args)
        data = self.client.get_all(model, model_id)

        data = data_utils.get_display_data_multi(self.columns, data)
        data = self._sort_data(parsed_args, data)
        return self.columns, data
Beispiel #7
0
 def take_action(self, parsed_args):
     result = self.get_client().get(self.base_url)
     try:
         data = data_utils.get_display_data_multi(self.columns, result)
         return self.columns, data
     except fc_error.BadDataException:
         return zip(*result.items())
    def take_action(self, args):
        configs = self.client.upload(
            path=args.file, cluster_id=args.env,
            node_ids=args.node, node_role=args.role)

        data = [c.data for c in configs]
        data = data_utils.get_display_data_multi(self.columns, data)
        return self.columns, data
    def take_action(self, args):
        data = self.client.get_filtered(cluster_id=args.env,
                                        node_ids=args.node,
                                        node_role=args.role,
                                        is_active=(not args.deleted))
        data = data_utils.get_display_data_multi(self.columns, data)

        return self.columns, data
Beispiel #10
0
    def take_action(self, args):
        configs = self.client.upload(path=args.file,
                                     cluster_id=args.env,
                                     node_ids=args.node,
                                     node_role=args.role)

        data = data_utils.get_display_data_multi(self.columns, configs)
        return self.columns, data
 def take_action(self, parsed_args):
     data = fc_client.get_request('/clusters/git-repos/')
     if parsed_args.env:
         data = [
             entry for entry in data if entry['env_id'] == parsed_args.env
         ]
     data = data_utils.get_display_data_multi(self.columns, data)
     return (self.columns, data)
Beispiel #12
0
 def take_action(self, parsed_args):
     data = self.client.get_components_by_id(parsed_args.id)
     # some keys (columns) can be missed in origin data
     # then create them with respective '-' value
     data = [{k: self.retrieve_data(d.get(k, '-'))
              for k in self.columns} for d in data]
     data = data_utils.get_display_data_multi(self.columns, data)
     data = self._sort_data(parsed_args, data)
     return self.columns, data
Beispiel #13
0
    def take_action(self, parsed_args):
        data = self.client.get_all()
        data = data_utils.get_display_data_multi(self.columns, data)

        scolumn_ids = [self.columns.index(col)
                       for col in parsed_args.sort_columns]

        data.sort(key=lambda x: [x[scolumn_id] for scolumn_id in scolumn_ids])

        return (self.columns, data)
Beispiel #14
0
    def take_action(self, parsed_args):
        data = self.client.get_all()
        data = data_utils.get_display_data_multi(self.columns, data)

        scolumn_ids = [
            self.columns.index(col) for col in parsed_args.sort_columns
        ]

        data.sort(key=lambda x: [x[scolumn_id] for scolumn_id in scolumn_ids])

        return (self.columns, data)
Beispiel #15
0
    def take_action(self, parsed_args):
        filters = {}
        for name, prop in self.filters.items():
            value = getattr(parsed_args, prop, None)
            if value is not None:
                filters[name] = value

        data = self.client.get_all(**filters)
        data = data_utils.get_display_data_multi(self.columns, data)
        data = self._sort_data(parsed_args, data)

        return self.columns, data
Beispiel #16
0
 def take_action(self, parsed_args):
     # print parser
     show_parameters = parsed_args.show_parameters
     data = self.client.get_all(transaction_id=parsed_args.id,
                                nodes=parsed_args.nodes,
                                statuses=parsed_args.statuses,
                                tasks_names=parsed_args.tasks_names,
                                show_parameters=show_parameters)
     if show_parameters:
         self.columns = self.client.tasks_records_keys
     else:
         self.columns = self.client.history_records_keys
     data = data_utils.get_display_data_multi(self.columns, data)
     return self.columns, data
Beispiel #17
0
 def take_action(self, parsed_args):
     data = self.client.list(
         env_id=parsed_args.env
     )
     # format fields
     for d in data:
         d['relations'] = "\n".join(
             'as "{type}" to {model}(ID={model_id})'
             .format(**r) for r in d['relations']
         )
         d['tasks'] = ', '.join(sorted(t['id'] for t in d['tasks']))
     data = data_utils.get_display_data_multi(self.columns, data)
     scolumn_ids = [self.columns.index(col)
                    for col in parsed_args.sort_columns]
     data.sort(key=lambda x: [x[scolumn_id] for scolumn_id in scolumn_ids])
     return self.columns, data
Beispiel #18
0
 def take_action(self, parsed_args):
     # print parser
     show_parameters = parsed_args.show_parameters
     data = self.client.get_all(
         transaction_id=parsed_args.id,
         nodes=parsed_args.nodes,
         statuses=parsed_args.statuses,
         tasks_names=parsed_args.tasks_names,
         show_parameters=show_parameters
     )
     if show_parameters:
         self.columns = self.client.tasks_records_keys
     else:
         self.columns = self.client.history_records_keys
     data = data_utils.get_display_data_multi(self.columns, data)
     return self.columns, data
Beispiel #19
0
    def take_action(self, args):
        data = self.client.list(env_id=args.env, filters=args.filters)

        # make table context applying special formatting to data copy
        display_data = []
        for d in data:
            d = d.copy()
            d.update({
                'relations': "\n".join(
                    'as "{type}" to {model}(ID={model_id})'.format(**r)
                    for r in d['relations']
                ),
                'tasks': ', '.join(sorted(t['id'] for t in d['tasks']))
            })
            display_data.append(d)

        data = data_utils.get_display_data_multi(self.columns, display_data)
        scolumn_ids = [self.columns.index(col) for col in args.sort_columns]
        data.sort(key=lambda x: [x[scolumn_id] for scolumn_id in scolumn_ids])
        return self.columns, data
Beispiel #20
0
    def take_action(self, parsed_args):
        ostf_credentials = {}
        if parsed_args.ostf_tenant_name is not None:
            ostf_credentials['tenant'] = parsed_args.ostf_tenant_name
        if parsed_args.ostf_username is not None:
            ostf_credentials['username'] = parsed_args.ostf_username
        if parsed_args.ostf_password is not None:
            ostf_credentials['password'] = parsed_args.ostf_password

        if not ostf_credentials:
            self.app.stdout.write("WARNING: ostf credentials are going to be "
                                  "mandatory in the next release.\n")

        data = self.client.start(parsed_args.env,
                                 ostf_credentials=ostf_credentials,
                                 test_sets=parsed_args.tests,
                                 force=parsed_args.force)

        msg = ("\nHealth check tests for environment with id {0} has been "
               "started:\n".format(parsed_args.env))
        self.app.stdout.write(msg)
        data = data_utils.get_display_data_multi(self.columns, data)
        return self.columns, data
    def test_get_display_data_multi(self):
        test_data = [{'a': 1, 'b': 2, 'c': 3}, {'b': 8, 'c': 9}]
        fields = ('b', 'c')

        result = data_utils.get_display_data_multi(fields, test_data)
        self.assertEqual([[2, 3], [8, 9]], result)
Beispiel #22
0
 def take_action(self, parsed_args):
     data = self.client.get_attributes_metadata_by_id(parsed_args.id)
     repos = data["editable"]["repo_setup"]["repos"]["value"]
     repos = data_utils.get_display_data_multi(self.columns, repos)
     repos = self._sort_data(parsed_args, repos)
     return self.columns, repos
Beispiel #23
0
    def take_action(self, parsed_args):
        data = self.client.get_status_all(parsed_args.env)

        data = data_utils.get_display_data_multi(self.columns, data)
        return self.columns, data
Beispiel #24
0
 def take_action(self, parsed_args):
     super(ListCommand, self).take_action(parsed_args)
     data = bs_image.get_all()
     data = data_utils.get_display_data_multi(self.columns, data)
     return (self.columns, data)
Beispiel #25
0
 def take_action(self, parsed_args):
     data = bs_image.get_all()
     data = data_utils.get_display_data_multi(self.columns, data)
     return (self.columns, data)
Beispiel #26
0
    def take_action(self, parsed_args):
        data = self.client.get_all_labels_for_nodes(
            node_ids=parsed_args.nodes)
        data = data_utils.get_display_data_multi(self.columns, data)

        return (self.columns, data)
Beispiel #27
0
    def test_get_display_data_multi(self):
        test_data = [{"a": 1, "b": 2, "c": 3}, {"b": 8, "c": 9}]
        fields = ("b", "c")

        result = data_utils.get_display_data_multi(fields, test_data)
        self.assertEqual([[2, 3], [8, 9]], result)
Beispiel #28
0
    def take_action(self, parsed_args):
        data = self.client.get_node_vms_list(parsed_args.node_id)
        data = data_utils.get_display_data_multi(self.columns, data)

        return (self.columns, data)
Beispiel #29
0
    def take_action(self, parsed_args):
        data = self.client.get_all_labels_for_nodes(node_ids=parsed_args.nodes)
        data = data_utils.get_display_data_multi(self.columns, data)

        return (self.columns, data)
Beispiel #30
0
    def take_action(self, parsed_args):
        data = self.client.get_all(environment_id=parsed_args.env,
                                   labels=parsed_args.labels)
        data = data_utils.get_display_data_multi(self.columns, data)

        return (self.columns, data)
Beispiel #31
0
 def take_action(self, parsed_args):
     data = bs_image.get_all()
     data = data_utils.get_display_data_multi(self.columns, data)
     return (self.columns, data)
Beispiel #32
0
    def take_action(self, parsed_args):

        data = self.client.get_all(environment_id=parsed_args.env)
        data = data_utils.get_display_data_multi(self.columns, data)

        return (self.columns, data)