To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
Function VcVmConfigFileGetAll
Description: Orchestrator Function to get all the vCenter Virtual Machine config files on all datastores.
publicVcVmConfigFileGetAll(strVCenterName:string):Properties{
letobjProperties:Properties=newProperties();
letarrVcSdkConnection:VcSdkConnection[]=VcPlugin.allSdkConnections;
letobjVcSdkConnection:VcSdkConnection=arrVcSdkConnection.find((objVcSdkConnection:VcSdkConnection)=>{
returnobjVcSdkConnection.name===strVCenterName;
});
letobjVcVmConfigFileQuery:VcVmConfigFileQuery=newVcVmConfigFileQuery();
letarrVcFileQuery:VcFileQuery[]= [];
arrVcFileQuery.push(objVcVmConfigFileQuery);
letobjVcHostDatastoreBrowserSearchSpec:VcHostDatastoreBrowserSearchSpec=newVcHostDatastoreBrowserSearchSpec();
objVcHostDatastoreBrowserSearchSpec.query=arrVcFileQuery;
letarrVcHostSystem:VcHostSystem[]=objVcSdkConnection.getAllHostSystems(null,"");
arrVcHostSystem.forEach((objVcHostSystem:VcHostSystem):void=>{
letarrVcDatastore:VcDatastore[]=objVcHostSystem.datastore;
arrVcDatastore.forEach((objVcDatastore:VcDatastore):void=>{
this.objLogger.info(`Data Store:${objVcDatastore.info.name}.`);
letobjVcHostDatastoreBrowser:VcHostDatastoreBrowser=objVcDatastore.browser;
letobjVcTask:VcTask=objVcHostDatastoreBrowser.searchDatastoreSubFolders_Task("["+objVcDatastore.name+"]",objVcHostDatastoreBrowserSearchSpec);
letarrVcHostDatastoreBrowserSearchResults:VcHostDatastoreBrowserSearchResults[]=this.WaitForVcTaskEnd(objVcTask,1);
arrVcHostDatastoreBrowserSearchResults.forEach((objVcHostDatastoreBrowserSearchResults:VcHostDatastoreBrowserSearchResults):void=>{
this.objLogger.info(`Data Store:${objVcDatastore.info.name} - Folder Path:${objVcHostDatastoreBrowserSearchResults.folderPath}.`);
letarrVcFileInfo:VcFileInfo[]=objVcHostDatastoreBrowserSearchResults.file;
arrVcFileInfo.forEach((objVcFileInfo:VcFileInfo):void=>{
objProperties.put(objVcFileInfo.path.substring(0,objVcFileInfo.path.length-4),objVcHostDatastoreBrowserSearchResults.folderPath+objVcFileInfo.path);
});
});
});
});
returnobjProperties;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
