<s> from sos . plugins import Plugin , RedHatPlugin , UbuntuPlugin , DebianPlugin <EOL> import os <EOL> import re <EOL> class Networking ( Plugin ) : <EOL> """<STR_LIT>""" <EOL> plugin_name = "<STR_LIT>" <EOL> profiles = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> trace_host = "<STR_LIT>" <EOL> option_list = [ ( "<STR_LIT>" , "<STR_LIT>" % trace_host , <EOL> "<STR_LIT>" , False ) ] <EOL> def get_bridge_name ( self , brctl_file ) : <EOL> """<STR_LIT>""" <EOL> out = [ ] <EOL> try : <EOL> brctl_out = open ( brctl_file ) . read ( ) <EOL> except : <EOL> return out <EOL> for line in brctl_out . splitlines ( ) : <EOL> if line . startswith ( "<STR_LIT>" ) or line . isspace ( ) or line [ : <NUM_LIT:1> ] . isspace ( ) : <EOL> continue <EOL> br_name , br_rest = line . split ( None , <NUM_LIT:1> ) <EOL> out . append ( br_name ) <EOL> return out <EOL> def get_eth_interfaces ( self , ip_link_out ) : <EOL> """<STR_LIT>""" <EOL> out = { } <EOL> for line in ip_link_out . splitlines ( ) : <EOL> match = re . match ( '<STR_LIT>' , line ) <EOL> if match : <EOL> iface = match . string . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] . lstrip ( ) <EOL> out [ iface ] = True <EOL> return out <EOL> def collect_iptable ( self , tablename ) : <EOL> """<STR_LIT>""" <EOL> if self . check_ext_prog ( "<STR_LIT>" % tablename ) : <EOL> cmd = "<STR_LIT>" + tablename + "<STR_LIT>" <EOL> self . add_cmd_output ( cmd ) <EOL> def setup ( self ) : <EOL> super ( Networking , self ) . setup ( ) <EOL> self . add_copy_spec ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> self . add_forbidden_path ( "<STR_LIT>" ) <EOL> self . add_forbidden_path ( "<STR_LIT>" ) <EOL> self . add_forbidden_path ( "<STR_LIT>" ) <EOL> self . add_cmd_output ( "<STR_LIT>" , root_symlink = "<STR_LIT>" ) <EOL> self . collect_iptable ( "<STR_LIT>" ) <EOL> self . collect_iptable ( "<STR_LIT>" ) <EOL> self . collect_iptable ( "<STR_LIT>" ) <EOL> self . add_cmd_output ( "<STR_LIT>" , root_symlink = "<STR_LIT>" ) <EOL> self . add_cmd_output ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> ip_link_result = self . call_ext_prog ( "<STR_LIT>" ) <EOL> if ip_link_result [ '<STR_LIT:status>' ] == <NUM_LIT:0> : <EOL> for eth in self . get_eth_interfaces ( ip_link_result [ '<STR_LIT>' ] ) : <EOL> self . add_cmd_output ( [ <EOL> "<STR_LIT>" + eth , <EOL> "<STR_LIT>" + eth , <EOL> "<STR_LIT>" + eth , <EOL> "<STR_LIT>" + eth , <EOL> "<STR_LIT>" + eth , <EOL> "<STR_LIT>" + eth , <EOL> "<STR_LIT>" + eth <EOL> ] ) <EOL> brctl_file = self . get_cmd_output_now ( "<STR_LIT>" ) <EOL> if brctl_file : <EOL> for br_name in self . get_bridge_name ( brctl_file ) : <EOL> self . add_cmd_output ( [ <EOL> "<STR_LIT>" + br_name , <EOL> "<STR_LIT>" + br_name <EOL> ] ) <EOL> nmcli_con_show_result = self . call_ext_prog ( <EOL> "<STR_LIT>" ) <EOL> if nmcli_con_show_result : <EOL> for con in nmcli_con_show_result [ '<STR_LIT>' ] . splitlines ( ) : <EOL> self . add_cmd_output ( "<STR_LIT>" % con ) <EOL> nmcli_dev_status_result = self . call_ext_prog ( <EOL> "<STR_LIT>" ) <EOL> if nmcli_dev_status_result : <EOL> for dev in nmcli_dev_status_result [ '<STR_LIT>' ] . splitlines ( ) : <EOL> self . add_cmd_output ( "<STR_LIT>" + dev ) <EOL> if self . get_option ( "<STR_LIT>" ) : <EOL> self . add_cmd_output ( "<STR_LIT>" % self . trace_host ) <EOL> return <EOL> def postproc ( self ) : <EOL> for root , dirs , files in os . walk ( <EOL> "<STR_LIT>" ) : <EOL> for net_conf in files : <EOL> self . do_file_sub ( <EOL> "<STR_LIT>" + net_conf , <EOL> r"<STR_LIT>" , r"<STR_LIT>" ) <EOL> class RedHatNetworking ( Networking , RedHatPlugin ) : <EOL> trace_host = "<STR_LIT>" <EOL> def setup ( self ) : <EOL> super ( RedHatNetworking , self ) . setup ( ) <EOL> class UbuntuNetworking ( Networking , UbuntuPlugin , DebianPlugin ) : <EOL> trace_host = "<STR_LIT>" <EOL> def setup ( self ) : <EOL> super ( UbuntuNetworking , self ) . setup ( ) <EOL> self . add_copy_spec ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> self . add_cmd_output ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> if self . get_option ( "<STR_LIT>" ) : <EOL> self . add_cmd_output ( "<STR_LIT>" % self . trace_host ) </s>
