os-apply-config --key doesn't work for non-string values

Bug #1243263 reported by Roman Podoliaka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-apply-config
Fix Released
Medium
Roman Podoliaka

Bug Description

When trying to print a non-string value I get the following error:

$ sudo os-apply-config --key nova.baremetal.use_file_injection --type raw
Traceback (most recent call last):
  File "/usr/local/bin/os-apply-config", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/venvs/os-apply-config/local/lib/python2.7/site-packages/os_apply_config/apply_config.py", line 235, in main
    opts.fallback_metadata)
  File "/opt/stack/venvs/os-apply-config/local/lib/python2.7/site-packages/os_apply_config/apply_config.py", line 68, in print_key
    value_types.ensure_type(config, type_name)
  File "/opt/stack/venvs/os-apply-config/local/lib/python2.7/site-packages/os_apply_config/value_types.py", line 37, in ensure_type
    if not re.match(TYPES[type_name], string_value):
  File "/opt/stack/venvs/os-apply-config/lib/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer

This is caused by the fact, that ensure_type() function accepts string values, but a parsed is passed (in this case, bool).

Changed in os-apply-config:
status: New → Incomplete
status: Incomplete → Confirmed
assignee: nobody → Roman Podolyaka (rpodolyaka)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to os-apply-config (master)

Fix proposed to branch: master
Review: https://review.openstack.org/53149

Changed in os-apply-config:
status: Confirmed → In Progress
Changed in os-apply-config:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-apply-config (master)

Reviewed: https://review.openstack.org/53149
Committed: http://github.com/openstack/os-apply-config/commit/a6669356923e9a2ffed358fc305f38d532807eab
Submitter: Jenkins
Branch: master

commit a6669356923e9a2ffed358fc305f38d532807eab
Author: Roman Podolyaka <email address hidden>
Date: Tue Oct 22 18:28:55 2013 +0300

    Fix printing of keys with non-string values

    When trying to print a key which has a non-string value
    (e.g. bool or int), TypeError exception is raised. This
    is caused by the fact, that ensure_type() function accepts
    string values, but parsed values are passed (i.e. False
    instead of 'False' or 12 instead of '12' and so on).

    Change-Id: I10f5e60994bc34288f15af07d2d255ace3755b57
    Closes-Bug: #1243263

Changed in os-apply-config:
status: In Progress → Fix Committed
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Contained in 0.1.4

Changed in os-apply-config:
status: Fix Committed → Fix Released
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.