class ClusterStopCmd(Cmd): options_list = [ (['-v', '--verbose'], { 'action': "store_true", 'dest': "verbose", 'help': "Print nodes that were not running", 'default': False }), (['--no-wait'], { 'action': "store_true", 'dest': "no_wait", 'help': "Do not wait for the node to be stopped", 'default': False }), (['-g', '--gently'], { 'action': "store_const", 'dest': "signal_event", 'help': "Shut down gently (default)", 'const': signal.SIGTERM, 'default': signal.SIGTERM }), (['--hang-up'], { 'action': "store_const", 'dest': "signal_event", 'help': "Shut down via hang up (kill -1)", 'const': get_default_signals()['1'] }), (['--not-gently'], { 'action': "store_const", 'dest': "signal_event", 'help': "Shut down immediately (kill -9)", 'const': get_default_signals()['9'] }), ] descr_text = "Stop all the nodes of the cluster" usage = "usage: ccm cluster stop [options] name" def validate(self, parser, options, args): Cmd.validate(self, parser, options, args, load_cluster=True) def run(self): try: not_running = self.cluster.stop( wait=not self.options.no_wait, signal_event=self.options.signal_event) if self.options.verbose and len(not_running) > 0: sys.stdout.write("The following nodes were not running: ") for node in not_running: sys.stdout.write(node.name + " ") print_("") except NodeError as e: print_(str(e), file=sys.stderr) exit(1)
class NodeStopCmd(Cmd): options_list = [ (['--no-wait'], { 'action': "store_true", 'dest': "no_wait", 'help': "Do not wait for the node to be stopped", 'default': False }), (['-g', '--gently'], { 'action': "store_const", 'dest': "signal_event", 'help': "Shut down gently (default)", 'const': signal.SIGTERM, 'default': signal.SIGTERM }), (['--hang-up'], { 'action': "store_const", 'dest': "signal_event", 'help': "Shut down via hang up (kill -1)", 'const': common.get_default_signals()['1'] }), (['--not-gently'], { 'action': "store_const", 'dest': "signal_event", 'help': "Shut down immediately (kill -9)", 'const': common.get_default_signals()['9'] }), ] descr_text = "Stop a node" usage = "usage: ccm node stop [options] name" def validate(self, parser, options, args): Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True) def run(self): try: if not self.node.stop(wait=not self.options.no_wait, signal_event=self.options.signal_event): print_("%s is not running" % self.name, file=sys.stderr) exit(1) except NodeError as e: print_(str(e), file=sys.stderr) exit(1)