Skip to content

Commit

Permalink
allow reloading plugins from config
Browse files Browse the repository at this point in the history
  • Loading branch information
cancan101 committed Feb 6, 2015
1 parent b4d1ad4 commit 4f4d756
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion starcluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 20 additions & 1 deletion starcluster/commands/addnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from starcluster import static
from completers import ClusterCompleter
from starcluster import completion


class CmdAddNode(ClusterCompleter):
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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:
Expand All @@ -121,8 +134,14 @@ 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)

0 comments on commit 4f4d756

Please sign in to comment.