diff options
Diffstat (limited to 'deploy/get_conf.py')
-rwxr-xr-x | deploy/get_conf.py | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/deploy/get_conf.py b/deploy/get_conf.py index 309b331b..eaac8b17 100755 --- a/deploy/get_conf.py +++ b/deploy/get_conf.py @@ -23,7 +23,9 @@ def decorator_mk(types): result = {} for item in item_list: ret = func(item) - if ret: + if ret.keys()[0] in result: + result[ret.keys()[0]].append(ret.values()[0][0]) + else: result.update(ret) return result return wrapter @@ -33,19 +35,24 @@ def decorator_mk(types): @decorator_mk('networks') def network(network=None): net_plane = network.get('name', '') + if net_plane == "TENANT": + net_plane = "physnet1" network.pop('name') map = {} map[net_plane] = network return map -@decorator_mk('hosts') -def interface(host=None): - hostname = host.get('name', '') - interface = host.get('interface', '') - map = {} - map[hostname] = interface - return map +@decorator_mk('interfaces') +def interface(interface=None): + net_name = interface.get('name', '') + if net_name == "TENANT": + net_name = "physnet1" + interface_name = interface.get('interface', '') + map2 = {} + map = {'ip': '', 'name': net_name} + map2[interface_name] = [map] + return map2 @decorator_mk('hosts') @@ -69,21 +76,27 @@ def host(host=None): def network_config_parse(s, dha_file): network_map = network(s) vip = s.get('internal_vip') - return network_map, vip + interface_map = interface(s) + return network_map, vip, interface_map def dha_config_parse(s, dha_file): - host_interface_map = interface(s) host_role_map = role(s) - host_ip_passwd_map = host(s) - return host_interface_map, host_role_map, host_ip_passwd_map + hosts_name = [] + for name in host_role_map: + hosts_name.append(name) + return hosts_name def config(dha_file, network_file): data = init(dha_file) - host_interface_map, host_role_map, host_ip_passwd_map = \ - dha_config_parse(data, dha_file) + hosts_name = dha_config_parse(data, dha_file) data = init(network_file) - network_map, vip = network_config_parse(data, network_file) - return host_interface_map, host_role_map, \ - host_ip_passwd_map, network_map, vip + network_map, vip, interface_map = network_config_parse(data, network_file) + for interface_name in interface_map: + for name in interface_map[interface_name]: + if name.get('name', None) == 'MANAGEMENT': + name['ip'] = network_map.get( + 'MANAGEMENT', None).get( + 'ip_ranges', None)[0].get('start', None) + return interface_map, hosts_name, network_map, vip |