Skip to content

Commit 84df42c

Browse files
fix: Improve VRF handling to make simpler
1 parent 6d8fb9a commit 84df42c

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

panos/network.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ def set_logical_router(
547547
update (bool): Apply the changes to the device (Default: False)
548548
running_config: If refresh is True, refresh from the running
549549
configuration (Default: False)
550+
vrf_name (str): Sets the vrf inside the LR. (Default: 'default')
550551
return_type (str): Specify what this function returns, can be
551552
either 'object' (the default) or 'bool'. If this is 'object',
552553
then the return value is the LogicalRouter in question. If
@@ -570,10 +571,12 @@ def set_logical_router(
570571
# If the LR isn't found, create it instead
571572
lr = LogicalRouter(name=lr_name)
572573
parent.add(lr)
573-
vrf = Vrf(name=vrf_name)
574-
lr.vrf = [vrf]
575574
lr.create()
576575

576+
# Create or locate the VRF
577+
vrf = Vrf(name=vrf_name)
578+
vrf.refreshall(lr)
579+
577580
# Pass all the vrfs to the update method
578581
return self._update_reference_in_objects(
579582
lr,

tests/live/test_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ def test_10_set_lr_for_interface(self, fw, state_map):
17551755
"""Test setting the LR for an interface instead of the other way around"""
17561756
state = self.sanity(fw, state_map)
17571757
eth: Interface = state.eth_obj_2
1758-
eth.set_logical_router(state.obj_2, update=True)
1758+
eth.set_logical_router(state.obj_2.name, update=True)
17591759

17601760
def update_state_obj(self, fw, state):
17611761
state.obj.ad_static = random.randint(10, 240)

0 commit comments

Comments
 (0)