diff --git a/starcluster/cluster.py b/starcluster/cluster.py index bbbaa127c..be651083b 100644 --- a/starcluster/cluster.py +++ b/starcluster/cluster.py @@ -178,11 +178,13 @@ def add_node(self, cluster_name, alias=None, no_create=False, def add_nodes(self, cluster_name, num_nodes, aliases=None, no_create=False, image_id=None, instance_type=None, zone=None, - placement_group=None, spot_bid=None): + placement_group=None, spot_bid=None, plugins=None): """ Add one or more nodes to cluster """ cl = self.get_cluster(cluster_name) + if plugins is not None: + cl.plugins = plugins return cl.add_nodes(num_nodes, aliases=aliases, image_id=image_id, instance_type=instance_type, zone=zone, placement_group=placement_group, spot_bid=spot_bid, diff --git a/starcluster/commands/addnode.py b/starcluster/commands/addnode.py index dd36ee52b..65388f960 100644 --- a/starcluster/commands/addnode.py +++ b/starcluster/commands/addnode.py @@ -17,6 +17,7 @@ from starcluster import static from completers import ClusterCompleter +from starcluster import completion class CmdAddNode(ClusterCompleter): @@ -70,6 +71,9 @@ class CmdAddNode(ClusterCompleter): tag = None def addopts(self, parser): + templates = [] + if self.cfg: + templates = self.cfg.clusters.keys() parser.add_option( "-a", "--alias", dest="alias", action="append", type="string", default=[], help="alias to give to the new node " @@ -97,6 +101,15 @@ def addopts(self, parser): "-x", "--no-create", dest="no_create", action="store_true", default=False, help="do not launch new EC2 instances when " "adding nodes (use existing instances instead)") + parser.add_option( + "--reload-plugins", dest="reload_plugins", action="store_true", + default=False, help="reload_plugins from config") + opt = parser.add_option("-c", "--cluster-template", action="store", + dest="cluster_template", choices=templates, + default=None, help="cluster template to use " + "from the config file") + if completion: + opt.completer = completion.ListCompleter(opt.choices) def execute(self, args): if len(args) != 1: @@ -121,8 +134,15 @@ def execute(self, args): if not self.opts.alias and self.opts.no_create: self.parser.error("you must specify one or more node aliases via " "the -a option when using -x") + if self.opts.reload_plugins: + template = (self.opts.cluster_template or + self.cm.get_default_cluster_template()) + plugins = self.cm.get_cluster_template(template, tag).plugins + else: + plugins = None + self.cm.add_nodes(tag, num_nodes, aliases=aliases, image_id=self.opts.image_id, instance_type=self.opts.instance_type, zone=self.opts.zone, spot_bid=self.opts.spot_bid, - no_create=self.opts.no_create) + no_create=self.opts.no_create, plugins=plugins)