File Name |
neo_events_policy.py |
|
Description |
This SDK manipulates NEO events policy data using NEO's REST API. The script includes the following main operations:
|
|
Usage |
neo_events_policy.py [-h] -s SERVER -u USERNAME -p PASSWORD [-r {http,https}] --port {80,443,3080,3443} |
|
Arguments |
-h |
Displays the help menu |
-s SERVER |
NEO server IP |
|
-u USERNAME |
NEO username |
|
-p PASSWORD |
NEO password |
|
--port |
The port used to communicate with NEO. If NEO is run on a physical machine:
If NEO run on a docker container:
|
|
-r {http,https} |
Connection protocol to NEO |
|
-o {get,getall,update} |
Script operations |
|
-t PARAMETERS |
URL parameters. Valid formats:
|
|
-f FILE |
A file in json format containing the payload of the request. |
'get'
Required Arguments |
|
Parameters |
'events_policy' – event policy ID of an existing policy |
Output example:
[root@ufm_sdk]# /opt/neo/venv/bin/python neo_events_policy.py -s 10.209.37.77 -u admin -r https --port 443 -p 123456 -o get -t "event_policy_id=event_policy_port_out_errors"
======================================================================
<<< NEO - Getting events policies data SDK >>>
----------------------------------------------------------------------
[*] Running Settings:
-> NEO server IP address: 10.209.37.77
-> NEO user name: admin
======================================================================
[*] Getting events policies data stages:
-1- Setting Up data...
-2- Sending Getting events policies data request...
======================================================================
[*] Getting events policies data results:
>> Getting events policies data request HTTP response status code: 200
>> Getting events policies data request HTTP response text:
{
"Category": "Device",
"SubCategory": "Networking",
"ActiveConditions": 3,
"InstanceID": "event_policy_port_out_errors",
"EventType": "Port Out Errors",
"Conditions": [
{
"Task": null,
"Severity": "Warning",
"InstanceID": "event_condition_out_errors_between_5_10",
"Overrides": null,
"Value": "5-10",
"Filter": null,
"Operator": "between",
"Trigger": "Out Errors",
"Mail": null, "OverriddenBy": null,
"Attribute": "Out Errors",
"ValueType": "str",
"Editable": true,
"Active": true,
"Message": "OutErrors counter rate threshold exceeded.",
"MellanoxCare": false
},
.
.
.
]
}
======================================================================
'getall'
Output example:
[root@ufm_sdk]# /opt/neo/venv/bin/python neo_events_policy.py -s 10.209.37.77 -u admin -r https --port 443 -p 123456 -o getall
======================================================================
<<< NEO - Getting all events policies data SDK >>>
----------------------------------------------------------------------
[*] Running Settings:
-> NEO server IP address: 10.209.37.77
-> NEO user name: admin
======================================================================
[*] Getting all events policies data stages:
-1- Setting Up data...
-2- Sending Getting all events policies data request...
======================================================================
[*] Getting all events policies data results:
>> Getting all events policies data request HTTP response status code: 200
>> Getting all events policies data request HTTP response text: [
{
"Category": "Device",
"SubCategory": "Networking",
"ActiveConditions": 3,
"InstanceID": "event_policy_port_out_errors",
"EventType": "Port Out Errors",
"Conditions": [
{
"Task": null,
"Severity": "Warning",
"InstanceID": "event_condition_out_errors_between_5_10",
"Overrides": null,
"Value": "5-10",
"Filter": null,
"Operator": "between",
"Trigger": "Out Errors",
"Mail": null,
"OverriddenBy": null,
"Attribute": "Out Errors",
"ValueType": "str",
"Editable": true,
"Active": true,
"Message": "OutErrors counter rate threshold exceeded.",
"MellanoxCare": false
},
]
.
.
.
},
======================================================================
'update'
Required Arguments |
|
File Name |
For the 'update' operation, you need to supply a file containing the payload of the request. For example: |
{ "Severity": "Warning", "Active": true |
Output example:
[root@ufm_sdk]# /opt/neo/venv/bin/python neo_events_policy.py -s 10.209.37.77 -u admin -r https --port 443 -p 123456 -o update -t "event_policy_id=event_policy_high_cpu_utilization" -f event_policy_example
======================================================================
<<< NEO - Updating event policy SDK >>>
----------------------------------------------------------------------
[*] Running Settings:
-> NEO server IP address: 10.209.37.77
-> NEO user name: admin
======================================================================
[*] Updating event policy stages:
-1- Setting Up data...
-2- Sending Updating event policy request...
======================================================================
[*] Updating event policy results:
>> Updating event policy request HTTP response status code: 200
======================================================================