Exemplo n.º 1
0
    def deployProbe(self, type_, name):
        """
		Instantiates and registers a new probe.
		Raises an exception in case of any error.
		"""
        self.getLogger().info("Deploying probe %s, type %s..." % (name, type_))
        if not ProbeImplementationManager.getProbeImplementationClasses(
        ).has_key(type_):
            raise Exception("No factory registered for probe type %s" % type_)

        if self.probes.has_key(name):
            raise Exception(
                "A probe with this name is already deployed on this agent")

        probeImplementation = ProbeImplementationManager.getProbeImplementationClasses(
        )[type_]()
        probe = ProbeImplementationAdapter(self, name, type_,
                                           probeImplementation)
        # We reference the probe as deployed, though the registration may fail...
        self.probes[name] = probe

        # We should raise exception in case of duplicated names, ...
        if self.registered:
            self.registerProbe(probe)
        else:
            self.getLogger().info(
                "Deferred probe registration: agent not registered yet.")
Exemplo n.º 2
0
def createProbe(uri, type_, transient=False):
    """
	Instantiates a new Test Adapter (i.e. a Probe instance) with its adapter
	from type_, uri.
	
	If the uri if of the form name@agent, we look for a remote type, prefixing the
	provided type with a "remote." to look for actually implemented type.
	If it does not, this is a local implementation, and we prefix the type with
	"local." (uri form: probe:name)
	
	@type  uri: string
	@param uri: a valid probe uri (probe:name or probe:name@agent)
	@type  type_: string
	@param type_: the test adapter implementation type.
	              Should not start with "remote." or "local.", as the
	              prefix is automatically added based on the uri format.

	@rtype: Probe
	@returns: a new probe instance, unconfigured, or None if no
	          implementation factory was found.
	"""
    # Derive the actual implementation identifier from the uri + given type
    u = Messages.Uri(uri)
    adapter = None
    if u.getUser():
        # The probe is remote.
        # We may look for additional stubs (interceptors) here
        adapter = RemoteProbeAdapter()
        # No need for a local implementation.
    else:
        # We're looking for a local probe only.
        # Search for an implementation in local plugin space
        if ProbeImplementationManager.getProbeImplementationClasses().has_key(
                type_):
            probeImplementation = ProbeImplementationManager.getProbeImplementationClasses(
            )[type_]()
            adapter = LocalProbeAdapter(probeImplementation)

    if adapter:
        # May raise an exception if the attachment is not feasible (Stubs and remote probes)
        adapter.attachToUri(uri, type_)
        adapter.setTransient(transient)
        return adapter
    # Otherwise, nothing to do.
    else:
        raise TestermanSAException(
            "No registered factory for test adapter/probe type %s" % type_)

    return None
Exemplo n.º 3
0
def createProbe(uri, type_, transient = False):
	"""
	Instantiates a new Test Adapter (i.e. a Probe instance) with its adapter
	from type_, uri.
	
	If the uri if of the form name@agent, we look for a remote type, prefixing the
	provided type with a "remote." to look for actually implemented type.
	If it does not, this is a local implementation, and we prefix the type with
	"local." (uri form: probe:name)
	
	@type  uri: string
	@param uri: a valid probe uri (probe:name or probe:name@agent)
	@type  type_: string
	@param type_: the test adapter implementation type.
	              Should not start with "remote." or "local.", as the
	              prefix is automatically added based on the uri format.

	@rtype: Probe
	@returns: a new probe instance, unconfigured, or None if no
	          implementation factory was found.
	"""
	# Derive the actual implementation identifier from the uri + given type
	u = Messages.Uri(uri)
	adapter = None
	if u.getUser():
		# The probe is remote. 
		# We may look for additional stubs (interceptors) here
		adapter = RemoteProbeAdapter()
		# No need for a local implementation.
	else:
		# We're looking for a local probe only.
		# Search for an implementation in local plugin space
		if ProbeImplementationManager.getProbeImplementationClasses().has_key(type_):
			probeImplementation = ProbeImplementationManager.getProbeImplementationClasses()[type_]()
			adapter = LocalProbeAdapter(probeImplementation)

	if adapter:
		# May raise an exception if the attachment is not feasible (Stubs and remote probes)
		adapter.attachToUri(uri, type_)
		adapter.setTransient(transient)
		return adapter
	# Otherwise, nothing to do.
	else:
		raise TestermanSAException("No registered factory for test adapter/probe type %s" % type_)
	
	return None
Exemplo n.º 4
0
	def deployProbe(self, type_, name):
		"""
		Instantiates and registers a new probe.
		Raises an exception in case of any error.
		"""
		self.getLogger().info("Deploying probe %s, type %s..." % (name, type_))
		if not ProbeImplementationManager.getProbeImplementationClasses().has_key(type_):
			raise Exception("No factory registered for probe type %s" % type_)
		
		if self.probes.has_key(name):
			raise Exception("A probe with this name is already deployed on this agent")

		probeImplementation = ProbeImplementationManager.getProbeImplementationClasses()[type_]()
		probe = ProbeImplementationAdapter(self, name, type_, probeImplementation)
		# We reference the probe as deployed, though the registration may fail...
		self.probes[name] = probe

		# We should raise exception in case of duplicated names, ...
		if self.registered:
			self.registerProbe(probe)
		else:
			self.getLogger().info("Deferred probe registration: agent not registered yet.")
Exemplo n.º 5
0
	def registerAgent(self):
		self.registered = False
		req = Messages.Request(method = "REGISTER", uri = self.getUri(), protocol = "Xa", version = "1.0")
		# we should add a list of supported probe types, os, etc ?
		req.setHeader("Agent-Supported-Probe-Types", ','.join(ProbeImplementationManager.getProbeImplementationClasses().keys()))
		response = self.request(req)
		if not response:
			raise Exception("Timeout")

		if response.getStatusCode() != 200:
			raise Exception("Unable to register: " + response.getReasonPhrase())

		self.registered = True
		self.getLogger().info("Agent %s registered" % self.getUri())