Permalink
Browse files

Fixed spothistory availability zone + added functionality to get the …

…zone from a cluster
  • Loading branch information...
1 parent e140f89 commit 7ac6fa5a901cdcd92d7a211457b4292f2f2a7c8e @FinchPowers FinchPowers committed Nov 15, 2012
Showing with 21 additions and 2 deletions.
  1. +21 −2 starcluster/commands/spothistory.py
@@ -47,6 +47,10 @@ def addopts(self, parser):
parser.add_option("-p", "--plot", dest="plot",
action="store_true", default=False,
help="plot spot history using matplotlib")
+ parser.add_option("-c", "--cluster-name", dest="cluster_name",
+ default=None,
+ help="limit results to the clusters master node "
+ "availability zone")
def execute(self, args):
instance_types = ', '.join(static.INSTANCE_TYPES.keys())
@@ -66,5 +70,20 @@ def execute(self, args):
start = utils.datetime_tuple_to_iso(
now - timedelta(days=self.opts.days_ago))
browser_cmd = self.cfg.globals.get("web_browser")
- self.ec2.get_spot_history(instance_type, start, end, self.opts.plot,
- plot_web_browser=browser_cmd)
+
+ zone = None
+ if self.opts.cluster_name:
+ cl = self.cm.get_cluster(self.opts.cluster_name,
+ require_keys=False)
+ zone = cl.nodes[0].placement
+ self.log.info("Cluster zone: " + zone)
+ if self.opts.zone:
+ if zone:
+ self.log.info("You specified a zone and a cluster to get the zone "
+ "from. Using the cluster zone.")
+ else:
+ zone = self.opts.zone
+ self.log.info("Specified zone: " + zone)
+
+ self.ec2.get_spot_history(instance_type, start, end, zone,
+ self.opts.plot, plot_web_browser=browser_cmd)

0 comments on commit 7ac6fa5

Please sign in to comment.