Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mso_st_filter_entry: Fix various issues #53241

Merged
merged 1 commit into from
Mar 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 35 additions & 44 deletions lib/ansible/modules/network/aci/mso_schema_template_filter_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
'''

EXAMPLES = r'''
- name: Add a new filter
mso_schema_template_filter:
- name: Add a new filter entry
mso_schema_template_filter_entry:
host: mso_host
username: admin
password: SomeSecretPassword
Expand All @@ -127,8 +127,8 @@
state: present
delegate_to: localhost

- name: Remove a filter
mso_schema_template_filter:
- name: Remove a filter entry
mso_schema_template_filter_entry:
host: mso_host
username: admin
password: SomeSecretPassword
Expand All @@ -138,8 +138,8 @@
state: absent
delegate_to: localhost

- name: Query a specific filters
mso_schema_template_filter:
- name: Query a specific filter entry
mso_schema_template_filter_entry:
host: mso_host
username: admin
password: SomeSecretPassword
Expand All @@ -150,8 +150,8 @@
delegate_to: localhost
register: query_result

- name: Query all filters
mso_schema_template_filter:
- name: Query all filter entries
mso_schema_template_filter_entry:
host: mso_host
username: admin
password: SomeSecretPassword
Expand Down Expand Up @@ -285,30 +285,31 @@ def main():

elif state == 'present':

if display_name is None:
display_name = mso.existing.get('displayName', entry)
if description is None:
description = mso.existing.get('description', '')
if ethertype is None:
ethertype = mso.existing.get('etherType', 'unspecified')
if ip_protocol is None:
ip_protocol = mso.existing.get('ipProtocol', 'unspecified')
if tcp_session_rules is None:
tcp_session_rules = mso.existing.get('tcpSessionRules', ['unspecified'])
if source_from is None:
source_from = mso.existing.get('sourceFrom', 'unspecified')
if source_to is None:
source_to = mso.existing.get('sourceTo', 'unspecified')
if destination_from is None:
destination_from = mso.existing.get('destinationFrom', 'unspecified')
if destination_to is None:
destination_to = mso.existing.get('destinationTo', 'unspecified')
if arp_flag is None:
arp_flag = mso.existing.get('arpFlag', 'unspecified')
if stateful is None:
stateful = mso.existing.get('stateful', False)
if fragments_only is None:
fragments_only = mso.existing.get('matchOnlyFragments', False)
if not mso.existing:
if display_name is None:
display_name = entry
if description is None:
description = ''
if ethertype is None:
ethertype = 'unspecified'
if ip_protocol is None:
ip_protocol = 'unspecified'
if tcp_session_rules is None:
tcp_session_rules = ['unspecified']
if source_from is None:
source_from = 'unspecified'
if source_to is None:
source_to = 'unspecified'
if destination_from is None:
destination_from = 'unspecified'
if destination_to is None:
destination_to = 'unspecified'
if arp_flag is None:
arp_flag = 'unspecified'
if stateful is None:
stateful = False
if fragments_only is None:
fragments_only = False

payload = dict(
name=entry,
Expand Down Expand Up @@ -347,18 +348,8 @@ def main():

else:
# Entry exists, we have to update it
ops.append(dict(op='replace', path=entry_path + '/displayName', value=display_name))
ops.append(dict(op='replace', path=entry_path + '/description', value=description))
ops.append(dict(op='replace', path=entry_path + '/etherType', value=ethertype))
ops.append(dict(op='replace', path=entry_path + '/ipProtocol', value=ip_protocol))
ops.append(dict(op='replace', path=entry_path + '/tcpSessionRules', value=tcp_session_rules))
ops.append(dict(op='replace', path=entry_path + '/sourceFrom', value=source_from))
ops.append(dict(op='replace', path=entry_path + '/sourceTo', value=source_to))
ops.append(dict(op='replace', path=entry_path + '/destinationFrom', value=destination_from))
ops.append(dict(op='replace', path=entry_path + '/destinationTo', value=destination_to))
ops.append(dict(op='replace', path=entry_path + '/arpFlag', value=arp_flag))
ops.append(dict(op='replace', path=entry_path + '/stateful', value=stateful))
ops.append(dict(op='replace', path=entry_path + '/matchOnlyFragments', value=fragments_only))
for (key, value) in mso.sent.items():
ops.append(dict(op='replace', path=entry_path + '/' + key, value=value))

mso.existing = mso.proposed

Expand Down