huawei.enterprise.hw_enterprise_snmp_trap module – SNMP Trap operations for Huawei Enterprise Storage

Note

This module is part of the huawei.enterprise collection (version 2.0.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install huawei.enterprise. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: huawei.enterprise.hw_enterprise_snmp_trap.

Synopsis

  • Supports the provisioning operations on a SNMP Trap such as modify and get the details of a SNMP Trap.

Requirements

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

  • Huawei Dorado v5/v6/v7 and OceanStor v5/v6/v7 Storage

Parameters

Parameter

Comments

cmo_trap_server_ip

string

Trap server address.

The value can be a domain name or an IPv4 or IPv6 address.

cmo_trap_server_port

string

Trap server port.

1 to 65535.

cmo_trap_server_type

string

Trap server type.

The value is 161 or from 20000 to 20100.

Choices:

  • "parsed"

  • "original"

  • "all"

  • "parsed_time_string"

  • "original_time_string"

cmo_trap_server_user

string

USM username.

cmo_trap_version

string

Trap version

Choices:

  • "SNMPv1"

  • "SNMPv2c"

  • "SNMPv3"

custom_vars

dictionary

Parameters used to extend those not currently supported by the module.

Configuration needs to be based on the REST API documentation for storage.

If necessary, you can contact the plugin technical support for assistance.

filter

list / elements=string

Parameter required for all query operations.

The response will include the storage parameters that match the indicate filter criteria.

Choices:

  • "type"

  • "id"

  • "cmo_trap_server_ip"

  • "cmo_trap_version"

  • "cmo_trap_server_port"

  • "cmo_trap_server_user"

  • "cmo_trap_server_type"

hostname

string / required

IP or FQDN of the huawei enterprise management system.

MultiIP config as ip1,ip2

id

string

SNMP Trap unique id.

password

string / required

The password of the PowerStore host.

socket_timeout

integer

Huawei Enterprise Storage rest api Timeout time.

Default: 60

state

string / required

Define whether the SNMP Trap should exist or not.

Choices:

  • "absent"

  • "present"

storage_port

integer

Port number for the Huawei Enterprise array.

If not passed, it will take 8088 as default.

Default: 8088

use_log

boolean

Whether to write plugin log to local filesystem.

Choices:

  • false ← (default)

  • true

username

string / required

The username of the PowerStore host.

valid_certs

string

The path of the SSL certificate variable to specify whether to validate SSL certificate or not.

If don’t set means no need to verify ssl cert.

Notes

Note

  • The check_mode is not supported.

  • The modules present in this collection named as ‘huawei.enterprise’ are built to support the Huawei Enterprise Storage System.

Examples

tasks:
- name: Add SNMP trap Service
  register: snmp_trap_info
  huawei.enterprise.hw_enterprise_snmp_trap:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    valid_certs: "{{ valid_certs }}"
    socket_timeout: "{{ socket_timeout }}"
    storage_port: "{{ storage_port }}"
    use_log: "{{ use_log }}"
    cmo_trap_server_ip: "< cmo_trap_server_ip >"
    cmo_trap_server_port: "< cmo_trap_server_port >"
    cmo_trap_server_user: "< cmo_trap_server_user >"
    cmo_trap_server_type: "< parsed | original | all | parsed_time_string | original_time_string >"
    cmo_trap_version: "< SNMPv1 | SNMPv2c | SNMPv3 >"
    state: "present"

- name: Modify SNMP Trap Service
  register: snmp_trap_info
  huawei.enterprise.hw_enterprise_snmp_trap:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    valid_certs: "{{ valid_certs }}"
    socket_timeout: "{{ socket_timeout }}"
    storage_port: "{{ storage_port }}"
    use_log: "{{ use_log }}"
    id: "{{ snmp_trap_info.snmp_trap_detail.id }}"
    cmo_trap_server_ip: "< cmo_trap_server_ip >"
    cmo_trap_server_port: "< cmo_trap_server_port >"
    cmo_trap_server_user: "< cmo_trap_server_user >"
    cmo_trap_server_type: "< parsed | original | all | parsed_time_string | original_time_string >"
    cmo_trap_version: "< SNMPv1 | SNMPv2c | SNMPv3 >"
    state: "present"

- name: Get All SNMP Trap Service
  register: all_snmp_trap
  huawei.enterprise.hw_enterprise_snmp_trap:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    valid_certs: "{{ valid_certs }}"
    socket_timeout: "{{ socket_timeout }}"
    storage_port: "{{ storage_port }}"
    use_log: "{{ use_log }}"
    state: "present"
    filter:
        - id
        - cmo_trap_server_ip
        - cmo_trap_server_port
        - cmo_trap_server_user
        - cmo_trap_server_type
        - cmo_trap_version

- name: Get SNMP Trap By Id
  register: snmp_trap_info
  huawei.enterprise.hw_enterprise_snmp_trap:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    valid_certs: "{{ valid_certs }}"
    socket_timeout: "{{ socket_timeout }}"
    storage_port: "{{ storage_port }}"
    use_log: "{{ use_log }}"
    id: "{{ snmp_trap_info.snmp_trap_detail.id }}"
    state: "present"
    filter:
      - id
      - cmo_trap_server_ip
      - cmo_trap_server_port
      - cmo_trap_server_user
      - cmo_trap_server_type
      - cmo_trap_version

- name: Delete SNMP Trap Service
  huawei.enterprise.hw_enterprise_snmp_trap:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    valid_certs: "{{ valid_certs }}"
    socket_timeout: "{{ socket_timeout }}"
    storage_port: "{{ storage_port }}"
    use_log: "{{ use_log }}"
    id: "{{ snmp_trap_info.snmp_trap_detail.id }}"
    state: "absent"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

actions

list / elements=string

playbook action lists

Returned: always

Sample: ["query"]

changed

boolean

Whether or not the resource has changed.

Returned: always

Sample: false

remark

string

task execute remark

Returned: always

Sample: "Query snmp trap successfully"

snmp_trap_detail

complex

Details of the SNMP Trap.

Returned: When SNMP Trap exists

Sample: {"cmo_trap_server_ip": "xxx.xxx.xxx.xxx", "cmo_trap_server_port": "162", "cmo_trap_server_type": "original", "cmo_trap_server_user": "test", "cmo_trap_version": "SNMPv1", "id": "2"}

cmo_trap_server_ip

string

Trap server address.

Returned: success

cmo_trap_server_port

string

Trap server port

Returned: success

cmo_trap_server_type

string

Trap server type.

Returned: success

cmo_trap_server_user

string

USM username.

Returned: success

cmo_trap_version

string

Trap version.

Returned: success

id

string

SNMP Trap unique id.

Returned: success

Authors

  • Huawei eSDK Ansible Team