def handle_completion(self): if self.is_completion_active(): gparser = self.create_global_parser(no_usage=True, add_help=False) # set sys.path to COMP_LINE if it exists self._init_completion() # fetch the global options gopts = self.get_global_opts() # try to load TethysClusterConfig into global options if gopts: try: cfg = config.TethysClusterConfig(gopts.CONFIG) cfg.load() except exception.ConfigError: cfg = None gopts.CONFIG = cfg scmap = {} for sc in commands.all_cmds: sc.gopts = gopts for n in sc.names: scmap[n] = sc listcter = completion.ListCompleter(scmap.keys()) subcter = completion.NoneCompleter() completion.autocomplete(gparser, listcter, None, subcter, subcommands=scmap) sys.exit(1)
def _completer(self): try: rimages = self.ec2.registered_images completion_list = [i.id for i in rimages] return completion.ListCompleter(completion_list) except Exception, e: log.error('something went wrong fix me: %s' % e)
def _completer(self): try: cm = self.cm clusters = cm.get_cluster_security_groups() completion_list = [cm.get_tag_from_sg(sg.name) for sg in clusters] return completion.ListCompleter(completion_list) except Exception, e: log.error('something went wrong fix me: %s' % e)
def _completer(self): try: instances = self.ec2.get_all_instances() completion_list = [i.id for i in instances] if self.show_dns_names: completion_list.extend([i.dns_name for i in instances]) return completion.ListCompleter(completion_list) except Exception, e: log.error('something went wrong fix me: %s' % e)
def _completer(self): try: rimages = self.ec2.registered_images completion_list = [ i.id for i in rimages if i.root_device_type == "instance-store" ] return completion.ListCompleter(completion_list) except Exception, e: log.error('something went wrong fix me: %s' % e)
def _completer(self): try: cm = self.cm clusters = cm.get_cluster_security_groups() compl_list = [cm.get_tag_from_sg(sg.name) for sg in clusters] max_num_nodes = 0 for scluster in clusters: num_instances = len(scluster.instances()) if num_instances > max_num_nodes: max_num_nodes = num_instances compl_list.extend(['master']) compl_list.extend([str(i) for i in range(0, num_instances)]) compl_list.extend( ["node%03d" % i for i in range(1, num_instances)]) return completion.ListCompleter(compl_list) except Exception, e: print e log.error('something went wrong fix me: %s' % e)
def _completer(self): try: completion_list = [v.id for v in self.ec2.get_volumes()] return completion.ListCompleter(completion_list) except Exception, e: log.error('something went wrong fix me: %s' % e)
def addopts(self, parser): templates = [] if self.cfg: templates = self.cfg.clusters.keys() parser.add_option("-x", "--no-create", dest="no_create", action="store_true", default=False, help="do not launch new EC2 instances when " "starting cluster (use existing instances instead)") parser.add_option("-o", "--create-only", dest="create_only", action="store_true", default=False, help="only launch/start EC2 instances, " "do not perform any setup routines") parser.add_option("-v", "--validate-only", dest="validate_only", action="store_true", default=False, help="only validate cluster settings, do " "not start a cluster") parser.add_option("-V", "--skip-validation", dest="validate", action="store_false", default=True, help="do not validate cluster settings") parser.add_option("-l", "--login-master", dest="login_master", action="store_true", default=False, help="login to master node after launch") parser.add_option("-q", "--disable-queue", dest="disable_queue", action="store_true", default=None, help="do not configure a queueing system (SGE)") parser.add_option("-Q", "--enable-queue", dest="disable_queue", action="store_false", default=None, help="configure a queueing system (SGE) (default)") parser.add_option("--force-spot-master", dest="force_spot_master", action="store_true", default=None, help="when creating a spot cluster " "the default is to launch the master as " "a flat-rate instance for stability. this option " "forces launching the master node as a spot " "instance when a spot cluster is requested.") parser.add_option("--no-spot-master", dest="force_spot_master", action="store_false", default=None, help="Do not launch the master node as a spot " "instance when a spot cluster is requested. " "(default)") parser.add_option("--public-ips", dest="public_ips", default=None, action='store_true', help="Assign public IPs to all VPC nodes " "(VPC clusters only)"), parser.add_option("--no-public-ips", dest="public_ips", default=None, action='store_false', help="Do NOT assign public ips to all VPC nodes " "(VPC clusters only) (default)"), opt = parser.add_option("-c", "--cluster-template", action="store", dest="cluster_template", choices=templates, default=None, help="cluster template to use " "from the config file") if completion: opt.completer = completion.ListCompleter(opt.choices) parser.add_option("-r", "--refresh-interval", dest="refresh_interval", type="int", action="callback", default=None, callback=self._positive_int, help="refresh interval when waiting for cluster " "nodes to come up (default: 30)") parser.add_option("-b", "--bid", dest="spot_bid", action="store", type="float", default=None, help="requests spot instances instead of flat " "rate instances. Uses SPOT_BID as max bid for " "the request.") parser.add_option("-d", "--description", dest="cluster_description", action="store", type="string", default="Cluster requested at %s" % time.strftime("%Y%m%d%H%M"), help="brief description of cluster") parser.add_option("-s", "--cluster-size", dest="cluster_size", action="callback", type="int", default=None, callback=self._positive_int, help="number of ec2 instances to launch") parser.add_option("-u", "--cluster-user", dest="cluster_user", action="store", type="string", default=None, help="name of user to create on cluster " "(defaults to sgeadmin)") opt = parser.add_option("-S", "--cluster-shell", dest="cluster_shell", action="store", choices=static.AVAILABLE_SHELLS.keys(), default=None, help="shell for cluster user " "(defaults to bash)") if completion: opt.completer = completion.ListCompleter(opt.choices) parser.add_option("-m", "--master-image-id", dest="master_image_id", action="store", type="string", default=None, help="AMI to use when launching master") parser.add_option("-n", "--node-image-id", dest="node_image_id", action="store", type="string", default=None, help="AMI to use when launching nodes") parser.add_option("-I", "--master-instance-type", dest="master_instance_type", action="store", choices=sorted(static.INSTANCE_TYPES.keys()), default=None, help="instance type for the master " "instance") opt = parser.add_option("-i", "--node-instance-type", dest="node_instance_type", action="store", choices=sorted(static.INSTANCE_TYPES.keys()), default=None, help="instance type for the node instances") if completion: opt.completer = completion.ListCompleter(opt.choices) parser.add_option("-a", "--availability-zone", dest="availability_zone", action="store", type="string", default=None, help="availability zone to launch instances in") parser.add_option("-k", "--keyname", dest="keyname", action="store", type="string", default=None, help="name of the keypair to use when " "launching the cluster") parser.add_option("-K", "--key-location", dest="key_location", action="store", type="string", default=None, metavar="FILE", help="path to an ssh private key that matches the " "cluster keypair") parser.add_option("-U", "--userdata-script", dest="userdata_scripts", action="append", default=None, metavar="FILE", help="Path to userdata script that will run on " "each node on start-up. Can be used multiple times.") parser.add_option("-P", "--dns-prefix", dest="dns_prefix", action='store_true', help="Prefix dns names of all nodes in the cluster " "with the cluster tag") parser.add_option("-p", "--no-dns-prefix", dest="dns_prefix", action='store_false', help="Do NOT prefix dns names of all nodes in the " "cluster with the cluster tag (default)") parser.add_option("-N", "--subnet-id", dest="subnet_id", action="store", type="string", help=("Launch cluster into a VPC subnet"))