X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FConfGen.py;h=a15a30e9a143302012700e3217dd9551d22b857a;hb=4b2f0074adbfe9816444cafb6476e2ea7ef634f4;hp=d97bbdb77178a47f2e74370876c254d2d0bac2f8;hpb=acd35ce6ae99071e262a2a5e032015f87dd95b33;p=integration%2Ftest.git diff --git a/csit/libraries/ConfGen.py b/csit/libraries/ConfGen.py index d97bbdb771..a15a30e9a1 100644 --- a/csit/libraries/ConfGen.py +++ b/csit/libraries/ConfGen.py @@ -21,7 +21,7 @@ def _parse_input(file_name): return pyhocon.ConfigFactory.parse_file(file_name) -def generate_akka(original_file, node_idx=1, nodes_ip_list=['127.0.0.1']): +def generate_akka(original_file, node_idx=1, nodes_ip_list=["127.0.0.1"]): """Generates akka.conf content. Args: @@ -35,14 +35,21 @@ def generate_akka(original_file, node_idx=1, nodes_ip_list=['127.0.0.1']): """ conf = _parse_input(original_file) - conf['odl-cluster-data']['akka']['remote']['netty']['tcp']['hostname'] = nodes_ip_list[node_idx - 1] - seed_nodes = [u'akka.tcp://opendaylight-cluster-data@{}:2550'.format(ip) for ip in nodes_ip_list] - conf['odl-cluster-data']['akka']['cluster']['seed-nodes'] = seed_nodes - conf['odl-cluster-data']['akka']['cluster']['roles'] = ["member-{}".format(node_idx)] + conf["odl-cluster-data"]["akka"]["remote"]["netty"]["tcp"][ + "hostname" + ] = nodes_ip_list[node_idx - 1] + seed_nodes = [ + "akka.tcp://opendaylight-cluster-data@{}:2550".format(ip) + for ip in nodes_ip_list + ] + conf["odl-cluster-data"]["akka"]["cluster"]["seed-nodes"] = seed_nodes + conf["odl-cluster-data"]["akka"]["cluster"]["roles"] = [ + "member-{}".format(node_idx) + ] return pyhocon.tool.HOCONConverter.to_hocon(conf) -def generate_modules(original_file, name='', namespace=''): +def generate_modules(original_file, name="", namespace=""): """Generates modules.conf content. If name and namespace parameters are filled, exactly one module item is added to the content of orginal file. @@ -59,13 +66,16 @@ def generate_modules(original_file, name='', namespace=''): :returns str: modules.conf content """ conf = _parse_input(original_file) - if name != '' and namespace != '': - conf['modules'].append( - pyhocon.ConfigTree([("name", name), ("namespace", namespace), ("shard-strategy", "module")])) + if name != "" and namespace != "": + conf["modules"].append( + pyhocon.ConfigTree( + [("name", name), ("namespace", namespace), ("shard-strategy", "module")] + ) + ) return pyhocon.tool.HOCONConverter.to_hocon(conf) -def generate_module_shards(original_file, nodes=1, shard_name='', replicas=[]): +def generate_module_shards(original_file, nodes=1, shard_name="", replicas=[]): """Generates module-shards.conf content. If shard_name and replicas parameters are filled, exactly one shard item is added to the content of orginal file. @@ -83,12 +93,30 @@ def generate_module_shards(original_file, nodes=1, shard_name='', replicas=[]): :returns str: module-shards.conf content """ conf = _parse_input(original_file) - for module_shard in conf['module-shards']: - module_shard["shards"][0]["replicas"] = ["member-{}".format(i + 1) for i in range(int(nodes))] - if shard_name != '' and replicas != []: - conf['module-shards'].append( - pyhocon.ConfigTree([("name", shard_name), - ("shards", [pyhocon.ConfigTree( - [("name", shard_name), - ("replicas", ["member-{}".format(i) for i in replicas])])])])) + for module_shard in conf["module-shards"]: + module_shard["shards"][0]["replicas"] = [ + "member-{}".format(i + 1) for i in range(int(nodes)) + ] + if shard_name != "" and replicas != []: + conf["module-shards"].append( + pyhocon.ConfigTree( + [ + ("name", shard_name), + ( + "shards", + [ + pyhocon.ConfigTree( + [ + ("name", shard_name), + ( + "replicas", + ["member-{}".format(i) for i in replicas], + ), + ] + ) + ], + ), + ] + ) + ) return pyhocon.tool.HOCONConverter.to_hocon(conf)