Skip to content

Commit ea40f9e

Browse files
committed
Add platform check
1 parent 17266ca commit ea40f9e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

capirca/lib/fortigate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,11 @@ class Term(aclgenerator.Term):
479479
_NGFW_MODE = 'profile-based'
480480
CURRENT_ID = 0
481481

482-
def __init__(self, term, object_container, verbose=True):
482+
def __init__(self, term, object_container, platform, verbose=True):
483483
super().__init__(term)
484484
self._term = term
485485
self._obj_container = object_container
486+
self.platform = platform
486487
self._term.verbose = verbose
487488

488489
self.id_ = type(self).CURRENT_ID
@@ -678,7 +679,7 @@ def __str__(self):
678679
if self._term.comment and self._term.verbose:
679680
lines += [f'{_SP * 2} set comments "{self._obj_container.fix_comment_length((" ").join(self._term.comment))}"']
680681
# fortigate local-in policy exception
681-
if self._term.destination_interface and not self._term.source_interface:
682+
if self.platform == "fortigatelocalin":
682683
lines += [f"{_SP * 2} set intf {self._term.destination_interface or 'any'}"]
683684
else:
684685
lines += [f"{_SP * 2} set srcintf {self._term.source_interface or 'any'}"]
@@ -854,7 +855,7 @@ def _TranslatePolicy(self, pol, exp_info):
854855
raise FortiGateDuplicateTermError(f"You have a duplicate term: {term.name}")
855856
term_dup_check.add(term.name)
856857

857-
new_term = Term(term, self._obj_container, verbose)
858+
new_term = Term(term, self._obj_container, self._PLATFORM, verbose)
858859

859860
self.fortigate_policies += [(header, term.name, new_term)]
860861

capirca/lib/fortigatelocalin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def __str__(self):
8989

9090
return '\n'.join(target)
9191

92+
class Term(fortigate.Term):
93+
_PLATFORM = 'fortigatelocalin'
94+
9295
class Error(Exception):
9396
pass
9497

0 commit comments

Comments
 (0)