Remove extra merge methods in plugins
Use the general method merge_configs in utils.configs. Change-Id: I5742541c5240a2dc941d1ae7c3534c4fedb36484
This commit is contained in:
parent
54e3dc0f9f
commit
4d713e69fc
|
@ -26,6 +26,7 @@ from sahara.plugins.vanilla import utils as vu
|
|||
from sahara.swift import swift_helper as swift
|
||||
from sahara.topology import topology_helper as th
|
||||
from sahara.utils import cluster_progress_ops as cpo
|
||||
from sahara.utils import configs as s_cfg
|
||||
from sahara.utils import files as f
|
||||
from sahara.utils import proxy
|
||||
from sahara.utils import xmlutils as x
|
||||
|
@ -83,8 +84,8 @@ def _provisioning_configs(pctx, instance):
|
|||
def _generate_configs(pctx, node_group):
|
||||
hadoop_xml_confs = _get_hadoop_configs(pctx, node_group)
|
||||
user_xml_confs, user_env_confs = _get_user_configs(pctx, node_group)
|
||||
xml_confs = _merge_configs(user_xml_confs, hadoop_xml_confs)
|
||||
env_confs = _merge_configs(pctx['env_confs'], user_env_confs)
|
||||
xml_confs = s_cfg.merge_configs(user_xml_confs, hadoop_xml_confs)
|
||||
env_confs = s_cfg.merge_configs(pctx['env_confs'], user_env_confs)
|
||||
|
||||
return xml_confs, env_confs
|
||||
|
||||
|
@ -190,8 +191,8 @@ def _get_user_configs(pctx, node_group):
|
|||
cl_xml_confs, cl_env_confs = _separate_configs(
|
||||
node_group.cluster.cluster_configs, pctx['env_confs'])
|
||||
|
||||
xml_confs = _merge_configs(cl_xml_confs, ng_xml_confs)
|
||||
env_confs = _merge_configs(cl_env_confs, ng_env_confs)
|
||||
xml_confs = s_cfg.merge_configs(cl_xml_confs, ng_xml_confs)
|
||||
env_confs = s_cfg.merge_configs(cl_env_confs, ng_env_confs)
|
||||
return xml_confs, env_confs
|
||||
|
||||
|
||||
|
@ -336,21 +337,6 @@ def _make_hadoop_paths(paths, hadoop_dir):
|
|||
return [path + hadoop_dir for path in paths]
|
||||
|
||||
|
||||
def _merge_configs(a, b):
|
||||
res = {}
|
||||
|
||||
def update(cfg):
|
||||
for service, configs in six.iteritems(cfg):
|
||||
if not res.get(service):
|
||||
res[service] = {}
|
||||
|
||||
res[service].update(configs)
|
||||
|
||||
update(a)
|
||||
update(b)
|
||||
return res
|
||||
|
||||
|
||||
@cpo.event_wrapper(
|
||||
True, step=_("Configure topology data"), param=('cluster', 1))
|
||||
def configure_topology_data(pctx, cluster):
|
||||
|
|
|
@ -32,36 +32,6 @@ class VanillaTwoConfigTestCase(base.SaharaTestCase):
|
|||
}
|
||||
self.assertEqual(expected, dirs)
|
||||
|
||||
def test_merge_configs(self):
|
||||
a = {
|
||||
'HDFS': {
|
||||
'param1': 'value1',
|
||||
'param2': 'value2'
|
||||
}
|
||||
}
|
||||
b = {
|
||||
'HDFS': {
|
||||
'param1': 'value3',
|
||||
'param3': 'value4'
|
||||
},
|
||||
'YARN': {
|
||||
'param5': 'value5'
|
||||
}
|
||||
}
|
||||
|
||||
res = c._merge_configs(a, b)
|
||||
expected = {
|
||||
'HDFS': {
|
||||
'param1': 'value3',
|
||||
'param2': 'value2',
|
||||
'param3': 'value4'
|
||||
},
|
||||
'YARN': {
|
||||
'param5': 'value5'
|
||||
}
|
||||
}
|
||||
self.assertEqual(expected, res)
|
||||
|
||||
|
||||
class FakeNG(object):
|
||||
def __init__(self, storage_paths=None):
|
||||
|
|
Loading…
Reference in New Issue