Commit 69dc78bc authored by David Johnson's avatar David Johnson

Fix Seg6Action to use only the 'encap' kwarg, a dict that pyroute2 accepts.

parent b7f3a243
Pipeline #3030 passed with stages
in 15 seconds
...@@ -166,30 +166,37 @@ class Seg6Action(RouteAction): ...@@ -166,30 +166,37 @@ class Seg6Action(RouteAction):
DB_KEYS = RouteAction.DB_KEYS DB_KEYS = RouteAction.DB_KEYS
NL_KEYS = RouteAction.NL_KEYS NL_KEYS = RouteAction.NL_KEYS
NL_KEYS.extend([ NL_KEYS.extend([
"mode","segments","keyid" "encap"
]) ])
OTHER_KEYS = [] OTHER_KEYS = []
def __init__(self,number=None,dst=None,dst_len=None,gateway=None,oif=None, def __init__(self,number=None,dst=None,dst_len=None,gateway=None,oif=None,
mode="inline",segments=None,keyid=None,family=socket.AF_INET): family=socket.AF_INET,encap={}):
if not mode in ["inline","encap","l2encap"]: if not encap:
raise Exception("invalid seg6 mode") encap = {}
if segments is None or len(segments) < 1: if 'mode' in encap \
raise Exception("no seg6 tunnel segments supplied") and not encap['mode'] in ["inline","encap","l2encap"]:
raise Exception("invalid seg6 encap[mode]")
else:
encap['mode'] = 'encap'
if not 'segs' in encap or encap['segs'] is None or len(encap['segs']) < 1:
raise Exception("no seg6 tunnel segs supplied")
if 'type' in encap and encap['type'] != 'seg6':
raise Exception("only encap[type] == seg6 supported")
if not 'type' in encap:
encap['type'] = 'seg6'
super(Seg6Action, self).__init__( super(Seg6Action, self).__init__(
number=number,dst=dst,dst_len=dst_len,gateway=gateway,oif=oif,family=family) number=number,dst=dst,dst_len=dst_len,gateway=gateway,oif=oif,family=family)
self.mode = mode self.encap = encap
self.segments = segments
self.keyid = keyid
@property @property
def type(self): def type(self):
return "seg6" return "seg6"
def __repr__(self): def __repr__(self):
return "Seg6Action(%s,%s/%s,%s,%s,%s,%s)" \ return "Seg6Action(%s,%s/%s,%s,%s)" \
% (str(self.number),str(self.dst),str(self.dst_len),str(self.oif), % (str(self.number),str(self.dst),str(self.dst_len),str(self.oif),
str(self.mode),str(self.segments),str(self.keyid)) str(self.encap))
class MultiAction(Action): class MultiAction(Action):
def __init__(self,number=None): def __init__(self,number=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment