Skip to content

Commit

Permalink
fin update
Browse files Browse the repository at this point in the history
  • Loading branch information
Girish5tri committed Oct 18, 2024
1 parent 8c3edd0 commit a44cb40
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 73 deletions.
15 changes: 0 additions & 15 deletions plugins/action/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@ 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"]

result = super(ActionModule, self).run(task_vars=task_vars)
if warnings:
if "warnings" in result:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ class Bgp_globalArgs(object): # pylint: disable=R0903
"type": "dict",
"options": {
"set": {"type": "bool"},
"number": {
"type": "int",
"deprecated_by": "asn",
"removed_at_date": "2027-01-01",
'number': {
'type': 'int',
'removed_at_date': '2027-01-31',
'removed_from_collection': 'cisco.ios',
},
"asn": {"type": "str"},
"dual_as": {"type": "bool"},
Expand Down
17 changes: 8 additions & 9 deletions plugins/module_utils/network/ios/config/bgp_global/bgp_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +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"]:
<<<<<<< Updated upstream
# self.want = self.handle_deprecates(self.want)
=======
>>>>>>> Stashed changes
self.generate_commands()
self.run_commands()
return self.result
Expand All @@ -164,8 +164,8 @@ def generate_commands(self):
"configuring new ASN".format(h_asn),
)

self.want = self.handle_deprecates(self.want)
self.have = self.handle_deprecates(self.have)
if self.want:
self.handle_deprecates(self.want)

for each in self.want, self.have:
self._bgp_global_list_to_dict(each)
Expand Down Expand Up @@ -197,8 +197,6 @@ 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):
Expand Down Expand Up @@ -362,10 +360,8 @@ 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 (
Expand Down Expand Up @@ -469,6 +465,7 @@ def handle_deprecates(self, want, is_nbr=False):
if "number" in want["local_as"]:
want["local_as"]["asn"] = str(want["local_as"].pop("number"))
return want
<<<<<<< Updated upstream

# def handle_deprecates(self, want, is_nbr=False):
# """
Expand All @@ -490,3 +487,5 @@ def handle_deprecates(self, want, is_nbr=False):
# want["local_as"]["asn"] = str(want["local_as"]["number"])
# del want["local_as"]["number"]
# return want
=======
>>>>>>> Stashed changes
2 changes: 1 addition & 1 deletion plugins/modules/ios_bgp_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@
type: bool
number:
description:
- DEPRECATED: This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead.
- "DEPRECATED: This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead."
- AS number used as local AS
- Please refer vendor documentation for valid values
type: int
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
config:
as_number: 65000
bgp:
asnotation: true
default:
ipv4_unicast: false
route_target:
Expand All @@ -27,6 +28,22 @@
remote_as: 100
shutdown:
set: false
- neighbor_address: 192.0.2.1
remote_as: "500.65083"
local_as:
asn: "501.65083"
no_prepend:
replace_as: true
set: true
set: true
- neighbor_address: 192.0.2.2
remote_as: 500
local_as:
number: 501
no_prepend:
replace_as: true
set: true
set: true
timers:
keepalive: 100
holdtime: 200
Expand Down
23 changes: 22 additions & 1 deletion tests/integration/targets/ios_bgp_global/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ merged:
- bgp log-neighbor-changes
- neighbor 198.0.2.1 remote-as 100
- neighbor 198.0.2.1 description merge neighbor

- bgp asnotation dot
- neighbor 192.0.2.1 remote-as 500.65083
- neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as
- neighbor 192.0.2.2 remote-as 500
- neighbor 192.0.2.2 local-as 501 no-prepend replace-as
after:
as_number: "65000"
bgp:
asnotation: true
default:
ipv4_unicast: false
route_target:
Expand All @@ -26,6 +31,22 @@ merged:
time: 50
log_neighbor_changes: true
neighbors:
- local_as:
no_prepend:
replace_as: true
set: true
asn: "501.65083"
set: true
neighbor_address: "192.0.2.1"
remote_as: "500.65083"
- local_as:
no_prepend:
replace_as: true
set: true
asn: "501"
set: true
neighbor_address: "192.0.2.2"
remote_as: "500"
- description: merge neighbor
neighbor_address: 198.0.2.1
remote_as: "100"
Expand Down
43 changes: 0 additions & 43 deletions tests/unit/modules/network/ios/test_ios_bgp_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,46 +919,3 @@ def test_ios_bgp_global_merged_asn(self):
]
result = self.execute_module(changed=True)
self.assertEqual(sorted(result["commands"]), sorted(commands))

def test_ios_bgp_global_merged_num(self):
set_module_args(
dict(
config=dict(
as_number="65000",
bgp=dict(
asnotation=True,
log_neighbor_changes=True,
graceful_shutdown=dict(
neighbors=dict(time=50),
local_preference=100,
community="100",
),
),
neighbors=[
dict(
neighbor_address="192.0.2.1",
remote_as="600.65083",
local_as=dict(
number="701",
no_prepend=dict(
replace_as=True,
set=True,
),
set=True,
),
),
],
),
state="merged",
),
)
commands = [
"router bgp 65000",
"bgp asnotation dot",
"bgp log-neighbor-changes",
"bgp graceful-shutdown all neighbors 50 local-preference 100 community 100",
"neighbor 192.0.2.1 remote-as 600.65083",
"neighbor 192.0.2.1 local-as 701 no-prepend replace-as",
]
result = self.execute_module(changed=True)
self.assertEqual(sorted(result["commands"]), sorted(commands))

0 comments on commit a44cb40

Please sign in to comment.