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 delete_from_db(self, params):
        """To delete nodes from fuel db:
                fuel node --node-id 1 --delete-from-db
                fuel node --node-id 1 2 --delete-from-db
            (this works only for offline nodes)
                fuel node --node-id 1 --delete-from-db --force
            (this forces deletion of nodes regardless of their state)
        """
        if not params.force:
            node_collection = NodeCollection.init_with_ids(params.node)

            online_nodes = [node for node in node_collection.data
                            if node['online']]

            if online_nodes:
                raise error.ActionException(
                    "Nodes with ids {0} cannot be deleted from cluster "
                    "because they are online. You might want to use the "
                    "--force option.".format(
                        [node['id'] for node in online_nodes]))

        NodeCollection.delete_by_ids(params.node)

        self.serializer.print_to_output(
            {},
            "Nodes with ids {0} have been deleted from Fuel db.".format(
                params.node)
        )
Exemplo n.º 3
0
    def delete_from_db(self, params):
        """To delete nodes from fuel db:
                fuel node --node-id 1 --delete-from-db
                fuel node --node-id 1 2 --delete-from-db
            (this works only for offline nodes)
                fuel node --node-id 1 --delete-from-db --force
            (this forces deletion of nodes regardless of their state)
        """
        if not params.force:
            node_collection = NodeCollection.init_with_ids(params.node)

            online_nodes = [
                node for node in node_collection.data if node['online']
            ]

            if online_nodes:
                raise error.ActionException(
                    "Nodes with ids {0} cannot be deleted from cluster "
                    "because they are online. You might want to use the "
                    "--force option.".format(
                        [node['id'] for node in online_nodes]))

        NodeCollection.delete_by_ids(params.node)

        self.serializer.print_to_output(
            {}, "Nodes with ids {0} have been deleted from Fuel db.".format(
                params.node))
Exemplo n.º 4
0
    def execute_tasks(self, params):
        """Execute deployment tasks
                fuel node --node 2 --tasks hiera netconfig
                fuel node --node 2 --skip hiera netconfig
                fuel node --node 2 --skip rsync --end pre_deployment
                fuel node --node 2 --end netconfig
                fuel node --node 2 --start hiera --end neutron
                fuel node --node 2 --start post_deployment
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        env_id_to_start = self.get_env_id(node_collection)

        env = Environment(env_id_to_start)

        if params.tasks:
            tasks = params.tasks
        else:
            tasks = env.get_tasks(
                skip=params.skip, end=params.end, start=params.start)

        task = env.execute_tasks(node_collection.collection, tasks=tasks)

        self.serializer.print_to_output(
            task.data,
            "Started tasks {0} for nodes {1}.".format(tasks, node_collection))
Exemplo n.º 5
0
    def execute_tasks(self, params):
        """Execute deployment tasks
                fuel node --node 2 --tasks hiera netconfig
                fuel node --node 2 --tasks netconfig --force
                fuel node --node 2 --skip hiera netconfig
                fuel node --node 2 --skip rsync --end pre_deployment_end
                fuel node --node 2 --end netconfig
                fuel node --node 2 --start hiera --end neutron
                fuel node --node 2 --start post_deployment_start
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        env_id_to_start = self.get_env_id(node_collection)

        env = Environment(env_id_to_start)

        tasks = params.tasks or None
        force = params.force or None

        if params.skip or params.end or params.start:
            tasks = env.get_tasks(
                skip=params.skip,
                end=params.end,
                start=params.start,
                include=tasks)

        if not tasks:
            self.serializer.print_to_output({}, "Nothing to run.")
            return

        task = env.execute_tasks(
            node_collection.collection, tasks=tasks, force=force)

        self.serializer.print_to_output(
            task.data,
            "Started tasks {0} for nodes {1}.".format(tasks, node_collection))
Exemplo n.º 6
0
    def execute_tasks(self, params):
        """Execute deployment tasks
                fuel node --node 2 --tasks hiera netconfig
                fuel node --node 2 --tasks netconfig --force
                fuel node --node 2 --skip hiera netconfig
                fuel node --node 2 --skip rsync --end pre_deployment_end
                fuel node --node 2 --end netconfig
                fuel node --node 2 --start hiera --end neutron
                fuel node --node 2 --start post_deployment_start
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        env_id_to_start = self.get_env_id(node_collection)

        env = Environment(env_id_to_start)

        tasks = params.tasks or None
        force = params.force or None

        if params.skip or params.end or params.start:
            tasks = env.get_tasks(skip=params.skip,
                                  end=params.end,
                                  start=params.start,
                                  include=tasks)

        if not tasks:
            self.serializer.print_to_output({}, "Nothing to run.")
            return

        task = env.execute_tasks(node_collection.collection,
                                 tasks=tasks,
                                 force=force)

        self.serializer.print_to_output(
            task.data,
            "Started tasks {0} for nodes {1}.".format(tasks, node_collection))
Exemplo n.º 7
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.º 8
0
    def start(self, params):
        """Deploy/Provision some node:
                fuel node --node-id 2 --provision
                fuel node --node-id 2 --deploy
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        method_type = "deploy" if params.deploy else "provision"
        env_id_to_start = self.get_env_id(node_collection)

        task = Environment(env_id_to_start).install_selected_nodes(
            method_type, node_collection.collection)

        self.serializer.print_to_output(
            task.data,
            "Started {0}ing {1}."
            .format(method_type, node_collection))
Exemplo n.º 9
0
 def start(self, params):
     """Deploy/Provision some node:
             fuel node --node-id 2 --provision
             fuel node --node-id 2 --deploy
     """
     node_collection = NodeCollection.init_with_ids(params.node)
     method_type = "deploy" if params.deploy else "provision"
     env_ids = set(n.env_id for n in node_collection)
     if len(env_ids) != 1:
         raise ActionException(
             "Inputed nodes assigned to multiple environments!")
     else:
         env_id_to_start = env_ids.pop()
     task = Environment(env_id_to_start).install_selected_nodes(
         method_type, node_collection.collection)
     self.serializer.print_to_output(
         task.data, "Started {0}ing {1}.".format(method_type,
                                                 node_collection))
Exemplo n.º 10
0
    def start(self, params):
        """Deploy/Provision some node:
                fuel node --node-id 2 --provision
                fuel node --node-id 2 --deploy
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        method_type = "deploy" if params.deploy else "provision"
        env_id_to_start = self.get_env_id(node_collection)

        if not env_id_to_start:
            raise error.ActionException(
                "Input nodes are not assigned to any environment!")

        task = Environment(env_id_to_start).install_selected_nodes(
            method_type, node_collection.collection)

        self.serializer.print_to_output(
            task.data, "Started {0}ing {1}.".format(method_type,
                                                    node_collection))
Exemplo n.º 11
0
 def start(self, params):
     """Deploy/Provision some node:
             fuel node --node-id 2 --provision
             fuel node --node-id 2 --deploy
     """
     node_collection = NodeCollection.init_with_ids(params.node)
     method_type = "deploy" if params.deploy else "provision"
     env_ids = set(n.env_id for n in node_collection)
     if len(env_ids) != 1:
         raise ActionException(
             "Inputed nodes assigned to multiple environments!")
     else:
         env_id_to_start = env_ids.pop()
     task = Environment(env_id_to_start).install_selected_nodes(
         method_type, node_collection.collection)
     self.serializer.print_to_output(
         task.data,
         "Started {0}ing {1}."
         .format(method_type, node_collection))
Exemplo n.º 12
0
def task_execute(tasks):
	if params.node != []:
		node_collection = NodeCollection.init_with_ids(params.node)
		Environment(cluster_id).execute_tasks(node_collection, tasks)
Exemplo n.º 13
0
def task_execute(tasks):
    if params.node != []:
        node_collection = NodeCollection.init_with_ids(params.node)
        Environment(cluster_id).execute_tasks(node_collection, tasks)