Skip to content

feat(network.StaticRoute): conditions and none value nexthop_type #578

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions panos/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,11 +1834,18 @@ def _setup(self):
VersionedParamPath(
"nexthop_type",
default="ip-address",
values=["discard", "ip-address", "next-vr"],
values=["discard", "ip-address", "next-vr", "none"],
path="nexthop/{nexthop_type}",
condition={"nexthop_type": ["discard", "ip-address", "next-vr"]},
)
)
params.append(
VersionedParamPath(
"nexthop",
path="nexthop/{nexthop_type}",
condition={"nexthop_type": ["ip-address", "next-vr"]},
)
)
params.append(VersionedParamPath("nexthop", path="nexthop/{nexthop_type}"))
params.append(VersionedParamPath("interface", path="interface"))
params.append(
VersionedParamPath("admin_dist", vartype="int", path="admin-dist")
Expand Down
50 changes: 50 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,56 @@ def test_element_str_from_virtualrouter_with_sr_parent(self):

self.assertEqual(expected, ret_val)

# VirtualRouter with nexthop_type=None StaticRoute child
def test_element_str_from_virtualrouter_with_sr_none(self):
"""StaticRoute > VirtualRouter"""
expected = b"".join(
[
b'<entry name="default"><interface><member>ethernet1/3</member>',
b"</interface><routing-table><ip><static-route>",
b'<entry name="my none route"><destination>3.3.3.3/32',
b"</destination>",
b"<interface>ethernet1/4</interface><metric>10</metric>",
b"</entry></static-route></ip></routing-table></entry>",
]
)

vro = panos.network.VirtualRouter("default", "ethernet1/3")
sro = panos.network.StaticRoute(
"my none route", "3.3.3.3/32", None, None, "ethernet1/4"
)

vro.add(sro)

ret_val = vro.element_str()

self.assertEqual(expected, ret_val)

# VirtualRouter with nexthop_type 'none' StaticRoute child
def test_element_str_from_virtualrouter_with_sr_none_str(self):
"""StaticRoute > VirtualRouter"""
expected = b"".join(
[
b'<entry name="default"><interface><member>ethernet1/3</member>',
b"</interface><routing-table><ip><static-route>",
b'<entry name="my none route"><destination>3.3.3.3/32',
b"</destination>",
b"<interface>ethernet1/4</interface><metric>10</metric>",
b"</entry></static-route></ip></routing-table></entry>",
]
)

vro = panos.network.VirtualRouter("default", "ethernet1/3")
sro = panos.network.StaticRoute(
"my none route", "3.3.3.3/32", "none", None, "ethernet1/4"
)

vro.add(sro)

ret_val = vro.element_str()

self.assertEqual(expected, ret_val)

# 3) EthernetInterface
def test_element_str_from_ethernetinterface(self):
expected = b"".join(
Expand Down
Loading