Exemplo n.º 1
0
    def list(self, params):
        """To list all available nodes:
                fuel node

            To filter them by environment:
                fuel --env-id 1 node

            It's Possible to manipulate nodes with their short mac addresses:
                fuel node --node-id 80:ac
                fuel node remove --node-id 80:ac,5d:a2
        """
        if params.node:
            node_collection = NodeCollection.init_with_ids(params.node)
        else:
            node_collection = NodeCollection.get_all()
        if params.env:
            node_collection.filter_by_env_id(int(params.env))
        self.serializer.print_to_output(
            node_collection.data,
            format_table(
                node_collection.data,
                acceptable_keys=self.acceptable_keys,
                column_to_join=("roles", "pending_roles")
            )
        )
Exemplo n.º 2
0
    def list(self, params):
        """Print all available releases:
                fuel release --list

           Print release with specific id=1:
                fuel release --rel 1
        """
        acceptable_keys = (
            "id",
            "name",
            "state",
            "operating_system",
            "version"
        )
        if params.release:
            release = Release(params.release)
            data = [release.get_fresh_data()]
        else:
            data = Release.get_all_data()
        self.serializer.print_to_output(
            data,
            format_table(
                data,
                acceptable_keys=acceptable_keys
            )
        )
    def list(self, params):
        """List all available configurations:
            fuel openstack-config --list --env 1
            fuel openstack-config --list --env 1 --node 1
            fuel openstack-config --list --env 1 --deleted
        """
        filters = {}

        if 'env' in params:
            filters['cluster_id'] = params.env

        if 'deleted' in params:
            filters['is_active'] = int(not params.deleted)

        if 'node' in params:
            filters['node_id'] = params.node

        if 'role' in params:
            filters['node_role'] = params.role

        configs = OpenstackConfig.get_filtered_data(**filters)

        self.serializer.print_to_output(
            configs,
            format_table(
                configs,
                acceptable_keys=self.acceptable_keys
            )
        )
Exemplo n.º 4
0
    def list(self, params):
        """List all available configurations:
            fuel openstack-config --list --env 1
            fuel openstack-config --list --env 1 --node 1[,2,3,...]
            fuel openstack-config --list --env 1 --deleted
        """
        filters = {'cluster_id': params.env}

        if 'deleted' in params:
            filters['is_active'] = int(not params.deleted)

        if 'node' in params:
            filters['node_ids'] = params.node

        if 'role' in params:
            filters['node_role'] = params.role

        configs = OpenstackConfig.get_filtered_data(**filters)

        self.serializer.print_to_output(
            configs,
            format_table(
                configs,
                acceptable_keys=self.acceptable_keys
            )
        )
Exemplo n.º 5
0
    def list(self, params):
        """To list all available nodes:
                fuel node

            To filter them by environment:
                fuel --env-id 1 node

            It's Possible to manipulate nodes with their short mac addresses:
                fuel node --node-id 80:ac
                fuel node remove --node-id 80:ac,5d:a2
        """
        if params.node:
            node_collection = NodeCollection.init_with_ids(params.node)
        else:
            node_collection = NodeCollection.get_all()
        if params.env:
            node_collection.filter_by_env_id(int(params.env))
        self.serializer.print_to_output(
            node_collection.data,
            format_table(
                node_collection.data,
                acceptable_keys=self.acceptable_keys,
                column_to_join=("roles", "pending_roles")
            )
        )
Exemplo n.º 6
0
 def list(self, params):
     """To list all health check test sets:
             fuel --env 1 health
         or:
             fuel --env 1 health --list
     """
     env = Environment(params.env)
     test_sets = env.get_testsets()
     self.serializer.print_to_output(test_sets, format_table(test_sets))
Exemplo n.º 7
0
 def list(self, params):
     """To list all health check test sets:
             fuel health
         or:
             fuel --env 1 health --list
     """
     env = Environment(params.env)
     test_sets = env.get_testsets()
     self.serializer.print_to_output(test_sets, format_table(test_sets))
Exemplo n.º 8
0
    def list(self, params):
        """Print all available plugins

                fuel plugins
                fuel plugins --list
        """
        plugins = Plugins.get_all_data()
        self.serializer.print_to_output(
            plugins,
            format_table(plugins, acceptable_keys=self.acceptable_keys))
Exemplo n.º 9
0
 def list(self, params):
     """Print all available environments:
             fuel env
     """
     acceptable_keys = ("id", "status", "name", "release_id",
                        "pending_release_id")
     data = Environment.get_all_data()
     if params.env:
         data = filter(lambda x: x[u"id"] == int(params.env), data)
     self.serializer.print_to_output(
         data, format_table(data, acceptable_keys=acceptable_keys))
Exemplo n.º 10
0
    def list(self, params):
        """Print all available roles

                fuel role --rel 1
        """
        roles = Role.get_all(params.release)

        acceptable_keys = ("name", )

        self.serializer.print_to_output(
            roles, format_table(roles, acceptable_keys=acceptable_keys))
Exemplo n.º 11
0
 def list(self, params):
     """Print all available roles and their
        conflicts for some release with id=1:
             fuel role --rel 1
     """
     release = Release(params.release, params=params)
     data = release.get_fresh_data()
     acceptable_keys = ("name", "conflicts")
     roles = [
         {"name": role_name, "conflicts": ", ".join(metadata.get("conflicts", ["-"]))}
         for role_name, metadata in data["roles_metadata"].iteritems()
     ]
     self.serializer.print_to_output(roles, format_table(roles, acceptable_keys=acceptable_keys))
Exemplo n.º 12
0
 def list(self, params):
     """Print all available roles and their
        conflicts for some release with id=1:
             fuel role --rel 1
     """
     release = Release(params.release, params=params)
     data = release.get_fresh_data()
     acceptable_keys = ("name", "conflicts")
     roles = [{
         "name": role_name,
         "conflicts": ", ".join(metadata.get("conflicts", ["-"]))
     } for role_name, metadata in data["roles_metadata"].iteritems()]
     self.serializer.print_to_output(
         roles, format_table(roles, acceptable_keys=acceptable_keys))
Exemplo n.º 13
0
    def test_show_full_history(self, print_mock):
        self.m_history_api = self.m_request.get(
            '/api/v1/transactions/1/deployment_history/?'
            'nodes=&'
            'statuses=&'
            'tasks_names=',
            json=utils.get_fake_deployment_history())

        self.execute(['fuel', 'deployment-tasks', '--tid', '1'])
        print_mock.assert_called_once_with(
            utils.get_fake_deployment_history(convert_legacy_fields=True),
            format_table(
                utils.get_fake_deployment_history(convert_legacy_fields=True),
                acceptable_keys=DeploymentHistoryClient.history_records_keys))
    def list(self, params):
        """To display all deployment tasks for task:
                fuel deployment-tasks --task-id 5

            To display deployment tasks for some nodes:
                fuel deployment-tasks --task-id 5 --nodes 1,2

            To display deployment tasks for some statuses(pending, error,
            ready, running):
                fuel deployment-tasks --task-id 5 --status pending,running

            To display deployment tasks for some statuses(pending, error,
            ready, running) on some nodes:
                fuel deployment-tasks --task-id 5 --status error --nodes 1,2

            To display certain deployment tasks results only:
                fuel deployment-tasks --task-id 5
                    --task-name task-name1,task-name2

            To display tasks parameters use:
                fuel deployment-tasks --task-id 5 --show-parameters

        """
        client = DeploymentHistoryClient()
        tasks_names = getattr(params, 'task-name', None)
        show_parameters = getattr(params, 'show-parameters')
        statuses = params.status.split(',') if params.status else []
        nodes = params.node.split(',') if params.node else []
        tasks_names = tasks_names.split(',') if tasks_names else []

        data = client.get_all(
            transaction_id=params.task,
            nodes=nodes,
            statuses=statuses,
            tasks_names=tasks_names,
            show_parameters=show_parameters
        )

        if show_parameters:
            table_keys = client.tasks_records_keys
        else:
            table_keys = client.history_records_keys
        self.serializer.print_to_output(
            data,
            format_table(
                data,
                acceptable_keys=table_keys
            )
        )
Exemplo n.º 15
0
    def test_show_tasks_history_with_parameters(self, print_mock):
        tasks_after_facade = [{
            'task_name':
            'controller-remaining-tasks',
            'task_parameters':
            'parameters: {puppet_manifest: /etc/puppet/'
            'modules/osnailyfacter/modular/globals/'
            'globals.pp,\n  puppet_modules: /etc/'
            'puppet/modules, timeout: 3600}\nrole: '
            '[controller]\ntype: puppet\nversion: 2.0.0'
            '\n',
            'status_by_node':
            '1 - ready - 2016-03-25T17:22:10 - '
            '2016-03-25T17:22:30\n'
            '2 - ready - 2016-03-25T17:22:10 - '
            '2016-03-25T17:22:30'
        }, {
            'task_name':
            'pending-task',
            'task_parameters':
            'parameters: {puppet_manifest: /etc/puppet/'
            'modules/osnailyfacter/modular/globals/'
            'globals.pp,\n  puppet_modules: /etc/puppet'
            '/modules, timeout: 3600}\nrole: '
            '[controller]\ntype: puppet\nversion: 2.0.0'
            '\n',
            'status_by_node':
            '1 - pending - not started - not ended\n'
            '2 - pending - not started - not ended'
        }]

        self.m_history_api = self.m_request.get(
            '/api/v1/transactions/1/deployment_history/?'
            'nodes=&'
            'statuses=&'
            'tasks_names=controller-remaining-tasks,pending-task',
            json=utils.get_fake_deployment_history(add_task_data=True))

        self.execute([
            'fuel', 'deployment-tasks', '--tid', '1', '--task-name',
            'controller-remaining-tasks,pending-task', '--node', '1,2',
            '--show-parameters'
        ])
        print_mock.assert_called_once_with(
            tasks_after_facade,
            format_table(
                tasks_after_facade,
                acceptable_keys=DeploymentHistoryClient.tasks_records_keys))
Exemplo n.º 16
0
    def list(self, params):
        """Print all available releases:
                fuel release --list

           Print release with specific id=1:
                fuel release --rel 1
        """
        acceptable_keys = ("id", "name", "state", "operating_system",
                           "version")
        if params.release:
            release = Release(params.release)
            data = [release.get_fresh_data()]
        else:
            data = Release.get_all_data()
        self.serializer.print_to_output(
            data, format_table(data, acceptable_keys=acceptable_keys))
Exemplo n.º 17
0
    def list(self, params):
        """To list all available network groups:
                fuel network-group list

            To filter them by node group:
                fuel network-group --node-group 1
        """
        group_collection = NetworkGroupCollection.get_all()
        if params.nodegroup:
            group_collection.filter_by_group_id(int(params.nodegroup.pop()))
        self.serializer.print_to_output(
            group_collection.data,
            format_table(
                group_collection.data,
                acceptable_keys=self.acceptable_keys,
            ))
Exemplo n.º 18
0
    def list(self, params):
        """To list all available node groups:
                fuel nodegroup

            To filter them by environment:
                fuel --env-id 1 nodegroup
        """
        group_collection = NodeGroupCollection.get_all()
        if params.env:
            group_collection.filter_by_env_id(int(params.env))
        self.serializer.print_to_output(
            group_collection.data,
            format_table(
                group_collection.data,
                acceptable_keys=self.acceptable_keys,
            ))
Exemplo n.º 19
0
    def list(self, params):
        """To display all tasks:
                fuel task

           To  display tasks with some ids:
                fuel task --tid 1,2,3
        """
        acceptable_keys = ("id", "status", "name", "cluster", "progress",
                           "uuid")
        if params.task:
            tasks_data = map(Task.get_fresh_data, Task.get_by_ids(params.task))
        else:
            tasks_data = Task.get_all_data()
        self.serializer.print_to_output(
            tasks_data,
            format_table(tasks_data, acceptable_keys=acceptable_keys))
    def test_show_full_history(self, print_mock):
        self.m_history_api = self.m_request.get(
            '/api/v1/transactions/1/deployment_history/?'
            'nodes=&'
            'statuses=&'
            'tasks_names=',
            json=utils.get_fake_deployment_history())

        self.execute(
            ['fuel', 'deployment-tasks', '--tid', '1']
        )
        print_mock.assert_called_once_with(
            utils.get_fake_deployment_history(convert_legacy_fields=True),
            format_table(
                utils.get_fake_deployment_history(convert_legacy_fields=True),
                acceptable_keys=DeploymentHistoryClient.history_records_keys))
Exemplo n.º 21
0
    def list(self, params):
        """Print all available roles

                fuel role --rel 1
        """
        roles = Role.get_all(params.release)

        acceptable_keys = ("name", )

        self.serializer.print_to_output(
            roles,
            format_table(
                roles,
                acceptable_keys=acceptable_keys
            )
        )
    def test_show_tasks_history_with_parameters(self, print_mock):
        tasks_after_facade = [
            {
                'task_name': 'controller-remaining-tasks',
                'task_parameters': 'parameters: {puppet_manifest: /etc/puppet/'
                                   'modules/osnailyfacter/modular/globals/'
                                   'globals.pp,\n  puppet_modules: /etc/'
                                   'puppet/modules, timeout: 3600}\nrole: '
                                   '[controller]\ntype: puppet\nversion: 2.0.0'
                                   '\n',
                'status_by_node': '1 - ready - 2016-03-25T17:22:10 - '
                                  '2016-03-25T17:22:30\n'
                                  '2 - ready - 2016-03-25T17:22:10 - '
                                  '2016-03-25T17:22:30'
            },
            {
                'task_name': 'pending-task',
                'task_parameters': 'parameters: {puppet_manifest: /etc/puppet/'
                                   'modules/osnailyfacter/modular/globals/'
                                   'globals.pp,\n  puppet_modules: /etc/puppet'
                                   '/modules, timeout: 3600}\nrole: '
                                   '[controller]\ntype: puppet\nversion: 2.0.0'
                                   '\n',
                'status_by_node': '1 - pending - not started - not ended\n'
                                  '2 - pending - not started - not ended'
            }
        ]

        self.m_history_api = self.m_request.get(
            '/api/v1/transactions/1/deployment_history/?'
            'nodes=&'
            'statuses=&'
            'tasks_names=controller-remaining-tasks,pending-task',
            json=utils.get_fake_deployment_history(add_task_data=True))

        self.execute(
            ['fuel', 'deployment-tasks',
             '--tid', '1',
             '--task-name', 'controller-remaining-tasks,pending-task',
             '--node', '1,2',
             '--show-parameters']
        )
        print_mock.assert_called_once_with(
            tasks_after_facade,
            format_table(
                tasks_after_facade,
                acceptable_keys=DeploymentHistoryClient.tasks_records_keys))
Exemplo n.º 23
0
    def list(self, params):
        """To list all available network groups:
                fuel network-group list

            To filter them by node group:
                fuel network-group --node-group 1
        """
        group_collection = NetworkGroupCollection.get_all()
        if params.nodegroup:
            group_collection.filter_by_group_id(int(params.nodegroup.pop()))
        self.serializer.print_to_output(
            group_collection.data,
            format_table(
                group_collection.data,
                acceptable_keys=self.acceptable_keys,
            )
        )
Exemplo n.º 24
0
    def list(self, params):
        """To display all deployment tasks for task:
                fuel deployment-tasks --task-id 5

            To display deployment tasks for some nodes:
                fuel deployment-tasks --task-id 5 --node 1,2

            To display deployment tasks for some statuses(pending, error,
            ready, running):
                fuel deployment-tasks --task-id 5 --status pending,running

            To display deployment tasks for some statuses(pending, error,
            ready, running) on some nodes:
                fuel deployment-tasks --task-id 5 --status error --node 1,2

            To display certain deployment tasks results only:
                fuel deployment-tasks --task-id 5
                    --task-name task-name1,task-name2

            To display tasks parameters use:
                fuel deployment-tasks --task-id 5 --show-parameters

        """
        client = DeploymentHistoryClient()
        tasks_names = getattr(params, 'task-name', None)
        show_parameters = getattr(params, 'show-parameters')
        statuses = params.status.split(',') if params.status else []
        nodes = params.node.split(',') if params.node else []
        tasks_names = tasks_names.split(',') if tasks_names else []
        include_summary = getattr(params, 'include-summary')

        data = client.get_all(transaction_id=params.task,
                              nodes=nodes,
                              statuses=statuses,
                              tasks_names=tasks_names,
                              show_parameters=show_parameters,
                              include_summary=include_summary)

        if show_parameters:
            table_keys = client.tasks_records_keys
        else:
            table_keys = client.history_records_keys
        if include_summary:
            table_keys += ('summary', )
        self.serializer.print_to_output(
            data, format_table(data, acceptable_keys=table_keys))
Exemplo n.º 25
0
    def list(self, params):
        """To list all available node groups:
                fuel nodegroup

            To filter them by environment:
                fuel --env-id 1 nodegroup
        """
        group_collection = NodeGroupCollection.get_all()
        if params.env:
            group_collection.filter_by_env_id(int(params.env))
        self.serializer.print_to_output(
            group_collection.data,
            format_table(
                group_collection.data,
                acceptable_keys=self.acceptable_keys,
            )
        )
Exemplo n.º 26
0
 def list(self, params):
     """Print all available environments:
             fuel env
     """
     acceptable_keys = ("id", "status", "name", "release_id", )
     data = Environment.get_all_data()
     if params.env:
         data = filter(
             lambda x: x[u"id"] == int(params.env),
             data
         )
     self.serializer.print_to_output(
         data,
         format_table(
             data,
             acceptable_keys=acceptable_keys
         )
     )
Exemplo n.º 27
0
    def list(self, params):
        """Print all available plugins

                fuel plugins
                fuel plugins --list
        """
        plugins = Plugins.get_all_data()
        # Replace original nested 'release' dictionary (from plugins meta
        # dictionary) to flat one with necessary release info (os, version)
        for plugin in plugins:
            releases = collections.defaultdict(list)
            for key in plugin['releases']:
                releases[key['os']].append(key['version'])
            plugin['releases'] = ', '.join('{} ({})'.format(k, ', '.join(v))
                                           for k, v in six.iteritems(releases))
        self.serializer.print_to_output(
            plugins,
            format_table(plugins, acceptable_keys=self.acceptable_keys))
Exemplo n.º 28
0
    def list(self, params):
        """Print all available plugins

                fuel plugins
                fuel plugins --list
        """
        plugins = Plugins.get_all_data()
        # Replace original nested 'release' dictionary (from plugins meta
        # dictionary) to flat one with necessary release info (os, version)
        for plugin in plugins:
            releases = collections.defaultdict(list)
            for key in plugin['releases']:
                releases[key['os']].append(key['version'])
            plugin['releases'] = ', '.join('{} ({})'.format(k, ', '.join(v))
                                           for k, v in six.iteritems(releases))
        self.serializer.print_to_output(
            plugins, format_table(plugins,
                                  acceptable_keys=self.acceptable_keys))
Exemplo n.º 29
0
    def list(self, params):
        """Print all available notifications:
                fuel notifications
                fuel notifications --list
        """
        notifications = Notifications.get_all_data()

        if not params.all:
            notifications = [notification for notification in notifications
                             if notification['status'] == 'unread']

        self.serializer.print_to_output(
            notifications,
            format_table(
                notifications,
                acceptable_keys=self.acceptable_keys
            )
        )
Exemplo n.º 30
0
    def list(self, params):
        """To display all tasks:
                fuel task

            To display tasks with some ids:
                fuel task --tid 1,2,3
        """
        acceptable_keys = ("id", "status", "name",
                           "cluster", "progress", "uuid")
        if params.task:
            tasks_data = map(
                Task.get_fresh_data,
                Task.get_by_ids(params.task)
            )
        else:
            tasks_data = Task.get_all_data()
        self.serializer.print_to_output(
            tasks_data,
            format_table(tasks_data, acceptable_keys=acceptable_keys)
        )
Exemplo n.º 31
0
    def upload(self, params):
        """Upload new configuration from file:
            fuel openstack-config --upload --env 1 --file config.yaml
            fuel openstack-config --upload --env 1 --node 1[,2,3,...]
                --file config.yaml
            fuel openstack-config --upload --env 1
                --role controller --file config.yaml
        """
        node_ids = getattr(params, 'node', None)
        node_role = getattr(params, 'role', None)
        data = OpenstackConfig.read_file(params.file)

        configs = OpenstackConfig.create(
            cluster_id=params.env,
            configuration=data['configuration'],
            node_ids=node_ids, node_role=node_role)
        configs = [c.data for c in configs]
        self.serializer.print_to_output(
            configs,
            format_table(
                configs,
                acceptable_keys=self.acceptable_keys
            )
        )
Exemplo n.º 32
0
 def assert_print_table(self, print_mock, plugins):
     print_mock.assert_called_once_with(
         plugins,
         format_table(plugins,
                      acceptable_keys=PluginAction.acceptable_keys))
 def assert_print_table(self, print_mock, plugins):
     print_mock.assert_called_once_with(
         plugins, format_table(
             plugins,
             acceptable_keys=PluginAction.acceptable_keys))