Package starcluster :: Package commands :: Module stop
[hide private]
[frames] | no frames]

Source Code for Module starcluster.commands.stop

 1  #!/usr/bin/env python 
 2   
 3  from starcluster.logger import log 
 4   
 5  from completers import ClusterCompleter 
 6   
 7   
8 -class CmdStop(ClusterCompleter):
9 """ 10 stop [options] <cluster_tag> ... 11 12 Stop a running cluster 13 14 Example: 15 16 $ starcluster stop mycluster 17 18 This will stop a currently running cluster tagged "mycluster" 19 20 If the cluster uses EBS-backed instances, all nodes will be put into 21 a 'stopped' state preserving the local disks. You can then use the start 22 command to resume the cluster later on without losing data. 23 24 If the cluster uses instance-store (S3) instances then all nodes wil be 25 terminated and the cluster's security group will be removed. This is the 26 same behavior as the 'terminate' command. 27 """ 28 names = ['stop'] 29
30 - def addopts(self, parser):
31 parser.add_option("-c", "--confirm", dest="confirm", 32 action="store_true", default=False, 33 help="Do not prompt for confirmation, " + \ 34 "just shutdown the cluster")
35
36 - def execute(self, args):
37 if not args: 38 self.parser.error("please specify a cluster") 39 for cluster_name in args: 40 cl = self.cm.get_cluster(cluster_name) 41 is_ebs = cl.is_ebs_cluster() 42 if not self.opts.confirm: 43 action = "Terminate" 44 if is_ebs: 45 action = "Stop EBS" 46 if cl.spot_bid: 47 action = "Terminate Spot EBS" 48 resp = raw_input("%s cluster %s (y/n)? " % 49 (action, cluster_name)) 50 if resp not in ['y', 'Y', 'yes']: 51 log.info("Aborting...") 52 continue 53 cl.stop_cluster() 54 if is_ebs and cl._nodes: 55 log.warn(("All EBS-backed nodes in '%s' are now in a " + \ 56 "'stopped' state") % cluster_name) 57 log.warn("You can restart this cluster by passing -x " + \ 58 "to the 'start' command") 59 log.warn("Use the 'terminate' command to *completely* " + \ 60 "terminate this cluster") 61 log.warn("NOTE: Unless EBS-backed nodes are in a " + \ 62 "'running' or 'terminated'") 63 log.warn("state, you are charged for the EBS volumes " + \ 64 "backing the nodes.")
65