Vanilla plugin configuration helper fixing:
* Added hidden configs, which could not be changed by user * Fixes issue with generating xml document with only text nodes Improves blueprint vanilla-plugin-configs-improvements Change-Id: Idd1f58e65fd68bcd197fa40618ebff94a1c8f24f
This commit is contained in:
parent
d557e5674c
commit
1bcfb954cc
@ -85,7 +85,7 @@ class Config(resources.BaseResource):
|
||||
"some_conf", "map_reduce", "node", is_optional=True
|
||||
"""
|
||||
|
||||
def __init__(self, name, applicable_target, scope, config_type="str",
|
||||
def __init__(self, name, applicable_target, scope, config_type="string",
|
||||
config_values=None, default_value=None, is_optional=False,
|
||||
description=None, priority=2):
|
||||
self.name = name
|
||||
|
@ -47,23 +47,27 @@ ENV_CONFS = {
|
||||
}
|
||||
}
|
||||
|
||||
HIDDEN_CONFS = ['fs.default.name', 'dfs.name.dir', 'dfs.data.dir',
|
||||
'mapred.job.tracker', 'mapred.system.dir', 'mapred.local.dir']
|
||||
|
||||
|
||||
def _initialise_configs():
|
||||
configs = []
|
||||
for service, config_lists in XML_CONFS.iteritems():
|
||||
for config_list in config_lists:
|
||||
for config in config_list:
|
||||
cfg = p.Config(config['name'], service, "node",
|
||||
is_optional=True, config_type="str",
|
||||
default_value=str(config['value']),
|
||||
description=config['description'])
|
||||
if cfg.default_value in ["true", "false"]:
|
||||
cfg.config_type = "bool"
|
||||
cfg.default_value = (cfg.default_value == 'true')
|
||||
if str(cfg.default_value).isdigit():
|
||||
cfg.config_type = "int"
|
||||
cfg.default_value = int(cfg.default_value)
|
||||
configs.append(cfg)
|
||||
if config['name'] not in HIDDEN_CONFS:
|
||||
cfg = p.Config(config['name'], service, "node",
|
||||
is_optional=True, config_type="string",
|
||||
default_value=str(config['value']),
|
||||
description=config['description'])
|
||||
if cfg.default_value in ["true", "false"]:
|
||||
cfg.config_type = "bool"
|
||||
cfg.default_value = (cfg.default_value == 'true')
|
||||
if str(cfg.default_value).isdigit():
|
||||
cfg.config_type = "int"
|
||||
cfg.default_value = int(cfg.default_value)
|
||||
configs.append(cfg)
|
||||
|
||||
for service, config_items in ENV_CONFS.iteritems():
|
||||
for name, param_format_str in config_items.iteritems():
|
||||
|
@ -62,6 +62,7 @@ class VanillaPluginTest(unittest2.TestCase):
|
||||
self.assertIsInstance(cfg.default_value, int)
|
||||
else:
|
||||
self.assertIsInstance(cfg.default_value, str)
|
||||
self.assertNotIn(cfg.name, c_h.HIDDEN_CONFS)
|
||||
|
||||
def test_extract_environment_configs(self):
|
||||
env_configs = {
|
||||
|
@ -45,13 +45,13 @@ class XMLUtilsTestCase(unittest2.TestCase):
|
||||
conf = x.load_hadoop_xml_defaults(
|
||||
'tests/unit/resources/test-default.xml')
|
||||
self.assertEquals(x.create_hadoop_xml({'name1': 'some_val1',
|
||||
'name2': 'some_val2'}, conf),
|
||||
'name2': 2}, conf),
|
||||
"""<?xml version="1.0" ?>
|
||||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
|
||||
<configuration>
|
||||
<property>
|
||||
<name>name2</name>
|
||||
<value>some_val2</value>
|
||||
<value>2</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>name1</name>
|
||||
|
@ -72,7 +72,7 @@ def create_hadoop_xml(configs, global_conf):
|
||||
xml_prop.appendChild(name_element)
|
||||
|
||||
# Give the <name> element some hadoop config name
|
||||
name_text = doc.createTextNode(name)
|
||||
name_text = doc.createTextNode(str(name))
|
||||
name_element.appendChild(name_text)
|
||||
|
||||
# Create a <value> element in <property>
|
||||
@ -80,7 +80,7 @@ def create_hadoop_xml(configs, global_conf):
|
||||
xml_prop.appendChild(value_element)
|
||||
|
||||
# Give the <value> element some hadoop config value
|
||||
value_text = doc.createTextNode(value)
|
||||
value_text = doc.createTextNode(str(value))
|
||||
value_element.appendChild(value_text)
|
||||
|
||||
# Return newly created XML
|
||||
|
Loading…
Reference in New Issue
Block a user