diff --git a/.gitignore b/.gitignore index 9156a66..277898d 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,7 @@ nosetests.xml # OpenStack Generated Files AUTHORS ChangeLog + +# Editors +*~ +*.swp diff --git a/README.md b/README.md index 428da63..1c55d8d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -os-config-applier -================= +os-apply-config +=============== -Apply configuration from cloud metadata. +Apply configuration from cloud metadata (JSON). # What does it do? -it turns a cloud-metadata file like this: +It turns a cloud-metadata file like this: ```javascript {"keystone": {"database": {"host": "127.0.0.1", "user": "keystone", "password": "foobar"}}} ``` @@ -21,7 +21,7 @@ connection = mysql://keystone:foobar@127.0.0.1/keystone Just pass it the path to a directory tree of templates: ``` -os-config-applier -t /home/me/my_templates +sudo os-apply-config -t /home/me/my_templates ``` # Templates @@ -59,9 +59,9 @@ connection = mysql://{{keystone.database.user}}:{{keystone.database.password}@{{ Configuration requiring logic is expressed in executable templates. -An executable template is a script which accepts configuration as a json string on standard in, and writes a config file to standard out. +An executable template is a script which accepts configuration as a JSON string on standard in, and writes a config file to standard out. -The script should exit non-zero if it encounters a problem, so that os-config-applier knows what's up. +The script should exit non-zero if it encounters a problem, so that os-apply-config knows what's up. The output of the script will be written to the path corresponding to the executable template's path in the template tree. @@ -96,11 +96,11 @@ puts Mustache.render(template, params) # Quick Start ```bash # install it -sudo pip install -U git+git://github.com/tripleo/os-config-applier.git +sudo pip install -U git+git://github.com/stackforge/os-config-applier.git # grab example templates -git clone git://github.com/tripleo/openstack-config-templates /tmp/config +git clone git://github.com/stackforge/triple-image-elements /tmp/config # run it -os-config-applier -t /tmp/config/templates/ -m /tmp/config/cfn-init-data.example -o /tmp/config_output +os-apply-config -t /tmp/config/elements/nova/os-config-applier/ -m /tmp/config/elements/boot-stack/config.json -o /tmp/config_output ``` diff --git a/os_config_applier/__init__.py b/os_apply_config/__init__.py similarity index 100% rename from os_config_applier/__init__.py rename to os_apply_config/__init__.py diff --git a/os_config_applier/config_exception.py b/os_apply_config/config_exception.py similarity index 100% rename from os_config_applier/config_exception.py rename to os_apply_config/config_exception.py diff --git a/os_config_applier/os_config_applier.py b/os_apply_config/os_apply_config.py similarity index 94% rename from os_config_applier/os_config_applier.py rename to os_apply_config/os_apply_config.py index 40c5579..3ae735d 100755 --- a/os_config_applier/os_config_applier.py +++ b/os_apply_config/os_apply_config.py @@ -27,8 +27,12 @@ from config_exception import ConfigException from renderers import JsonRenderer from value_types import ensure_type -TEMPLATES_DIR = os.environ.get('OS_CONFIG_APPLIER_TEMPLATES', - '/opt/stack/os-config-applier/templates') +TEMPLATES_DIR = os.environ.get('OS_CONFIG_APPLIER_TEMPLATES', None) +if TEMPLATES_DIR is None: + TEMPLATES_DIR = '/opt/stack/os-apply-config/templates' + if not os.path.isdir(TEMPLATES_DIR): + # Backwards compat with the old name. + TEMPLATES_DIR = '/opt/stack/os-config-applier/templates' def install_config(config_path, template_root, @@ -227,8 +231,8 @@ DATE_FORMAT = '%Y/%m/%d %I:%M:%S %p' def add_handler(logger, handler): handler.setFormatter(logging.Formatter(LOG_FORMAT, datefmt=DATE_FORMAT)) logger.addHandler(handler) -logger = logging.getLogger('os-config-applier') +logger = logging.getLogger('os-apply-config') logger.setLevel(logging.INFO) add_handler(logger, logging.StreamHandler()) if os.geteuid() == 0: - add_handler(logger, logging.FileHandler('/var/log/os-config-applier.log')) + add_handler(logger, logging.FileHandler('/var/log/os-apply-config.log')) diff --git a/os_config_applier/renderers.py b/os_apply_config/renderers.py similarity index 100% rename from os_config_applier/renderers.py rename to os_apply_config/renderers.py diff --git a/os_config_applier/tests/__init__.py b/os_apply_config/tests/__init__.py similarity index 100% rename from os_config_applier/tests/__init__.py rename to os_apply_config/tests/__init__.py diff --git a/os_config_applier/tests/templates/etc/glance/script.conf b/os_apply_config/tests/templates/etc/glance/script.conf similarity index 100% rename from os_config_applier/tests/templates/etc/glance/script.conf rename to os_apply_config/tests/templates/etc/glance/script.conf diff --git a/os_config_applier/tests/templates/etc/keystone/keystone.conf b/os_apply_config/tests/templates/etc/keystone/keystone.conf similarity index 100% rename from os_config_applier/tests/templates/etc/keystone/keystone.conf rename to os_apply_config/tests/templates/etc/keystone/keystone.conf diff --git a/os_config_applier/tests/test_json_renderer.py b/os_apply_config/tests/test_json_renderer.py similarity index 97% rename from os_config_applier/tests/test_json_renderer.py rename to os_apply_config/tests/test_json_renderer.py index 0fa4f0a..2b34218 100644 --- a/os_config_applier/tests/test_json_renderer.py +++ b/os_apply_config/tests/test_json_renderer.py @@ -18,7 +18,7 @@ import json import testtools from testtools import content -from os_config_applier import renderers +from os_apply_config import renderers TEST_JSON = '{"a":{"b":[1,2,3,"foo"],"c": "the quick brown fox"}}' diff --git a/os_config_applier/tests/test_os_config_applier.py b/os_apply_config/tests/test_os_apply_config.py similarity index 93% rename from os_config_applier/tests/test_os_config_applier.py rename to os_apply_config/tests/test_os_apply_config.py index a731891..102fa61 100644 --- a/os_config_applier/tests/test_os_config_applier.py +++ b/os_apply_config/tests/test_os_apply_config.py @@ -20,8 +20,8 @@ import tempfile import fixtures import testtools -from os_config_applier import config_exception -from os_config_applier import os_config_applier as oca +from os_apply_config import config_exception +from os_apply_config import os_apply_config as oca # example template tree TEMPLATES = os.path.join(os.path.dirname(__file__), 'templates') @@ -58,7 +58,7 @@ OUTPUT = { def main_path(): return ( os.path.dirname(os.path.realpath(__file__)) + - '/../os_config_applier.py') + '/../os_apply_config.py') def template(relpath): @@ -75,7 +75,7 @@ class TestRunOSConfigApplier(testtools.TestCase): stderr = self.useFixture(fixtures.StringStream('stderr')).stream self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) self.logger = self.useFixture( - fixtures.FakeLogger(name="os-config-applier")) + fixtures.FakeLogger(name="os-apply-config")) fd, self.path = tempfile.mkstemp() with os.fdopen(fd, 'w') as t: t.write(json.dumps(CONFIG)) @@ -83,7 +83,7 @@ class TestRunOSConfigApplier(testtools.TestCase): def test_print_key(self): self.assertEqual(0, oca.main( - ['os-config-applier.py', '--metadata', self.path, '--key', + ['os-apply-config.py', '--metadata', self.path, '--key', 'database.url', '--type', 'raw'])) self.stdout.seek(0) self.assertEqual(CONFIG['database']['url'], @@ -92,13 +92,13 @@ class TestRunOSConfigApplier(testtools.TestCase): def test_print_key_missing(self): self.assertEqual(1, oca.main( - ['os-config-applier.py', '--metadata', self.path, '--key', + ['os-apply-config.py', '--metadata', self.path, '--key', 'does.not.exist'])) self.assertIn('does not exist', self.logger.output) def test_print_key_missing_default(self): self.assertEqual(0, oca.main( - ['os-config-applier.py', '--metadata', self.path, '--key', + ['os-apply-config.py', '--metadata', self.path, '--key', 'does.not.exist', '--key-default', ''])) self.stdout.seek(0) self.assertEqual('', self.stdout.read().strip()) @@ -106,12 +106,12 @@ class TestRunOSConfigApplier(testtools.TestCase): def test_print_key_wrong_type(self): self.assertEqual(1, oca.main( - ['os-config-applier.py', '--metadata', self.path, '--key', + ['os-apply-config.py', '--metadata', self.path, '--key', 'x', '--type', 'int'])) self.assertIn('cannot interpret value', self.logger.output) def test_print_templates(self): - oca.main(['os-config-applier', '--print-templates']) + oca.main(['os-apply-config', '--print-templates']) self.stdout.seek(0) self.assertEqual(self.stdout.read().strip(), oca.TEMPLATES_DIR) self.assertEqual('', self.logger.output) @@ -121,7 +121,7 @@ class OSConfigApplierTestCase(testtools.TestCase): def setUp(self): super(OSConfigApplierTestCase, self).setUp() - self.useFixture(fixtures.FakeLogger('os-config-applier')) + self.useFixture(fixtures.FakeLogger('os-apply-config')) self.useFixture(fixtures.NestedTempfile()) def test_install_config(self): diff --git a/os_config_applier/tests/test_value_type.py b/os_apply_config/tests/test_value_type.py similarity index 96% rename from os_config_applier/tests/test_value_type.py rename to os_apply_config/tests/test_value_type.py index db8d8f4..946458e 100644 --- a/os_config_applier/tests/test_value_type.py +++ b/os_apply_config/tests/test_value_type.py @@ -15,8 +15,8 @@ import testtools -from os_config_applier import config_exception -from os_config_applier import value_types +from os_apply_config import config_exception +from os_apply_config import value_types class ValueTypeTestCase(testtools.TestCase): diff --git a/os_config_applier/value_types.py b/os_apply_config/value_types.py similarity index 100% rename from os_config_applier/value_types.py rename to os_apply_config/value_types.py diff --git a/setup.cfg b/setup.cfg index 1ee4b4b..8880344 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,11 @@ [metadata] -name = os-config-applier +name = os-apply-config author = OpenStack author-email = openstack-dev@lists.openstack.org -summary = OpenStack configuration from cloud metadata +summary = Config files from cloud metadata description-file = README.md -home-page = http://github.com/tripleo/os-config-applier +home-page = http://github.com/stackforge/os-config-applier classifier = Development Status :: 4 - Beta Environment :: Console @@ -18,7 +18,7 @@ classifier = [files] packages = - os_config_applier + os_apply_config [global] setup-hooks = @@ -26,7 +26,8 @@ setup-hooks = [entry_points] console_scripts = - os-config-applier = os_config_applier.os_config_applier:main + os-config-applier = os_apply_config.os_apply_config:main + os-apply-config = os_apply_config.os_apply_config:main [egg_info] tag_build =