@@ -4612,7 +4612,7 @@ def get_netkvm_param_value(vm, param, nic_index=0):
46124612
46134613
46144614def create_ovs_bridge (
4615- ovs_bridge_name , session = None , ignore_status = False , ip_options = ""
4615+ ovs_bridge_name , session = None , ignore_status = False , ip_options = "" , iface_name = None
46164616):
46174617 """
46184618 Create ovs bridge via tmux command on local or remote
@@ -4621,6 +4621,7 @@ def create_ovs_bridge(
46214621 :param session: The remote session
46224622 :param ignore_status: Whether to raise an exception when command fails
46234623 :param ip_options: ip command options
4624+ :param iface_name: if given use this interface instead of discovering
46244625 :return: The command status and output
46254626 """
46264627 runner = process .run
@@ -4632,7 +4633,13 @@ def create_ovs_bridge(
46324633 runner = local_runner
46334634 if session :
46344635 runner = session .cmd
4635- iface_name = get_net_if (runner = runner , state = "UP" , ip_options = ip_options )[0 ]
4636+ if not iface_name :
4637+ up_ifaces = get_net_if (runner = runner , state = "UP" , ip_options = ip_options )
4638+ if not up_ifaces :
4639+ raise exceptions .TestError (
4640+ "No network interfaces in UP state found for bridge creation"
4641+ )
4642+ iface_name = up_ifaces [0 ]
46364643 if not utils_package .package_install (["tmux" , "dhcp-client" ], session ):
46374644 raise exceptions .TestError ("Failed to install the required packages." )
46384645
@@ -4660,7 +4667,7 @@ def create_ovs_bridge(
46604667
46614668
46624669def delete_ovs_bridge (
4663- ovs_bridge_name , session = None , ignore_status = False , ip_options = ""
4670+ ovs_bridge_name , session = None , ignore_status = False , ip_options = "" , iface_name = None
46644671):
46654672 """
46664673 Delete ovs bridge via tmux command on local or remote
@@ -4669,6 +4676,7 @@ def delete_ovs_bridge(
46694676 :param session: The remote session
46704677 :param ignore_status: Whether to raise an exception when command fails
46714678 :param ip_options: ip command options
4679+ :param iface_name: if given use this interface instead of discovering
46724680 :return: The command status and output
46734681 """
46744682 runner = process .run
@@ -4680,7 +4688,13 @@ def delete_ovs_bridge(
46804688 runner = local_runner
46814689 if session :
46824690 runner = session .cmd
4683- iface_name = get_net_if (runner = runner , state = "UP" , ip_options = ip_options )[0 ]
4691+ if not iface_name :
4692+ up_ifaces = get_net_if (runner = runner , state = "UP" , ip_options = ip_options )
4693+ if not up_ifaces :
4694+ raise exceptions .TestError (
4695+ "No network interfaces in UP state found for bridge deletion"
4696+ )
4697+ iface_name = up_ifaces [0 ]
46844698 if not utils_package .package_install (["tmux" , "dhcp-client" ], session ):
46854699 raise exceptions .TestError ("Failed to install the required packages." )
46864700
0 commit comments