diff --git a/savanna/plugins/provisioning.py b/savanna/plugins/provisioning.py index 90495a31..84e68241 100644 --- a/savanna/plugins/provisioning.py +++ b/savanna/plugins/provisioning.py @@ -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 diff --git a/savanna/plugins/vanilla/config_helper.py b/savanna/plugins/vanilla/config_helper.py index a90a44b2..5e168914 100644 --- a/savanna/plugins/vanilla/config_helper.py +++ b/savanna/plugins/vanilla/config_helper.py @@ -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(): diff --git a/savanna/tests/unit/plugins/vanilla/test_plugin.py b/savanna/tests/unit/plugins/vanilla/test_plugin.py index a85d4d4e..36ae20e9 100644 --- a/savanna/tests/unit/plugins/vanilla/test_plugin.py +++ b/savanna/tests/unit/plugins/vanilla/test_plugin.py @@ -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 = { diff --git a/savanna/tests/unit/utils/test_xml_utils.py b/savanna/tests/unit/utils/test_xml_utils.py index ea74c8c2..4198b7f1 100644 --- a/savanna/tests/unit/utils/test_xml_utils.py +++ b/savanna/tests/unit/utils/test_xml_utils.py @@ -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), """ name2 - some_val2 + 2 name1 diff --git a/savanna/utils/xmlutils.py b/savanna/utils/xmlutils.py index 2a657b28..97a528ec 100644 --- a/savanna/utils/xmlutils.py +++ b/savanna/utils/xmlutils.py @@ -72,7 +72,7 @@ def create_hadoop_xml(configs, global_conf): xml_prop.appendChild(name_element) # Give the element some hadoop config name - name_text = doc.createTextNode(name) + name_text = doc.createTextNode(str(name)) name_element.appendChild(name_text) # Create a element in @@ -80,7 +80,7 @@ def create_hadoop_xml(configs, global_conf): xml_prop.appendChild(value_element) # Give the 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