Function: vCenter Host System NTP Server Toggle

by Simon Sparks · 2 February 2026

To use this function add it to the class library file named PluginVCHostSystemService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: PluginVCHostSystemService.ts

Public Function: NtpServerConfigure

publicNtpServerConfigure(objVcHostSystem:VcHostSystem,arrNtpServerIp:string[]):void{

this.NtpServerToggle(objVcHostSysteme,arrNtpServerIp);
}

Public Function: NtpServerUnconfigure

publicNtpServerUnconfigure(objVcHostSysteme:VcHostSystem):void{

this.NtpServerToggle(objVcHostSysteme, [])
}

Private Function: NtpServerToggle

privateNtpServerToggle(objVcHostSystem:VcHostSystem,arrNtpServerIp:string[]):void{
letobjVcHostNtpConfig:VcHostNtpConfig=newVcHostNtpConfig();
objVcHostNtpConfig.server=arrNtpServerIp

letobjVcHostDateTimeConfig:VcHostDateTimeConfig=newVcHostDateTimeConfig();
objVcHostDateTimeConfig.ntpConfig=objVcHostNtpConfig;

letobjVcHostConfigManager:VcHostConfigManager=objVcHostSystem.configManager;

letobjVcHostDateTimeSystem:VcHostDateTimeSystem=objVcHostConfigManager.dateTimeSystem;

objVcHostDateTimeSystem.updateDateTimeConfig(objVcHostDateTimeConfig);

letobjVcHostFirewallRulesetIpList:VcHostFirewallRulesetIpList=newVcHostFirewallRulesetIpList();
objVcHostFirewallRulesetIpList.allIp=false;
objVcHostFirewallRulesetIpList.ipAddress=arrNtpServerIp;

letobjVcHostFirewallRulesetRulesetSpec:VcHostFirewallRulesetRulesetSpec=newVcHostFirewallRulesetRulesetSpec();
objVcHostFirewallRulesetRulesetSpec.allowedHosts=objVcHostFirewallRulesetIpList;

letobjVcHostFirewallSystem:VcHostFirewallSystem=objVcHostConfigManager.firewallSystem;

objVcHostFirewallSystem.updateRuleset("ntpClient",objVcHostFirewallRulesetRulesetSpec);

letobjVcHostServiceSystem:VcHostServiceSystem=objVcHostConfigManager.serviceSystem;

if (arrVcHostNtpIp.length===0){
objVcHostServiceSystem.updateServicePolicy("ntpd","off");
objVcHostServiceSystem.stopService("ntpd");
}elseif (arrVcHostNtpIp.length>0){
objVcHostServiceSystem.updateServicePolicy("ntpd","on");
objVcHostServiceSystem.startService("ntpd");
}
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like