This repository was archived by the owner on Apr 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed
pyof/v0x04/controller2switch Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 7
7
from pyof .foundation .exceptions import PackException , ValidationError
8
8
from pyof .v0x04 .common .action import ListOfActions
9
9
from pyof .v0x04 .common .header import Header , Type
10
- from pyof .v0x04 .common .port import Port , PortNo
10
+ from pyof .v0x04 .common .port import PortNo
11
11
12
12
__all__ = ('PacketOut' ,)
13
13
@@ -122,17 +122,8 @@ def _update_actions_len(self):
122
122
self .actions_len = ListOfActions (self .actions ).get_size ()
123
123
124
124
def _validate_in_port (self ):
125
- port = self .in_port
126
-
127
- if isinstance (port , PortNo ):
128
- valid = port in _VIRT_IN_PORTS
129
- elif isinstance (port , int ):
130
- # Must use "else" because PortNo is an IntEnum and (int instance)
131
- valid = port >= 1 and port < PortNo .OFPP_MAX .value
132
- elif isinstance (port , Port ):
133
- valid = port .is_valid ()
134
- else : # unknown value
135
- valid = False
136
-
137
- if not valid :
138
- raise ValidationError ('{} is not a valid input port.' .format (port ))
125
+ is_valid_range = self .in_port > 0 and self .in_port <= PortNo .OFPP_MAX
126
+ is_valid_virtual_in_ports = self .in_port in _VIRT_IN_PORTS
127
+
128
+ if (is_valid_range or is_valid_virtual_in_ports ) is False :
129
+ raise ValidationError (f'{ self .in_port } is not a valid input port.' )
You can’t perform that action at this time.
0 commit comments