コード例 #1
0
 def _list_network_adapters(self):
     self.logger.info('Health : Listing scheduled jobs')
     net = self.wmi.Win32_NetworkAdapter()
     for n in net:
         netcard = utils.decode_output_cmd(n.Caption)
         IPv4 = ''
         IPv6 = ''
         DHCP_server = ''
         DNS_server = ''
         adapter_type = ''
         nbtstat_value = ''
         if n.AdapterTypeID:
             adapter_type = NETWORK_ADAPTATER[int(n.AdapterTypeID)]
         netconnectionstatus = n.NetConnectionStatus
         mac_address = n.MACAddress
         description = n.Description
         physical_adapter = ''
         product_name = ''
         database_path = ''
         speed = ''
         if n.Speed:
             speed = n.Speed
         if netconnectionstatus:
             nic = self.wmi.Win32_NetworkAdapterConfiguration(
                 MACAddress=mac_address)
             for nc in nic:
                 if nc:
                     if nc.DatabasePath:
                         database_path = nc.DatabasePath
                         database_path = database_path.replace('\n', '')
                     if nc.IPAddress:
                         IPv4 = nc.IPAddress[0]
                         if len(nc.IPaddress) > 1:
                             IPv6 = nc.IPAddress[1]
                         nbtstat = 'nbtstat -A ' + IPv4
                         p = subprocess.Popen(nbtstat,
                                              shell=True,
                                              stdout=subprocess.PIPE)
                         output, errors = p.communicate()
                         output = utils.decode_output_cmd(output)
                         nbtstat_value = output.split('\r\n')
                         nbtstat_value = ''.join(
                             [n.replace('\n', '') for n in nbtstat_value])
                     if nc.DNSServerSearchOrder:
                         DNS_server = nc.DNSServerSearchOrder[0]
                         if nc.DHCPEnabled:
                             DHCP_server = nc.DHCPServer
         yield netcard, adapter_type, description, mac_address, product_name, physical_adapter, product_name, speed, IPv4, IPv6, DHCP_server, DNS_server, database_path, nbtstat_value
コード例 #2
0
	def _list_network_adapters(self):
		self.logger.info('Health : Listing scheduled jobs')
		net=self.wmi.Win32_NetworkAdapter()
		for n in net:
			netcard=utils.decode_output_cmd(n.Caption)
			IPv4=''
			IPv6=''
			DHCP_server=''
			DNS_server=''
			adapter_type=''
			nbtstat_value=''
			if n.AdapterTypeID:
				adapter_type=NETWORK_ADAPTATER[int(n.AdapterTypeID)]
			netconnectionstatus=n.NetConnectionStatus
			mac_address=n.MACAddress
			description=n.Description
			physical_adapter=''
			product_name=''
			database_path=''
			speed=''
			if n.Speed:
				speed=n.Speed
			if netconnectionstatus:
				nic=self.wmi.Win32_NetworkAdapterConfiguration(MACAddress=mac_address)
				for nc in nic:
					if nc:
						if nc.DatabasePath:
							database_path=nc.DatabasePath
							database_path=database_path.replace('\n','')
						if nc.IPAddress:						
							IPv4=nc.IPAddress[0]
							if len(nc.IPaddress)>1: 
								IPv6=nc.IPAddress[1]
							nbtstat='nbtstat -A '+ IPv4
							p=subprocess.Popen(nbtstat, shell=True, stdout=subprocess.PIPE)
							output, errors = p.communicate()
							output=utils.decode_output_cmd(output)
							nbtstat_value=output.split('\r\n')
							nbtstat_value=''.join([n.replace('\n','') for n in nbtstat_value])
						if nc.DNSServerSearchOrder:
							DNS_server=nc.DNSServerSearchOrder[0]
							if nc.DHCPEnabled:
								DHCP_server=nc.DHCPServer	
			yield netcard,adapter_type,description,mac_address,product_name,physical_adapter,product_name,speed,IPv4,IPv6,DHCP_server,DNS_server,database_path,nbtstat_value