Move management code to inventory lib.

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
This commit is contained in:
Nolan Brubaker 2016-10-06 12:10:43 -04:00
parent 34b5dcc053
commit 0d9eb88ab1
5 changed files with 13 additions and 6 deletions

0
lib/__init__.py Normal file
View File

View File

@ -20,10 +20,17 @@
"""Returns data about containers and groups in tabular formats.""" """Returns data about containers and groups in tabular formats."""
# NOTE(nrb/palendae): The contents of this file were moved # 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 # 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__": if __name__ == "__main__":
manage_inventory.main() manage.main()

View File

@ -6,11 +6,11 @@ import sys
import test_inventory import test_inventory
import unittest import unittest
MANAGE_DIR = path.join(os.getcwd(), 'scripts') MANAGE_DIR = path.join(os.getcwd(), 'lib')
sys.path.append(MANAGE_DIR) sys.path.append(MANAGE_DIR)
import manage_inventory as mi import manage as mi
def setUpModule(): def setUpModule():

View File

@ -151,7 +151,7 @@ commands =
coverage report --show-missing --include={toxinidir}/playbooks/inventory/* coverage report --show-missing --include={toxinidir}/playbooks/inventory/*
coverage erase coverage erase
coverage run {toxinidir}/tests/test_manage.py coverage run {toxinidir}/tests/test_manage.py
coverage report --show-missing --include={toxinidir}/scripts/* coverage report --show-missing --include={toxinidir}/lib/*
[testenv:linters] [testenv:linters]