diff --git a/PyExec.py b/PyExec.py index 4a6e600..d5255bf 100644 --- a/PyExec.py +++ b/PyExec.py @@ -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()) diff --git a/pyexecplugins/pyexecplugins.py b/pyexecplugins/pyexecplugins.py index 738a4df..3c1338b 100644 --- a/pyexecplugins/pyexecplugins.py +++ b/pyexecplugins/pyexecplugins.py @@ -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: