VMware Aria Automation Orchestrator

 View Only
  • 1.  Enable / Disable vCenter Alarm Actions on an ESXi Host

    Posted Aug 02, 2019 09:12 PM

    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!



  • 2.  RE: Enable / Disable vCenter Alarm Actions on an ESXi Host
    Best Answer

    Broadcom Employee
    Posted Aug 03, 2019 08:21 AM

    Here is some code to enable / disable alarm actions on a host:

    // Disable alarm actions on 'host'

    var alarmMgr = host.sdkConnection.alarmManager;

    alarmMgr.enableAlarmActions(host, false);

    // Enable alarm actions on 'host'

    var alarmMgr = host.sdkConnection.alarmManager;

    alarmMgr.enableAlarmActions(host, true);

    ---------------------------------------------------------------------------------------------------------

    Was it helpful? Let us know by completing this short survey here.



  • 3.  RE: Enable / Disable vCenter Alarm Actions on an ESXi Host

    Posted Feb 07, 2023 12:54 PM

    Post updated:

    I asked for an action which queries if ESXi host alarm action are enabled?
    I think, this could work:

     

     

     

    var sdkConnection = [VC:HostSystem].sdkConnection;
    return sdkConnection.alarmManager.areAlarmActionsEnabled([VC:HostSystem]);

     

     

     

     

     



  • 4.  RE: Enable / Disable vCenter Alarm Actions on an ESXi Host

    Broadcom Employee
    Posted Jan 04, 2026 01:46 PM

    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
    ------------------------------