Esempio n. 1
0
def collect_validation_messages(conf, error_list):
  validator = validate.Validator()
  conf.validate(validator, preserve_errors=True)
  message = []
  cm_extras = {
    'hadoop_hdfs_home': [('hadoop', 'hdfs_clusters', 'default')],
    'hadoop_bin': [('hadoop', 'hdfs_clusters', 'default'), ('hadoop', 'yarn_clusters', 'default'), ('hadoop', 'yarn_clusters', 'ha')],
    'hadoop_mapred_home': [('hadoop', 'yarn_clusters', 'default'), ('hadoop', 'yarn_clusters', 'ha')],
    'hadoop_conf_dir': [('hadoop', 'yarn_clusters', 'default'), ('hadoop', 'yarn_clusters', 'ha')],
    'ssl_cacerts': [('beeswax', 'ssl'), ('impala', 'ssl')],
    'remote_data_dir': [('liboozie', )],
    'shell': [()]
  }
  whitelist_extras = ((sections, name) for sections, name in get_extra_values(conf) if not (name in desktop.conf.APP_BLACKLIST.get() or (name in cm_extras.keys() and sections in cm_extras[name])))

  for sections, name in whitelist_extras:
    the_section = conf
    hierarchy_sections_string = ''
    try:
      parent = conf
      for section in sections:
        the_section = parent[section]
        hierarchy_sections_string += "[" * the_section.depth + section + "]" * the_section.depth + " "
        parent = the_section
    except KeyError, ex:
      LOG.warn("Section %s not found: %s" % (section, str(ex)))

    the_value = ''
    try:
      # the_value may be a section or a value
      the_value = the_section[name]
    except KeyError, ex:
      LOG.warn("Error in accessing Section or Value %s: %s" % (name, str(ex)))
Esempio n. 2
0
File: views.py Progetto: ranade1/hue
def collect_validation_messages(conf, error_list):
    validator = validate.Validator()
    conf.validate(validator, preserve_errors=True)
    message = []
    cm_extras = {
        'hadoop_hdfs_home': [('hadoop', 'hdfs_clusters', 'default')],
        'hadoop_bin': [('hadoop', 'hdfs_clusters', 'default'),
                       ('hadoop', 'yarn_clusters', 'default'),
                       ('hadoop', 'yarn_clusters', 'ha')],
        'hadoop_mapred_home': [('hadoop', 'yarn_clusters', 'default'),
                               ('hadoop', 'yarn_clusters', 'ha')],
        'hadoop_conf_dir': [('hadoop', 'yarn_clusters', 'default'),
                            ('hadoop', 'yarn_clusters', 'ha')],
        'ssl_cacerts': [('beeswax', 'ssl'), ('impala', 'ssl')],
        'remote_data_dir': [('liboozie', )],
        'shell': [()],
    }

    whitelist_extras = (
        (sections, name) for sections, name in get_extra_values(conf)
        if not (name in desktop.conf.APP_BLACKLIST.get() or (
            name in list(cm_extras.keys()) and sections in cm_extras[name])))

    for sections, name in whitelist_extras:
        the_section = conf
        hierarchy_sections_string = ''

        try:
            parent = conf
            for section in sections:
                the_section = parent[section]
                hierarchy_sections_string += "[" * the_section.depth + section + "]" * the_section.depth + " "
                parent = the_section
        except KeyError as ex:
            LOG.warning("Section %s not found: %s" % (section, str(ex)))

        the_value = ''
        try:
            # the_value may be a section or a value
            the_value = the_section[name]
        except KeyError as ex:
            LOG.warning("Error in accessing Section or Value %s: %s" %
                        (name, str(ex)))

        section_or_value = 'keyvalue'
        if isinstance(the_value, dict):
            # Sections are subclasses of dict
            section_or_value = 'section'

        section_string = hierarchy_sections_string or "top level"
        message.append('Extra %s, %s in the section: %s' %
                       (section_or_value, name, section_string))

    if message:
        error = {
            'name': 'ini configuration',
            'message': ', '.join(message),
        }
        error_list.append(error)
Esempio n. 3
0
File: views.py Progetto: uk0/hue
def collect_validation_messages(conf, error_list):
  validator = validate.Validator()
  conf.validate(validator, preserve_errors=True)
  message = []
  for sections, name in get_extra_values(conf):
    the_section = conf
    hierarchy_sections_string = ''
    try:
      parent = conf
      for section in sections:
        the_section = parent[section]
        hierarchy_sections_string += "[" * the_section.depth + section + "]" * the_section.depth + " "
        parent = the_section
    except KeyError, ex:
      LOG.warn("Section %s not found: %s" % (section, str(ex)))

    the_value = ''
    try:
      # the_value may be a section or a value
      the_value = the_section[name]
    except KeyError, ex:
      LOG.warn("Error in accessing Section or Value %s: %s" % (name, str(ex)))