5 Commits

Author SHA1 Message Date
Nolan Brubaker
ea6954f72f Use python import machinery for inventory code
Change Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7 restructured the python
inventory generation code so that it would be possible to install it
with pip. This change removes (most) of the import path hacks and
switches to using a pip-installed version of osa_toolkit.

Of note, the path hacks are left in place for the dynamic_inventory.py
file for now, as that file is really more of an endpoint, but is tested.

Also, the bootstrap-ansible.sh script was modified to install the code;
this is unnecessary with the tox environments because the tox directive
'usedevelop=True' does that already. Production environments still need
this, though.

Finally, to maintain usability when called directly, the interpreter for
dynamic_inventory.py was updated from `/usr/bin/env` to
`/opt/ansible-runime/python`. This change ensures that in a full
deployment the user is using the exact same code paths whether Ansible
invokes the script, or it is called directly. This also means that using
the script locally on a development machine, it must be invoked as an
argument to Python, unless the ansible-runtime directory exists.

Change-Id: Iafa573b1b144f98528d5e0aceb3f36e9de2a22a2
2017-07-28 16:39:52 +00:00
Nolan Brubaker
fa5336ca36 Fix Python 3 dictionary incompatibilities
There were two instances of abusing old Python 2 behaviors around
dictionary keys that Python 3 no longer allows. These are both fixed.

Change-Id: I5865ee3becf52fca590a1c0c897bcd968210ac9d
2017-06-08 18:41:35 +00:00
Nolan Brubaker
a1d51d58e7 Improve compatibiliity with Python 3
This patchset introduces some changes to improve compability with Python
3. It does _not_ make the codebase 100% Python 3 compatible, however.

Changes made:

* Fix import of the Queue module to look for 'queue' on ImportError
* Rename `iteritems` calls to `items`.

Some remaining compatibility issues:

* Bytes vs string objects - this compromises most of the errors we
  currently have, across all files and tests
* Treating `dict_keys` objects as lists and calling `append`
  (generate._parse_global_variables)
* Altering dictionary keys during iteration
  (test_inventory.testing_deleting_elements)

Change-Id: I6ad9601c5835703f44cc0752cef15c682298a40e
2017-06-06 10:44:13 -04:00
Jimmy McCrory
4a35fe9ea2 Remove unused properties from environment files
The 'service_name' property is a holdover from when there was a common
role used to install all OpenStack services. This is now a default
variable within each individual role. Similarly, the 'log_directory'
property for galera containers is now handled by the 'log_dirs' variable
within its playbook.

The dynamic inventory script has been updated to create an empty
'properties' dict for any container skeletons within the environment
that do not have one already defined.

Change-Id: Icd852f24251c1cef0fa162d33e2422be83e0a833
2017-05-08 16:10:53 -07:00
Nolan Brubaker
2be3319ac9 Restructure lib directory to install via pip
This change allows the currently existing modules to be imported from
the `osa_toolkit` package.

In order to install the python modules used by the inventory via
setup.py with pbr, we need to rename the lib directory to match the name
of the package we wish to install.

pbr doesn't allow for doing any kind of directory renaming within the
setup.{cfg,py} files, but we need to keep using it in order to consume
global requirements updates.

Change-Id: Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7
2017-03-30 10:19:01 -04:00