Skip to content

Commit

Permalink
Refactor(eos_cli_config_gen): Wildcard dict to list for event-handlers (
Browse files Browse the repository at this point in the history
  • Loading branch information
KonikaChaurasiya-GSLab authored Mar 25, 2022
1 parent e6549da commit d8adbc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
event_handlers:
tracking:
- name: tracking
action_type: bash
action: /mnt/flash/tracking.sh
delay: 300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ monitor_connectivity:
```yaml
### Event Handler ###
event_handlers:
< event_handler_name >:
- name: < event_handler_name >
action_type: < Type of action. [bash, increment, log] >
action: < Command to execute >
delay: < Event-handler delay in seconds >
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{# eos - event-handler #}
{% if event_handlers is defined and event_handlers is iterable %}
{% if event_handlers is arista.avd.defined %}

## Event Handler

### Event Handler Summary

| Handler | Action Type | Action | Trigger |
| ------- | ----------- | ------ | ------- |
{% for handler in event_handlers | arista.avd.natural_sort %}
| {{ handler }} | {{ event_handlers[handler].action_type }} | {{ event_handlers[handler].action }} | {{ event_handlers[handler].trigger }} |
{% for handler in event_handlers | arista.avd.convert_dicts('name') | arista.avd.natural_sort('name') %}
| {{ handler.name }} | {{ handler.action_type }} | {{ handler.action }} | {{ handler.trigger }} |
{% endfor %}

### Event Handler Device Configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{# eos - Event handlers #}
{% if event_handlers is arista.avd.defined %}
{% for handler in event_handlers %}
{% for handler in event_handlers | arista.avd.convert_dicts('name') | arista.avd.natural_sort('name') %}
!
event-handler {{ handler }}
{% if event_handlers[handler].trigger is arista.avd.defined %}
trigger {{ event_handlers[handler].trigger }}
{% if event_handlers[handler].regex is arista.avd.defined %}
regex {{ event_handlers[handler].regex }}
event-handler {{ handler.name }}
{% if handler.trigger is arista.avd.defined %}
trigger {{ handler.trigger }}
{% if handler.regex is arista.avd.defined %}
regex {{ handler.regex }}
{% endif %}
{% endif %}
{% if event_handlers[handler].action is arista.avd.defined and event_handlers[handler].action_type is arista.avd.defined %}
action {{ event_handlers[handler].action_type }} {{ event_handlers[handler].action }}
{% if handler.action is arista.avd.defined and handler.action_type is arista.avd.defined %}
action {{ handler.action_type }} {{ handler.action }}
{% endif %}
{% if event_handlers[handler].delay is arista.avd.defined %}
delay {{ event_handlers[handler].delay }}
{% if handler.delay is arista.avd.defined %}
delay {{ handler.delay }}
{% endif %}
{% if event_handlers[handler].asynchronous is arista.avd.defined(true) %}
{% if handler.asynchronous is arista.avd.defined(true) %}
asynchronous
{% endif %}
{% endfor %}
Expand Down

0 comments on commit d8adbc2

Please sign in to comment.