Exemple #1
0
def extract_common_args(command, parser, cl_args):
  try:
    # do not pop like cli because ``topologies`` subcommand still needs it
    cluster_role_env = cl_args['cluster/[role]/[env]']
    config_path = cl_args['config_path']
  except KeyError:
    # if some of the arguments are not found, print error and exit
    subparser = utils.get_subparser(parser, command)
    print(subparser.format_help())
    return dict()
  cluster = utils.get_heron_cluster(cluster_role_env)
  config_path = utils.get_heron_cluster_conf_dir(cluster, config_path)

  new_cl_args = dict()
  try:
    cluster_tuple = utils.parse_cluster_role_env(cluster_role_env, config_path)
    new_cl_args['cluster'] = cluster_tuple[0]
    new_cl_args['role'] = cluster_tuple[1]
    new_cl_args['environ'] = cluster_tuple[2]
    new_cl_args['config_path'] = config_path
  except Exception as e:
    Log.error("Unable to get valid topology location: %s" % str(e))
    return dict()

  cl_args.update(new_cl_args)
  return cl_args
Exemple #2
0
def extract_common_args(command, parser, cl_args):
    '''
  Extract all the common args for all commands
  :param command:
  :param parser:
  :param cl_args:
  :return:
  '''
    try:
        cluster_role_env = cl_args.pop('cluster/[role]/[env]')
        config_path = cl_args['config_path']
        override_config_file = utils.parse_override_config(
            cl_args['config_property'])
    except KeyError:
        # if some of the arguments are not found, print error and exit
        subparser = utils.get_subparser(parser, command)
        print subparser.format_help()
        return dict()

    cluster = utils.get_heron_cluster(cluster_role_env)
    config_path = utils.get_heron_cluster_conf_dir(cluster, config_path)
    if not os.path.isdir(config_path):
        Log.error("Config path cluster directory does not exist: %s" %
                  config_path)
        return dict()

    new_cl_args = dict()
    try:
        cluster_tuple = utils.parse_cluster_role_env(cluster_role_env,
                                                     config_path)
        new_cl_args['cluster'] = cluster_tuple[0]
        new_cl_args['role'] = cluster_tuple[1]
        new_cl_args['environ'] = cluster_tuple[2]
        new_cl_args['config_path'] = config_path
        new_cl_args['override_config_file'] = override_config_file
    except Exception as ex:
        Log.error("Argument cluster/[role]/[env] is not correct: %s" % str(ex))
        return dict()

    cl_args.update(new_cl_args)
    return cl_args
Exemple #3
0
def extract_common_args(command, parser, cl_args):
  '''
  Extract all the common args for all commands
  :param command:
  :param parser:
  :param cl_args:
  :return:
  '''
  try:
    cluster_role_env = cl_args.pop('cluster/[role]/[env]')
    config_path = cl_args['config_path']
    override_config_file = utils.parse_override_config(cl_args['config_property'])
  except KeyError:
    # if some of the arguments are not found, print error and exit
    subparser = utils.get_subparser(parser, command)
    print subparser.format_help()
    return dict()

  cluster = utils.get_heron_cluster(cluster_role_env)
  config_path = utils.get_heron_cluster_conf_dir(cluster, config_path)
  if not os.path.isdir(config_path):
    Log.error("Config path cluster directory does not exist: %s" % config_path)
    return dict()

  new_cl_args = dict()
  try:
    cluster_tuple = utils.parse_cluster_role_env(cluster_role_env, config_path)
    new_cl_args['cluster'] = cluster_tuple[0]
    new_cl_args['role'] = cluster_tuple[1]
    new_cl_args['environ'] = cluster_tuple[2]
    new_cl_args['config_path'] = config_path
    new_cl_args['override_config_file'] = override_config_file
  except Exception as ex:
    Log.error("Argument cluster/[role]/[env] is not correct: %s" % str(ex))
    return dict()

  cl_args.update(new_cl_args)
  return cl_args