def list_all(self, provider): """ Find and print clusters that have a running namenode instances """ legacy_clusters = get_cluster(provider).get_clusters_with_role(MASTER) clusters = get_cluster(provider).get_clusters_with_role(NAMENODE) clusters.extend(legacy_clusters) if not clusters: print "No running clusters" else: for cluster in clusters: print cluster
def list_all(self, provider): """ Find and print clusters that have a running namenode instances """ legacy_clusters = get_cluster(provider).get_clusters_with_role(MASTER) clusters = list(get_cluster(provider).get_clusters_with_role(NAMENODE)) clusters.extend(legacy_clusters) if not clusters: print "No running clusters" else: for cluster in clusters: print cluster
def parse_options_and_config(command, option_list=[], extra_arguments=(), unbounded_args=False): """ Parse the arguments to command using the given option list, and combine with any configuration parameters. If unbounded_args is true then there must be at least as many extra arguments as specified by extra_arguments (the first argument is always CLUSTER). Otherwise there must be exactly the same number of arguments as extra_arguments. """ expected_arguments = ["CLUSTER",] expected_arguments.extend(extra_arguments) (options_dict, args) = parse_options(command, option_list, expected_arguments, unbounded_args) config_dir = get_config_dir(options_dict) logging.debug("Config dir %s from %s", config_dir, options_dict) config_files = [os.path.join(config_dir, CONFIG_FILENAME)] if 'config_dir' not in options_dict: # if config_dir not set, then also search in current directory config_files.insert(0, CONFIG_FILENAME) config = ConfigParser.ConfigParser() read_files = config.read(config_files) logging.debug("Read %d configuration files: %s", len(read_files), ", ".join(read_files)) cluster_name = args[0] opt = merge_config_with_options(cluster_name, config, options_dict) logging.debug("Options: %s", str(opt)) service_name = get_service_name(opt) cloud_provider = get_cloud_provider(opt) cluster = get_cluster(cloud_provider)(cluster_name, config_dir) service = get_service(service_name, cloud_provider)(cluster) return (opt, args, service)
def parse_options_and_config(command, option_list=[], extra_arguments=(), unbounded_args=False): """ Parse the arguments to command using the given option list, and combine with any configuration parameters. If unbounded_args is true then there must be at least as many extra arguments as specified by extra_arguments (the first argument is always CLUSTER). Otherwise there must be exactly the same number of arguments as extra_arguments. """ expected_arguments = [ "CLUSTER", ] expected_arguments.extend(extra_arguments) (options_dict, args) = parse_options(command, option_list, expected_arguments, unbounded_args) config_dir = get_config_dir(options_dict) config_files = [os.path.join(config_dir, CONFIG_FILENAME)] if 'config_dir' not in options_dict: # if config_dir not set, then also search in current directory config_files.insert(0, CONFIG_FILENAME) config = ConfigParser.RawConfigParser() read_files = config.read(config_files) logging.debug("Read %d configuration files: %s", len(read_files), ", ".join(read_files)) cluster_name = args[0] opt = merge_config_with_options(cluster_name, config, options_dict) logging.debug("Options: %s", str(opt)) service_name = get_service_name(opt) cloud_provider = get_cloud_provider(opt) cluster = get_cluster(cloud_provider)(cluster_name, config_dir) service = get_service(service_name, cloud_provider)(cluster) return (opt, args, service)