Run removal workflow through SSH
This commit is contained in:
@@ -61,22 +61,31 @@ public class RouterController {
|
|||||||
try {
|
try {
|
||||||
service.forceStatus(id, RouterStatus.PROVISIONING);
|
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) {
|
if (result.exitCode() != 0) {
|
||||||
var finished = deploymentService.finishSuccess(deployment, result.stdout());
|
throw new IllegalStateException(result.stderr());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
var finishedDeployment = deploymentService.finishSuccess(
|
||||||
var failed = deploymentService.finishFailure(deployment, e.getMessage());
|
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);
|
service.forceStatus(id, RouterStatus.FAILED);
|
||||||
return DeploymentResponse.from(failed);
|
|
||||||
|
return DeploymentResponse.from(failedDeployment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,12 +98,18 @@ public class RouterController {
|
|||||||
try {
|
try {
|
||||||
service.forceStatus(id, RouterStatus.PROVISIONING); // or REMOVING if you want later
|
service.forceStatus(id, RouterStatus.PROVISIONING); // or REMOVING if you want later
|
||||||
|
|
||||||
// simulate removal
|
var result = sshService.executeOnConfiguredVps(
|
||||||
var finished = deploymentService.finishSuccess(
|
"echo 'Removing router: " + router.getName() + "' && whoami && hostname"
|
||||||
deployment,
|
|
||||||
"Removal completed successfully"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (result.exitCode() != 0) {
|
||||||
|
throw new IllegalStateException(result.stderr());
|
||||||
|
}
|
||||||
|
|
||||||
|
var finished = deploymentService.finishSuccess(
|
||||||
|
deployment,
|
||||||
|
result.stdout()
|
||||||
|
);
|
||||||
service.forceStatus(id, RouterStatus.REMOVED);
|
service.forceStatus(id, RouterStatus.REMOVED);
|
||||||
|
|
||||||
return DeploymentResponse.from(finished);
|
return DeploymentResponse.from(finished);
|
||||||
|
|||||||
Reference in New Issue
Block a user