#NEWLINE# def set_vf_interface_vlan( pci_addr , mac_addr , vlan = 0 ) : #NEWLINE# #INDENT# pf_ifname = pci_utils . get_ifname_by_pci_address ( pci_addr , pf_interface = True ) #NEWLINE# vf_ifname = pci_utils . get_ifname_by_pci_address ( pci_addr ) #NEWLINE# vf_num = pci_utils . get_vf_num_by_pci_address ( pci_addr ) #NEWLINE# exit_code = [ 0 , 2 , 254 ] #NEWLINE# port_state = ( 'up' if ( vlan > 0 ) else 'down' ) #NEWLINE# utils . execute ( 'ip' , 'link' , 'set' , pf_ifname , 'vf' , vf_num , 'mac' , mac_addr , 'vlan' , vlan , run_as_root = True , check_exit_code = exit_code ) #NEWLINE# utils . execute ( 'ip' , 'link' , 'set' , vf_ifname , port_state , run_as_root = True , check_exit_code = exit_code )