Skip to content

Commit

Permalink
Run plugins support for more plugins arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mich committed Aug 5, 2014
1 parent b847b68 commit c3e097d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions starcluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def list_clusters(self, cluster_groups=None, show_ssh_status=False):
print 'Cluster nodes: N/A'
print

def run_plugin(self, plugin_name, cluster_tag):
def run_plugin(self, plugin_name, cluster_tag, args=[]):
"""
Run a plugin defined in the config.
Expand All @@ -392,7 +392,7 @@ def run_plugin(self, plugin_name, cluster_tag):
raise exception.ClusterNotRunning(cluster_tag)
plugs = [self.cfg.get_plugin(plugin_name)]
plug = deathrow._load_plugins(plugs)[0]
cl.run_plugin(plug, name=plugin_name)
cl.run_plugin(plug, name=plugin_name, args=args)


class Cluster(object):
Expand Down Expand Up @@ -1909,7 +1909,8 @@ def run_plugins(self, plugins=None, method_name="run", node=None,
for plug in plugs:
self.run_plugin(plug, method_name=method_name, node=node)

def run_plugin(self, plugin, name='', method_name='run', node=None):
def run_plugin(self, plugin, name='', method_name='run', node=None,
args=[]):
"""
Run a StarCluster plugin.
Expand All @@ -1928,7 +1929,7 @@ def run_plugin(self, plugin, name='', method_name='run', node=None):
(plugin_name, method_name))
return
args = [self.nodes, self.master_node, self.cluster_user,
self.cluster_shell, self.volumes]
self.cluster_shell, self.volumes] + args
if node:
args.insert(0, node)
log.info("Running plugin %s" % plugin_name)
Expand Down
7 changes: 4 additions & 3 deletions starcluster/commands/runplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class CmdRunPlugin(CmdBase):
names = ['runplugin', 'rp']

def execute(self, args):
if len(args) != 2:
if len(args) < 2:
self.parser.error("Please provide a plugin_name and <cluster_tag>")
plugin_name, cluster_tag = args
self.cm.run_plugin(plugin_name, cluster_tag)
plugin_name, cluster_tag = args[0:2]
args = args[2:]
self.cm.run_plugin(plugin_name, cluster_tag, args)

0 comments on commit c3e097d

Please sign in to comment.