Collect and cache metadata, run hooks on changes.
Go to file
Steve Baker 61ff6aaec7 Use TEST-NET-1 for unit tests, not 127.0.0.1
Currently if http requests are not correctly mocked, behaviour of the
unit tests will depend on what happens to be running on localhost.

Jobs like gate-os-collect-config-python27-ubuntu-xenial are currently
broken because discover requests are being made to localhost and
something has change in the environment to cause test failure.

This change does the following:
- replace unit tests addresses from 127.0.0.1 to 192.0.2.1 (TEST-NET-1)
- fix mocking of tests which now stall because 192.0.2.1 isn't accessable
- change the mocking approach to keystoneclient.discover.Discover to
  a simple stub class

Change-Id: I6d9450d6854b9f50dac0f55f54f1ea1d579a27ac
2016-10-12 12:16:52 +13:00
os_collect_config Use TEST-NET-1 for unit tests, not 127.0.0.1 2016-10-12 12:16:52 +13:00
.coveragerc Change ignore-errors to ignore_errors 2015-09-21 14:41:46 +00:00
.gitignore Modify gitignore to ignore cover 2014-09-12 15:53:50 +09:00
.gitreview Update stackforge references to openstack 2013-08-17 22:59:30 -04:00
.testr.conf Remove env vars we don't use. 2013-03-28 04:05:31 +01:00
LICENSE Aligned tests with OpenStack standards. 2013-03-28 03:40:38 +01:00
MANIFEST.in Ensure that README file makes it into the tarball 2013-07-07 11:56:08 -04:00
README.rst Add diagram to os-collect-config README.rst 2014-03-26 09:13:19 -07:00
os-collect-config-and-friends.odg Add diagram to os-collect-config README.rst 2014-03-26 09:13:19 -07:00
os-collect-config-and-friends.svg Add diagram to os-collect-config README.rst 2014-03-26 09:13:19 -07:00
requirements.txt Updated from global requirements 2016-07-09 03:15:49 +00:00
setup.cfg Revert "Support building wheels (PEP-427)" 2013-11-29 12:56:17 +02:00
setup.py Updated from global requirements 2015-09-17 12:15:44 +00:00
test-requirements.txt Updated from global requirements 2016-07-09 03:15:49 +00:00
tox.ini Deprecated tox -downloadcache option removed 2016-04-23 15:19:25 +00:00

README.rst

os-collect-config

Collect configuration from cloud metadata sources

What does it do?

It collects data from defined configuration sources and runs a defined hook whenever the metadata has been changed.

image

1

Usage

You must define what sources to collect configuration data from in /etc/os-collect-config.conf.

The format of this file is:

[default]
command=os-refresh-config

[cfn]
metadata_url=http://192.0.2.99:8000/v1/
access_key_id = ABCDEFGHIJLMNOP01234567890
secret_access_key = 01234567890ABCDEFGHIJKLMNOP
path = MyResource
stack_name = my.stack

These sources will be polled and whenever any of them is changed, default.command will be run. A file will be written to the cache dir, os_config_files.json, which will be a json list of the file paths to the current copy of each metadata source. This list will also be set as a colon separated list in the environment variable OS_CONFIG_FILES for the command that is run. So in the example above, os-refresh-config would be executed with something like this in OS_CONFIG_FILES:

/var/lib/os-collect-config/ec2.json:/var/lib/os-collect-config/cfn.json

The previous version of the metadata from a source (if available) is present at $FILENAME.last.

When run without a command, the metadata sources are printed as a json document.

Quick Start

Install:

sudo pip install -U git+git://git.openstack.org/openstack/os-collect-config.git

Run it on an OpenStack instance with access to ec2 metadata:

os-collect-config

That should print out a json representation of the entire ec2 metadata tree.


  1. Recommend using LibreOffice draw to edit os-collect-config-and-friends.odg and regenerate the svg file. Alternatively edit the svg directly, but remove the .odg file if that is done.↩︎