Skip to content

Commit

Permalink
Alert rule - Create, Update, Delete / Check mode, Diff, UT (#106)
Browse files Browse the repository at this point in the history
* updated alert rule module

* updated TC

* updated moule arguments

* updated with modify, check mode, diff, UT

* fixed sanity issue

* updated channel args

* updated playbook

* sanity issue fix

* updated module name

* updated TC

* issue fix for sanity

* removed unused file

* fix for ANSISILON-2007

* sanity issue fix

* updated docs, and playbook

* updated module docs

* diff idempotancy update

* updated review comments

Co-authored-by: Bhavneet-Sharma <[email protected]>

* updated review comments

Co-authored-by: Bhavneet-Sharma <[email protected]>

* updated playbook example

* updated playbook example

* updated playbook

* updated playbook example

* update the playbook

Co-authored-by: Bhavneet-Sharma <[email protected]>

* update the playbook

Co-authored-by: Bhavneet-Sharma <[email protected]>

* updated playbook

* updated RST file

* updated module docs

* updated module and UT

---------

Co-authored-by: Bhavneet-Sharma <[email protected]>
  • Loading branch information
felixs88 and Bhavneet-Sharma authored Aug 21, 2024
1 parent c5b1405 commit 4911d3a
Show file tree
Hide file tree
Showing 5 changed files with 1,032 additions and 0 deletions.
250 changes: 250 additions & 0 deletions docs/modules/alert_rule.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
.. _alert_rule_module:


alert_rule -- Manage alert rule on a PowerScale Storage System
==============================================================

.. contents::
:local:
:depth: 1


Synopsis
--------

Manage alert rule on a PowerScale Storage System includes create, modify and delete.



Requirements
------------
The below requirements are needed on the host that executes this module.

- A Dell PowerScale Storage system.
- Ansible-core 2.15 or later.
- Python 3.10, 3.11 or 3.12.



Parameters
----------

state (optional, str, present)
The state option is used to mention the existence of server certificate.


name (True, str, None)
The *name* of the rule is a unique that cannot be changed.


condition (optional, str, None)
Trigger condition for alert.


categories (optional, list, None)
Event group categories to be alerted.


channels (optional, list, None)
Channels for the alert.

This is option is required for create alert condition.


eventgroup_ids (optional, list, None)
Event group ID is to be alerted.


exclude_eventgroup_ids (optional, list, None)
Event group categories to be excluded from alerts.


interval (optional, int, None)
Required with ``ONGOING`` condition only, period in seconds between alerts of ongoing conditions.


limit (optional, int, None)
Required with ``NEW EVENTS`` condition only, limits the number of alerts sent as events are added.


severities (optional, list, None)
Severities to be alerted.


transient (optional, int, None)
Any event group lasting less than this many seconds is deemed transient and will not generate alerts under this condition.


onefs_host (True, str, None)
IP address or FQDN of the PowerScale cluster.


port_no (False, str, 8080)
Port number of the PowerScale cluster.It defaults to 8080 if not specified.


verify_ssl (True, bool, None)
boolean variable to specify whether to validate SSL certificate or not.

``true`` - indicates that the SSL certificate should be verified.

``false`` - indicates that the SSL certificate should not be verified.


api_user (True, str, None)
username of the PowerScale cluster.


api_password (True, str, None)
the password of the PowerScale cluster.





Notes
-----

.. note::
- The modules present in this collection named as 'dellemc.powerscale' are built to support the Dell PowerScale storage platform.




Examples
--------

.. code-block:: yaml+jinja


- name: To create the a new alert condition
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
validate_certs: "{{ validate_certs }}"
state: present
name: alert_rule_new
condition: NEW
categories:
- all
- SYS_DISK_EVENTS
channels:
- SupportAssist
eventgroup_ids:
- 100010001
- 100010002
- 100010003
exclude_eventgroup_ids:
- 100010005
interval: 11
transient: 10
limit: 10
severities:
- emergency

- name: To update the existing alert condition
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
validate_certs: "{{ validate_certs }}"
state: present
name: alert_rule_new
condition: NEW
categories:
- all
- SYS_DISK_EVENTS
- NODE_STATUS_EVENTS
channels:
- SupportAssist
eventgroup_ids:
- 100010001
- 100010002
exclude_eventgroup_ids:
- 100010005
interval: 1100
transient: 10
limit: 10
severities:
- emergency
- critical

- name: To delete the existing alert condition
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
validate_certs: "{{ validate_certs }}"
state: absent
name: alert_rule_new



Return Values
-------------

changed (always, bool, false)
A boolean indicating if the task had to make changes.


alert_conditions (always, dict, {'name': 'alert_rule_new', 'condition': 'NEW', 'categories': ['all', 'SYS_DISK_EVENTS'], 'channels': ['SupportAssist'], 'eventgroup_ids': ['100010001', '100010002', '100010003'], 'exclude_eventgroup_ids': ['100010005'], 'interval': 11, 'limit': 10, 'severities': ['emergency'], 'transient': 10})
The alert condition details.


name (, str, )
The name of the alert condition.


condition (, str, )
The condition of the alert condition.


categories (, list, )
The categories of the alert condition.


channels (, list, )
The channels of the alert condition.


eventgroup_ids (, list, )
The event group IDs of the alert condition.


exclude_eventgroup_ids (, list, )
The event group categories of the alert condition.


interval (, int, )
The interval of the alert condition.


limit (, int, )
The limit of the alert condition.


severities (, list, )
The severities of the alert condition.


transient (, int, )
The transient of the alert condition.






Status
------





Authors
~~~~~~~

- Felix Stephen (@felixs88) <[email protected]>

103 changes: 103 additions & 0 deletions playbooks/modules/alert_rule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
- name: Alert Rule operations on PowerScale Array
hosts: localhost
connection: local

tasks:

- name: Get the alert channel and alert group details
dellemc.powerscale.info:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
verify_ssl: "{{ verify_ssl }}"
port: "{{ port }}"
gather_subset:
- alert_channels
- event_group
register: result_info

- name: Create alert rule with basic options
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
verify_ssl: "{{ verify_ssl }}"
port: "{{ port }}"
state: present
name: test_alert_rule
categories: []
channels:
- "{{ result_info.alert_channels[0]['channels'][0].name }}"
condition: "NEW"
eventgroup_ids:
- "{{ result_info.event_groups[0]['eventgroup_definitions'][0].id }}"
exclude_eventgroup_ids: []
interval: 0
limit: 0
severities: []
transient: 0

- name: Create alert rule with all options
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
verify_ssl: "{{ verify_ssl }}"
port: "{{ port }}"
state: present
name: test_rule_new
condition: "NEW"
categories:
- all
channels:
- "{{ result_info.alert_channels[0]['channels'][0].name }}"
eventgroup_ids:
- "{{ result_info.event_groups[0]['eventgroup_definitions'][0].id }}"
- "{{ result_info.event_groups[0]['eventgroup_definitions'][1].id }}"
- "{{ result_info.event_groups[0]['eventgroup_definitions'][2].id }}"
exclude_eventgroup_ids:
- "{{ result_info.event_groups[0]['eventgroup_definitions'][3].id }}"
interval: 11
transient: 10
limit: 10
severities:
- emergency
- critical

- name: Update alert rule
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
verify_ssl: "{{ verify_ssl }}"
port: "{{ port }}"
state: present
name: test_rule_new
condition: "NEW"
categories:
- SYS_DISK_EVENTS
- NODE_STATUS_EVENTS
channels:
- "{{ result_info.alert_channels[0]['channels'][0].name }}"
eventgroup_ids:
- "{{ result_info.event_groups[0]['eventgroup_definitions'][0].id }}"
- "{{ result_info.event_groups[0]['eventgroup_definitions'][1].id }}"
exclude_eventgroup_ids:
- "{{ result_info.event_groups[0]['eventgroup_definitions'][3].id }}"
interval: 11
transient: 10
limit: 10
severities:
- emergency
- critical

- name: Delete alert rule
dellemc.powerscale.alert_rule:
onefs_host: "{{ onefs_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
verify_ssl: "{{ verify_ssl }}"
port: "{{ port }}"
state: absent
name: test_rule_new
Loading

0 comments on commit 4911d3a

Please sign in to comment.