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)
continue
PyExecPlugin.registerTaskDefinitions(self.server)
PyExecPlugin.registerTaskDefinitions(self.server, self.auth)
def start(self):
self.logger.info("Started PyExec with plugins: %s", PyExecPlugin.getPluginNames())

View File

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