99from xcpngutils import configure_logging , error_wrapped , run_command , raise_plugin_error
1010
1111OPENFLOW_PROTOCOL = "OpenFlow11"
12+ OVS_OFCTL_CMD = "ovs-ofctl"
1213VALID_PROTOCOLS = {"tcp" , "udp" , "icmp" , "ip" , "arp" }
1314PROTOCOLS_WITH_PORTS = {"tcp" , "udp" }
1415
@@ -139,7 +140,6 @@ def parse_priority(args):
139140 except ValueError :
140141 return None , "'{}' is not a valid priority" .format (priority )
141142
142- return priority , None
143143
144144class Parser :
145145 def __init__ (self , args ):
@@ -253,7 +253,7 @@ def add_rule(_session, args):
253253 if rule_args ["protocol" ] in PROTOCOLS_WITH_PORTS and not rule_args ["port" ]:
254254 log_and_raise_error (E_PARAMS , "add_rule: No port provided, tcp and udp requires one" )
255255
256- ofctl_cmd = ["ovs-ofctl" , "-O" , OPENFLOW_PROTOCOL , "add-flow" , rule_args ["bridge" ]]
256+ ofctl_cmd = [OVS_OFCTL_CMD , "-O" , OPENFLOW_PROTOCOL , "add-flow" , rule_args ["bridge" ]]
257257
258258 # We can now build the open flow rule
259259 rules = build_rules_string (rule_args )
@@ -294,7 +294,7 @@ def del_rule(_session, args):
294294 if rule_args ["protocol" ] in PROTOCOLS_WITH_PORTS and not rule_args ["port" ]:
295295 log_and_raise_error (E_PARAMS , "del_rule: No port provided, tcp and udp requires one" )
296296
297- ofctl_cmd = ["ovs-ofctl" , "-O" , OPENFLOW_PROTOCOL , "del-flows" , rule_args ["bridge" ]]
297+ ofctl_cmd = [OVS_OFCTL_CMD , "-O" , OPENFLOW_PROTOCOL , "del-flows" , rule_args ["bridge" ]]
298298
299299 # We can now build the open flow rule
300300 rules = build_rules_string (rule_args )
@@ -316,7 +316,7 @@ def dump_flows(_session, args):
316316 if err :
317317 log_and_raise_error (E_PARSER , "dump flows: {}" .format (err ))
318318
319- ofctl_cmd = ["ovs-ofctl" , "-O" , OPENFLOW_PROTOCOL , "dump-flows" , bridge ]
319+ ofctl_cmd = [OVS_OFCTL_CMD , "-O" , OPENFLOW_PROTOCOL , "dump-flows" , bridge ]
320320 cmd = run_command (ofctl_cmd , check = False )
321321 if cmd ['returncode' ]:
322322 log_and_raise_error (E_OVSCALL , "Error dumping flows: %s: %s" % (format (ofctl_cmd ), cmd ['stderr' ]))
0 commit comments