def execute(self, args): if len(args) != 1: self.parser.error("please specify a <tag_name> for this cluster") cfg = self.cfg use_experimental = cfg.globals.get('enable_experimental') if self.opts.spot_bid is not None and not use_experimental: raise exception.ExperimentalFeature('Using spot instances') tag = self.tag = args[0] template = self.opts.cluster_template if not template: template = cfg.get_default_cluster_template(tag) log.info("Using default cluster template: %s" % template) scluster = cfg.get_cluster_template(template, tag) scluster.update(self.specified_options_dict) if cluster.cluster_exists(tag,cfg) and not self.opts.no_create: raise exception.ClusterExists(tag) #from starcluster.utils import ipy_shell; ipy_shell(); check_running = self.opts.no_create if check_running: log.info("Validating existing instances...") if scluster.is_running_valid(): log.info('Existing instances are valid') else: log.error('existing instances are not compatible with cluster' + \ ' template settings') sys.exit(1) log.info("Validating cluster template settings...") if scluster.is_valid(): log.info('Cluster template settings are valid') if not self.opts.validate_only: if self.opts.spot_bid is not None: cmd = ' '.join(sys.argv[1:]) + ' --no-create' launch_group = static.SECURITY_GROUP_TEMPLATE % tag msg = experimental.spotmsg % {'cmd':cmd, 'launch_group': launch_group} self.warn_experimental(msg) self.catch_ctrl_c() scluster.start(create=not self.opts.no_create) if self.opts.login_master: cluster.ssh_to_master(tag, self.cfg) else: log.error('settings for cluster template "%s" are not valid' % template) sys.exit(1)
def execute(self, args): if not args: self.parser.error("please specify a cluster") for arg in args: cluster.ssh_to_master(arg, self.cfg, user=self.opts.USER)
scluster._validate(validate_running=validate_running) if validate_only: return except exception.ClusterValidationError,e: log.error('settings for cluster template "%s" are not valid:' % template) raise if self.opts.spot_bid is not None: cmd = ' '.join(sys.argv[1:]) + ' --no-create' launch_group = static.SECURITY_GROUP_TEMPLATE % tag msg = experimental.spotmsg % {'cmd':cmd, 'launch_group': launch_group} self.warn_experimental(msg) self.catch_ctrl_c() scluster.start(create=create, validate=False) if self.opts.login_master: cluster.ssh_to_master(tag, self.cfg) class CmdStop(CmdBase): """ stop [options] <cluster> Shutdown a running cluster Example: $ starcluster stop mycluster This will stop a currently running cluster tagged "mycluster" """ names = ['stop']