diff --git a/plugins/action/ios.py b/plugins/action/ios.py index 24a1a6582..d9dffe6a3 100644 --- a/plugins/action/ios.py +++ b/plugins/action/ios.py @@ -47,20 +47,20 @@ def run(self, tmp=None, task_vars=None): % self._play_context.connection, } - # Handle deprecated 'number' parameter - if "config" in self._task.args and self._task.args["config"] is not None: - config = self._task.args["config"] - if "neighbors" in config: - for neighbor in config["neighbors"]: - if "local_as" in neighbor: - if "number" in neighbor["local_as"]: - display.deprecated( - msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", - date="2027-01-01", - collection_name="cisco.ios", - ) - neighbor["local_as"]["asn"] = str(neighbor["local_as"]["number"]) - del neighbor["local_as"]["number"] + # # Handle deprecated 'number' parameter + # if "config" in self._task.args and self._task.args["config"] is not None: + # config = self._task.args["config"] + # if "neighbors" in config: + # for neighbor in config["neighbors"]: + # if "local_as" in neighbor: + # if "number" in neighbor["local_as"]: + # display.deprecated( + # msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", + # date="2027-01-01", + # collection_name="cisco.ios", + # ) + # neighbor["local_as"]["asn"] = str(neighbor["local_as"]["number"]) + # del neighbor["local_as"]["number"] result = super(ActionModule, self).run(task_vars=task_vars) if warnings: diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index abf63d3ff..e611ca412 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -140,7 +140,11 @@ def execute_module(self): :rtype: A dictionary :returns: The result from module execution """ + if self.want: + self.want = self.handle_deprecates(self.want) + if self.state not in ["parsed", "gathered"]: + #self.want = self.handle_deprecates(self.want) self.generate_commands() self.run_commands() return self.result @@ -160,8 +164,8 @@ def generate_commands(self): "configuring new ASN".format(h_asn), ) - if self.want: - self.handle_deprecates(self.want) + self.want = self.handle_deprecates(self.want) + self.have = self.handle_deprecates(self.have) for each in self.want, self.have: self._bgp_global_list_to_dict(each) @@ -193,6 +197,8 @@ def _compare(self, want, have): the `want` and `have` data with the `parsers` defined for the Bgp_global network resource. """ + want = self.handle_deprecates(want) + self.generic_list_parsers = ["distributes", "aggregate_addresses", "networks"] if self._has_bgp_inject_maps(want): @@ -356,8 +362,10 @@ def _compare_neighbor_lists(self, want, have): ] for name, w_neighbor in want.items(): + w_neighbor = self.handle_deprecates(w_neighbor, is_nbr=True) handle_shutdown_default = False have_nbr = have.pop(name, {}) + have_nbr = self.handle_deprecates(have_nbr, is_nbr=True) want_route = w_neighbor.pop("route_maps", {}) have_route = have_nbr.pop("route_maps", {}) if ( @@ -459,5 +467,27 @@ def handle_deprecates(self, want, is_nbr=False): else: if "local_as" in want: if "number" in want["local_as"]: - want["local_as"]["asn"] = want["local_as"].pop("number") + want["local_as"]["asn"] = str(want["local_as"].pop("number")) return want + + + # def handle_deprecates(self, want, is_nbr=False): + # """ + # Handles deprecated values post rewrite + # neighbor.route_map [dict] - neighbor.route_maps [list:dict] + + # Args: + # want (_type_): Handle want attributes for deprecated values + # is_nbr (bool, optional): activates neighbor part on recursion. Defaults to False. + # """ + # if not is_nbr: + # if want.get("neighbors"): + # _want_nbrs = want.get("neighbors", {}) + # for nbr in _want_nbrs: + # nbr = self.handle_deprecates(nbr, is_nbr=True) + # else: + # if "local_as" in want: + # if "number" in want["local_as"]: + # want["local_as"]["asn"] = str(want["local_as"]["number"]) + # del want["local_as"]["number"] + # return want