Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
2.7 KiB

# functions about connections to other instances
# -------------------------------------------------------------------
"""
"""
import basic.program
import tools.config_tool
import basic.constants as B
import tools.data_const as D
def getConnection(job, comp, nr):
#job = basic.program.Job.getInstance()
verify = job.getDebugLevel("conn_tool")
conn = {}
if job.conf.confs.get(B.SUBJECT_TOOL).get("connsrc") == D.DFILE_TYPE_YML:
conn = tools.config_tool.getConfig(job, "tool", B.SUBJECT_CONN)
xtypes = None
if ("types" in conn["env"][comp]):
xtypes = conn["env"][comp]["types"]
instnr = "inst" + str(nr)
if conn["env"][comp][instnr]:
if (xtypes is not None):
conn["env"][comp][instnr]["types"] = xtypes
return conn["env"][comp][instnr]
else:
job.m.setFatal("Conn-Tool: Comp not configured " + comp + " " + str(nr))
return None
def getConnections(job, comp):
"""
it reads the connection-attributes for each instances of this component
general attributes are added to the connection-attributes
:param comp:
:return:
"""
#job = basic.program.Job.getInstance()
verify = job.getDebugLevel("conn_tool")
msg = None
if hasattr(comp, "m") and comp.m is not None:
msg = comp.m
elif hasattr(job, "m") and job.m is not None:
msg = job.m
else:
raise Exception("message-object is missing")
msg.debug(verify, "getConnections " + comp)
conn = {}
conns = []
# if a datest-database exists read the connections
conndb = {}
if job.conf.confs.get("db"):
# select
pass
conn = tools.config_tool.getConfig(job, "tool", B.SUBJECT_CONN)
if not comp in conn[B.SUBJECT_ENV]:
job.m.setFatal("Conn-Tool: Comp not configured " + comp)
attr = {}
if B.CONF_NODE_GENERAL in conn[B.SUBJECT_ENV]:
for a in conn[B.SUBJECT_ENV][B.CONF_NODE_GENERAL]:
attr[a] = conn[B.SUBJECT_ENV][B.CONF_NODE_GENERAL]
for a in conn[B.SUBJECT_ENV][comp]:
if "inst" in a and a != B.SUBJECT_INST:
continue
attr[a] = conn["env"][comp][a]
#if ("types" in conn["env"][comp]):
# xtypes = conn["env"][comp]["types"]
for i in range(conn[B.SUBJECT_ENV][comp][B.SUBJECT_INST][B.ATTR_INST_CNT]):
#print("range " + str(i + 1))
instnr = "inst" + str(i + 1)
#if (xtypes is not None):
# conn["env"][comp][instnr]["types"] = xtypes
for a in attr:
if a in conn["env"][comp][instnr]:
continue # dont overwrite an instance-specific value
conn["env"][comp][instnr][a] = attr[a]
conns.append(conn["env"][comp][instnr])
return conns