コード例 #1
0
ファイル: client.py プロジェクト: jfillatre/extensivetesting
	def resolveHost(self, host):
		"""
		Make a resolution of the host passed as argument
		
		@param host: host to resolv
		@type host: string
		
		@return: associated ip to the host
		@rtype: string
		"""
		dstIp = ''
		self.debug('dns resolve host...')
		if self.logEventSent: 
			layer_dns = self.encapsule( layer=templates.dns( more=templates.resolv(hostname=host) ) )
			self.logSentEvent( shortEvt = 'resolution', tplEvt = layer_dns )
				
		try:
			dstIp = socket.gethostbyname( host )
			self.debug('hostname %s resolv to %s' % (host, dstIp) )
			if self.logEventReceived: 
				layer_dns = self.encapsule( layer=templates.dns( more=templates.resolv_success(hostname=host, destinationIp=dstIp) ) )
				self.logRecvEvent( shortEvt = 'resolution success', tplEvt = layer_dns )

		except Exception as e:
			if self.logEventReceived: 
				layer_dns = self.encapsule( layer=templates.dns( more=templates.resolv_failed(hostname=host, error=str(e) ) ) )
				self.logRecvEvent( shortEvt = 'resolution failed', tplEvt = layer_dns )
		return dstIp
コード例 #2
0
ファイル: client.py プロジェクト: jfillatre/extensivetesting
	def isResolutionFailed(self, timeout=1.0):
		"""
		Waits to receive "resolution failed" event until the end of the timeout
		
		@param timeout: time max to wait to receive event in second (default=1s)
		@type timeout: float			
		
		@return: an event matching with the template or None otherwise
		@rtype: templatemessage
		"""
		TestAdapterLib.check_timeout(caller=TestAdapterLib.caller(), timeout=timeout)
		
		expected = templates.dns(more=templates.resolv_failed())
		evt = self.received( expected = expected, timeout = timeout )
		return evt
コード例 #3
0
ファイル: client.py プロジェクト: eagle842/extensivetesting
    def isResolutionFailed(self, timeout=1.0):
        """
		Waits to receive "resolution failed" event until the end of the timeout
		
		@param timeout: time max to wait to receive event in second (default=1s)
		@type timeout: float			
		
		@return: an event matching with the template or None otherwise
		@rtype: templatemessage
		"""
        if not (isinstance(timeout, int) or isinstance(timeout, float)):
            raise TestAdapterLib.ValueException(
                TestAdapterLib.caller(),
                "timeout argument is not a float or integer (%s)" %
                type(timeout))

        expected = templates.dns(more=templates.resolv_failed())
        evt = self.received(expected=expected, timeout=timeout)
        return evt