Skip to content

Commit

Permalink
Merge pull request #116 from SUNET/bugfix.sync_initjob_parsing_to_1.6
Browse files Browse the repository at this point in the history
Parse result of init jobs as expected from v1.6 code
  • Loading branch information
indy-independence committed Jul 2, 2024
2 parents ba50141 + 8e01206 commit d6acbf4
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions public/components/JobList.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,43 @@ class JobList extends React.Component {
/>,
];
}
if (job.function_name === "init_access_device_step1") {
if (
job.function_name === "init_access_device_step1" ||
job.function_name === "init_fabric_device_step1"
) {
const deviceResult = Object.values(job.result.devices);
const results = deviceResult[0].job_tasks
.map((task) => {
if (task.task_name === "napalm_get") {
if (task.failed === true) {
return "Device changed management IP";
// before v1.6 failed init jobs would have napalm_get output in result and failed = false on napalm_get task
if (
(typeof task.result === "string" &&
task.result.length === 0 &&
task.failed === true) ||
(typeof task.result === "object" && task.failed === false)
) {
return "Error: Device kept old management IP";
}
return "Error: Device kept old management IP";
return "New management IP set";
}
if (task.task_name === "Generate initial device config") {
if (task.failed === true) {
return "Error: Failed to generate config";
return `Error: Failed to generate configuration from template: ${task.result}`;
}
return "Configuration was generated successfully from template";
}
if (task.task_name === "ztp_device_cert") {
return task.result;
}
// push config will have status failed pre v1.6 because timeout after changing IP, ignore failed status and look at exception type
if (task.task_name === "Push base management config") {
if (
typeof task.result === "string" &&
task.result.includes("ReplaceConfigException")
) {
return `Error: Failed to push configuration: ${task.result}`;
}
return "Config generated successfully";
return "Pushed base configuration";
}
})
.filter((result) => {
Expand Down

0 comments on commit d6acbf4

Please sign in to comment.