Skip to content

Commit

Permalink
Move management code to inventory lib.
Browse files Browse the repository at this point in the history
This change moves the management code into a library file for
consolidated access to the code. Nothing is changed with the interface
to the inventory-manage script.

The lib/__init__.py file is necessary for python to
import the lib directory as a package, which will become more important
as more code is relocated there.

The code was originally moved to playbooks/inventory/lib, but doing so
made Ansible try to run the python files, which they intentionally will
not do.

Change-Id: I2e31927ec48022c7a504096780977319882c6bdf
  • Loading branch information
Nolan Brubaker committed Oct 11, 2016
1 parent 34b5dcc commit 0d9eb88
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
Empty file added lib/__init__.py
Empty file.
File renamed without changes.
13 changes: 10 additions & 3 deletions scripts/inventory-manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@
"""Returns data about containers and groups in tabular formats."""

# NOTE(nrb/palendae): The contents of this file were moved
# to manage_inventory.py in order to facilitate importing of the python code
# to manage.py in order to facilitate importing of the python code

# This file remains for backwards compatibility
import manage_inventory
import os
import sys

cwd = os.path.abspath(os.path.dirname(__file__))
import_path = os.path.join(cwd, '..', 'lib')
sys.path.append(import_path)

import manage

if __name__ == "__main__":
manage_inventory.main()
manage.main()
4 changes: 2 additions & 2 deletions tests/test_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import test_inventory
import unittest

MANAGE_DIR = path.join(os.getcwd(), 'scripts')
MANAGE_DIR = path.join(os.getcwd(), 'lib')

sys.path.append(MANAGE_DIR)

import manage_inventory as mi
import manage as mi


def setUpModule():
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ commands =
coverage report --show-missing --include={toxinidir}/playbooks/inventory/*
coverage erase
coverage run {toxinidir}/tests/test_manage.py
coverage report --show-missing --include={toxinidir}/scripts/*
coverage report --show-missing --include={toxinidir}/lib/*


[testenv:linters]
Expand Down

0 comments on commit 0d9eb88

Please sign in to comment.