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 Function:
publicVcHostSystemNtpServerConfigure(objVcHostSystem:VcHostSystem,arrNtpServerIp:string[]):void{
this.VcHostSystemNtpServerToggle(objVcHostSysteme,"on",arrNtpServerIp);
}Public Function:
publicVcHostSystemNtpServerUnconfigure(objVcHostSysteme:VcHostSystem):void{
this.VcHostSystemNtpServerToggle(objVcHostSysteme,"off")
}Private Function: VcHostSystemNtpServerToggle
privateVcHostSystemNtpServerToggle(objVcHostSystem:VcHostSystem,strServiceState:"on"|"off",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;
objVcHostServiceSystem.updateServicePolicy("ntpd",strServiceState);
if (strServiceState==="on")
{
objVcHostServiceSystem.startService("ntpd");
}
else
{
objVcHostServiceSystem.stopService("ntpd");
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
