From 752b471d03fad54e1285a637024ce72bedb7e5e8 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Wed, 5 Sep 2018 04:13:06 +0530 Subject: [PATCH] To resolve nios_network issue where vendor-encapsulated-options can not have a use_option flag (#44259) * To resolve nios_network issue where vendor-encapsulated-options can not have a use_option flag (#43925) * to resolve 43657 * fix shippable error (cherry picked from commit 4e5dbb92dcf759e4901523380307218dbf8e64a4) * adding changelog --- .../nios_network_vendor_specfic_dhcp_fix.yaml | 4 ++++ .../modules/net_tools/nios/nios_network.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 changelogs/fragments/nios_network_vendor_specfic_dhcp_fix.yaml diff --git a/changelogs/fragments/nios_network_vendor_specfic_dhcp_fix.yaml b/changelogs/fragments/nios_network_vendor_specfic_dhcp_fix.yaml new file mode 100644 index 00000000000..b7c4df0aa3f --- /dev/null +++ b/changelogs/fragments/nios_network_vendor_specfic_dhcp_fix.yaml @@ -0,0 +1,4 @@ +--- +bugfixes: + - To resolve nios_network issue where vendor-encapsulated-options can not have a use_option flag. + (https://github.com/ansible/ansible/pull/43925) diff --git a/lib/ansible/modules/net_tools/nios/nios_network.py b/lib/ansible/modules/net_tools/nios/nios_network.py index 82e13907b4e..2075d3db9ef 100644 --- a/lib/ansible/modules/net_tools/nios/nios_network.py +++ b/lib/ansible/modules/net_tools/nios/nios_network.py @@ -178,6 +178,19 @@ def check_ip_addr_type(ip): return NIOS_IPV6_NETWORK +def check_vendor_specific_dhcp_option(module, ib_spec): + '''This function will check if the argument dhcp option belongs to vendor-specific and if yes then will remove + use_options flag which is not supported with vendor-specific dhcp options. + ''' + for key, value in iteritems(ib_spec): + if isinstance(module.params[key], list): + temp_dict = module.params[key][0] + if 'num' in temp_dict: + if temp_dict['num'] in (43, 124, 125): + del module.params[key][0]['use_option'] + return ib_spec + + def main(): ''' Main entry point for module execution ''' @@ -218,6 +231,9 @@ def main(): network_type = check_ip_addr_type(obj_filter['network']) wapi = WapiModule(module) + # to check for vendor specific dhcp option + ib_spec = check_vendor_specific_dhcp_option(module, ib_spec) + result = wapi.run(network_type, ib_spec) module.exit_json(**result)