Commit 713a3e86 authored by Antonio Terceiro's avatar Antonio Terceiro
Browse files

dispatcher: Action: extract method for getting logging_info

This is used whenever you want to send logging_info for remote logging,
for example to lava-dispatcher-host.
parent 96e44395
......@@ -1040,3 +1040,25 @@ class Action:
if testclass["class"].needs_overlay():
return True
return False
def get_logging_info(self):
job_id = self.job.job_id
logging_url = master_cert = slave_cert = socks_proxy = ipv6 = None
handler = getattr(self.logger, "handler", None)
if handler:
logging_url = handler.logging_url
master_cert = handler.master_cert
slave_cert = handler.slave_cert
socks_proxy = handler.socks_proxy
ipv6 = handler.ipv6
job_id = handler.job_id
return {
"logging_url": logging_url,
"master_cert": master_cert,
"slave_cert": slave_cert,
"socks_proxy": socks_proxy,
"ipv6": ipv6,
"job_id": job_id,
}
......@@ -281,26 +281,7 @@ class LxcCreateUdevRuleAction(DeployAction):
return connection
device_info = self.job.device.get("device_info", [])
logging_url = master_cert = slave_cert = socks_proxy = ipv6 = None
job_id = self.job.job_id
if self.logger.handler:
logging_url = self.logger.handler.logging_url
master_cert = self.logger.handler.master_cert
slave_cert = self.logger.handler.slave_cert
socks_proxy = self.logger.handler.socks_proxy
ipv6 = self.logger.handler.ipv6
job_id = self.logger.handler.job_id
logging = {
"logging_url": logging_url,
"master_cert": master_cert,
"slave_cert": slave_cert,
"socks_proxy": socks_proxy,
"ipv6": ipv6,
"job_id": job_id,
}
job_prefix = self.job.parameters["dispatcher"].get("prefix", "")
for device in device_info:
data = {
......@@ -314,7 +295,7 @@ class LxcCreateUdevRuleAction(DeployAction):
data,
lxc_name,
container_type="lxc",
logging_info=logging,
logging_info=self.get_logging_info(),
)
return connection
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment