Type script layer changes to timeout configurable
This commit is contained in:
Родитель
0dded06709
Коммит
718b687734
|
@ -150,6 +150,15 @@
|
||||||
"visibleRule": "action = Take Snapshot of Virtual Machines || action = Deploy Virtual Machines using Template",
|
"visibleRule": "action = Take Snapshot of Virtual Machines || action = Deploy Virtual Machines using Template",
|
||||||
"helpMarkDown": "Provide a description for the action."
|
"helpMarkDown": "Provide a description for the action."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "timeout",
|
||||||
|
"type": "string",
|
||||||
|
"label": "Wait Time",
|
||||||
|
"defaultValue": "1200",
|
||||||
|
"required": false,
|
||||||
|
"helpMarkDown": "Specify wait time in seconds for the Virtual Machine to be in ready state for deployment.",
|
||||||
|
"visibleRule": "action = Power On Virtual Machines || action = Shutdown Virtual Machines || action = Take Snapshot of Virtual Machines || action = Revert Snapshot of Virtual Machines || action = Deploy Virtual Machines using Template"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "skipca",
|
"name": "skipca",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -29,6 +29,7 @@ export class VmOperations {
|
||||||
|
|
||||||
public static getCmdArgsForAction(actionName: string): string {
|
public static getCmdArgsForAction(actionName: string): string {
|
||||||
var cmdArgs = "";
|
var cmdArgs = "";
|
||||||
|
var timeout = "";
|
||||||
switch (actionName) {
|
switch (actionName) {
|
||||||
case "Deploy Virtual Machines using Template":
|
case "Deploy Virtual Machines using Template":
|
||||||
var template = tl.getInput("template", true);
|
var template = tl.getInput("template", true);
|
||||||
|
@ -36,6 +37,7 @@ export class VmOperations {
|
||||||
var datastore = tl.getInput("datastore", true);
|
var datastore = tl.getInput("datastore", true);
|
||||||
var description = tl.getInput("description", false);
|
var description = tl.getInput("description", false);
|
||||||
var customizationspec = tl.getInput("customizationspec", false);
|
var customizationspec = tl.getInput("customizationspec", false);
|
||||||
|
timeout = tl.getInput("timeout", false);
|
||||||
var computeName = null;
|
var computeName = null;
|
||||||
switch (computeType) {
|
switch (computeType) {
|
||||||
case "ESXi Host":
|
case "ESXi Host":
|
||||||
|
@ -52,19 +54,21 @@ export class VmOperations {
|
||||||
tl.exit(1);
|
tl.exit(1);
|
||||||
}
|
}
|
||||||
cmdArgs += " -clonetemplate \"" + template + "\" -computetype \"" + computeType + "\" -computename \"" +
|
cmdArgs += " -clonetemplate \"" + template + "\" -computetype \"" + computeType + "\" -computename \"" +
|
||||||
computeName + "\" -datastore \"" + datastore + "\" -customizationspec \"" + customizationspec + "\" -description \"" + description + "\"";
|
computeName + "\" -datastore \"" + datastore + "\" -customizationspec \"" + customizationspec + "\" -description \"" + description + "\" -timeout " + timeout;
|
||||||
break;
|
break;
|
||||||
case "Take Snapshot of Virtual Machines":
|
case "Take Snapshot of Virtual Machines":
|
||||||
var snapshotName = tl.getInput("snapshotName", true);
|
var snapshotName = tl.getInput("snapshotName", true);
|
||||||
var snapshotVMMemory = "true";
|
var snapshotVMMemory = "true";
|
||||||
var quiesceGuestFileSystem = "false";
|
var quiesceGuestFileSystem = "false";
|
||||||
var description: string = tl.getInput("description", false);
|
var description: string = tl.getInput("description", false);
|
||||||
|
timeout = tl.getInput("timeout", false);
|
||||||
cmdArgs += " -snapshotOps create -snapshotName \"" + snapshotName + "\" -snapshotVMMemory " + snapshotVMMemory + " -quiesceGuestFileSystem " +
|
cmdArgs += " -snapshotOps create -snapshotName \"" + snapshotName + "\" -snapshotVMMemory " + snapshotVMMemory + " -quiesceGuestFileSystem " +
|
||||||
quiesceGuestFileSystem + " -description \"" + description + "\"";
|
quiesceGuestFileSystem + " -description \"" + description + "\" -timeout " + timeout;
|
||||||
break;
|
break;
|
||||||
case "Revert Snapshot of Virtual Machines":
|
case "Revert Snapshot of Virtual Machines":
|
||||||
var snapshotName = tl.getInput("snapshotName", true);
|
var snapshotName = tl.getInput("snapshotName", true);
|
||||||
cmdArgs += " -snapshotOps restore -snapshotName \"" + snapshotName + "\"";
|
timeout = tl.getInput("timeout", false);
|
||||||
|
cmdArgs += " -snapshotOps restore -snapshotName \"" + snapshotName + "\" -timeout " + timeout;
|
||||||
break;
|
break;
|
||||||
case "Delete Snapshot of Virtual Machines":
|
case "Delete Snapshot of Virtual Machines":
|
||||||
var snapshotName = tl.getInput("snapshotName", true);
|
var snapshotName = tl.getInput("snapshotName", true);
|
||||||
|
@ -74,10 +78,12 @@ export class VmOperations {
|
||||||
cmdArgs += " -deletevm delete";
|
cmdArgs += " -deletevm delete";
|
||||||
break;
|
break;
|
||||||
case "Power On Virtual Machines":
|
case "Power On Virtual Machines":
|
||||||
cmdArgs += " -powerops poweron";
|
timeout = tl.getInput("timeout", false);
|
||||||
|
cmdArgs += " -powerops poweron -timeout " + timeout;
|
||||||
break;
|
break;
|
||||||
case "Shutdown Virtual Machines":
|
case "Shutdown Virtual Machines":
|
||||||
cmdArgs += " -powerops shutdown";
|
timeout = tl.getInput("timeout", false);
|
||||||
|
cmdArgs += " -powerops shutdown -timeout " + timeout;
|
||||||
break;
|
break;
|
||||||
case "Power off Virtual Machines":
|
case "Power off Virtual Machines":
|
||||||
cmdArgs += " -powerops poweroff";
|
cmdArgs += " -powerops poweroff";
|
||||||
|
|
|
@ -143,13 +143,14 @@ describe("getCmdArgsForAction", (): void => {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should read snapshot name, snapshot vm memory, quiesce file system and description for create snapshot", (): void => {
|
it("Should read snapshot name, snapshot vm memory, quiesce file system,description and timeout for create snapshot", (): void => {
|
||||||
getInputStub.withArgs("snapshotName", true).returns("dummySnapshotName");
|
getInputStub.withArgs("snapshotName", true).returns("dummySnapshotName");
|
||||||
getInputStub.withArgs("description", false).returns("Sample description");
|
getInputStub.withArgs("description", false).returns("Sample description");
|
||||||
|
getInputStub.withArgs("timeout", false).returns("1200");
|
||||||
|
|
||||||
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Take Snapshot of Virtual Machines");
|
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Take Snapshot of Virtual Machines");
|
||||||
|
|
||||||
cmdArgs.should.contain("-snapshotOps create -snapshotName \"dummySnapshotName\" -snapshotVMMemory true -quiesceGuestFileSystem false -description \"Sample description\"");
|
cmdArgs.should.contain("-snapshotOps create -snapshotName \"dummySnapshotName\" -snapshotVMMemory true -quiesceGuestFileSystem false -description \"Sample description\" -timeout 1200");
|
||||||
debugStub.should.have.been.calledOnce;
|
debugStub.should.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -159,15 +160,16 @@ describe("getCmdArgsForAction", (): void => {
|
||||||
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Take Snapshot of Virtual Machines");
|
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Take Snapshot of Virtual Machines");
|
||||||
|
|
||||||
cmdArgs.should.contain("-snapshotOps create -snapshotName \"dummySnapshotName\" -snapshotVMMemory true -quiesceGuestFileSystem false -description \"undefined\"");
|
cmdArgs.should.contain("-snapshotOps create -snapshotName \"dummySnapshotName\" -snapshotVMMemory true -quiesceGuestFileSystem false -description \"undefined\"");
|
||||||
getInputStub.should.have.callCount(2);
|
getInputStub.should.have.callCount(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should read snapshot name for restore snapshot action", (): void => {
|
it("Should read snapshot name for restore snapshot action and timeout", (): void => {
|
||||||
getInputStub.withArgs("snapshotName", true).returns("dummySnapshotName");
|
getInputStub.withArgs("snapshotName", true).returns("dummySnapshotName");
|
||||||
|
getInputStub.withArgs("timeout", false).returns("1200");
|
||||||
|
|
||||||
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Revert Snapshot of Virtual Machines");
|
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Revert Snapshot of Virtual Machines");
|
||||||
|
|
||||||
cmdArgs.should.contain("-snapshotOps restore -snapshotName \"dummySnapshotName\"");
|
cmdArgs.should.contain("-snapshotOps restore -snapshotName \"dummySnapshotName\" -timeout 1200");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should read snapshot name for delete snapshot action", (): void => {
|
it("Should read snapshot name for delete snapshot action", (): void => {
|
||||||
|
@ -178,17 +180,18 @@ describe("getCmdArgsForAction", (): void => {
|
||||||
cmdArgs.should.contain("-snapshotOps delete -snapshotName \"dummySnapshotName\"");
|
cmdArgs.should.contain("-snapshotOps delete -snapshotName \"dummySnapshotName\"");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should read template, computeType, hostname, datastore, customization spec and description for clone template", (): void => {
|
it("Should read template, computeType, hostname, datastore, customization spec,description and timeout for clone template", (): void => {
|
||||||
getInputStub.withArgs("template", true).returns("dummyTemplate");
|
getInputStub.withArgs("template", true).returns("dummyTemplate");
|
||||||
getInputStub.withArgs("computeType", true).returns("ESXi Host");
|
getInputStub.withArgs("computeType", true).returns("ESXi Host");
|
||||||
getInputStub.withArgs("hostname", true).returns("Dummy Host");
|
getInputStub.withArgs("hostname", true).returns("Dummy Host");
|
||||||
getInputStub.withArgs("datastore", true).returns("Dummy Datastore");
|
getInputStub.withArgs("datastore", true).returns("Dummy Datastore");
|
||||||
getInputStub.withArgs("description", false).returns("Dummy description");
|
getInputStub.withArgs("description", false).returns("Dummy description");
|
||||||
getInputStub.withArgs("customizationspec", false).returns("Dummy Customization Spec");
|
getInputStub.withArgs("customizationspec", false).returns("Dummy Customization Spec");
|
||||||
|
getInputStub.withArgs("timeout", false).returns("1200");
|
||||||
|
|
||||||
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Deploy Virtual Machines using Template");
|
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Deploy Virtual Machines using Template");
|
||||||
|
|
||||||
cmdArgs.should.contain("-clonetemplate \"dummyTemplate\" -computetype \"ESXi Host\" -computename \"Dummy Host\" -datastore \"Dummy Datastore\" -customizationspec \"Dummy Customization Spec\" -description \"Dummy description\"");
|
cmdArgs.should.contain("-clonetemplate \"dummyTemplate\" -computetype \"ESXi Host\" -computename \"Dummy Host\" -datastore \"Dummy Datastore\" -customizationspec \"Dummy Customization Spec\" -description \"Dummy description\" -timeout 1200");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should read cluster name if compute is cluster and read empty description", (): void => {
|
it("Should read cluster name if compute is cluster and read empty description", (): void => {
|
||||||
|
@ -225,16 +228,20 @@ describe("getCmdArgsForAction", (): void => {
|
||||||
cmdArgs.should.contain("-deletevm delete");
|
cmdArgs.should.contain("-deletevm delete");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should construct command action for power on vm operation", (): void => {
|
it("Should construct command action for power on vm operation and read timeout", (): void => {
|
||||||
|
getInputStub.withArgs("timeout", false).returns("1200");
|
||||||
|
|
||||||
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Power On Virtual Machines");
|
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Power On Virtual Machines");
|
||||||
|
|
||||||
cmdArgs.should.contain("-powerops poweron");
|
cmdArgs.should.contain("-powerops poweron -timeout 1200");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should construct command action for shutdown vm operation", (): void => {
|
it("Should construct command action for shutdown vm operation and read timeout", (): void => {
|
||||||
|
getInputStub.withArgs("timeout", false).returns("1200");
|
||||||
|
|
||||||
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Shutdown Virtual Machines");
|
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Shutdown Virtual Machines");
|
||||||
|
|
||||||
cmdArgs.should.contain("-powerops shutdown");
|
cmdArgs.should.contain("-powerops shutdown -timeout 1200");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should construct command action for power off vm operation", (): void => {
|
it("Should construct command action for power off vm operation", (): void => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче