diff --git a/plugins/module_utils/network/sonic/argspec/bgp_as_paths/bgp_as_paths.py b/plugins/module_utils/network/sonic/argspec/bgp_as_paths/bgp_as_paths.py index 31a64980f..dec9b930e 100644 --- a/plugins/module_utils/network/sonic/argspec/bgp_as_paths/bgp_as_paths.py +++ b/plugins/module_utils/network/sonic/argspec/bgp_as_paths/bgp_as_paths.py @@ -37,7 +37,8 @@ def __init__(self, **kwargs): pass argument_spec = {'config': {'elements': 'dict', - 'options': {'members': {'elements': 'str', + 'options': {'permit': {'required': False, 'type': 'bool'}, + 'members': {'elements': 'str', 'required': False, 'type': 'list'}, 'name': {'required': True, 'type': 'str'}}, diff --git a/plugins/module_utils/network/sonic/config/aaa/aaa.py b/plugins/module_utils/network/sonic/config/aaa/aaa.py index 9a97d89d5..85f93bc73 100644 --- a/plugins/module_utils/network/sonic/config/aaa/aaa.py +++ b/plugins/module_utils/network/sonic/config/aaa/aaa.py @@ -191,7 +191,7 @@ def build_create_aaa_payload(self, commands): auth_method = commands["authentication"]["data"]["group"] payload['openconfig-system:aaa']['authentication']['config']['authentication-method'].append(auth_method) if "fail_through" in commands["authentication"]["data"]: - cfg = {'openconfig-system-ext:failthrough': str(commands["authentication"]["data"]["fail_through"])} + cfg = {'failthrough': str(commands["authentication"]["data"]["fail_through"])} payload['openconfig-system:aaa']['authentication']['config'].update(cfg) return payload @@ -215,7 +215,7 @@ def remove_default_entries(self, data): def get_delete_all_aaa_request(self, have): requests = [] if "authentication" in have and have["authentication"]: - if "local" or "group" in have["authentication"]["data"]: + if "local" in have["authentication"]["data"] or "group" in have["authentication"]["data"]: request = self.get_authentication_method_delete_request() requests.append(request) if "fail_through" in have["authentication"]["data"]: @@ -230,7 +230,7 @@ def get_authentication_method_delete_request(self): return request def get_failthrough_delete_request(self): - path = 'data/openconfig-system:system/aaa/authentication/config/openconfig-system-ext:failthrough' + path = 'data/openconfig-system:system/aaa/authentication/config/failthrough' method = DELETE request = {'path': path, 'method': method} return request diff --git a/plugins/module_utils/network/sonic/config/bgp/bgp.py b/plugins/module_utils/network/sonic/config/bgp/bgp.py index 9f3535b05..031ef052b 100644 --- a/plugins/module_utils/network/sonic/config/bgp/bgp.py +++ b/plugins/module_utils/network/sonic/config/bgp/bgp.py @@ -64,9 +64,9 @@ class Bgp(ConfigBase): network_instance_path = '/data/openconfig-network-instance:network-instances/network-instance' protocol_bgp_path = 'protocols/protocol=BGP,bgp/bgp' - log_neighbor_changes_path = 'openconfig-bgp-ext:logging-options/config/log-neighbor-state-changes' - holdtime_path = 'config/openconfig-bgp-ext:hold-time' - keepalive_path = 'config/openconfig-bgp-ext:keepalive-interval' + log_neighbor_changes_path = 'logging-options/config/log-neighbor-state-changes' + holdtime_path = 'config/hold-time' + keepalive_path = 'config/keepalive-interval' def __init__(self, module): super(Bgp, self).__init__(module) @@ -208,8 +208,8 @@ def get_delete_max_med_requests(self, vrf_name, max_med, match): match_max_med_on_startup = match.get('max_med', {}).get('on_startup') if match_max_med_on_startup: - requests.append({'path': generic_del_path + "openconfig-bgp-ext:max-med/config/time", 'method': DELETE}) - requests.append({'path': generic_del_path + "openconfig-bgp-ext:max-med/config/max-med-val", 'method': DELETE}) + requests.append({'path': generic_del_path + "max-med/config/time", 'method': DELETE}) + requests.append({'path': generic_del_path + "max-med/config/max-med-val", 'method': DELETE}) return requests @@ -236,25 +236,25 @@ def get_delete_bestpath_requests(self, vrf_name, bestpath, match): as_path = bestpath.get('as_path', None) if as_path and match_as_path: if as_path.get('confed', None) is not None and match_as_path.get('confed', None): - requests.append({'path': route_selection_del_path + "openconfig-bgp-ext:compare-confed-as-path", 'method': DELETE}) + requests.append({'path': route_selection_del_path + "compare-confed-as-path", 'method': DELETE}) if as_path.get('ignore', None) is not None and match_as_path.get('ignore', None): requests.append({'path': route_selection_del_path + "ignore-as-path-length", 'method': DELETE}) if as_path.get('multipath_relax', None) is not None and match_as_path.get('multipath_relax', None): requests.append({'path': multi_paths_del_path + "allow-multiple-as", 'method': DELETE}) if as_path.get('multipath_relax_as_set', None) is not None and match_as_path.get('multipath_relax_as_set', None): - requests.append({'path': multi_paths_del_path + "openconfig-bgp-ext:as-set", 'method': DELETE}) + requests.append({'path': multi_paths_del_path + "as-set", 'method': DELETE}) match_med = match_bestpath.get('med', None) med = bestpath.get('med', None) if med and match_med: if med.get('confed', None) is not None and match_med.get('confed', None): - requests.append({'path': route_selection_del_path + "openconfig-bgp-ext:med-confed", 'method': DELETE}) + requests.append({'path': route_selection_del_path + "med-confed", 'method': DELETE}) if med.get('missing_as_worst', None) is not None and match_med.get('missing_as_worst', None): - requests.append({'path': route_selection_del_path + "openconfig-bgp-ext:med-missing-as-worst", 'method': DELETE}) + requests.append({'path': route_selection_del_path + "med-missing-as-worst", 'method': DELETE}) if med.get('always_compare_med', None) is not None and match_med.get('always_compare_med', None): requests.append({'path': route_selection_del_path + "always-compare-med", 'method': DELETE}) if med.get('max_med_val', None) is not None and match_med.get('max_med_val', None): - requests.append({'path': generic_del_path + "openconfig-bgp-ext:max-med/config/admin-max-med-val", 'method': DELETE}) + requests.append({'path': generic_del_path + "max-med/config/admin-max-med-val", 'method': DELETE}) return requests @@ -283,11 +283,11 @@ def get_delete_specific_bgp_param_request(self, command, match): requests.append({"path": url, "method": DELETE}) if holdtime and match['timers'].get('holdtime', None) != 180: - url = '%s=%s/%s/global/config/openconfig-bgp-ext:hold-time' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) + url = '%s=%s/%s/global/config/hold-time' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) requests.append({"path": url, "method": DELETE}) if keepalive and match['timers'].get('keepalive_interval', None) != 60: - url = '%s=%s/%s/global/config/openconfig-bgp-ext:keepalive-interval' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) + url = '%s=%s/%s/global/config/keepalive-interval' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) requests.append({"path": url, "method": DELETE}) # Delete the log_neighbor_changes only when existing values is True. @@ -355,7 +355,7 @@ def get_modify_multi_paths_req(self, vrf_name, as_path): if as_path_multipath_relax is not None: multipath_cfg['allow-multiple-as'] = as_path_multipath_relax if as_path_multipath_relax_as_set is not None: - multipath_cfg['openconfig-bgp-ext:as-set'] = as_path_multipath_relax_as_set + multipath_cfg['as-set'] = as_path_multipath_relax_as_set payload = {"openconfig-network-instance:config": multipath_cfg} if payload: @@ -385,7 +385,7 @@ def get_modify_route_selection_req(self, vrf_name, compare_routerid, as_path, me as_path_confed = as_path.get('confed', None) as_path_ignore = as_path.get('ignore', None) if as_path_confed is not None: - route_selection_cfg['openconfig-bgp-ext:compare-confed-as-path'] = as_path_confed + route_selection_cfg['compare-confed-as-path'] = as_path_confed if as_path_ignore is not None: route_selection_cfg['ignore-as-path-length'] = as_path_ignore @@ -394,9 +394,9 @@ def get_modify_route_selection_req(self, vrf_name, compare_routerid, as_path, me med_missing_as_worst = med.get('missing_as_worst', None) always_compare_med = med.get('always_compare_med', None) if med_confed is not None: - route_selection_cfg['openconfig-bgp-ext:med-confed'] = med_confed + route_selection_cfg['med-confed'] = med_confed if med_missing_as_worst is not None: - route_selection_cfg['openconfig-bgp-ext:med-missing-as-worst'] = med_missing_as_worst + route_selection_cfg['med-missing-as-worst'] = med_missing_as_worst if always_compare_med is not None: route_selection_cfg['always-compare-med'] = always_compare_med method = PATCH @@ -437,7 +437,7 @@ def get_modify_max_med_requests(self, vrf_name, max_med): if on_startup_med is not None: payload = { - 'openconfig-bgp-ext:max-med': { + 'max-med': { 'config': { 'max-med-val': on_startup_med, 'time': on_startup_time @@ -446,7 +446,7 @@ def get_modify_max_med_requests(self, vrf_name, max_med): } if payload: - url = '%s=%s/%s/global/openconfig-bgp-ext:max-med' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) + url = '%s=%s/%s/global/max-med' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) request = {"path": url, "method": method, "data": payload} return [request] @@ -457,7 +457,7 @@ def get_modify_log_change_request(self, vrf_name, log_neighbor_changes): payload = {} if log_neighbor_changes is not None: - payload['openconfig-bgp-ext:log-neighbor-state-changes'] = log_neighbor_changes + payload['log-neighbor-state-changes'] = log_neighbor_changes if payload: url = '%s=%s/%s/global/%s' % (self.network_instance_path, vrf_name, self.protocol_bgp_path, self.log_neighbor_changes_path) @@ -471,7 +471,7 @@ def get_modify_holdtime_request(self, vrf_name, holdtime): payload = {} if holdtime is not None: - payload['openconfig-bgp-ext:hold-time'] = str(holdtime) + payload['hold-time'] = str(holdtime) if payload: url = '%s=%s/%s/global/%s' % (self.network_instance_path, vrf_name, self.protocol_bgp_path, self.holdtime_path) @@ -485,7 +485,7 @@ def get_modify_keepalive_request(self, vrf_name, keepalive_interval): payload = {} if keepalive_interval is not None: - payload['openconfig-bgp-ext:keepalive-interval'] = str(keepalive_interval) + payload['keepalive-interval'] = str(keepalive_interval) if payload: url = '%s=%s/%s/global/%s' % (self.network_instance_path, vrf_name, self.protocol_bgp_path, self.keepalive_path) @@ -564,7 +564,7 @@ def get_modify_bgp_requests(self, commands, have): if 'keepalive_interval' in conf['timers']: keepalive_interval = conf['timers']['keepalive_interval'] - if not any([cfg for cfg in have if cfg['vrf_name'] == vrf_name and (cfg['bgp_as'] == as_val)]): + if not any(cfg for cfg in have if cfg['vrf_name'] == vrf_name and (cfg['bgp_as'] == as_val)): new_bgp_req = self.get_new_bgp_request(vrf_name, as_val) if new_bgp_req: requests.append(new_bgp_req) diff --git a/plugins/module_utils/network/sonic/config/bgp_af/bgp_af.py b/plugins/module_utils/network/sonic/config/bgp_af/bgp_af.py index a7c3add61..97df7f6ce 100644 --- a/plugins/module_utils/network/sonic/config/bgp_af/bgp_af.py +++ b/plugins/module_utils/network/sonic/config/bgp_af/bgp_af.py @@ -255,7 +255,7 @@ def get_modify_redistribute_requests(self, vrf_name, conf_afi, conf_safi, conf_r cfg_data['src-protocol'] = "openconfig-policy-types:%s" % (conf_protocol) cfg_data['config'] = {'address-family': afi_cfg} if conf_metric is not None: - cfg_data['config']['openconfig-network-instance-ext:metric'] = conf_metric + cfg_data['config']['metric'] = conf_metric conf_route_map = conf_redis.get('route_map', None) if conf_route_map: @@ -292,14 +292,14 @@ def get_modify_network_request(self, vrf_name, conf_afi, conf_safi, conf_network request = None afi_safi = ("%s_%s" % (conf_afi, conf_safi)).upper() url = '%s=%s/%s/' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) - url += '%s=%s/openconfig-bgp-ext:network-config' % (self.afi_safi_path, afi_safi) + url += '%s=%s/network-config' % (self.afi_safi_path, afi_safi) network_payload = [] for each in conf_network: payload = {} payload = {'config': {'prefix': each}, 'prefix': each} network_payload.append(payload) if network_payload: - new_payload = {'openconfig-bgp-ext:network-config': {'network': network_payload}} + new_payload = {'network-config': {'network': network_payload}} request = {"path": url, "method": PATCH, "data": new_payload} return request @@ -308,8 +308,8 @@ def get_modify_dampening_request(self, vrf_name, conf_afi, conf_safi, conf_dampe request = None afi_safi = ("%s_%s" % (conf_afi, conf_safi)).upper() url = '%s=%s/%s/' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) - url += '%s=%s/openconfig-bgp-ext:route-flap-damping' % (self.afi_safi_path, afi_safi) - damp_payload = {'openconfig-bgp-ext:route-flap-damping': {'config': {'enabled': conf_dampening}}} + url += '%s=%s/route-flap-damping' % (self.afi_safi_path, afi_safi) + damp_payload = {'route-flap-damping': {'config': {'enabled': conf_dampening}}} if damp_payload: request = {"path": url, "method": PATCH, "data": damp_payload} return request @@ -499,7 +499,7 @@ def get_delete_advertise_default_gw_request(self, vrf_name, conf_afi, conf_safi) def get_delete_dampening_request(self, vrf_name, conf_afi, conf_safi): afi_safi = ("%s_%s" % (conf_afi, conf_safi)).upper() url = '%s=%s/%s' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) - url += '/%s=%s/openconfig-bgp-ext:route-flap-damping/config/enabled' % (self.afi_safi_path, afi_safi) + url += '/%s=%s/route-flap-damping/config/enabled' % (self.afi_safi_path, afi_safi) return({"path": url, "method": DELETE}) @@ -629,7 +629,7 @@ def get_delete_network_request(self, vrf_name, conf_afi, conf_safi, conf_network requests = [] afi_safi = ("%s_%s" % (conf_afi, conf_safi)).upper() url = '%s=%s/%s/' % (self.network_instance_path, vrf_name, self.protocol_bgp_path) - url += '%s=%s/openconfig-bgp-ext:network-config/network=' % (self.afi_safi_path, afi_safi) + url += '%s=%s/network-config/network=' % (self.afi_safi_path, afi_safi) mat_list = [] for conf in conf_network: if mat_network: @@ -726,7 +726,7 @@ def get_delete_redistribute_requests(self, vrf_name, conf_afi, conf_safi, conf_r continue if new_metric_flag and ext_metric_flag: - url += '%s,%s,%s/config/openconfig-network-instance-ext:metric' % (src_protocol, dst_protocol, addr_family) + url += '%s,%s,%s/config/metric' % (src_protocol, dst_protocol, addr_family) requests.append({'path': url, 'method': DELETE}) if new_route_flag and ext_route_flag: diff --git a/plugins/module_utils/network/sonic/config/bgp_as_paths/bgp_as_paths.py b/plugins/module_utils/network/sonic/config/bgp_as_paths/bgp_as_paths.py index 533bc037e..dc2b023b1 100644 --- a/plugins/module_utils/network/sonic/config/bgp_as_paths/bgp_as_paths.py +++ b/plugins/module_utils/network/sonic/config/bgp_as_paths/bgp_as_paths.py @@ -215,10 +215,16 @@ def _state_deleted(self, want, have, diff): def get_new_add_request(self, conf): request = None members = conf.get('members', None) + permit = conf.get('permit', None) + permit_str = "" + if permit: + permit_str = "PERMIT" + else: + permit_str = "DENY" if members: url = "data/openconfig-routing-policy:routing-policy/defined-sets/openconfig-bgp-policy:bgp-defined-sets/as-path-sets" method = "PATCH" - cfg = {'as-path-set-name': conf['name'], 'as-path-set-member': members} + cfg = {'as-path-set-name': conf['name'], 'as-path-set-member': members, 'openconfig-bgp-policy-ext:action': permit_str} as_path_set = {'as-path-set-name': conf['name'], 'config': cfg} payload = {'openconfig-bgp-policy:as-path-sets': {'as-path-set': [as_path_set]}} request = {"path": url, "method": method, "data": payload} @@ -248,6 +254,13 @@ def get_delete_single_as_path_requests(self, name): request = {"path": url.format(name), "method": method} return request + def get_delete_single_as_path_action_requests(self, name): + url = "data/openconfig-routing-policy:routing-policy/defined-sets/openconfig-bgp-policy:bgp-defined-sets/as-path-sets/as-path-set={}" + url = url + "/openconfig-bgp-policy-ext:action" + method = "DELETE" + request = {"path": url.format(name), "method": method} + return request + def get_delete_as_path_requests(self, commands, have, is_delete_all): requests = [] if is_delete_all: @@ -256,6 +269,7 @@ def get_delete_as_path_requests(self, commands, have, is_delete_all): for cmd in commands: name = cmd['name'] members = cmd['members'] + permit = cmd['permit'] if members: diff_members = [] for item in have: @@ -266,6 +280,11 @@ def get_delete_as_path_requests(self, commands, have, is_delete_all): diff_members.append(member_want) if diff_members: requests.append(self.get_delete_single_as_path_member_requests(name, diff_members)) + + elif permit: + for item in have: + if item['name'] == name: + requests.append(self.get_delete_single_as_path_action_requests(name)) else: for item in have: if item['name'] == name: diff --git a/plugins/module_utils/network/sonic/config/bgp_neighbors/bgp_neighbors.py b/plugins/module_utils/network/sonic/config/bgp_neighbors/bgp_neighbors.py index 1d45e5ae6..e0834a9a7 100644 --- a/plugins/module_utils/network/sonic/config/bgp_neighbors/bgp_neighbors.py +++ b/plugins/module_utils/network/sonic/config/bgp_neighbors/bgp_neighbors.py @@ -326,7 +326,7 @@ def build_bgp_peer_groups_payload(self, cmd, have, bgp_as, vrf_name): peer_group_cfg.update({'peer-group-name': peer_group['name']}) bgp_peer_group.update({'peer-group-name': peer_group['name']}) if peer_group.get('bfd', None) is not None: - bgp_peer_group.update({'openconfig-bfd:enable-bfd': {'config': {'enabled': peer_group['bfd']}}}) + bgp_peer_group.update({'enable-bfd': {'config': {'enabled': peer_group['bfd']}}}) if peer_group.get('timers', None) is not None: if peer_group['timers'].get('holdtime', None) is not None: tmp_timers.update({'hold-time': str(peer_group['timers']['holdtime'])}) @@ -334,9 +334,9 @@ def build_bgp_peer_groups_payload(self, cmd, have, bgp_as, vrf_name): tmp_timers.update({'keepalive-interval': str(peer_group['timers']['keepalive'])}) if peer_group.get('capability', None) is not None: if peer_group['capability'].get('dynamic', None) is not None: - tmp_capability.update({'openconfig-bgp-ext:capability-dynamic': peer_group['capability']['dynamic']}) + tmp_capability.update({'capability-dynamic': peer_group['capability']['dynamic']}) if peer_group['capability'].get('extended_nexthop', None) is not None: - tmp_capability.update({'openconfig-bgp-ext:capability-extended-nexthop': peer_group['capability']['extended_nexthop']}) + tmp_capability.update({'capability-extended-nexthop': peer_group['capability']['extended_nexthop']}) if peer_group.get('advertisement_interval', None) is not None: tmp_timers.update({'minimum-advertisement-interval': str(peer_group['advertisement_interval'])}) if peer_group.get('remote_as', None) is not None: @@ -389,7 +389,7 @@ def build_bgp_peer_groups_payload(self, cmd, have, bgp_as, vrf_name): del_nei.update({'address_family': {'afis': afis_list}}) requests.extend(self.delete_specific_peergroup_param_request(vrf_name, del_nei)) origin = each['allowas_in']['origin'] - samp.update({'openconfig-bgp-ext:allow-own-as': {'config': {'origin': origin, "enabled": bool("true")}}}) + samp.update({'allow-own-as': {'config': {'origin': origin, "enabled": bool("true")}}}) if each['allowas_in'].get('value', None) is not None: if have_pg_af: if have_pg_af.get('allowas_in', None) is not None: @@ -403,7 +403,7 @@ def build_bgp_peer_groups_payload(self, cmd, have, bgp_as, vrf_name): del_nei.update({'address_family': {'afis': afis_list}}) requests.extend(self.delete_specific_peergroup_param_request(vrf_name, del_nei)) as_count = each['allowas_in']['value'] - samp.update({'openconfig-bgp-ext:allow-own-as': {'config': {'as-count': as_count, "enabled": bool("true")}}}) + samp.update({'allow-own-as': {'config': {'as-count': as_count, "enabled": bool("true")}}}) if samp: afi.append(samp) if tmp_timers: @@ -450,7 +450,7 @@ def build_bgp_neighbors_payload(self, cmd, have, bgp_as, vrf_name): tmp_capability = {} tmp_remote = {} if neighbor.get('bfd', None) is not None: - bgp_neighbor.update({'openconfig-bfd:enable-bfd': {'config': {'enabled': neighbor['bfd']}}}) + bgp_neighbor.update({'enable-bfd': {'config': {'enabled': neighbor['bfd']}}}) if neighbor.get('timers', None) is not None: if neighbor['timers'].get('holdtime', None) is not None: tmp_timers.update({'hold-time': str(neighbor['timers']['holdtime'])}) @@ -458,9 +458,9 @@ def build_bgp_neighbors_payload(self, cmd, have, bgp_as, vrf_name): tmp_timers.update({'keepalive-interval': str(neighbor['timers']['keepalive'])}) if neighbor.get('capability', None) is not None: if neighbor['capability'].get('dynamic', None) is not None: - tmp_capability.update({'openconfig-bgp-ext:capability-dynamic': neighbor['capability']['dynamic']}) + tmp_capability.update({'capability-dynamic': neighbor['capability']['dynamic']}) if neighbor['capability'].get('extended_nexthop', None) is not None: - tmp_capability.update({'openconfig-bgp-ext:capability-extended-nexthop': neighbor['capability']['extended_nexthop']}) + tmp_capability.update({'capability-extended-nexthop': neighbor['capability']['extended_nexthop']}) if neighbor.get('advertisement_interval', None) is not None: tmp_timers.update({'minimum-advertisement-interval': str(neighbor['advertisement_interval'])}) if neighbor.get('neighbor', None) is not None: @@ -540,7 +540,7 @@ def get_delete_specific_bgp_peergroup_param_request(self, vrf_name, cmd, want_ma want_pg_match = next((cfg for cfg in want_peer_group if cfg['name'] == name), None) if want_pg_match: keys = ['remote_as', 'timers', 'advertisement_interval', 'bfd', 'capability', 'address_family'] - if not any([want_pg_match.get(key, None) for key in keys]): + if not any(want_pg_match.get(key, None) for key in keys): requests.append(self.get_delete_vrf_specific_peergroup_request(vrf_name, name)) else: requests.extend(self.delete_specific_peergroup_param_request(vrf_name, each)) @@ -569,13 +569,13 @@ def delete_specific_peergroup_param_request(self, vrf_name, cmd): requests.append({'path': delete_path, 'method': DELETE}) if cmd.get('capability', None) is not None: if cmd['capability'].get('dynamic', None) is not None: - delete_path = delete_static_path + '/config/openconfig-bgp-ext:capability-dynamic' + delete_path = delete_static_path + '/config/capability-dynamic' requests.append({'path': delete_path, 'method': DELETE}) if cmd['capability'].get('extended_nexthop', None) is not None: - delete_path = delete_static_path + '/config/openconfig-bgp-ext:capability-extended-nexthop' + delete_path = delete_static_path + '/config/capability-extended-nexthop' requests.append({'path': delete_path, 'method': DELETE}) if cmd.get('bfd', None) is not None: - delete_path = delete_static_path + '/openconfig-bfd:enable-bfd/config/enabled' + delete_path = delete_static_path + '/enable-bfd/config/enabled' requests.append({'path': delete_path, 'method': DELETE}) if cmd.get('address_family', None) is not None: if cmd['address_family'].get('afis', None) is None: @@ -598,10 +598,10 @@ def delete_specific_peergroup_param_request(self, vrf_name, cmd): requests.append({'path': delete_path, 'method': DELETE}) if allowas_in: if allowas_in.get('origin', None): - delete_path = delete_static_path + '/afi-safis/afi-safi=%s/openconfig-bgp-ext:allow-own-as/config/origin' % (afi_safi_name) + delete_path = delete_static_path + '/afi-safis/afi-safi=%s/allow-own-as/config/origin' % (afi_safi_name) requests.append({'path': delete_path, 'method': DELETE}) if allowas_in.get('value', None): - delete_path = delete_static_path + '/afi-safis/afi-safi=%s/openconfig-bgp-ext:allow-own-as/config/as-count' % (afi_safi_name) + delete_path = delete_static_path + '/afi-safis/afi-safi=%s/allow-own-as/config/as-count' % (afi_safi_name) requests.append({'path': delete_path, 'method': DELETE}) return requests @@ -624,7 +624,7 @@ def get_delete_specific_bgp_param_request(self, vrf_name, cmd, want_match): want_nei_match = next(cfg for cfg in want_neighbors if cfg['neighbor'] == neighbor) if want_nei_match: keys = ['remote_as', 'peer_group', 'timers', 'advertisement_interval', 'bfd', 'capability'] - if not any([want_nei_match.get(key, None) for key in keys]): + if not any(want_nei_match.get(key, None) for key in keys): requests.append(self.delete_neighbor_whole_request(vrf_name, neighbor)) else: requests.extend(self.delete_specific_param_request(vrf_name, each)) @@ -661,13 +661,13 @@ def delete_specific_param_request(self, vrf_name, cmd): requests.append({'path': delete_path, 'method': DELETE}) if cmd.get('capability', None) is not None: if cmd['capability'].get('dynamic', None) is not None: - delete_path = delete_static_path + '/config/openconfig-bgp-ext:capability-dynamic' + delete_path = delete_static_path + '/config/capability-dynamic' requests.append({'path': delete_path, 'method': DELETE}) if cmd['capability'].get('extended_nexthop', None) is not None: - delete_path = delete_static_path + '/config/openconfig-bgp-ext:capability-extended-nexthop' + delete_path = delete_static_path + '/config/capability-extended-nexthop' requests.append({'path': delete_path, 'method': DELETE}) if cmd.get('bfd', None) is not None: - delete_path = delete_static_path + '/openconfig-bfd:enable-bfd/config/enabled' + delete_path = delete_static_path + '/enable-bfd/config/enabled' requests.append({'path': delete_path, 'method': DELETE}) return requests diff --git a/plugins/module_utils/network/sonic/config/bgp_neighbors_af/bgp_neighbors_af.py b/plugins/module_utils/network/sonic/config/bgp_neighbors_af/bgp_neighbors_af.py index d3c004ba6..8bba08f34 100644 --- a/plugins/module_utils/network/sonic/config/bgp_neighbors_af/bgp_neighbors_af.py +++ b/plugins/module_utils/network/sonic/config/bgp_neighbors_af/bgp_neighbors_af.py @@ -68,11 +68,11 @@ class Bgp_neighbors_af(ConfigBase): neighbor_path = 'neighbors/neighbor' afi_safi_path = 'afi-safis/afi-safi' activate_path = "/config/enabled" - ref_client_path = "/config/openconfig-bgp-ext:route-reflector-client" - serv_client_path = "/config/openconfig-bgp-ext:route-server-client" - allowas_origin_path = "/openconfig-bgp-ext:allow-own-as/config/origin" - allowas_value_path = "/openconfig-bgp-ext:allow-own-as/config/as-count" - allowas_enabled_path = "/openconfig-bgp-ext:allow-own-as/config/enabled" + ref_client_path = "/config/route-reflector-client" + serv_client_path = "/config/route-server-client" + allowas_origin_path = "/allow-own-as/config/origin" + allowas_value_path = "/allow-own-as/config/as-count" + allowas_enabled_path = "/allow-own-as/config/enabled" def __init__(self, module): super(Bgp_neighbors_af, self).__init__(module) @@ -244,8 +244,8 @@ def get_single_neighbors_af_modify_request(self, match, vrf_name, conf_neighbor_ afi_safi_cfg['afi-safi-name'] = afi_safi_name self.set_val(afi_safi_cfg, conf_nei_addr_fam, 'activate', 'enabled') - self.set_val(afi_safi_cfg, conf_nei_addr_fam, 'route_reflector_client', 'openconfig-bgp-ext:route-reflector-client') - self.set_val(afi_safi_cfg, conf_nei_addr_fam, 'route_server_client', 'openconfig-bgp-ext:route-server-client') + self.set_val(afi_safi_cfg, conf_nei_addr_fam, 'route_reflector_client', 'route-reflector-client') + self.set_val(afi_safi_cfg, conf_nei_addr_fam, 'route_server_client', 'route-server-client') if afi_safi_cfg: afi_safi['config'] = afi_safi_cfg @@ -281,7 +281,7 @@ def get_single_neighbors_af_modify_request(self, match, vrf_name, conf_neighbor_ allowas_in_cfg['as-count'] = value if allowas_in_cfg: allowas_in_cfg['enabled'] = True - afi_safi['openconfig-bgp-ext:allow-own-as'] = {'config': allowas_in_cfg} + afi_safi['allow-own-as'] = {'config': allowas_in_cfg} if afi_safi: afi_safis.append(afi_safi) @@ -405,7 +405,7 @@ def process_delete_specific_params(self, vrf_name, conf_neighbor_val, conf_nei_a if conf_route_map and mat_route_map: del_routes = [] for route in conf_route_map: - if any([e_route for e_route in mat_route_map if route['direction'] == e_route['direction']]): + if any(e_route for e_route in mat_route_map if route['direction'] == e_route['direction']): del_routes.append(route) if del_routes: requests.extend(self.get_delete_neighbor_af_routemaps_requests(vrf_name, conf_neighbor_val, conf_afi, conf_safi, del_routes)) diff --git a/plugins/module_utils/network/sonic/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/sonic/config/l3_interfaces/l3_interfaces.py index ae710b109..d1b735251 100644 --- a/plugins/module_utils/network/sonic/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/sonic/config/l3_interfaces/l3_interfaces.py @@ -305,7 +305,7 @@ def get_delete_l3_interfaces_requests(self, want, have): addr = ip['address'].split('/')[0] del_url = ipv4_addr_url.format(intf_name=name, sub_intf_name=sub_intf, address=addr) if match_ip['secondary']: - del_url += '/config/openconfig-interfaces-ext:secondary' + del_url += '/config/secondary' ipv4_del_reqs.insert(0, {"path": del_url, "method": DELETE}) else: ipv4_del_reqs.append({"path": del_url, "method": DELETE}) @@ -500,7 +500,7 @@ def build_create_payload(self, addrs_payload): def build_create_addr_payload(self, ip, mask, secondary=None): cfg = {'ip': ip, 'prefix-length': float(mask)} if secondary: - cfg['openconfig-interfaces-ext:secondary'] = secondary + cfg['secondary'] = secondary addr_payload = {'ip': ip, 'openconfig-if-ip:config': cfg} return addr_payload diff --git a/plugins/module_utils/network/sonic/config/radius_server/radius_server.py b/plugins/module_utils/network/sonic/config/radius_server/radius_server.py index 816b9a114..dfa65482f 100644 --- a/plugins/module_utils/network/sonic/config/radius_server/radius_server.py +++ b/plugins/module_utils/network/sonic/config/radius_server/radius_server.py @@ -185,11 +185,11 @@ def get_radius_global_payload(self, conf): global_cfg = {} if conf.get('auth_type', None): - global_cfg['openconfig-system-ext:auth-type'] = conf['auth_type'] + global_cfg['auth-type'] = conf['auth_type'] if conf.get('key', None): - global_cfg['openconfig-system-ext:secret-key'] = conf['key'] + global_cfg['secret-key'] = conf['key'] if conf.get('timeout', None): - global_cfg['openconfig-system-ext:timeout'] = conf['timeout'] + global_cfg['timeout'] = conf['timeout'] if global_cfg: payload = {'openconfig-system:config': global_cfg} @@ -219,11 +219,11 @@ def get_radius_server_payload(self, hosts): if host.get('name', None): host_cfg = {'address': host['name']} if host.get('auth_type', None): - host_cfg['openconfig-system-ext:auth-type'] = host['auth_type'] + host_cfg['auth-type'] = host['auth_type'] if host.get('priority', None): - host_cfg['openconfig-system-ext:priority'] = host['priority'] + host_cfg['priority'] = host['priority'] if host.get('vrf', None): - host_cfg['openconfig-system-ext:vrf'] = host['vrf'] + host_cfg['vrf'] = host['vrf'] if host.get('timeout', None): host_cfg['timeout'] = host['timeout'] @@ -232,6 +232,8 @@ def get_radius_server_payload(self, hosts): radius_port_key_cfg['auth-port'] = host['port'] if host.get('key', None): radius_port_key_cfg['secret-key'] = host['key'] + if host.get('retransmit', None): + radius_port_key_cfg['retransmit-attempts'] = host['retransmit'] if host.get('source_interface', None): radius_port_key_cfg['openconfig-aaa-radius-ext:source-interface'] = host['source_interface'] @@ -317,7 +319,7 @@ def get_delete_global_params(self, conf, match): requests = [] - url = 'data/openconfig-system:system/aaa/server-groups/server-group=RADIUS/config/openconfig-system-ext:' + url = 'data/openconfig-system:system/aaa/server-groups/server-group=RADIUS/config/' if conf.get('auth_type', None) and match.get('auth_type', None) and match['auth_type'] != 'pap': requests.append({'path': url + 'auth-type', 'method': DELETE}) if conf.get('key', None) and match.get('key', None): diff --git a/plugins/module_utils/network/sonic/config/tacacs_server/tacacs_server.py b/plugins/module_utils/network/sonic/config/tacacs_server/tacacs_server.py index 90c8a80a6..498fcbe28 100644 --- a/plugins/module_utils/network/sonic/config/tacacs_server/tacacs_server.py +++ b/plugins/module_utils/network/sonic/config/tacacs_server/tacacs_server.py @@ -185,13 +185,13 @@ def get_tacacs_global_payload(self, conf): global_cfg = {} if conf.get('auth_type', None): - global_cfg['openconfig-system-ext:auth-type'] = conf['auth_type'] + global_cfg['auth-type'] = conf['auth_type'] if conf.get('key', None): - global_cfg['openconfig-system-ext:secret-key'] = conf['key'] + global_cfg['secret-key'] = conf['key'] if conf.get('source_interface', None): - global_cfg['openconfig-system-ext:source-interface'] = conf['source_interface'] + global_cfg['source-interface'] = conf['source_interface'] if conf.get('timeout', None): - global_cfg['openconfig-system-ext:timeout'] = conf['timeout'] + global_cfg['timeout'] = conf['timeout'] if global_cfg: payload = {'openconfig-system:config': global_cfg} @@ -205,11 +205,11 @@ def get_tacacs_server_payload(self, hosts): if host.get('name', None): host_cfg = {'address': host['name']} if host.get('auth_type', None): - host_cfg['openconfig-system-ext:auth-type'] = host['auth_type'] + host_cfg['auth-type'] = host['auth_type'] if host.get('priority', None): - host_cfg['openconfig-system-ext:priority'] = host['priority'] + host_cfg['priority'] = host['priority'] if host.get('vrf', None): - host_cfg['openconfig-system-ext:vrf'] = host['vrf'] + host_cfg['vrf'] = host['vrf'] if host.get('timeout', None): host_cfg['timeout'] = host['timeout'] @@ -273,7 +273,7 @@ def get_delete_global_params(self, conf, match): requests = [] - url = 'data/openconfig-system:system/aaa/server-groups/server-group=TACACS/config/openconfig-system-ext:' + url = 'data/openconfig-system:system/aaa/server-groups/server-group=TACACS/config/' if conf.get('auth_type', None) and match.get('auth_type', None) and match['auth_type'] != 'pap': requests.append({'path': url + 'auth-type', 'method': DELETE}) if conf.get('key', None) and match.get('key', None): diff --git a/plugins/module_utils/network/sonic/facts/aaa/aaa.py b/plugins/module_utils/network/sonic/facts/aaa/aaa.py index ac5ba9365..2dd3538e7 100644 --- a/plugins/module_utils/network/sonic/facts/aaa/aaa.py +++ b/plugins/module_utils/network/sonic/facts/aaa/aaa.py @@ -104,8 +104,8 @@ def parse_sonic_aaa(self, spec, conf): for i, word in enumerate(conf['authentication-method']): if word in choices: temp['group'] = conf['authentication-method'][i] - if ('openconfig-system-ext:failthrough' in conf): - temp['fail_through'] = conf['openconfig-system-ext:failthrough'] + if ('failthrough' in conf): + temp['fail_through'] = conf['failthrough'] if temp: config['authentication']['data'] = temp return utils.remove_empties(config) diff --git a/plugins/module_utils/network/sonic/facts/bgp/bgp.py b/plugins/module_utils/network/sonic/facts/bgp/bgp.py index c4fca96ee..c86b53c2a 100644 --- a/plugins/module_utils/network/sonic/facts/bgp/bgp.py +++ b/plugins/module_utils/network/sonic/facts/bgp/bgp.py @@ -35,20 +35,20 @@ class BgpFacts(object): global_params_map = { 'bgp_as': 'as', 'router_id': 'router-id', - 'holdtime': 'openconfig-bgp-ext:hold-time', - 'keepalive_interval': 'openconfig-bgp-ext:keepalive-interval', - 'log_neighbor_changes': ['openconfig-bgp-ext:logging-options', 'log-neighbor-state-changes'], - 'as_path_confed': ['route-selection-options', 'openconfig-bgp-ext:compare-confed-as-path'], + 'holdtime': 'hold-time', + 'keepalive_interval': 'keepalive-interval', + 'log_neighbor_changes': ['logging-options', 'log-neighbor-state-changes'], + 'as_path_confed': ['route-selection-options', 'compare-confed-as-path'], 'as_path_ignore': ['route-selection-options', 'ignore-as-path-length'], 'as_path_multipath_relax': ['use-multiple-paths', 'ebgp', 'config', 'allow-multiple-as'], - 'as_path_multipath_relax_as_set': ['use-multiple-paths', 'ebgp', 'config', 'openconfig-bgp-ext:as-set'], + 'as_path_multipath_relax_as_set': ['use-multiple-paths', 'ebgp', 'config', 'as-set'], 'compare_routerid': ['route-selection-options', 'external-compare-router-id'], - 'med_confed': ['route-selection-options', 'openconfig-bgp-ext:med-confed'], - 'med_missing_as_worst': ['route-selection-options', 'openconfig-bgp-ext:med-missing-as-worst'], + 'med_confed': ['route-selection-options', 'med-confed'], + 'med_missing_as_worst': ['route-selection-options', 'med-missing-as-worst'], 'always_compare_med': ['route-selection-options', 'always-compare-med'], - 'admin_max_med': ['openconfig-bgp-ext:max-med', 'admin-max-med-val'], - 'max_med_on_startup_timer': ['openconfig-bgp-ext:max-med', 'time'], - 'max_med_on_startup_med_val': ['openconfig-bgp-ext:max-med', 'max-med-val'], + 'admin_max_med': ['max-med', 'admin-max-med-val'], + 'max_med_on_startup_timer': ['max-med', 'time'], + 'max_med_on_startup_med_val': ['max-med', 'max-med-val'], } def __init__(self, module, subspec='config', options='options'): diff --git a/plugins/module_utils/network/sonic/facts/bgp_af/bgp_af.py b/plugins/module_utils/network/sonic/facts/bgp_af/bgp_af.py index ae5df8bce..e046f1360 100644 --- a/plugins/module_utils/network/sonic/facts/bgp_af/bgp_af.py +++ b/plugins/module_utils/network/sonic/facts/bgp_af/bgp_af.py @@ -45,12 +45,12 @@ class Bgp_afFacts(object): 'route_map': 'policy-name', 'prefix': 'prefix', 'neighbor': 'neighbor-address', - 'route_reflector_client': 'openconfig-bgp-ext:route-reflector-client', - 'route_server_client': 'openconfig-bgp-ext:route-server-client', - 'next_hop_self': ['openconfig-bgp-ext:next-hop-self', 'enabled'], - 'remove_private_as': ['openconfig-bgp-ext:remove-private-as', 'enabled'], - 'prefix_list_in': ['openconfig-bgp-ext:prefix-list', 'import-policy'], - 'prefix_list_out': ['openconfig-bgp-ext:prefix-list', 'export-policy'], + 'route_reflector_client': 'route-reflector-client', + 'route_server_client': 'route-server-client', + 'next_hop_self': ['next-hop-self', 'enabled'], + 'remove_private_as': ['remove-private-as', 'enabled'], + 'prefix_list_in': ['prefix-list', 'import-policy'], + 'prefix_list_out': ['prefix-list', 'export-policy'], 'maximum_prefix': ['prefix-limit', 'max-prefixes'], 'activate': 'enabled', 'advertise_all_vni': ['l2vpn-evpn', 'openconfig-bgp-evpn-ext:config', 'advertise-all-vni'], @@ -58,14 +58,14 @@ class Bgp_afFacts(object): 'advertise_list': ['l2vpn-evpn', 'openconfig-bgp-evpn-ext:config', 'advertise-list'], 'ebgp': ['use-multiple-paths', 'ebgp', 'maximum-paths'], 'ibgp': ['use-multiple-paths', 'ibgp', 'maximum-paths'], - 'network': ['openconfig-bgp-ext:network-config', 'network'], - 'dampening': ['openconfig-bgp-ext:route-flap-damping', 'config', 'enabled'] + 'network': ['network-config', 'network'], + 'dampening': ['route-flap-damping', 'config', 'enabled'] } af_redis_params_map = { 'protocol': 'src-protocol', 'afi': 'address-family', - 'metric': 'openconfig-network-instance-ext:metric', + 'metric': 'metric', 'route_map': 'import-policy' } diff --git a/plugins/module_utils/network/sonic/facts/bgp_as_paths/bgp_as_paths.py b/plugins/module_utils/network/sonic/facts/bgp_as_paths/bgp_as_paths.py index be29185f3..822db22a4 100644 --- a/plugins/module_utils/network/sonic/facts/bgp_as_paths/bgp_as_paths.py +++ b/plugins/module_utils/network/sonic/facts/bgp_as_paths/bgp_as_paths.py @@ -65,8 +65,13 @@ def get_as_path_list(self): as_name = as_path["as-path-set-name"] member_config = as_path['config'] members = member_config.get("as-path-set-member", []) + permit_str = member_config.get("openconfig-bgp-policy-ext:action", None) result['name'] = as_name result['members'] = members + if permit_str and permit_str == "PERMIT": + result['permit'] = True + else: + result['permit'] = False as_path_list_configs.append(result) # with open('/root/ansible_log.log', 'a+') as fp: # fp.write('as_path_list: ' + str(as_path_list_configs) + '\n') @@ -116,7 +121,9 @@ def render_config(self, spec, conf): try: config['name'] = str(conf['name']) config['members'] = conf['members'] + config['permit'] = conf['permit'] except TypeError: config['name'] = None config['members'] = None + config['permit'] = None return utils.remove_empties(config) diff --git a/plugins/module_utils/network/sonic/facts/bgp_neighbors/bgp_neighbors.py b/plugins/module_utils/network/sonic/facts/bgp_neighbors/bgp_neighbors.py index a05c6d7b6..aa4bb670a 100644 --- a/plugins/module_utils/network/sonic/facts/bgp_neighbors/bgp_neighbors.py +++ b/plugins/module_utils/network/sonic/facts/bgp_neighbors/bgp_neighbors.py @@ -42,9 +42,9 @@ class Bgp_neighborsFacts(object): 'keepalive': 'keepalive-interval', 'holdtime': 'hold-time', 'advertisement_interval': 'minimum-advertisement-interval', - 'bfd': ['openconfig-bfd:enable-bfd', 'enabled'], - 'dynamic': 'openconfig-bgp-ext:capability-dynamic', - 'extended_nexthop': 'openconfig-bgp-ext:capability-extended-nexthop', + 'bfd': ['enable-bfd', 'enabled'], + 'dynamic': 'capability-dynamic', + 'extended_nexthop': 'capability-extended-nexthop', } def __init__(self, module, subspec='config', options='options'): diff --git a/plugins/module_utils/network/sonic/facts/bgp_neighbors_af/bgp_neighbors_af.py b/plugins/module_utils/network/sonic/facts/bgp_neighbors_af/bgp_neighbors_af.py index b5b64bd00..3b28a6333 100644 --- a/plugins/module_utils/network/sonic/facts/bgp_neighbors_af/bgp_neighbors_af.py +++ b/plugins/module_utils/network/sonic/facts/bgp_neighbors_af/bgp_neighbors_af.py @@ -35,10 +35,10 @@ class Bgp_neighbors_afFacts(object): neighbor_af_params_map = { 'afi': 'afi-safi-name', - 'route_reflector_client': 'openconfig-bgp-ext:route-reflector-client', - 'route_server_client': 'openconfig-bgp-ext:route-server-client', - 'allowas_in_origin': ['openconfig-bgp-ext:allow-own-as', 'origin'], - 'allowas_in_value': ['openconfig-bgp-ext:allow-own-as', 'as-count'], + 'route_reflector_client': 'route-reflector-client', + 'route_server_client': 'route-server-client', + 'allowas_in_origin': ['allow-own-as', 'origin'], + 'allowas_in_value': ['allow-own-as', 'as-count'], 'in_route_name': ['apply-policy', 'import-policy'], 'out_route_name': ['apply-policy', 'export-policy'], 'activate': 'enabled', @@ -63,7 +63,7 @@ def fill_route_map(self, data): if route_map_key in data: route_map = data['route_map'] for e_route in data[route_map_key]: - direction = route_map_key.split('_')[0] + direction = route_map_key.split('_', maxsplit=1)[0] route_map.append({'name': e_route, 'direction': direction}) data.pop(route_map_key) diff --git a/plugins/module_utils/network/sonic/facts/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/sonic/facts/l2_interfaces/l2_interfaces.py index 2f1bdcc2d..39df568da 100644 --- a/plugins/module_utils/network/sonic/facts/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/sonic/facts/l2_interfaces/l2_interfaces.py @@ -47,6 +47,16 @@ def __init__(self, module, subspec='config', options='options'): self.generated_spec = utils.generate_dict(facts_argument_spec) + def vlan_range_to_list(self, in_range): + range_bounds = in_range.split('-') + range_bottom = int(range_bounds[0]) + range_top = int(range_bounds[1]) + 1 + vlan_list = list(range(range_bottom, range_top)) + vlan_dict_list = [] + for vlan in vlan_list: + vlan_dict_list.append({'vlan': vlan}) + return vlan_dict_list + def get_l2_interfaces_from_interfaces(self, interfaces): l2_interfaces = [] @@ -68,7 +78,16 @@ def get_l2_interfaces_from_interfaces(self, interfaces): if(open_cfg_vlan['config'].get('trunk-vlans')): new_det['trunk'] = {} new_det['trunk']['allowed_vlans'] = [] - new_det['trunk']['allowed_vlans'].extend([dict({'vlan': vlan}) for vlan in open_cfg_vlan['config'].get('trunk-vlans')]) + + # Save trunk vlans as a list of single vlan dicts: Convert + # any ranges to lists of individual vlan dicts and merge + # each resulting "range list" onto the main list for the + # interface. + for vlan in open_cfg_vlan['config'].get('trunk-vlans'): + if isinstance(vlan, str) and '-' in vlan: + new_det['trunk']['allowed_vlans'].extend(self.vlan_range_to_list(vlan)) + else: + new_det['trunk']['allowed_vlans'].append({'vlan': vlan}) l2_interfaces.append(new_det) return l2_interfaces diff --git a/plugins/module_utils/network/sonic/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/sonic/facts/l3_interfaces/l3_interfaces.py index 61aa2eaca..e1462ea16 100644 --- a/plugins/module_utils/network/sonic/facts/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/sonic/facts/l3_interfaces/l3_interfaces.py @@ -90,7 +90,7 @@ def get_l3_interfaces(self): if ipv4.get('config') and ipv4.get('config').get('ip'): temp = dict() temp['address'] = str(ipv4['config']['ip']) + '/' + str(ipv4['config']['prefix-length']) - temp['secondary'] = ipv4['config']['openconfig-interfaces-ext:secondary'] + temp['secondary'] = ipv4['config']['secondary'] l3_ipv4.append(temp) if l3_ipv4: l3_dict['ipv4']['addresses'] = l3_ipv4 diff --git a/plugins/module_utils/network/sonic/facts/radius_server/radius_server.py b/plugins/module_utils/network/sonic/facts/radius_server/radius_server.py index f37bf96bb..72593b225 100644 --- a/plugins/module_utils/network/sonic/facts/radius_server/radius_server.py +++ b/plugins/module_utils/network/sonic/facts/radius_server/radius_server.py @@ -101,12 +101,12 @@ def get_all_radius_server(self): if "openconfig-system:config" in response[0][1]: raw_radius_global_data = response[0][1].get("openconfig-system:config", {}) - if 'openconfig-system-ext:auth-type' in raw_radius_global_data: - radius_server_data['auth_type'] = raw_radius_global_data['openconfig-system-ext:auth-type'] - if 'openconfig-system-ext:secret-key' in raw_radius_global_data: - radius_server_data['key'] = raw_radius_global_data['openconfig-system-ext:secret-key'] - if 'openconfig-system-ext:timeout' in raw_radius_global_data: - radius_server_data['timeout'] = raw_radius_global_data['openconfig-system-ext:timeout'] + if 'auth-type' in raw_radius_global_data: + radius_server_data['auth_type'] = raw_radius_global_data['auth-type'] + if 'secret-key' in raw_radius_global_data: + radius_server_data['key'] = raw_radius_global_data['secret-key'] + if 'timeout' in raw_radius_global_data: + radius_server_data['timeout'] = raw_radius_global_data['timeout'] request = [{"path": "data/openconfig-system:system/aaa/server-groups/server-group=RADIUS/openconfig-aaa-radius-ext:radius/config", "method": GET}] try: @@ -141,12 +141,12 @@ def get_all_radius_server(self): host_data['name'] = radius_host['address'] cfg = radius_host.get('config', None) if cfg: - if 'openconfig-system-ext:auth-type' in cfg: - host_data['auth_type'] = cfg['openconfig-system-ext:auth-type'] - if 'openconfig-system-ext:priority' in cfg: - host_data['priority'] = cfg['openconfig-system-ext:priority'] - if 'openconfig-system-ext:vrf' in cfg: - host_data['vrf'] = cfg['openconfig-system-ext:vrf'] + if 'auth-type' in cfg: + host_data['auth_type'] = cfg['auth-type'] + if 'priority' in cfg: + host_data['priority'] = cfg['priority'] + if 'vrf' in cfg: + host_data['vrf'] = cfg['vrf'] if 'timeout' in cfg: host_data['timeout'] = cfg['timeout'] if radius_host.get('radius', None) and radius_host['radius'].get('config', None): diff --git a/plugins/module_utils/network/sonic/facts/tacacs_server/tacacs_server.py b/plugins/module_utils/network/sonic/facts/tacacs_server/tacacs_server.py index cef8b751f..a1e79910f 100644 --- a/plugins/module_utils/network/sonic/facts/tacacs_server/tacacs_server.py +++ b/plugins/module_utils/network/sonic/facts/tacacs_server/tacacs_server.py @@ -101,14 +101,14 @@ def get_all_tacacs_server(self): if "openconfig-system:config" in response[0][1]: raw_tacacs_global_data = response[0][1].get("openconfig-system:config", {}) - if 'openconfig-system-ext:auth-type' in raw_tacacs_global_data: - tacacs_server_data['auth_type'] = raw_tacacs_global_data['openconfig-system-ext:auth-type'] - if 'openconfig-system-ext:secret-key' in raw_tacacs_global_data: - tacacs_server_data['key'] = raw_tacacs_global_data['openconfig-system-ext:secret-key'] - if 'openconfig-system-ext:source-interface' in raw_tacacs_global_data: - tacacs_server_data['source_interface'] = raw_tacacs_global_data['openconfig-system-ext:source-interface'] - if 'openconfig-system-ext:timeout' in raw_tacacs_global_data: - tacacs_server_data['timeout'] = raw_tacacs_global_data['openconfig-system-ext:timeout'] + if 'auth-type' in raw_tacacs_global_data: + tacacs_server_data['auth_type'] = raw_tacacs_global_data['auth-type'] + if 'secret-key' in raw_tacacs_global_data: + tacacs_server_data['key'] = raw_tacacs_global_data['secret-key'] + if 'source-interface' in raw_tacacs_global_data: + tacacs_server_data['source_interface'] = raw_tacacs_global_data['source-interface'] + if 'timeout' in raw_tacacs_global_data: + tacacs_server_data['timeout'] = raw_tacacs_global_data['timeout'] request = [{"path": "data/openconfig-system:system/aaa/server-groups/server-group=TACACS/servers", "method": GET}] hosts = [] @@ -127,14 +127,14 @@ def get_all_tacacs_server(self): host_data['name'] = tacacs_host['address'] cfg = tacacs_host.get('config', None) if cfg: - if 'openconfig-system-ext:auth-type' in cfg: - host_data['auth_type'] = cfg['openconfig-system-ext:auth-type'] - if 'openconfig-system-ext:priority' in cfg: - host_data['priority'] = cfg['openconfig-system-ext:priority'] - if 'openconfig-system-ext:vrf' in cfg: - host_data['vrf'] = cfg['openconfig-system-ext:vrf'] - if 'timout' in cfg: - host_data['timout'] = cfg['timout'] + if 'auth-type' in cfg: + host_data['auth_type'] = cfg['auth-type'] + if 'priority' in cfg: + host_data['priority'] = cfg['priority'] + if 'vrf' in cfg: + host_data['vrf'] = cfg['vrf'] + if 'timeout' in cfg: + host_data['timeout'] = cfg['timeout'] if tacacs_host.get('tacacs', None) and tacacs_host['tacacs'].get('config', None): tacas_cfg = tacacs_host['tacacs']['config'] if tacas_cfg.get('port', None): diff --git a/plugins/module_utils/network/sonic/utils/bgp_utils.py b/plugins/module_utils/network/sonic/utils/bgp_utils.py index 768676c8a..5010255c6 100644 --- a/plugins/module_utils/network/sonic/utils/bgp_utils.py +++ b/plugins/module_utils/network/sonic/utils/bgp_utils.py @@ -75,9 +75,9 @@ def get_peergroups(module, vrf_name): pg = {} if 'config' in peer_group and 'peer-group-name' in peer_group['config']: pg.update({'name': peer_group['config']['peer-group-name']}) - if 'openconfig-bfd:enable-bfd' in peer_group and 'config' in peer_group['openconfig-bfd:enable-bfd']: - if 'enabled' in peer_group['openconfig-bfd:enable-bfd']['config']: - pg.update({'bfd': peer_group['openconfig-bfd:enable-bfd']['config']['enabled']}) + if 'enable-bfd' in peer_group and 'config' in peer_group['enable-bfd']: + if 'enabled' in peer_group['enable-bfd']['config']: + pg.update({'bfd': peer_group['enable-bfd']['config']['enabled']}) if 'timers' in peer_group and 'config' in peer_group['timers']: if 'minimum-advertisement-interval' in peer_group['timers']['config']: pg.update({'advertisement_interval': peer_group['timers']['config']['minimum-advertisement-interval']}) @@ -89,10 +89,10 @@ def get_peergroups(module, vrf_name): if 'keepalive-interval' in peer_group['timers']['config']: timers.update({'keepalive': peer_group['timers']['config']['keepalive-interval']}) capability = {} - if 'config' in peer_group and 'openconfig-bgp-ext:capability-dynamic' in peer_group['config']: - capability.update({'dynamic': peer_group['config']['openconfig-bgp-ext:capability-dynamic']}) - if 'config' in peer_group and 'openconfig-bgp-ext:capability-extended-nexthop' in peer_group['config']: - capability.update({'extended_nexthop': peer_group['config']['openconfig-bgp-ext:capability-extended-nexthop']}) + if 'config' in peer_group and 'capability-dynamic' in peer_group['config']: + capability.update({'dynamic': peer_group['config']['capability-dynamic']}) + if 'config' in peer_group and 'capability-extended-nexthop' in peer_group['config']: + capability.update({'extended_nexthop': peer_group['config']['capability-extended-nexthop']}) remote_as = {} if 'config' in peer_group and 'peer-as' in peer_group['config']: remote_as.update({'peer_as': peer_group['config']['peer-as']}) @@ -114,9 +114,9 @@ def get_peergroups(module, vrf_name): samp.update({'safi': safi}) if 'config' in each and 'enabled' in each['config']: samp.update({'activate': each['config']['enabled']}) - if 'openconfig-bgp-ext:allow-own-as' in each and 'config' in each['openconfig-bgp-ext:allow-own-as']: + if 'allow-own-as' in each and 'config' in each['allow-own-as']: allowas_in = {} - allowas_conf = each['openconfig-bgp-ext:allow-own-as']['config'] + allowas_conf = each['allow-own-as']['config'] if 'origin' in allowas_conf and allowas_conf['origin']: allowas_in.update({'origin': allowas_conf['origin']}) elif 'as-count' in allowas_conf and allowas_conf['as-count']: diff --git a/plugins/modules/sonic_bgp_as_paths.py b/plugins/modules/sonic_bgp_as_paths.py index 05f0ebf67..eec17536f 100644 --- a/plugins/modules/sonic_bgp_as_paths.py +++ b/plugins/modules/sonic_bgp_as_paths.py @@ -58,6 +58,11 @@ elements: str description: - Members of this BGP as-path; regular expression string can be provided. + permit: + required: False + type: bool + description: + - Permits or denies this as path. state: description: - The state of the configuration after module completion. diff --git a/plugins/modules/sonic_command.py b/plugins/modules/sonic_command.py index 080c9d499..65f691b5e 100644 --- a/plugins/modules/sonic_command.py +++ b/plugins/modules/sonic_command.py @@ -24,7 +24,7 @@ argument that causes the module to wait for a specific condition before returning or time out if the condition is not met. - This module does not support running commands in configuration mode. - To configure SONiC devices, use M(sonic_config). + To configure SONiC devices, use M(dellemc.enterprise_sonic.sonic_config). options: commands: description: diff --git a/plugins/modules/sonic_facts.py b/plugins/modules/sonic_facts.py index 4e1045c19..943a90d43 100644 --- a/plugins/modules/sonic_facts.py +++ b/plugins/modules/sonic_facts.py @@ -34,7 +34,7 @@ to a given subset. Possible values for this argument include all, min, hardware, config, legacy, and interfaces. Can specify a list of values to include a larger subset. Values can also be used - with an initial C(M(!)) to specify that a specific subset should + with an initial '!' to specify that a specific subset should not be collected. required: false type: list @@ -46,7 +46,7 @@ to a given subset. Possible values for this argument include all and the resources like 'all', 'interfaces', 'vlans', 'lag_interfaces', 'l2_interfaces', 'l3_interfaces'. Can specify a list of values to include a larger subset. Values - can also be used with an initial C(M(!)) to specify that a + can also be used with an initial '!' to specify that a specific subset should not be collected. required: false type: list @@ -81,7 +81,6 @@ dellemc.enterprise_sonic.sonic_facts: gather_subset: all gather_network_resources: all - - name: Collects VLAN and interfaces facts dellemc.enterprise_sonic.sonic_facts: gather_subset: @@ -89,23 +88,19 @@ gather_network_resources: - vlans - interfaces - - name: Do not collects VLAN and interfaces facts dellemc.enterprise_sonic.sonic_facts: gather_network_resources: - "!vlans" - "!interfaces" - - name: Collects VLAN and minimal default facts dellemc.enterprise_sonic.sonic_facts: gather_subset: min gather_network_resources: vlans - - name: Collect lag_interfaces and minimal default facts dellemc.enterprise_sonic.sonic_facts: gather_subset: min gather_network_resources: lag_interfaces - """ RETURN = """ @@ -119,7 +114,6 @@ def main(): """ Main entry point for module execution - :returns: ansible_facts """ module = AnsibleModule(argument_spec=FactsArgs.argument_spec, diff --git a/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml b/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml index a036211f2..f2e31e4a2 100644 --- a/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml +++ b/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml @@ -16,9 +16,11 @@ tests: - name: test members: - "11" + permit: True - name: test_1 members: - "101.101" + permit: False - name: test_case_02 description: Update created BGP properties state: merged @@ -29,17 +31,20 @@ tests: - "22" - "33" - 44 + permit: True - name: test_1 members: - "101.101" - "201.201" - "301.301" + permit: False - name: test_2 members: - '111\\:' - '11\\d+' - '113\\*' - '114\\' + permit: True - name: test_case_03 description: Delete BGP properties state: deleted @@ -52,19 +57,22 @@ tests: - "101.101" - "201.201" - "301.301" + permit: False - name: test_2 members: - '111\\:' - '11\\d+' - '113\\*' - '114\\' + permit: True - name: test_case_04 description: Delete BGP properties state: deleted input: - name: test - members: + members: + permit: - name: test_case_05 description: Delete BGP properties state: deleted - input: [] \ No newline at end of file + input: [] diff --git a/tests/regression/roles/sonic_radius_server/defaults/main.yml b/tests/regression/roles/sonic_radius_server/defaults/main.yml index 018ec6d26..6a79dc88d 100644 --- a/tests/regression/roles/sonic_radius_server/defaults/main.yml +++ b/tests/regression/roles/sonic_radius_server/defaults/main.yml @@ -14,7 +14,6 @@ tests: state: merged input: auth_type: chap - key: chap timeout: 12 nas_ip: 10.11.12.13 retransmit: 5 @@ -26,7 +25,6 @@ tests: priority: 3 vrf: mgmt timeout: 12 - key: chap port: 55 source_interface: "{{ interface1 }}" retransmit: 7 @@ -35,7 +33,6 @@ tests: priority: 4 vrf: mgmt timeout: 15 - key: pap port: 56 source_interface: "{{ interface2 }}" retransmit: 8 @@ -44,7 +41,6 @@ tests: priority: 6 vrf: mgmt timeout: 20 - key: mschapv2 port: 57 source_interface: "{{ interface3 }}" retransmit: 9 @@ -53,13 +49,11 @@ tests: state: merged input: auth_type: mschapv2 - key: login timeout: 24 servers: host: - name: my_host auth_type: mschapv2 - key: mschapv2 port: 45 timeout: 9 vrf: mgmt @@ -83,7 +77,6 @@ tests: state: merged input: auth_type: chap - key: chap timeout: 12 nas_ip: 10.11.12.13 retransmit: 5 @@ -95,7 +88,6 @@ tests: priority: 3 vrf: mgmt timeout: 12 - key: chap port: 55 source_interface: "{{ interface1 }}" retransmit: 7 @@ -104,7 +96,6 @@ tests: priority: 4 vrf: mgmt timeout: 15 - key: pap port: 56 source_interface: "{{ interface2 }}" retransmit: 8 @@ -113,7 +104,6 @@ tests: priority: 6 vrf: mgmt timeout: 20 - key: mschapv2 port: 57 source_interface: "{{ interface3 }}" retransmit: 9 diff --git a/tests/regression/roles/sonic_tacacs_server/defaults/main.yml b/tests/regression/roles/sonic_tacacs_server/defaults/main.yml index d98a11675..0f9b3e3c4 100644 --- a/tests/regression/roles/sonic_tacacs_server/defaults/main.yml +++ b/tests/regression/roles/sonic_tacacs_server/defaults/main.yml @@ -14,26 +14,22 @@ tests: state: merged input: auth_type: chap - key: chap source_interface: "{{ interface1 }}" timeout: 12 servers: host: - name: my_host auth_type: chap - key: chap port: 55 timeout: 12 priority: 3 - name: my_host1 auth_type: login - key: login port: 60 timeout: 14 priority: 4 - name: my_host2 auth_type: login - key: login port: 60 timeout: 14 priority: 4 @@ -42,14 +38,12 @@ tests: state: merged input: auth_type: login - key: login source_interface: "{{ interface2 }}" timeout: 24 servers: host: - name: my_host auth_type: mschap - key: mschap port: 45 timeout: 9 priority: 5 @@ -77,19 +71,16 @@ tests: host: - name: my_host auth_type: chap - key: chap port: 55 timeout: 12 priority: 3 - name: my_host1 auth_type: login - key: login port: 60 timeout: 14 priority: 4 - name: my_host2 auth_type: login - key: login port: 60 timeout: 14 priority: 4 diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/tests/sanity/ignore-2.13.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class