Public bug reported:

If we register a DictOpt type config option in nova, then the following
error will be given when running tools/config/generate_sample.sh to
generate nova.conf.sample:

'NoneType' object has no attribute 'group'

The tools/config/generate_sample.sh calls
openstack.common.config.generator to execute the generation of config
sample, and in openstack.common.config.generator there doesn't exist a
way to process DictOpt type options:

STROPT = "StrOpt"
BOOLOPT = "BoolOpt"
INTOPT = "IntOpt"
FLOATOPT = "FloatOpt"
LISTOPT = "ListOpt"
MULTISTROPT = "MultiStrOpt"

OPT_TYPES = {
    STROPT: 'string value',
    BOOLOPT: 'boolean value',
    INTOPT: 'integer value',
    FLOATOPT: 'floating point value',
    LISTOPT: 'list value',
    MULTISTROPT: 'multi valued',
}

OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT,
                                              FLOATOPT, LISTOPT,
                                              MULTISTROPT]))

…

def _print_opt(opt):
    opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help
    if not opt_help:
        sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name)
        opt_help = ""
    opt_type = None
    try:
        opt_type = OPTION_REGEX.search(str(type(opt))).group(0)
    except (ValueError, AttributeError) as err:
        sys.stderr.write("%s\n" % str(err))
        sys.exit(1)
    opt_help += ' (' + OPT_TYPES[opt_type] + ')'
    print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH)))
    if opt.deprecated_opts:
        for deprecated_opt in opt.deprecated_opts:
            if deprecated_opt.name:
                deprecated_group = (deprecated_opt.group if
                                    deprecated_opt.group else "DEFAULT")
                print('# Deprecated group/name - [%s]/%s' %
                      (deprecated_group,
                       deprecated_opt.name))
    try:
        if opt_default is None:
            print('#%s=<None>' % opt_name)
        elif opt_type == STROPT:
            assert(isinstance(opt_default, six.string_types))
            print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
                                                          opt_default)))
        elif opt_type == BOOLOPT:
            assert(isinstance(opt_default, bool))
            print('#%s=%s' % (opt_name, str(opt_default).lower()))
        elif opt_type == INTOPT:
            assert(isinstance(opt_default, int) and
                   not isinstance(opt_default, bool))
            print('#%s=%s' % (opt_name, opt_default))
        elif opt_type == FLOATOPT:
            assert(isinstance(opt_default, float))
            print('#%s=%s' % (opt_name, opt_default))
        elif opt_type == LISTOPT:
            assert(isinstance(opt_default, list))
            print('#%s=%s' % (opt_name, ','.join(opt_default)))
        elif opt_type == MULTISTROPT:
            assert(isinstance(opt_default, list))
            if not opt_default:
                opt_default = ['']
            for default in opt_default:
                print('#%s=%s' % (opt_name, default))
        print('')
    except Exception:
        sys.stderr.write('Error in option "%s"\n' % opt_name)
        sys.exit(1)

Since the DictOpt value is not recognized , the code exists with an exception.
This problem will also affect tools/config/check_uptodate.sh because that also 
depend on the same module to process config sample generation.

** Affects: nova
     Importance: Undecided
     Assignee: Xinyuan Huang (xyhuang)
         Status: New

** Affects: oslo
     Importance: Undecided
     Assignee: Xinyuan Huang (xyhuang)
         Status: New

** Changed in: oslo
     Assignee: (unassigned) => Xinyuan Huang (xyhuang)

** Also affects: nova
   Importance: Undecided
       Status: New

** Changed in: nova
     Assignee: (unassigned) => Xinyuan Huang (xyhuang)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1276859

Title:
  config sample generator cannot recognize DictOpt type options

Status in OpenStack Compute (Nova):
  New
Status in Oslo - a Library of Common OpenStack Code:
  New

Bug description:
  If we register a DictOpt type config option in nova, then the
  following error will be given when running
  tools/config/generate_sample.sh to generate nova.conf.sample:

  'NoneType' object has no attribute 'group'

  The tools/config/generate_sample.sh calls
  openstack.common.config.generator to execute the generation of config
  sample, and in openstack.common.config.generator there doesn't exist a
  way to process DictOpt type options:

  STROPT = "StrOpt"
  BOOLOPT = "BoolOpt"
  INTOPT = "IntOpt"
  FLOATOPT = "FloatOpt"
  LISTOPT = "ListOpt"
  MULTISTROPT = "MultiStrOpt"

  OPT_TYPES = {
      STROPT: 'string value',
      BOOLOPT: 'boolean value',
      INTOPT: 'integer value',
      FLOATOPT: 'floating point value',
      LISTOPT: 'list value',
      MULTISTROPT: 'multi valued',
  }

  OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT,
                                                FLOATOPT, LISTOPT,
                                                MULTISTROPT]))

  …

  def _print_opt(opt):
      opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help
      if not opt_help:
          sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name)
          opt_help = ""
      opt_type = None
      try:
          opt_type = OPTION_REGEX.search(str(type(opt))).group(0)
      except (ValueError, AttributeError) as err:
          sys.stderr.write("%s\n" % str(err))
          sys.exit(1)
      opt_help += ' (' + OPT_TYPES[opt_type] + ')'
      print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH)))
      if opt.deprecated_opts:
          for deprecated_opt in opt.deprecated_opts:
              if deprecated_opt.name:
                  deprecated_group = (deprecated_opt.group if
                                      deprecated_opt.group else "DEFAULT")
                  print('# Deprecated group/name - [%s]/%s' %
                        (deprecated_group,
                         deprecated_opt.name))
      try:
          if opt_default is None:
              print('#%s=<None>' % opt_name)
          elif opt_type == STROPT:
              assert(isinstance(opt_default, six.string_types))
              print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
                                                            opt_default)))
          elif opt_type == BOOLOPT:
              assert(isinstance(opt_default, bool))
              print('#%s=%s' % (opt_name, str(opt_default).lower()))
          elif opt_type == INTOPT:
              assert(isinstance(opt_default, int) and
                     not isinstance(opt_default, bool))
              print('#%s=%s' % (opt_name, opt_default))
          elif opt_type == FLOATOPT:
              assert(isinstance(opt_default, float))
              print('#%s=%s' % (opt_name, opt_default))
          elif opt_type == LISTOPT:
              assert(isinstance(opt_default, list))
              print('#%s=%s' % (opt_name, ','.join(opt_default)))
          elif opt_type == MULTISTROPT:
              assert(isinstance(opt_default, list))
              if not opt_default:
                  opt_default = ['']
              for default in opt_default:
                  print('#%s=%s' % (opt_name, default))
          print('')
      except Exception:
          sys.stderr.write('Error in option "%s"\n' % opt_name)
          sys.exit(1)

  Since the DictOpt value is not recognized , the code exists with an exception.
  This problem will also affect tools/config/check_uptodate.sh because that 
also depend on the same module to process config sample generation.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1276859/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to