コード例 #1
0
ファイル: start.py プロジェクト: karanindia/StarCluster-1
    def execute(self, args):
        if len(args) != 1:
            self.parser.error("please specify a <cluster_tag>")
        tag = args[0]
        if tag.find("master") > -1:
            # Because of Node.is_master
            raise exception.ClusterValidationError("Cluster name cannot "
                                                   "contain master")

        create = not self.opts.no_create
        scluster = self.cm.get_cluster_group_or_none(tag)
        if scluster and create:
            scluster = self.cm.get_cluster(tag,
                                           group=scluster,
                                           load_receipt=False,
                                           require_keys=False)
            stopped_ebs = scluster.is_cluster_stopped()
            is_ebs = False
            if not stopped_ebs:
                is_ebs = scluster.is_ebs_cluster()
            raise exception.ClusterExists(tag,
                                          is_ebs=is_ebs,
                                          stopped_ebs=stopped_ebs)
        if not create and not scluster:
            raise exception.ClusterDoesNotExist(tag)
        create_only = self.opts.create_only
        validate = self.opts.validate
        validate_running = self.opts.no_create
        validate_only = self.opts.validate_only
        config_on_master = self.opts.config_on_master

        if scluster:
            if config_on_master:
                scluster = self.cm.get_cluster(tag,
                                               group=scluster,
                                               load_receipt=False)
                validate_running = False
            else:
                scluster = self.cm.get_cluster(tag, group=scluster)
                validate_running = True
        else:
            template = self.opts.cluster_template
            if not template:
                try:
                    template = self.cm.get_default_cluster_template()
                except exception.NoDefaultTemplateFound, e:
                    try:
                        ctmpl = e.options[0]
                    except IndexError:
                        ctmpl = "smallcluster"
                    e.msg += " \n\nAlternatively, you can specify a cluster "
                    e.msg += "template to use by passing the '-c' option to "
                    e.msg += "the 'start' command, e.g.:\n\n"
                    e.msg += "    $ starcluster start -c %s %s" % (ctmpl, tag)
                    raise e
                log.info("Using default cluster template: %s" % template)
            scluster = self.cm.get_cluster_template(template, tag)
コード例 #2
0
 def execute(self, args):
     if len(args) != 1:
         self.parser.error("please specify a <cluster_tag>")
     tag = self.tag = args[0]
     create = not self.opts.no_create
     create_only = self.opts.create_only
     scluster = self.cm.get_cluster_or_none(tag, require_keys=False)
     validate = self.opts.validate
     validate_running = self.opts.no_create
     validate_only = self.opts.validate_only
     if scluster and create:
         stopped_ebs = scluster.is_cluster_stopped()
         is_ebs = False
         if not stopped_ebs:
             is_ebs = scluster.is_ebs_cluster()
         raise exception.ClusterExists(tag,
                                       is_ebs=is_ebs,
                                       stopped_ebs=stopped_ebs)
     if not scluster and not create:
         raise exception.ClusterDoesNotExist(tag)
     elif scluster:
         validate_running = True
     else:
         template = self.opts.cluster_template
         if not template:
             try:
                 template = self.cm.get_default_cluster_template()
             except exception.NoDefaultTemplateFound, e:
                 try:
                     ctmpl = e.options[0]
                 except IndexError:
                     ctmpl = "smallcluster"
                 e.msg += " \n\nAlternatively, you can specify a cluster "
                 e.msg += "template to use by passing the '-c' option to "
                 e.msg += "the 'start' command, e.g.:\n\n"
                 e.msg += "    $ starcluster start -c %s %s" % (ctmpl, tag)
                 raise e
             log.info("Using default cluster template: %s" % template)
         scluster = self.cm.get_cluster_template(template, tag)
コード例 #3
0
 def execute(self, args):
     if len(args) != 1:
         self.parser.error("please specify a <cluster_tag>")
     tag = self.tag = args[0]
     create = not self.opts.no_create
     create_only = self.opts.create_only
     cluster_exists = self.cm.get_cluster_or_none(tag)
     validate = self.opts.validate
     validate_running = self.opts.no_create
     validate_only = self.opts.validate_only
     if cluster_exists and create:
         stopped_ebs = cluster_exists.is_cluster_stopped()
         is_ebs = False
         if not stopped_ebs:
             is_ebs = cluster_exists.is_ebs_cluster()
         raise exception.ClusterExists(tag,
                                       is_ebs=is_ebs,
                                       stopped_ebs=stopped_ebs)
     if not cluster_exists and not create:
         raise exception.ClusterDoesNotExist(tag)
     scluster = None
     if cluster_exists:
         validate_running = True
         scluster = self.cm.get_cluster(tag)
         log.info(
             "Using original template used to launch cluster '%s'" % \
             scluster.cluster_tag)
     else:
         template = self.opts.cluster_template
         if not template:
             template = self.cm.get_default_cluster_template()
             log.info("Using default cluster template: %s" % template)
         scluster = self.cm.get_cluster_template(template, tag)
     scluster.update(self.specified_options_dict)
     if not self.opts.refresh_interval:
         interval = self.cfg.globals.get("refresh_interval")
         scluster.refresh_interval = interval
     if validate:
         try:
             scluster._validate(validate_running=validate_running)
         except exception.ClusterValidationError:
             if not cluster_exists:
                 log.error(
                     'settings for cluster template "%s" are not valid:' % \
                     template)
             raise
     else:
         log.warn("SKIPPING VALIDATION - USE AT YOUR OWN RISK")
     if validate_only:
         return
     if self.opts.spot_bid is not None and not self.opts.no_create:
         cmd = ' '.join(sys.argv[1:])
         cmd = cmd.replace('--no-create', '').replace('-x', '')
         cmd += ' -x'
         msg = user_msgs.spotmsg % {
             'cmd': cmd,
             'size': scluster.cluster_size,
             'tag': tag
         }
         self.warn_experimental(msg, num_secs=5)
     self.catch_ctrl_c()
     scluster.start(create=create, create_only=create_only, validate=False)
     if self.opts.login_master:
         scluster.ssh_to_master()