Type script layer changes to timeout configurable

This commit is contained in:
Subrahmanyam Mandavilli 2016-05-19 11:35:59 +05:30
Родитель 0dded06709
Коммит 718b687734
3 изменённых файлов: 38 добавлений и 16 удалений

Просмотреть файл

@ -150,6 +150,15 @@
"visibleRule": "action = Take Snapshot of Virtual Machines || action = Deploy Virtual Machines using Template",
"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",
"type": "boolean",

Просмотреть файл

@ -29,6 +29,7 @@ export class VmOperations {
public static getCmdArgsForAction(actionName: string): string {
var cmdArgs = "";
var timeout = "";
switch (actionName) {
case "Deploy Virtual Machines using Template":
var template = tl.getInput("template", true);
@ -36,6 +37,7 @@ export class VmOperations {
var datastore = tl.getInput("datastore", true);
var description = tl.getInput("description", false);
var customizationspec = tl.getInput("customizationspec", false);
timeout = tl.getInput("timeout", false);
var computeName = null;
switch (computeType) {
case "ESXi Host":
@ -52,19 +54,21 @@ export class VmOperations {
tl.exit(1);
}
cmdArgs += " -clonetemplate \"" + template + "\" -computetype \"" + computeType + "\" -computename \"" +
computeName + "\" -datastore \"" + datastore + "\" -customizationspec \"" + customizationspec + "\" -description \"" + description + "\"";
computeName + "\" -datastore \"" + datastore + "\" -customizationspec \"" + customizationspec + "\" -description \"" + description + "\" -timeout " + timeout;
break;
case "Take Snapshot of Virtual Machines":
var snapshotName = tl.getInput("snapshotName", true);
var snapshotVMMemory = "true";
var quiesceGuestFileSystem = "false";
var description: string = tl.getInput("description", false);
timeout = tl.getInput("timeout", false);
cmdArgs += " -snapshotOps create -snapshotName \"" + snapshotName + "\" -snapshotVMMemory " + snapshotVMMemory + " -quiesceGuestFileSystem " +
quiesceGuestFileSystem + " -description \"" + description + "\"";
quiesceGuestFileSystem + " -description \"" + description + "\" -timeout " + timeout;
break;
case "Revert Snapshot of Virtual Machines":
var snapshotName = tl.getInput("snapshotName", true);
cmdArgs += " -snapshotOps restore -snapshotName \"" + snapshotName + "\"";
timeout = tl.getInput("timeout", false);
cmdArgs += " -snapshotOps restore -snapshotName \"" + snapshotName + "\" -timeout " + timeout;
break;
case "Delete Snapshot of Virtual Machines":
var snapshotName = tl.getInput("snapshotName", true);
@ -74,10 +78,12 @@ export class VmOperations {
cmdArgs += " -deletevm delete";
break;
case "Power On Virtual Machines":
cmdArgs += " -powerops poweron";
timeout = tl.getInput("timeout", false);
cmdArgs += " -powerops poweron -timeout " + timeout;
break;
case "Shutdown Virtual Machines":
cmdArgs += " -powerops shutdown";
timeout = tl.getInput("timeout", false);
cmdArgs += " -powerops shutdown -timeout " + timeout;
break;
case "Power off Virtual Machines":
cmdArgs += " -powerops poweroff";

Просмотреть файл

@ -143,13 +143,14 @@ describe("getCmdArgsForAction", (): void => {
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("description", false).returns("Sample description");
getInputStub.withArgs("timeout", false).returns("1200");
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;
});
@ -159,15 +160,16 @@ describe("getCmdArgsForAction", (): void => {
var cmdArgs = vmOperations.VmOperations.getCmdArgsForAction("Take Snapshot of Virtual Machines");
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("timeout", false).returns("1200");
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 => {
@ -178,17 +180,18 @@ describe("getCmdArgsForAction", (): void => {
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("computeType", true).returns("ESXi Host");
getInputStub.withArgs("hostname", true).returns("Dummy Host");
getInputStub.withArgs("datastore", true).returns("Dummy Datastore");
getInputStub.withArgs("description", false).returns("Dummy description");
getInputStub.withArgs("customizationspec", false).returns("Dummy Customization Spec");
getInputStub.withArgs("timeout", false).returns("1200");
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 => {
@ -225,16 +228,20 @@ describe("getCmdArgsForAction", (): void => {
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");
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");
cmdArgs.should.contain("-powerops shutdown");
cmdArgs.should.contain("-powerops shutdown -timeout 1200");
});
it("Should construct command action for power off vm operation", (): void => {