Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow reloading plugins from config #499

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 21 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,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)