Run removal workflow through SSH

This commit is contained in:
litoral05
2026-05-05 11:41:57 +01:00
parent 36004ef3a9
commit 70157f4d35
@@ -61,22 +61,31 @@ public class RouterController {
try {
service.forceStatus(id, RouterStatus.PROVISIONING);
var result = sshService.executeOnConfiguredVps("whoami && hostname");
var result = sshService.executeOnConfiguredVps(
"echo 'Provisioning router: " + router.getName() + "' && whoami && hostname"
);
if (result.exitCode() == 0) {
var finished = deploymentService.finishSuccess(deployment, result.stdout());
service.forceStatus(id, RouterStatus.PROVISIONED);
return DeploymentResponse.from(finished);
} else {
var failed = deploymentService.finishFailure(deployment, result.stderr());
service.forceStatus(id, RouterStatus.FAILED);
return DeploymentResponse.from(failed);
if (result.exitCode() != 0) {
throw new IllegalStateException(result.stderr());
}
} catch (Exception e) {
var failed = deploymentService.finishFailure(deployment, e.getMessage());
var finishedDeployment = deploymentService.finishSuccess(
deployment,
result.stdout()
);
service.forceStatus(id, RouterStatus.PROVISIONED);
return DeploymentResponse.from(finishedDeployment);
} catch (Exception exception) {
var failedDeployment = deploymentService.finishFailure(
deployment,
exception.getMessage()
);
service.forceStatus(id, RouterStatus.FAILED);
return DeploymentResponse.from(failed);
return DeploymentResponse.from(failedDeployment);
}
}
@@ -89,12 +98,18 @@ public class RouterController {
try {
service.forceStatus(id, RouterStatus.PROVISIONING); // or REMOVING if you want later
// simulate removal
var finished = deploymentService.finishSuccess(
deployment,
"Removal completed successfully"
var result = sshService.executeOnConfiguredVps(
"echo 'Removing router: " + router.getName() + "' && whoami && hostname"
);
if (result.exitCode() != 0) {
throw new IllegalStateException(result.stderr());
}
var finished = deploymentService.finishSuccess(
deployment,
result.stdout()
);
service.forceStatus(id, RouterStatus.REMOVED);
return DeploymentResponse.from(finished);