|
@ -26,7 +26,8 @@ import basic.constants as B |
|
|
|
|
|
|
|
|
comps = {} |
|
|
comps = {} |
|
|
PARAM_NOSUBNODE = ["artifact", "components", "instance"] |
|
|
PARAM_NOSUBNODE = ["artifact", "components", "instance"] |
|
|
|
|
|
DEFAULT_INST_CNT = 1 |
|
|
|
|
|
DEFAULT_INST_SGL = "y" |
|
|
|
|
|
|
|
|
def getComponents(mainfct): |
|
|
def getComponents(mainfct): |
|
|
job = basic.program.Job.getInstance() |
|
|
job = basic.program.Job.getInstance() |
|
@ -41,6 +42,22 @@ def getComponents(mainfct): |
|
|
return out |
|
|
return out |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getInstanceAttributes(conf): |
|
|
|
|
|
""" |
|
|
|
|
|
the attributes for instancing the component are set from configuration or from default |
|
|
|
|
|
:param conf: |
|
|
|
|
|
:return: a complete set of these attributes |
|
|
|
|
|
""" |
|
|
|
|
|
out = {} |
|
|
|
|
|
out[B.ATTR_INST_CNT] = DEFAULT_INST_CNT |
|
|
|
|
|
out[B.ATTR_INST_SGL] = DEFAULT_INST_SGL |
|
|
|
|
|
if B.SUBJECT_INST in conf: |
|
|
|
|
|
for attr in [B.ATTR_INST_CNT, B.ATTR_INST_SGL]: |
|
|
|
|
|
if attr in conf[B.SUBJECT_INST]: |
|
|
|
|
|
out[attr] = conf[B.SUBJECT_INST][attr] |
|
|
|
|
|
return out |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ComponentManager: |
|
|
class ComponentManager: |
|
|
__instance = None |
|
|
__instance = None |
|
|
""" |
|
|
""" |
|
@ -64,7 +81,7 @@ class ComponentManager: |
|
|
return |
|
|
return |
|
|
for k in job.conf.confs["applicationen"].get(anw): |
|
|
for k in job.conf.confs["applicationen"].get(anw): |
|
|
job.m.logDebug("applicationscomponente -- " + k + ":") |
|
|
job.m.logDebug("applicationscomponente -- " + k + ":") |
|
|
self.createComponents(k, 0, "") |
|
|
self.createComponent(k, 0, "") |
|
|
|
|
|
|
|
|
def setComponents(self): |
|
|
def setComponents(self): |
|
|
# set components from parameter-file |
|
|
# set components from parameter-file |
|
@ -96,90 +113,85 @@ class ComponentManager: |
|
|
else: |
|
|
else: |
|
|
raise Exception("Klasse noch nicht initialisiert") |
|
|
raise Exception("Klasse noch nicht initialisiert") |
|
|
|
|
|
|
|
|
def createComponents(self, componentName, nr, suffix): |
|
|
def createComponent(self, componentName, nr, suffix): |
|
|
""" |
|
|
""" |
|
|
in order to create a component it must be loaded |
|
|
in order to create a component it must be loaded |
|
|
* knogwedge of the application - which components should be created |
|
|
* knogwedge of the application - which components should be created |
|
|
* technical-knowledge of the instanciated component, especially the connection, user, password |
|
|
* technical-knowledge of the instanciated component, especially the connection, user, password |
|
|
* business-knowledge of the component, especially of their interfaces resp. artifacts |
|
|
* business-knowledge of the component, especially of their interfaces resp. artifacts |
|
|
:param componentName: Name of the component |
|
|
:param componentName: Name of the component |
|
|
:param nr: |
|
|
:param nr: for numbered instance if component is multiple |
|
|
:param suffix: |
|
|
:param suffix: suffix for specific context of the component |
|
|
:return: |
|
|
:return: |
|
|
""" |
|
|
""" |
|
|
job = basic.program.Job.getInstance() |
|
|
job = basic.program.Job.getInstance() |
|
|
verify = job.getDebugLevel("job_tool") |
|
|
verify = job.getDebugLevel("job_tool") |
|
|
componentName = componentName.lower() |
|
|
componentName = componentName.lower() |
|
|
print("createComponent " + componentName) |
|
|
job.debug(verify, "createComponent " + componentName) |
|
|
confs = utils.config_tool.getConfig("comp", componentName) |
|
|
confs = utils.config_tool.getConfig("comp", componentName) |
|
|
conns = utils.conn_tool.getConnections(componentName) |
|
|
conns = utils.conn_tool.getConnections(componentName) |
|
|
print("createComponent -91- " + componentName + " : " + str(confs)) |
|
|
instAttr = getInstanceAttributes(confs) |
|
|
if nr > 0 and int(confs["conf"]["instance"]["count"]) > 1: |
|
|
job.debug(verify, "createComponent -91- " + componentName + " : " + str(confs)) |
|
|
|
|
|
if nr > 0 and int(instAttr[B.ATTR_INST_CNT]) > 1: |
|
|
job.m.setError("for multiple callers are multiple calls not implemented ") |
|
|
job.m.setError("for multiple callers are multiple calls not implemented ") |
|
|
if nr > 0 and len(conns) == 0: |
|
|
if nr > 0 and len(conns) == 0: |
|
|
job.m.setError("for multiple calls has only one call configured") |
|
|
job.m.setError("for multiple calls has only one call configured") |
|
|
print(confs) |
|
|
print(confs) |
|
|
print("createComponent 1 " + componentName) |
|
|
parContent = job.loadParameter() |
|
|
print(getComponentPath(componentName)) |
|
|
|
|
|
print("createComponent 2 " + componentName) |
|
|
|
|
|
cmodul = importlib.import_module(getComponentPath(componentName)) |
|
|
|
|
|
class_ = getattr(cmodul, getComponentClass(componentName)) |
|
|
|
|
|
readedPar = job.loadParameter() |
|
|
|
|
|
if len(conns) == 1: |
|
|
if len(conns) == 1: |
|
|
|
|
|
c = self.createInstance(componentName, parContent, confs, conns, 0) |
|
|
print("createComponent 3 a " + componentName) |
|
|
print("createComponent 3 a " + componentName) |
|
|
if nr > 0 and confs["conf"]["instance"]["single"] == "n": |
|
|
self.createSubComponents(c, nr, suffix) |
|
|
name = componentName + "_0" + str(nr) |
|
|
|
|
|
else: |
|
|
|
|
|
name = componentName |
|
|
|
|
|
c = class_() |
|
|
|
|
|
c.name = name |
|
|
|
|
|
c.conf = confs["conf"] |
|
|
|
|
|
c.conf[B.SUBJECT_CONN] = conns[0] |
|
|
|
|
|
c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) |
|
|
|
|
|
c.init() |
|
|
|
|
|
print("createComponent 4 a " + componentName) |
|
|
|
|
|
print(vars(c)) |
|
|
|
|
|
print(vars(c.m)) |
|
|
|
|
|
if readedPar is not None: |
|
|
|
|
|
print("createComponent 5 a " + name + " : " + str(readedPar)) |
|
|
|
|
|
if name in readedPar["comps"]: |
|
|
|
|
|
for k in readedPar["comps"][name].keys(): |
|
|
|
|
|
c.conf[k] = readedPar["comps"][name][k] |
|
|
|
|
|
comps[name] = c |
|
|
|
|
|
self.createComponent(c, nr, suffix) |
|
|
|
|
|
else: |
|
|
else: |
|
|
i = 1 |
|
|
i = 1 |
|
|
print("createComponent 3 b " + componentName) |
|
|
print("createComponent 3 b " + componentName) |
|
|
for cn in conns: |
|
|
for cn in conns: |
|
|
name = componentName + "_0" + str(i) |
|
|
c = self.createInstance(componentName, parContent, confs, conns, i) |
|
|
c = class_() |
|
|
self.createSubComponents(c, i, suffix) |
|
|
c.name = name |
|
|
|
|
|
c.conf = confs["conf"] |
|
|
|
|
|
c.conf[B.SUBJECT_CONN] = conns[0] |
|
|
|
|
|
c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) |
|
|
|
|
|
c.init() |
|
|
|
|
|
print("createComponent 4 b " + componentName) |
|
|
|
|
|
print(vars(c)) |
|
|
|
|
|
if readedPar is not None: |
|
|
|
|
|
if name in readedPar["comps"]: |
|
|
|
|
|
for k in readedPar["comps"][name].keys(): |
|
|
|
|
|
c.conf[k] = readedPar["comps"][name][k] |
|
|
|
|
|
else: |
|
|
|
|
|
print("comp fehlt "+name) |
|
|
|
|
|
comps[name] = c |
|
|
|
|
|
self.createComponent(c, i, suffix) |
|
|
|
|
|
i = i + 1 |
|
|
i = i + 1 |
|
|
print("createComponent 9 " + componentName) |
|
|
print("createComponent 9 " + componentName) |
|
|
print(comps) |
|
|
print(comps) |
|
|
|
|
|
|
|
|
def createComponent(self, comp, nr, suffix): |
|
|
def createInstance(self, compName, parContent, confs, conns, nr): |
|
|
|
|
|
""" |
|
|
|
|
|
instance a component |
|
|
|
|
|
:param compName: name without suffix or number |
|
|
|
|
|
:param parContent: content of the parameter-file which is dumped from a pre-step |
|
|
|
|
|
:param confs: configuration of the component |
|
|
|
|
|
:param conns: connection-attributes for the specific environment |
|
|
|
|
|
:param nr: number if component is multiple |
|
|
|
|
|
:return: instance of the component with all necessary attributes |
|
|
|
|
|
""" |
|
|
|
|
|
cmodul = importlib.import_module(getComponentPath(compName)) |
|
|
|
|
|
class_ = getattr(cmodul, getComponentClass(compName)) |
|
|
|
|
|
c = class_() |
|
|
|
|
|
if nr > 0: |
|
|
|
|
|
name = compName + "_0" + str(nr) |
|
|
|
|
|
i = nr - 1 |
|
|
|
|
|
else: |
|
|
|
|
|
name = compName |
|
|
|
|
|
i = 0 |
|
|
|
|
|
c.name = name |
|
|
|
|
|
c.conf = confs["conf"] |
|
|
|
|
|
c.conf[B.SUBJECT_CONN] = conns[i] |
|
|
|
|
|
c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) |
|
|
|
|
|
c.init() |
|
|
|
|
|
if parContent is not None: |
|
|
|
|
|
print("createComponent 5 a " + name + " : " + str(parContent)) |
|
|
|
|
|
if name in parContent["comps"]: |
|
|
|
|
|
for k in parContent["comps"][name].keys(): |
|
|
|
|
|
c.conf[k] = parContent["comps"][name][k] |
|
|
|
|
|
comps[name] = c |
|
|
|
|
|
return c |
|
|
|
|
|
|
|
|
|
|
|
def createSubComponents(self, comp, nr, suffix): |
|
|
job = basic.program.Job.getInstance() |
|
|
job = basic.program.Job.getInstance() |
|
|
verify = -2 + job.getDebugLevel("job_tool") |
|
|
verify = -2 + job.getDebugLevel("job_tool") |
|
|
job.debug(verify, "getComponents " + str(comp.conf["components"])) |
|
|
job.debug(verify, "getComponents " + str(comp.conf[B.ATTR_INST_SUBCOMP])) |
|
|
for c in comp.conf["components"].keys(): |
|
|
for c in comp.conf[B.ATTR_INST_SUBCOMP].keys(): |
|
|
if c == "none": |
|
|
if c == "none": |
|
|
continue |
|
|
continue |
|
|
self.createComponents(c, nr, suffix) |
|
|
self.createComponent(c, nr, suffix) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getComponentFolder(comp): |
|
|
def getComponentFolder(comp): |
|
@ -220,6 +232,7 @@ def isParameterSubnode(key): |
|
|
return False |
|
|
return False |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getPlainCompname(name): |
|
|
def getPlainCompname(name): |
|
|
if "_0" in name: |
|
|
if "_0" in name: |
|
|
return name[0:-3] |
|
|
return name[0:-3] |
|
|