@@ -58,15 +58,15 @@ class ConfigurationException(Exception):
5858 worker_group_yaml_file = os .path .join (GROUP_VARS_PATH , filename )
5959 # checking if it is a file
6060 if os .path .isfile (worker_group_yaml_file ):
61- with open (worker_group_yaml_file , mode = "r" , encoding = "utf -8" ) as worker_group_yaml :
61+ with open (worker_group_yaml_file , mode = "r" , encoding = "UTF -8" ) as worker_group_yaml :
6262 worker_groups .append (yaml .safe_load (worker_group_yaml ))
6363
6464# read common configuration
65- with open ("/opt/playbook/vars/common_configuration.yaml" , mode = "r" , encoding = "utf -8" ) as common_configuration_file :
65+ with open ("/opt/playbook/vars/common_configuration.yaml" , mode = "r" , encoding = "UTF -8" ) as common_configuration_file :
6666 common_config = yaml .safe_load (common_configuration_file )
6767logging .info (f"Maximum 'is active' attempts: { common_config ['cloud_scheduling' ]['sshTimeout' ]} " )
6868# read clouds.yaml
69- with open ("/etc/openstack/clouds.yaml" , mode = "r" , encoding = "utf -8" ) as clouds_file :
69+ with open ("/etc/openstack/clouds.yaml" , mode = "r" , encoding = "UTF -8" ) as clouds_file :
7070 clouds = yaml .safe_load (clouds_file )["clouds" ]
7171
7272connections = {} # connections to cloud providers
@@ -107,7 +107,7 @@ def get_server_vars(name):
107107 server_vars = {"volumes" : []}
108108 if os .path .isfile (host_vars_path ):
109109 logging .info (f"Found host_vars file { host_vars_path } ." )
110- with open (host_vars_path , mode = "r" , encoding = "utf -8" ) as host_vars_file :
110+ with open (host_vars_path , mode = "r" , encoding = "UTF -8" ) as host_vars_file :
111111 server_vars = yaml .safe_load (host_vars_file )
112112 logging .info (f"Loaded Vars: { server_vars } " )
113113 else :
@@ -171,7 +171,7 @@ def volumes_host_vars_update(connection, server, host_vars):
171171 logging .debug (f"Added Configuration: Instance { server ['name' ]} has volume { volume ['name' ]} "
172172 f"as device { volume ['device' ]} that is going to be mounted to "
173173 f"{ volume .get ('mountPoint' )} " )
174- with open (host_vars_path , mode = "w+" , encoding = "utf -8" ) as host_vars_file :
174+ with open (host_vars_path , mode = "w+" , encoding = "UTF -8" ) as host_vars_file :
175175 yaml .dump (host_vars , host_vars_file )
176176 logging .info (f"{ host_vars_path } .lock released" )
177177
@@ -219,7 +219,7 @@ def start_server(name, start_worker_group, start_data):
219219 userdata = ""
220220 userdata_file_path = f"/opt/slurm/userdata_{ start_worker_group ['cloud_identifier' ]} .txt"
221221 if os .path .isfile (userdata_file_path ):
222- with open (userdata_file_path , mode = "r" , encoding = "utf -8" ) as userdata_file :
222+ with open (userdata_file_path , mode = "r" , encoding = "UTF -8" ) as userdata_file :
223223 userdata = userdata_file .read ()
224224 # create server and ...
225225 image = select_image (start_worker_group , connection )
@@ -301,15 +301,15 @@ def update_hosts(name, ip): # pylint: disable=invalid-name
301301 logging .info ("Updating hosts.yaml" )
302302 with FileLock ("hosts.yaml.lock" ):
303303 logging .info ("Lock acquired" )
304- with open (HOSTS_FILE_PATH , mode = "r" , encoding = "utf -8" ) as hosts_file :
304+ with open (HOSTS_FILE_PATH , mode = "r" , encoding = "UTF -8" ) as hosts_file :
305305 hosts = yaml .safe_load (hosts_file )
306306 logging .info (f"Existing hosts { hosts } " )
307307 if not hosts or "host_entries" not in hosts :
308308 logging .info (f"Resetting host entries because { 'first run' if hosts else 'broken' } ." )
309309 hosts = {"host_entries" : {}}
310310 hosts ["host_entries" ][name ] = ip
311311 logging .info (f"Added host { name } with ip { hosts ['host_entries' ][name ]} " )
312- with open (HOSTS_FILE_PATH , mode = "w" , encoding = "utf -8" ) as hosts_file :
312+ with open (HOSTS_FILE_PATH , mode = "w" , encoding = "UTF -8" ) as hosts_file :
313313 yaml .dump (hosts , hosts_file )
314314 logging .info ("Wrote hosts file. Released hosts.yaml.lock." )
315315
0 commit comments