passign authorization header also for task registration
This commit is contained in:
parent
1a85ae9f8d
commit
be37768e00
|
@ -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())
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue