8 """Script to set the value of the Connectivity Service port in the specified Session of the specified
9 OKS database file. If the new port is not specified, it is set to a random available port number."""
11 if session_name ==
"":
12 print(f
"Error: the session name needs to be specified")
16 session = db.get_dal(
"Session", session_name)
18 print(f
"Error could not find Session {session_name} in file {oksfile}")
22 "schema/confmodel/dunedaq.schema.xml"
27 new_port = find_free_port()
29 new_port = connsvc_port
31 if session.connectivity_service
is not None:
32 session.connectivity_service.service.port = new_port
33 db.update_dal(session.connectivity_service.service)
35 for app
in session.infrastructure_applications:
36 if app.className() ==
"ConnectionService":
38 for clparam
in app.commandline_parameters:
39 if "gunicorn" in clparam:
40 pattern = re.compile(
r'(.*0\.0\.0\.0)\:\d+(.*)')
41 app.commandline_parameters[index] = pattern.sub(f
'\\1:{new_port}\\2', clparam)