Add SSH command execution service
This commit is contained in:
@@ -78,4 +78,34 @@ public class RouterController {
|
||||
return DeploymentResponse.from(failedDeployment);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/remove")
|
||||
public DeploymentResponse remove(@PathVariable UUID id) {
|
||||
Router router = service.findById(id);
|
||||
|
||||
var deployment = deploymentService.startDeployment(router, DeploymentAction.REMOVE);
|
||||
|
||||
try {
|
||||
service.forceStatus(id, RouterStatus.PROVISIONING); // or REMOVING if you want later
|
||||
|
||||
// simulate removal
|
||||
var finished = deploymentService.finishSuccess(
|
||||
deployment,
|
||||
"Removal completed successfully"
|
||||
);
|
||||
|
||||
service.forceStatus(id, RouterStatus.REMOVED);
|
||||
|
||||
return DeploymentResponse.from(finished);
|
||||
} catch (Exception e) {
|
||||
var failed = deploymentService.finishFailure(
|
||||
deployment,
|
||||
e.getMessage()
|
||||
);
|
||||
|
||||
service.forceStatus(id, RouterStatus.FAILED);
|
||||
|
||||
return DeploymentResponse.from(failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user