Rename to os-apply-config.
The name os-config-applier was too confusing given os-refresh-config as the partner program, so we've decided to rename to os-apply-config. To aid migration the old command name and default template path are still supported. Change-Id: I39725595275e7b4375ac4fda52e6a14b7071f7e9
This commit is contained in:
parent
48e6c5f40e
commit
ba51abbdf1
4
.gitignore
vendored
4
.gitignore
vendored
@ -38,3 +38,7 @@ nosetests.xml
|
||||
# OpenStack Generated Files
|
||||
AUTHORS
|
||||
ChangeLog
|
||||
|
||||
# Editors
|
||||
*~
|
||||
*.swp
|
||||
|
20
README.md
20
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
|
||||
```
|
||||
|
@ -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'))
|
@ -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"}}'
|
||||
|
@ -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):
|
@ -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):
|
11
setup.cfg
11
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 =
|
||||
|
Loading…
Reference in New Issue
Block a user