generate_sample.sh does not generate sample configuration for modules using "_" builtin.

Bug #1183731 reported by Ann Taraday
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Ann Taraday

Bug Description

If we use generate_sample.sh for modules that contains "_" builtin and has configuration declaration, it won't gererate samlpe configuration for such module.
generate_sample.sh calls extract_opts.py, so the problem is in the extract_opts.py.
For example,

akamyshnikova@akamyshnikova:/opt/stack/cinder$ python tools/conf/extract_opts.py cinder/backup/manager.py
####################
# cinder.conf sample #
####################

[DEFAULT]

# Total option count: 0
akamyshnikova@akamyshnikova:/opt/stack/cinder$

If we use debug for this command we see that

 /opt/stack/cinder/tools/conf/extract_opts.py(81)_print_module()
-> mod_obj = importutils.import_module(mod_str)
(Pdb) n
NameError: "name '_' is not defined"

So, if we add to extract_opts.py

import __builtin__
setattr(__builtin__, '_', lambda x: x)

everything works correctly:

akamyshnikova@akamyshnikova:/opt/stack/cinder$ python tools/conf/extract_opts.py cinder/backup/manager.py
####################
# cinder.conf sample #
####################

[DEFAULT]

#
# Options defined in cinder.backup.manager
#

# Service to use for backups. (string value)
#backup_service=cinder.backup.services.swift

# Total option count: 1

Changed in cinder:
assignee: nobody → Ann Kamyshnikova (akamyshnikova)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/30235
Committed: http://github.com/openstack/cinder/commit/9cdccf36c6d8a07cfdc3ee0e974736951317005b
Submitter: Jenkins
Branch: master

commit 9cdccf36c6d8a07cfdc3ee0e974736951317005b
Author: Ann Kamyshnikova <email address hidden>
Date: Thu May 23 13:33:30 2013 +0400

    Add "_" builtin method for config generation

    extract_opts.py fails to generate config without this

    bug 1183731

    Change-Id: Icf3b45d5d7262607336f5d5e7a0a14b0dee9741d

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → havana-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: havana-1 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.