inventory-manage.py fails with syntax error when removing items

Bug #1663328 reported by Joel Griffiths
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Fix Released
Undecided
Joel Griffiths

Bug Description

There are two errors in the lib/manage.py:

Syntax Error: seprator should be separator.
Function Call Error: filesys.save_inventory should be called with a path, not a filename

scripts/inventory-manage.py -r log1
Traceback (most recent call last):
  File "scripts/inventory-manage.py", line 36, in <module>
    manage.main()
  File "/opt/openstack-ansible/scripts/../lib/manage.py", line 336, in main
    seprators=(',', ': '))
  File "/usr/lib/python2.7/json/__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
TypeError: __init__() got an unexpected keyword argument 'seprators'

I've fixed it locally with this patch. Hoping to upload the fix myself:

diff --git a/lib/manage.py b/lib/manage.py
index 74b2e7e..4ad77e1 100644
--- a/lib/manage.py
+++ b/lib/manage.py
@@ -25,6 +25,8 @@ import prettytable
 import dictutils as du
 import filesystem as filesys

+import os.path
+

 def args():
     """Setup argument Parsing."""
@@ -331,8 +333,8 @@ def main():
     else:
         du.recursive_dict_removal(inventory, user_args['remove_item'])
         inventory_json = json.dumps(inventory, indent=2,
- seprators=(',', ': '))
- filesys.save_inventory(inventory_json, filename)
+ separators=(',', ': '))
+ filesys.save_inventory(inventory_json, os.path.dirname(filename))
         print('Success. . .')

 if __name__ == "__main__":

Changed in openstack-ansible:
assignee: nobody → Joel Griffiths (joelgriffiths)
Changed in openstack-ansible:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible (master)

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

Changed in openstack-ansible:
assignee: Joel Griffiths (joelgriffiths) → Joel Griffiths (5s-ubuntu)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible (master)

Reviewed: https://review.openstack.org/433802
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible/commit/?id=3a08bb7b78b52590e9994703262fe54e4e7f7099
Submitter: Jenkins
Branch: master

commit 3a08bb7b78b52590e9994703262fe54e4e7f7099
Author: Joel Griffiths <email address hidden>
Date: Mon Feb 13 23:06:14 2017 +0000

    Fix error during 'inventory-manage.py -r' calls

    Use load_inventory instead for load_from_json. Rename
    load_from_json to _load_from_json.

    Move most of the --clear-ip and --remove calls to their
    corresponding functions. Modified other calls to account
    for the change

    Add a test to test for inventory item removal.

    fixes bug: 1663328

    Change-Id: I2dbecb085383b3d02e298cc09b02566d1e52a064

Changed in openstack-ansible:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/438353

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible (stable/ocata)

Reviewed: https://review.openstack.org/438353
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible/commit/?id=7df772c0fc44c3df8f2c09113ca23f8efcf87029
Submitter: Jenkins
Branch: stable/ocata

commit 7df772c0fc44c3df8f2c09113ca23f8efcf87029
Author: Joel Griffiths <email address hidden>
Date: Mon Feb 13 23:06:14 2017 +0000

    Fix error during 'inventory-manage.py -r' calls

    Use load_inventory instead for load_from_json. Rename
    load_from_json to _load_from_json.

    Move most of the --clear-ip and --remove calls to their
    corresponding functions. Modified other calls to account
    for the change

    Add a test to test for inventory item removal.

    fixes bug: 1663328

    Change-Id: I2dbecb085383b3d02e298cc09b02566d1e52a064
    (cherry picked from commit 3a08bb7b78b52590e9994703262fe54e4e7f7099)

tags: added: in-stable-ocata
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.