示例#1
0
 def delete(self, params):
     """Delete the specified node groups
            fuel --env 1 nodegroup --delete --group 1
            fuel --env 1 nodegroup --delete --group 2,3,4
     """
     ngs = NodeGroup.get_by_ids(params.group)
     for n in ngs:
         if n.name == "default":
             raise ActionException("Default node groups cannot be deleted.")
         NodeGroup.delete(n.id)
示例#2
0
 def unassign_all(self):
     nodes = self.get_all_nodes()
     if not nodes:
         raise ActionException(
             "Environment with id={0} doesn't have nodes to remove.".format(
                 self.id))
     return self.connection.post_request(
         "clusters/{0}/unassignment/".format(self.id), [{
             "id": n.id
         } for n in nodes])
示例#3
0
    def assign(self, params):
        """Assign nodes to specified node group:
                fuel nodegroup --assign --node 1 --group 1
                fuel nodegroup --assign --node 2,3,4 --group 1
        """
        if len(params.group) > 1:
            raise ActionException(
                "Nodes can only be assigned to one node group.")

        group = NodeGroup(params.group.pop())
        group.assign(params.node)
示例#4
0
 def assign(self, params):
     """Assign nodes to specified node group:
             fuel --env 1 nodegroup --assign --node 1 --group 1
             fuel --env 1 nodegroup --assign --node 2,3,4 --group 1
     """
     nodes = [n.id for n in map(Node, params.node)]
     ngs = map(NodeGroup, params.group)
     if len(ngs) > 1:
         raise ActionException(
             "Nodes can only be assigned to one node group.")
     NodeGroup.assign(ngs[0].id, nodes)
示例#5
0
 def delete(self, params):
     """Delete the specified node groups
            fuel nodegroup --delete --group 1
            fuel nodegroup --delete --group 2,3,4
     """
     ngs = NodeGroup.get_by_ids(params.group)
     for n in ngs:
         if n.name == "default":
             raise ActionException("Default node groups cannot be deleted.")
         data = NodeGroup.delete(n.id)
         self.serializer.print_to_output(
             data, u"Node group with id={id} was deleted!".format(id=n.id))
示例#6
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))