I have created a solution for this in TypeScript using the Aria Build Tools
https://github.com/vmware/build-tools-for-vmware-aria
The first step is to create a function to check if Alarm Actions are currently enabled or not.
public VcHostSystemAreAlarmActionsEnabled(@notNull @notEmpty @required objVcHostSystem: VcHostSystem): boolean {
let objVcSdkConnection: VcSdkConnection = objVcHostSystem.sdkConnection;
let objVcAlarmManager: VcAlarmManager = objVcSdkConnection.alarmManager;
let blnAreAlarmActionsEnabled: boolean = objVcAlarmManager.areAlarmActionsEnabled(objVcHostSystem);
return blnAreAlarmActionsEnabled;
}
The second step is to create a helper function that will enable us to toggle the setting on and off.
private VcHostSystemAlarmActionsToggle(@notNull @notEmpty @required objVcHostSystem: VcHostSystem, @notNull @notEmpty @required blnAlarmActionsState: boolean): void {
let objVcSdkConnection: VcSdkConnection = objVcHostSystem.sdkConnection;
let objVcAlarmManager: VcAlarmManager = objVcSdkConnection.alarmManager;
objVcAlarmManager.enableAlarmActions(objVcHostSystem, blnAlarmActionsState);
}
The third step is to create 2 functions to call the helper function to do the enable and disable.
public VcHostSystemAlarmActionsEnable(@notNull @notEmpty @required objVcHostSystem: VcHostSystem): void {
this.VcHostSystemAlarmActionsToggle(objVcHostSystem, true);
}
public VcHostSystemAlarmActionsDisable(@notNull @notEmpty @required objVcHostSystem: VcHostSystem): void {
this.VcHostSystemAlarmActionsToggle(objVcHostSystem, false);
}
------------------------------
Simon Sparks
Automation & Orchestration Consultant
North West England, UK, Europe
Broadcom Employee
------------------------------
Original Message:
Sent: Aug 02, 2019 09:12 PM
From: Jamison618
Subject: Enable / Disable vCenter Alarm Actions on an ESXi Host
Hello,
I'm building a workflow that I need to temporarily disable alarm actions on a host. Would someone be kind enough to post a code snippet that I could create an action with? I have a PS script I made but I'm a noob with JavaScript.
The input being esxHost (VC:HostSystem)
Thanks in advance!