passign authorization header also for task registration

This commit is contained in:
dcore94 2022-04-20 15:54:26 +02:00
parent 1a85ae9f8d
commit be37768e00
2 changed files with 4 additions and 2 deletions

View File

@ -50,7 +50,7 @@ class PyExec():
logging.warning("Skipping plugin %s %s", path, err) logging.warning("Skipping plugin %s %s", path, err)
continue continue
PyExecPlugin.registerTaskDefinitions(self.server) PyExecPlugin.registerTaskDefinitions(self.server, self.auth)
def start(self): def start(self):
self.logger.info("Started PyExec with plugins: %s", PyExecPlugin.getPluginNames()) self.logger.info("Started PyExec with plugins: %s", PyExecPlugin.getPluginNames())

View File

@ -27,7 +27,7 @@ class PyExecPlugins(type):
def getAlias(cls, name): def getAlias(cls, name):
return cls.alias.get(name) return cls.alias.get(name)
def registerTaskDefinitions(cls, server): def registerTaskDefinitions(cls, server, auth):
url = server + "/metadata/taskdefs" url = server + "/metadata/taskdefs"
#pyexec generic taskdefinition #pyexec generic taskdefinition
taskdefs = [ taskdefs = [
@ -47,6 +47,8 @@ class PyExecPlugins(type):
#Post all new (or not) task definitions to orchestrator #Post all new (or not) task definitions to orchestrator
logging.getLogger("pyexec").debug("Recording task definitions %s", taskdefs) logging.getLogger("pyexec").debug("Recording task definitions %s", taskdefs)
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}
if auth != None:
headers['Authorization'] = 'Basic ' + auth
try: try:
response = requests.request("POST", url, headers=headers, data=json.dumps(taskdefs)) response = requests.request("POST", url, headers=headers, data=json.dumps(taskdefs))
except Exception as e: except Exception as e: