1414from bibigrid .core .utility .handler import configuration_handler
1515from bibigrid .core .utility .paths import ansible_resources_path as aRP
1616from bibigrid .core .utility .paths .basic_path import ROOT_PATH
17- from bibigrid .core .utility .statics .create_statics import MASTER_IDENTIFIER , VPNGTW_IDENTIFIER , WORKER_IDENTIFIER
17+ from bibigrid .core .utility .statics .create_statics import master_identifier , vpngtw_identifier , worker_identifier
1818from bibigrid .core .utility .wireguard import wireguard_keys
1919
2020PYTHON_INTERPRETER = "/usr/bin/python3"
@@ -72,7 +72,7 @@ def get_full_volume_name(volume, name, count):
7272def get_worker_host_vars (* , cluster_id , worker , worker_count ):
7373 write_host_vars_remote = []
7474 for worker_number in range (worker .get ('count' , 1 )):
75- name = WORKER_IDENTIFIER (cluster_id = cluster_id , additional = worker_count + worker_number )
75+ name = worker_identifier (cluster_id = cluster_id , additional = worker_count + worker_number )
7676 write_volumes = []
7777 for i , volume in enumerate (worker .get ("volumes" , [])):
7878 volume_name = get_full_volume_name (volume , name , i )
@@ -86,10 +86,10 @@ def get_worker_vars(*, provider, configuration, cluster_id, worker,
8686 worker_count ): # pylint: disable-msg=too-many-locals
8787 write_worker_vars_remote = []
8888 flavor_dict = provider .create_flavor_dict (flavor = worker ["type" ])
89- name = WORKER_IDENTIFIER (cluster_id = cluster_id ,
89+ name = worker_identifier (cluster_id = cluster_id ,
9090 additional = f"[{ worker_count } -{ worker_count + worker .get ('count' , 1 ) - 1 } ]" )
9191 group_name = name .replace ("[" , "" ).replace ("]" , "" ).replace (":" , "_" ).replace ("-" , "_" )
92- regexp = WORKER_IDENTIFIER (cluster_id = cluster_id , additional = r"\d+" )
92+ regexp = worker_identifier (cluster_id = cluster_id , additional = r"\d+" )
9393 partitions = worker .get ("partitions" , []) + [configuration ["cloud_identifier" ]]
9494 if not configuration .get ("noAllPartition" ):
9595 partitions .append ("all" )
@@ -124,11 +124,11 @@ def get_worker_vars(*, provider, configuration, cluster_id, worker,
124124
125125
126126def get_vpn_vars (* , provider , configuration , cluster_id , vpngtw , vpn_count ):
127- name = VPNGTW_IDENTIFIER (cluster_id = cluster_id , additional = f"{ vpn_count } " )
127+ name = vpngtw_identifier (cluster_id = cluster_id , additional = f"{ vpn_count } " )
128128 wireguard_ip = f"10.0.0.{ vpn_count + 2 } " # skipping 0 and 1 (master)
129129 vpn_count += 1
130130 flavor_dict = provider .create_flavor_dict (flavor = vpngtw ["type" ])
131- regexp = WORKER_IDENTIFIER (cluster_id = cluster_id , additional = r"\d+" )
131+ regexp = worker_identifier (cluster_id = cluster_id , additional = r"\d+" )
132132 vpngtw_dict = {"name" : name , "regexp" : regexp , "image" : vpngtw ["image" ],
133133 "network" : configuration ["network" ], "network_cidrs" : configuration ["subnet_cidrs" ],
134134 "floating_ip" : configuration ["floating_ip" ], "private_v4" : configuration ["private_v4" ],
@@ -144,7 +144,7 @@ def get_vpn_vars(*, provider, configuration, cluster_id, vpngtw, vpn_count):
144144
145145def get_master_vars (provider , configuration , cluster_id ):
146146 master = configuration ["masterInstance" ]
147- name = MASTER_IDENTIFIER (cluster_id = cluster_id )
147+ name = master_identifier (cluster_id = cluster_id )
148148 flavor_dict = provider .create_flavor_dict (flavor = master ["type" ])
149149 partitions = master .get ("partitions" , []) + [configuration ["cloud_identifier" ]]
150150 if not configuration .get ("noAllPartition" ):
@@ -269,7 +269,7 @@ def generate_ansible_hosts_yaml(ssh_user, configurations, cluster_id, log): # p
269269 @return: ansible_hosts yaml (dict)
270270 """
271271 log .info ("Generating ansible hosts file..." )
272- master_name = MASTER_IDENTIFIER (cluster_id = cluster_id )
272+ master_name = master_identifier (cluster_id = cluster_id )
273273 ansible_hosts_yaml = {"vpn" : {"hosts" : {},
274274 "children" : {"master" : {"hosts" : {master_name : to_instance_host_dict (ssh_user )}},
275275 "vpngtw" : {"hosts" : {}}}}, "workers" : {"hosts" : {}, "children" : {}}}
@@ -280,7 +280,7 @@ def generate_ansible_hosts_yaml(ssh_user, configurations, cluster_id, log): # p
280280 vpngtw_count = 0
281281 for configuration in configurations :
282282 for worker in configuration .get ("workerInstances" , []):
283- name = WORKER_IDENTIFIER (cluster_id = cluster_id ,
283+ name = worker_identifier (cluster_id = cluster_id ,
284284 additional = f"[{ worker_count } :{ worker_count + worker .get ('count' , 1 ) - 1 } ]" )
285285 worker_dict = to_instance_host_dict (ssh_user , ip = "" )
286286 group_name = name .replace ("[" , "" ).replace ("]" , "" ).replace (":" , "_" ).replace ("-" , "_" )
@@ -290,7 +290,7 @@ def generate_ansible_hosts_yaml(ssh_user, configurations, cluster_id, log): # p
290290 worker_count += worker .get ('count' , 1 )
291291
292292 if configuration .get ("vpnInstance" ):
293- name = VPNGTW_IDENTIFIER (cluster_id = cluster_id , additional = vpngtw_count )
293+ name = vpngtw_identifier (cluster_id = cluster_id , additional = vpngtw_count )
294294 vpngtw_dict = to_instance_host_dict (ssh_user , ip = "" )
295295 vpngtw_dict ["ansible_host" ] = configuration ["floating_ip" ]
296296 vpngtws [name ] = vpngtw_dict
0 commit comments