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