To use this function add it to the class library file named vCenterServerService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: vCenterServerService.ts
Description: Orchestrator Function to Toggle SSH on ESXi Hosts
Public Function:
publicVcHostSystemSSHEnable(objVcHostSystem:VcHostSystem):void{
this.VcHostSystemSSHToggle(objVcHostSystem,"on");
}Public Function:
publicVcHostSystemSSHEnable(objVcHostSystem:VcHostSystem):void{
this.VcHostSystemSSHToggle(objVcHostSystem,"off");
}Private Function: VcHostSystemDisableToggle
privateVcHostSystemSSHToggle(objVcHostSystem:VcHostSystem,strServiceStatus:"on"|"off"):void{
letobjVcHostConfigManager:VcHostConfigManager=objVcHostSystem.configManager;
letobjVcHostServiceSystem:VcHostServiceSystem=objVcHostConfigManager.serviceSystem;
letobjVcHostService:VcHostService=this.VcHostServiceFindByName(objVcHostServiceSystem,"TSM-SSH");
if (objVcHostService.policy==="on"&&strServiceStatus==="on" )
{
// Do Nothing
}
elseif (objVcHostService.policy==="on"&&strServiceStatus==="off" )
{
objVcHostServiceSystem.updateServicePolicy(objVcHostService.key,"off");
}
elseif (objVcHostService.policy==="off"&&strServiceStatus==="on" )
{
objVcHostServiceSystem.updateServicePolicy(objVcHostService.key,"on");
}
elseif (objVcHostService.policy==="off"&&strServiceStatus==="off" )
{
// Do Nothing
}
if (objVcHostService.running===true&&strServiceStatus==="on" )
{
// Do Nothing
}
elseif (objVcHostService.running===true&&strServiceStatus==="off" )
{
objVcHostServiceSystem.stopService("TSM-SSH");
}
elseif (objVcHostService.running===false&&strServiceStatus==="on" )
{
objVcHostServiceSystem.startService("TSM-SSH");
}
elseif (objVcHostService.running===false&&strServiceStatus==="off" )
{
// Do Nothing
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
