To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
public VcSdkConnectionGetAll(): VcSdkConnection[] {
let arrVcSdkConnection: VcSdkConnection[] = this.serverFindAllForType<VcSdkConnection>("VC:SdkConnection");
return arrVcSdkConnection;
}
public VcSdkConnectionCreate(strVcSdkConnectionHostName: string): VcSdkConnection {
let arrVcSdkConnection: VcSdkConnection[] = this.serverFindAllForType<VcSdkConnection>("VC:SdkConnection");
let objVcSdkConnection: VcSdkConnection = arrVcSdkConnection.find((objVcSdkConnection: VcSdkConnection): boolean => {
return objVcSdkConnection.name === strVcSdkConnectionHostName;
});
if (!objVcSdkConnection) {
let blnEnabled: boolean = true;
let blnSessionPerUser: boolean = false;
let strPbmUrl: string = `https://${strVcSdkConnectionHostName}:443/pbm`;
let strSmsUrl: string = `https://${strVcSdkConnectionHostName}:443/sms/sdk`;
try {
VcPlugin.validateConnection(strVcSdkConnectionHostName, 443, "/sdk", objSecret.username, objSecret.password);
}
catch (objException) {
this.objLogger.warn(`Failed to connect to ${strVcSdkConnectionHostName}/sdk.`);
}
try {
VcPlugin.validatePbmServiceAvailability(strPbmUrl);
}
catch (objException) {
this.objLogger.warn(`Failed to connect to ${strPbmUrl}.`);
}
try {
VcPlugin.validateSmsServiceAvailability(strSmsUrl);
}
catch (objException) {
this.objLogger.warn(`Failed to connect to ${strSmsUrl}.`);
}
objVcSdkConnection = VcPlugin.registerVCenterServerInstance(
blnEnabled,
strVcSdkConnectionHostName,
443,
`/sdk`,
blnSessionPerUser,
objSecret.username,
objSecret.password,
'vsphere.local',
strPbmUrl,
strSmsUrl
);
}
return objVcSdkConnection;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
