Top use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
public WaitForVcTaskEnd(@notNull @notEmpty @required objVcTask: VcTask, @notNull @notEmpty @required intPollRate: number): any {
while (objVcTask.info !== null) {
let objVcTaskInfoState: VcTaskInfoState = objVcTask.info.state;
if (objVcTaskInfoState.value === "success") {
break;
}
else if (objVcTaskInfoState.value === "error") {
if (objVcTask.info.error.localizedMessage === null) {
throw `Task '${objVcTask.info.name}' has encountered an unknown error`;
}
else {
throw `Task '${objVcTask.info.name}' error: '${objVcTask.info.error.localizedMessage}'`;
}
}
else if (objVcTaskInfoState.value === "running") {
if (objVcTask.info.progress === null) {
this.objLogger.info(`${objVcTask.info.name} - Queued or In Progress...`);
}
else {
this.objLogger.info(`${objVcTask.info.name} - Progress: ${objVcTask.info.progress} %`);
}
}
System.sleep(intPollRate * 1000);
}
this.objLogger.info(objVcTask.info.name + " - Completed");
System.sleep(2 * 1000);
if (objVcTask !== null && objVcTask.info !== null && objVcTask.info.result_AnyValue !== null) {
let objVcSdkConnection: VcSdkConnection = objVcTask.sdkConnection;
return VcPlugin.convertToVimManagedObject(objVcSdkConnection, objVcTask.info.result_AnyValue);
}
else {
return null;
}
}
Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
