class WorkerMainConfig(object): def __init__(self, data): self.config = OrderedDict() _, block = data fields = { "command": (config_base.read_string, True), "remoteserver": (config_base.read_string, True), "remoteport": (config_base.read_string, True), "fromdelimiter": (config_base.read_delimiter, True), "todelimiter": (config_base.read_delimiter, True), "fromterminator": (config_base.read_delimiter, True), "toterminator": (config_base.read_delimiter, True) } for n, l in block: try: what = l.split("=")[0] which = l.split("=")[1] self.config[what] = config_base.read_config( fields, what, which) except Exception, e: raise ParsingError("Config line %s : invalid item : %s " % (n, str(e))) config_base.check_config("Worker", fields, self.config)
class WorkerMessageConfig(object): def __init__(self, data): okparams = [["translatedXML"]] fields = { "messageID": (config_base.read_message_id, True), "replymessageID": (config_base.read_message_id, True) } self.config = OrderedDict() self.messages = [] params, block = data config_base.myassert( len(params) == len(okparams), "Invalid message definition") config_base.myassert(params[0] in okparams[0], "Invalid message parameter " + params[0]) self.type = params[0] for n, l in block: try: what = l.split("=")[0] which = l.split("=")[1] if what == "message": self.messages.append(which) else: self.config[what] = config_base.read_config( fields, what, which) except Exception, e: raise ParsingError("Config line %s : invalid item : %s " % (n, str(e))) config_base.check_config("Worker message", fields, self.config)
class WorkerEncapsulationConfig(object): def __init__(self, data): self.config = OrderedDict() params, block = data okparams = [["terminated", "http"]] fields = { "contentType": (config_base.read_string, False), "requestMethod": (config_base.read_string, False), "requestURI": (config_base.read_string, False) } config_base.myassert( len(params) == len(okparams), "Invalid encapsulation definition") config_base.myassert(params[0] in okparams[0], "Invalid encapsulation parameter " + params[0]) self.config["type"] = params[0] fields = {} for n, l in block: try: what = l.split("=")[0] which = l.split("=")[1] self.config[what] = config_base.read_config( fields, what, which) except Exception, e: raise ParsingError("Config line %s : invalid item : %s " % (n, str(e))) config_base.check_config("Worker encapsulation", fields, self.config)
class WorkerTransportConfig(object): def __init__(self, data): okparams = [["raw", "tls"]] fields = {"port": (config_base.read_string, True)} self.config = OrderedDict() params, block = data config_base.myassert( len(params) == len(okparams), "Invalid transport definition") config_base.myassert(params[0] in okparams[0], "Invalid worker parameter " + params[0]) self.config["type"] = params[0] for n, l in block: try: what = l.split("=")[0] which = l.split("=")[1] self.config[what] = config_base.read_config( fields, what, which) except Exception, e: raise ParsingError("Config line %s : invalid item : %s " % (n, str(e))) config_base.check_config("Worker transport", fields, self.config)
class XMLMessageConfig(): """ holds config data for an individual xml message defn """ # class level dict of message types xml_messages = OrderedDict() xml_workermessages = OrderedDict() def __init__(self, config, name, params, configdata): config_sections = config_base.get_sections(configdata) self.items = OrderedDict() self.request_elems = [] self.response_elems = [] self.messagetype = params[0] self.request_value_count = 0 self.reply_value_count = 0 # populate request and reply data fields = { "messageType": (config_base.read_string, True), "workerMessageType": (config_base.read_string, True) } for n, l in config_sections["main"][1]: try: what = l.split("=")[0] which = l.split("=")[1] self.items[what] = config_base.read_config(fields, what, which) except Exception, e: raise ParsingError("Config line %s : invalid item : %s " % (n, str(e))) config_base.check_config("Message %s" % self.messagetype, fields, self.items) self.xml_messages[self.items["messageType"]] = self self.xml_workermessages[self.items["workerMessageType"]] = self if "request" in config_sections: for n, l in config_sections["request"][1]: try: which, what = l.split("=") if which == "valueCount": self.request_value_count = int(what) else: lineclass = classlookup[which] if lineclass: self.request_elems.append( lineclass(config, n, what)) except: raise ParsingError( "Invalid configuration : %s at line %s " % (l, n)) else: raise ParsingError("xmlmessage %s missing request definition" % self.messagetype) if "reply" in config_sections: for n, l in config_sections["reply"][1]: try: which, what = l.split("=") if which == "valueCount": self.reply_value_count = int(what) else: lineclass = classlookup[which] if lineclass: self.response_elems.append( lineclass(config, n, what)) except: raise ParsingError( "Invalid configuration : %s at line %s " % (l, n)) else: raise ParsingError("xmlmessage %s missing reply definition" % self.messagetype) if self.request_value_count == 0: raise ParsingError("xmlmessage %s missing request value count " % self.messagetype) if self.request_value_count - 1 != self.request_elems[-1].ssv_col: raise ParsingError( "xmlmessage %s invalid request value count %s " % (self.messagetype, self.request_value_count)) if self.reply_value_count == 0: raise ParsingError("xmlmessage %s missing reply value count " % self.messagetype) if self.reply_value_count - 1 != self.response_elems[-1].ssv_col: raise ParsingError("xmlmessage %s invalid reply value count %s " % (self.messagetype, self.reply_value_count))