Merge "Refactor check_configure_sriov to prevent dublicate adding sriov_pfs" into stable/zed
This commit is contained in:
		@@ -124,10 +124,14 @@ def parse_opts(argv):
 | 
			
		||||
 | 
			
		||||
def check_configure_sriov(obj):
 | 
			
		||||
    configure_sriov = False
 | 
			
		||||
    if isinstance(obj, objects.SriovPF):
 | 
			
		||||
        configure_sriov = True
 | 
			
		||||
    elif hasattr(obj, 'members') and obj.members is not None:
 | 
			
		||||
        for member in obj.members:
 | 
			
		||||
            if isinstance(member, objects.SriovPF):
 | 
			
		||||
                configure_sriov = True
 | 
			
		||||
        elif hasattr(member, "members") and member.members is not None:
 | 
			
		||||
                break
 | 
			
		||||
            else:
 | 
			
		||||
                configure_sriov = check_configure_sriov(member)
 | 
			
		||||
    return configure_sriov
 | 
			
		||||
 | 
			
		||||
@@ -282,14 +286,11 @@ def main(argv=sys.argv, main_logger=None):
 | 
			
		||||
            obj = objects.object_from_json(iface_json)
 | 
			
		||||
        except utils.SriovVfNotFoundException:
 | 
			
		||||
            continue
 | 
			
		||||
        if isinstance(obj, objects.SriovPF):
 | 
			
		||||
            configure_sriov = True
 | 
			
		||||
            provider.add_object(obj)
 | 
			
		||||
        elif hasattr(obj, 'members') and obj.members is not None:
 | 
			
		||||
        if check_configure_sriov(obj):
 | 
			
		||||
            configure_sriov = True
 | 
			
		||||
            provider.add_object(obj)
 | 
			
		||||
 | 
			
		||||
            # Look for the presence of SriovPF as members of LinuxBond and that
 | 
			
		||||
            # LinuxBond is member of OvsBridge
 | 
			
		||||
            sriovpf_member_of_bond_ovs_port_list.extend(
 | 
			
		||||
                get_sriovpf_member_of_bond_ovs_port(obj))
 | 
			
		||||
 | 
			
		||||
@@ -323,7 +324,8 @@ def main(argv=sys.argv, main_logger=None):
 | 
			
		||||
                restart_openvswitch=restart_ovs)
 | 
			
		||||
 | 
			
		||||
    for iface_json in iface_array:
 | 
			
		||||
        # All objects other than the sriov_pf will be added here.
 | 
			
		||||
        # All sriov_pfs at top level or at any member level will be
 | 
			
		||||
        # ignored and all other objects are parsed will be added here.
 | 
			
		||||
        # The VFs are expected to be available now and an exception
 | 
			
		||||
        # SriovVfNotFoundException shall be raised if not available.
 | 
			
		||||
        try:
 | 
			
		||||
@@ -331,7 +333,7 @@ def main(argv=sys.argv, main_logger=None):
 | 
			
		||||
        except utils.SriovVfNotFoundException:
 | 
			
		||||
            if not opts.noop:
 | 
			
		||||
                raise
 | 
			
		||||
        if not isinstance(obj, objects.SriovPF):
 | 
			
		||||
        if not check_configure_sriov(obj):
 | 
			
		||||
            provider.add_object(obj)
 | 
			
		||||
 | 
			
		||||
    if configure_sriov and not opts.noop:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user