diff --git a/Orchestrator/ProcessorTypes.txt b/Orchestrator/ProcessorTypes.txt new file mode 100644 index 00000000..a62af5c0 --- /dev/null +++ b/Orchestrator/ProcessorTypes.txt @@ -0,0 +1,69 @@ +#Input arg +# [ +# { +# "Type": , +# host: , +# port: , +# bodyObject: +# }, +# { +# "Type": "CMDStart", +# "Command": "" +# }, +# { +# "Type": "OrchestratorRestart" +# }, +# { +# "Type": "GlobalDictKeyListValueSet", +# "KeyList": ["key1","key2",...], +# "Value": +# }, +# { +# "Type": "GlobalDictKeyListValueAppend", +# "KeyList": ["key1","key2",...], +# "Value": +# }, +# { +# "Type": "GlobalDictKeyListValueGet", +# "KeyList": ["key1","key2",...] +# }, +# { +# "Type":"ProcessStart", +# "Path":"", +# "ArgList":[] +# +# }, +# { +# "Type":"ProcessStartIfTurnedOff", +# "CheckTaskName":"", #Check if current task name is not active (then start process), +# "Path":"", +# "ArgList":[] +# +# }, +# { +# "Type":"ProcessStop", +# "Name":"", +# "FlagForce":True, +# "User":"" #Empty, user or %username% +# }, +# { +# "Type":"PythonStart", +# "ModuleName":"", +# "FunctionName":"", +# "ArgList":[], +# "ArgDict":{} +# }, +# { +# "Type":"WindowsLogon", +# "Domain":"", +# "User":"", +# "Password":"" +# # Return "Result": True - user is logged on, False - user is not logged on +# } +# ] +################################## +#Output result +# with attributes: +# "DateTimeUTCStringStart" +# "DateTimeUTCStringStop" +# "Result" \ No newline at end of file diff --git a/Orchestrator/Settings/AccessUser_ND.py b/Orchestrator/Settings/AccessUser_ND.py index 183a8ff1..7f359fc7 100644 --- a/Orchestrator/Settings/AccessUser_ND.py +++ b/Orchestrator/Settings/AccessUser_ND.py @@ -1,28 +1,32 @@ +# Init Section +gUserNameStr = "ND" # User name +gDomainNameStr = "" # DOMAIN or EMPTY str +gDomainIsDefaultBool = True # If domain is exist and is default (default = you can type login without domain name) + def SettingsUpdate(inDict): - ################################################## - #""/"ND" MethodMatchURLList - l__ND_RuleMethodMatchURLBeforeList={ - ("","ND"): { - "MethodMatchURLBeforeList": [ - { - "Method":"GET", - "MatchType":"Beginwith", - "URL":"/", - #"FlagAccessDefRequestGlobalAuthenticate": TestDef - "FlagAccess": True - }, - { - "Method":"POST", - "MatchType":"Beginwith", - "URL":"/", - #"FlagAccessDefRequestGlobalAuthenticate": TestDef - "FlagAccess": True - } - ], - "ControlPanelKeyAllowedList": ["TestControlPanel", "RobotRDPActive","RobotScreenActive", "ControlPanel_Template"] # If empty - all is allowed - } + lRuleDomainUserDict = { + "MethodMatchURLBeforeList": [ + { + "Method":"GET", + "MatchType":"Beginwith", + "URL":"/", + #"FlagAccessDefRequestGlobalAuthenticate": TestDef + "FlagAccess": True + }, + { + "Method":"POST", + "MatchType":"Beginwith", + "URL":"/", + #"FlagAccessDefRequestGlobalAuthenticate": TestDef + "FlagAccess": True + } + ], + "ControlPanelKeyAllowedList": ["TestControlPanel", "RobotRDPActive","RobotScreenActive", "ControlPanel_Template"] # If empty - all is allowed } - #Append to global list - inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update(l__ND_RuleMethodMatchURLBeforeList) + # Case add domain + user + inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({(gDomainNameStr.upper(),gUserNameStr.upper()):lRuleDomainUserDict}) + if gDomainIsDefaultBool: + # Case add default domain + user + inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({("",gUserNameStr.upper()):lRuleDomainUserDict}) #Return current dict return inDict \ No newline at end of file diff --git a/Orchestrator/Settings/AccessUser_SuperToken.py b/Orchestrator/Settings/AccessUser_SuperToken.py index f12b2a22..32d51bba 100644 --- a/Orchestrator/Settings/AccessUser_SuperToken.py +++ b/Orchestrator/Settings/AccessUser_SuperToken.py @@ -1,35 +1,39 @@ -import datetime +# Init Section +gUserNameStr = "SUPERTOKEN" # User name +gDomainNameStr = "" # DOMAIN or EMPTY str +gDomainIsDefaultBool = False # If domain is exist and is default (default = you can type login without domain name) +gAuthTokenPermanentStr = "1992-04-03-0643-ru-b4ff-openrpa52zzz" # Set the permanent Auth token if it is needed, or empty def SettingsUpdate(inDict): - ################################################## - #""/"SuperToken" MethodMatchURLList - l__SuperToken_RuleMethodMatchURLBeforeList={ - ("","SUPERTOKEN"): { #!!!!!only in upper case!!!! - "MethodMatchURLBeforeList": [ - { - "Method":"GET", - "MatchType":"Beginwith", - "URL":"/", - #"FlagAccessDefRequestGlobalAuthenticate": TestDef - "FlagAccess": True - }, - { - "Method":"POST", - "MatchType":"Beginwith", - "URL":"/", - #"FlagAccessDefRequestGlobalAuthenticate": TestDef - "FlagAccess": True - } - ] - } + lRuleDomainUserDict = { + "MethodMatchURLBeforeList": [ + { + "Method":"GET", + "MatchType":"Beginwith", + "URL":"/", + #"FlagAccessDefRequestGlobalAuthenticate": TestDef + "FlagAccess": True + }, + { + "Method":"POST", + "MatchType":"Beginwith", + "URL":"/", + #"FlagAccessDefRequestGlobalAuthenticate": TestDef + "FlagAccess": True + } + ], + "ControlPanelKeyAllowedList": ["TestControlPanel", "RobotRDPActive","RobotScreenActive", "ControlPanel_Template"] # If empty - all is allowed } - #Append to global list - inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update(l__SuperToken_RuleMethodMatchURLBeforeList) + # Case add domain + user + inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({(gDomainNameStr.upper(),gUserNameStr.upper()):lRuleDomainUserDict}) + if gDomainIsDefaultBool: + # Case add default domain + user + inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({("",gUserNameStr.upper()):lRuleDomainUserDict}) #"":{"User":"", "Domain":"", "TokenDatetime":} #!!!!!!!!!!!!!!!!!!!!!!! #Attention: default supertoken is 1992-04-03-0643-ru-b4ff-openrpa52zzz - please change it when you will customize OpenRPA in your company #!!!!!!!!!!!!!!!!!!!!!!! inDict["Server"]["AccessUsers"]["AuthTokensDict"].update( - {"1992-04-03-0643-ru-b4ff-openrpa52zzz":{"User":"SuperToken", "Domain":"", "TokenDatetime": datetime.datetime.now(), "FlagDoNotExpire":True}} + {gAuthTokenPermanentStr:{"User":gUserNameStr, "Domain":gDomainNameStr, "TokenDatetime": datetime.datetime.now(), "FlagDoNotExpire":True}} ) #Return current dict return inDict \ No newline at end of file diff --git a/Orchestrator/Settings/SettingsOrchestratorExample.py b/Orchestrator/Settings/SettingsOrchestratorExample.py index edc6392e..3eb37f8a 100644 --- a/Orchestrator/Settings/SettingsOrchestratorExample.py +++ b/Orchestrator/Settings/SettingsOrchestratorExample.py @@ -2,6 +2,11 @@ import psutil import datetime import logging import sys # stdout fro logging +# Init variables +gControlPanelPyFilePathList = [ # .py file path list for call SettingsUpdate + r"" +] + def RenderRobotR01(inGlobalConfiguration): #Subheader Variants lSubheaderRunTrueText="Состояние: Работает" @@ -321,7 +326,7 @@ def Settings(): #Lambda function to get files .py from settings folder except Settings.py lFileList = [f for f in os.listdir(lSettingsPath) if os.path.isfile(os.path.join(lSettingsPath, f)) and f.split(".")[-1] == "py" and os.path.join(lSettingsPath, f) != __file__] import importlib.util - for lModuleFilePathItem in lFileList: + for lModuleFilePathItem in lFileList + gControlPanelPyFilePathList: # UPD 2020 04 27 Add gControlPanelPyFilePathList to import py files from Robots lModuleName = lModuleFilePathItem[0:-3] lFileFullPath = os.path.join(lSettingsPath, lModuleFilePathItem) lTechSpecification = importlib.util.spec_from_file_location(lModuleName, lFileFullPath) diff --git a/Orchestrator/ControlPanel_Template.py b/Orchestrator/Template_ControlPanel.py similarity index 57% rename from Orchestrator/ControlPanel_Template.py rename to Orchestrator/Template_ControlPanel.py index 0b4bcd11..def2e70e 100644 --- a/Orchestrator/ControlPanel_Template.py +++ b/Orchestrator/Template_ControlPanel.py @@ -16,6 +16,39 @@ gRobotToOrchestratorKeyList = ["Storage",gRobotKeyStr,"RobotToOrchestrator"] gOrchestratorToRobotResetKeyList = ["Storage",gRobotKeyStr,"OrchestratorToRobotReset"] gOrchestratorToRobotResetSafeStopKeyList = gOrchestratorToRobotResetKeyList+["SafeTurnOffBool"] +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Activity list +## Robot START (create RDP session, send CMD to start process) +gActivityROBOTStartTimeHH_MMStr = "03:00" # Time "HH:MM" [Server time] to execute activity, example "05:10" +gActivityROBOTStartWeekdayList = [0,1,2,3,4] # WeekdayList when atcivity is starting, default [0,1,2,3,4,5,6] +gActivityROBOTStartList = [ + { # Start RDP Session + "DefNameStr":"RDPSessionConnect", # Function name in RobotRDPActive.Processor + "ArgList":[], # Args list + "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inHostStr": gRDPSessionHostStr, "inPortStr": gRDPSessionPortStr, "inLoginStr": gRobotADLoginStr, "inPasswordStr": gRobotADPasswordStr} # Args dictionary + }, + { # Run robot file in RDP session + "DefNameStr":"RDPSessionProcessStartIfNotRunning", # Function name in RobotRDPActive.Processor + "ArgList":[], # Args list + "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inProcessNameWEXEStr": f"{gRobotProcessNameWOEXEStr}.exe", "inFilePathStr": gRobotStartFilePathStr, "inFlagGetAbsPathBool": False} # Args dictionary + } +] +## Robot FORCE STOP (send CMD to stop process, logoff) +gActivityROBOTStopTimeHH_MMStr = "08:00" # Time "HH:MM" [Server time] to execute activity, example "05:10" +gActivityROBOTStopWeekdayList = [0,1,2,3,4] # WeekdayList when atcivity is starting, default [0,1,2,3,4,5,6] +gActivityROBOTStopList = [ + { # Kill process + "DefNameStr":"RDPSessionProcessStop", # Function name in RobotRDPActive.Processor + "ArgList":[], # Args list + "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inProcessNameWEXEStr":f"{gRobotProcessNameWOEXEStr}.exe","inFlagForceCloseBool": True} # Args dictionary + }, + { # Logoff RDP Session + "DefNameStr":"RDPSessionLogoff", # Function name in RobotRDPActive.Processor + "ArgList":[], # Args list + "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr} # Args dictionary + } +] +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Function, which is generate Dict for front-endswith def ControlPanelRenderDict(inGSettings): """result={ @@ -37,35 +70,11 @@ def ControlPanelRenderDict(inGSettings): }""" # START :: Create activities :: START # ## Robot START (create RDP session, send CMD to start process) - lActivityROBOTStartList = [ - { # Start RDP Session - "DefNameStr":"RDPSessionConnect", # Function name in RobotRDPActive.Processor - "ArgList":[], # Args list - "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inHostStr": gRDPSessionHostStr, "inPortStr": gRDPSessionPortStr, "inLoginStr": gRobotADLoginStr, "inPasswordStr": gRobotADPasswordStr} # Args dictionary - }, - { # Run robot file in RDP session - "DefNameStr":"RDPSessionProcessStartIfNotRunning", # Function name in RobotRDPActive.Processor - "ArgList":[], # Args list - "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inProcessNameWEXEStr": f"{gRobotProcessNameWOEXEStr}.exe", "inFilePathStr": gRobotStartFilePathStr, "inFlagGetAbsPathBool": False} # Args dictionary - } - ] - lActivityROBOTStartEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(lActivityROBOTStartList)});".replace("\"","\'") + lActivityROBOTStartEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStartList)});".replace("\"","\'") ## Robot SAFE STOP (SAFE STOP COMMAND (FROM ROBOT RULES), Logoff must do robot when safe turn off) lActivityROBOTSafeStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(gOrchestratorToRobotResetSafeStopKeyList)},true);".replace("\"","\'") - ## Robot FORCE STOP (create RDP session, send CMD to start process) - lActivityROBOTStopList = [ - { # Kill process - "DefNameStr":"RDPSessionProcessStop", # Function name in RobotRDPActive.Processor - "ArgList":[], # Args list - "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr, "inProcessNameWEXEStr":f"{gRobotProcessNameWOEXEStr}.exe","inFlagForceCloseBool": True} # Args dictionary - }, - { # Logoff RDP Session - "DefNameStr":"RDPSessionLogoff", # Function name in RobotRDPActive.Processor - "ArgList":[], # Args list - "ArgDict":{"inRDPSessionKeyStr": gRDPSessionKeyStr} # Args dictionary - } - ] - lActivityROBOTStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(lActivityROBOTStopList)});".replace("\"","\'") + ## Robot FORCE STOP (send CMD to stop process, logoff) + lActivityROBOTStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStopList)});".replace("\"","\'") # END :: Create activities :: END # # START :: Init result dict template :: START # # lBodyKeyValue_r3_start=f'Start' @@ -75,10 +84,11 @@ def ControlPanelRenderDict(inGSettings): "DataStorageKey":gControlPanelKeyStr, # CLIENT SIDE:: Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side "SubheaderText":"", "BodyKeyValueList":[ - {"Key":"Info","Value":"1"}, - {"Key":"Info","Value":"2"}, - {"Key":"Info","Value":"3"}, - {"Key":"Statistic","Value":""} + {"Key":"Scheduler","Value":""}, + {"Key":"Start","Value":f"at {gActivityROBOTStartTimeHH_MMStr} in weekdays {gActivityROBOTStartWeekdayList}"}, + {"Key":"Stop (kill)","Value":f"at {gActivityROBOTStopTimeHH_MMStr} in weekdays {gActivityROBOTStopWeekdayList}"}, + {"Key":"Statistic","Value":""}, + {"Key":"...","Value":""} ], "FooterText":"Last update: 9:38:00 09.10.2019", "FooterButtonX2List":[ @@ -117,8 +127,32 @@ def TechDictKeyList_ItemGet(inDict, inKeyList, inDefault={}): lResult=inDefault return lResult # # # # # # # # # # # # # # # # # # # # # # # # +# Scheduler to start/stop process +## Start ROBOT at time +lActivityTimeItemRobotStart = { + "TimeHH:MM": gActivityROBOTStartTimeHH_MMStr, #Time [HH:MM] to trigger activity + "WeekdayList": gActivityROBOTStartWeekdayList, #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7] + "Activity":{ + "Type": "GlobalDictKeyListValueSet", #Activity type + "KeyList": ['RobotRDPActive','ActivityList'] # RobotRDP Active ActivityList + "Value": gActivityROBOTStartList # ActivityList - see upper + } +} +## Force stop ROBOT at time +lActivityTimeItemRobotStop = { + "TimeHH:MM": gActivityROBOTStopTimeHH_MMStr, #Time [HH:MM] to trigger activity + "WeekdayList": gActivityROBOTStopWeekdayList, #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7] + "Activity":{ + "Type": "GlobalDictKeyListValueSet", #Activity type + "KeyList": ['RobotRDPActive','ActivityList'] # RobotRDP Active ActivityList + "Value": gActivityROBOTStopList # ActivityList - see upper + } +} #Orchestrator settings update def SettingsUpdate(inGSettings): #Add RobotRDPActive in control panel inGSettings["ControlPanelDict"]["RobotList"].append({"RenderFunction": ControlPanelRenderDict, "KeyStr": gControlPanelKeyStr}) + # Add scheduler activity in Scheduler.ActivityTimeList + inGSettings["Scheduler"]["ActivityTimeList"].append(lActivityTimeItemRobotStart) + inGSettings["Scheduler"]["ActivityTimeList"].append(lActivityTimeItemRobotStop) return inGSettings \ No newline at end of file diff --git a/Orchestrator/Template_Settings_AccessUser.py b/Orchestrator/Template_Settings_AccessUser.py new file mode 100644 index 00000000..1b7febbd --- /dev/null +++ b/Orchestrator/Template_Settings_AccessUser.py @@ -0,0 +1,32 @@ +# Init Section +gUserNameStr = "Login" # User name without domain name +gDomainNameStr = "" # DOMAIN or EMPTY str if no domain +gDomainIsDefaultBool = True # If domain is exist and is default (default = you can type login without domain name) + +def SettingsUpdate(inDict): + lRuleDomainUserDict = { + "MethodMatchURLBeforeList": [ + { + "Method":"GET", + "MatchType":"Beginwith", + "URL":"/", + #"FlagAccessDefRequestGlobalAuthenticate": TestDef + "FlagAccess": True + }, + { + "Method":"POST", + "MatchType":"Beginwith", + "URL":"/", + #"FlagAccessDefRequestGlobalAuthenticate": TestDef + "FlagAccess": True + } + ], + "ControlPanelKeyAllowedList": ["TestControlPanel", "RobotRDPActive","RobotScreenActive", "ControlPanel_Template"] # If empty - all is allowed + } + # Case add domain + user + inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({(gDomainNameStr.upper(),gUserNameStr.upper()):lRuleDomainUserDict}) + if gDomainIsDefaultBool: + # Case add default domain + user + inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({("",gUserNameStr.upper()):lRuleDomainUserDict}) + #Return current dict + return inDict \ No newline at end of file