Add cachedir and command options
This commit is contained in:
parent
ae75926f47
commit
21db93faba
|
@ -20,6 +20,17 @@ from os_collect_config import ec2
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
|
opts = [
|
||||||
|
cfg.StrOpt('command',
|
||||||
|
short='c',
|
||||||
|
help='Command to run on metadata changes.'),
|
||||||
|
cfg.StrOpt('cachedir',
|
||||||
|
short='d',
|
||||||
|
default='/var/run/os-collect-config',
|
||||||
|
help='Directory in which to store local cache of metadata')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def setup_conf():
|
def setup_conf():
|
||||||
ec2_group = cfg.OptGroup(name='ec2',
|
ec2_group = cfg.OptGroup(name='ec2',
|
||||||
title='EC2 Metadata options')
|
title='EC2 Metadata options')
|
||||||
|
@ -27,6 +38,8 @@ def setup_conf():
|
||||||
conf = cfg.ConfigOpts()
|
conf = cfg.ConfigOpts()
|
||||||
conf.register_group(ec2_group)
|
conf.register_group(ec2_group)
|
||||||
conf.register_opts(ec2.opts, group='ec2')
|
conf.register_opts(ec2.opts, group='ec2')
|
||||||
|
|
||||||
|
conf.register_opts(opts)
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,3 +47,6 @@ def __main__():
|
||||||
conf = setup_conf()
|
conf = setup_conf()
|
||||||
log.setup("os-collect-config")
|
log.setup("os-collect-config")
|
||||||
print json.dumps(ec2.collect(conf), indent=1)
|
print json.dumps(ec2.collect(conf), indent=1)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
__main__()
|
||||||
|
|
|
@ -35,7 +35,7 @@ def _fetch_metadata(fetch_url):
|
||||||
try:
|
try:
|
||||||
(resp, content) = h.request(fetch_url)
|
(resp, content) = h.request(fetch_url)
|
||||||
except httplib2.socks.HTTPError as e:
|
except httplib2.socks.HTTPError as e:
|
||||||
log.getLogger().warn(e)
|
log.getLogger(__name__).warn(e)
|
||||||
raise exc.Ec2MetadataNotAvailable
|
raise exc.Ec2MetadataNotAvailable
|
||||||
if fetch_url[-1] == '/':
|
if fetch_url[-1] == '/':
|
||||||
new_content = {}
|
new_content = {}
|
||||||
|
|
|
@ -38,3 +38,4 @@ class TestCollect(testtools.TestCase):
|
||||||
def test_setup_conf(self):
|
def test_setup_conf(self):
|
||||||
conf = collect.setup_conf()
|
conf = collect.setup_conf()
|
||||||
self.assertThat(conf, matchers.IsInstance(cfg.ConfigOpts))
|
self.assertThat(conf, matchers.IsInstance(cfg.ConfigOpts))
|
||||||
|
self.assertEquals('/var/run/os-collect-config', conf.cachedir)
|
||||||
|
|
Loading…
Reference in New Issue