Example #1
0
 def nsc_findNS(self, ident=None):
    """
    Locating the Name Server by using given nsHost and nsPort
    """
    locator = NameServerLocator(identification=ident)
    try:
       if self.nsHost:
          self._log('connecting to Name Server (%s:%s)' % (self.nsHost,
                                                           self.nsPort))
          self.NS = locator.getNS(self.nsHost, self.nsPort, trace=1, bcaddr=self.bcAddr)
       else:
          self._log('broadcasting to find Name Server')
          self.NS = locator.getNS(None, None, trace = 1, bcaddr=self.bcAddr) 
          self.nsHost = self.NS.URI.address
          self.nsPort = self.NS.URI.port
       self.NS._setIdentification(ident)
       self._log('Name Server found, URI = %s' % self.NS.URI)
       self._setNSData()
    except ConnectionDeniedError, e:
       if str(e).find( Pyro.constants.deniedReasons[Pyro.constants.DENIED_SECURITY] ) != -1:
          msg = 'Authentication required:'
          dlg = wx.TextEntryDialog(self, msg, 'Authentication',
                                  style=wx.OK|wx.CANCEL|wx.TE_PASSWORD)
          dlg.CentreOnParent()
          if dlg.ShowModal() == wx.ID_OK:
             ident = dlg.GetValue()
             self.nsc_findNS(ident)
          else:
             self.NS = None
             self._log('Connection to Name Server denied!','error')
       else:
          self.NS = None
          self._logError('Unable to connect to Name Server')
Example #2
0
 def nsc_findNS(self, ident=None):
    """
    Locating the Name Server by using given nsHost and nsPort
    """
    locator = NameServerLocator(identification=ident)
    try:
       if self.nsHost:
          self._log('connecting to Name Server (%s:%s)' % (self.nsHost,
                                                           self.nsPort))
          self.NS = locator.getNS(self.nsHost, self.nsPort, trace=1, bcaddr=self.bcAddr)
       else:
          self._log('broadcasting to find Name Server')
          self.NS = locator.getNS(None, None, trace = 1, bcaddr=self.bcAddr) 
          self.nsHost = self.NS.URI.address
          self.nsPort = self.NS.URI.port
       self.NS._setIdentification(ident)
       self._log('Name Server found, URI = %s' % self.NS.URI)
       self._setNSData()
    except ConnectionDeniedError, e:
       if str(e).find( Pyro.constants.deniedReasons[Pyro.constants.DENIED_SECURITY] ) != -1:
          msg = 'Authentication required:'
          dlg = wx.TextEntryDialog(self, msg, 'Authentication',
                                  style=wx.OK|wx.CANCEL|wx.TE_PASSWORD)
          dlg.CentreOnParent()
          if dlg.ShowModal() == wx.ID_OK:
             ident = dlg.GetValue()
             self.nsc_findNS(ident)
          else:
             self.NS = None
             self._log('Connection to Name Server denied!','error')
       else:
          self.NS = None
          self._logError('Unable to connect to Name Server')
Example #3
0
 def configure(self):
     pyro_obj = ObjBase()
     pyro_obj.delegateTo(self.service_obj)
     (self.pd, pd) = (Daemon(), Daemon())
     ns = NameServerLocator().getNS()
     pd.useNameServer(ns)
     pyro_id = 'REMOTESVC' + to_str(self.service_id)
     try:
         ns.unregister(pyro_id)
     except NamingError:
         pass
     pd.connect(pyro_obj, pyro_id)
     self.service_obj.set_external_ref(pd.getProxyForObj(pyro_obj))
Example #4
0
File: nsc.py Project: aacevedor/dbs
	def connect(self, sysCmd=None):
		host = self.Args.getOpt('h',None)
		bcaddr = self.Args.getOpt('c',None)
		port = int(self.Args.getOpt('p', 0))
		ident = self.Args.getOpt('i',None)
		if port==0:
			port=None

		locator = NameServerLocator(identification=ident)
		if not sysCmd:
			self.NS = locator.getNS(host,port,1,bcaddr=bcaddr)
			print 'NS is at',self.NS.URI.address,'('+(getHostname(self.NS.URI.address) or '??')+') port',self.NS.URI.port
			self.NS._setIdentification(ident)
		else:
			result = locator.sendSysCommand(sysCmd,host,port,1,bcaddr=bcaddr)
			print 'Result from system command',sysCmd,':',result
Example #5
0
 def configure(self):
     pyro_obj = ObjBase()
     pyro_obj.delegateTo(self.service_obj)
     #Start the Pyro Daemon and register the ProcessInst object
     self.pd = pd = Daemon()
     ns = NameServerLocator().getNS()
     pd.useNameServer(ns)
     pyro_id = "REMOTESVC" + to_str(self.service_id)
     #Remove any existing reference to this id
     try:
         ns.unregister(pyro_id)
     except NamingError:
         #the name is not found, which is fine
         pass
     pd.connect(pyro_obj, pyro_id)
     #set the pyro self reference
     self.service_obj.set_external_ref(pd.getProxyForObj(pyro_obj))
Example #6
0
 def __init__(self):
     self.processes = []
     #check if pyro name server is runnign
     try:
         NameServerLocator().getNS()
     except NamingError:
         raise ServiceException("Pyro name server is not found. \
                                Please run pyro-ns")
     initClient()
Example #7
0
 def configure(self):
     #Start the Pyro Daemon and register the ProcessInst object
     self.pd = pd = Daemon()
     ns = NameServerLocator().getNS()
     pd.useNameServer(ns)
     logger.debug("Local Pyro started")
Example #8
0
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import time
from convirt.core.utils.utils import to_unicode, to_str
import logging

logger = logging.getLogger("convirt.services")

enable_processes = True
try:
    from processing import Process
    from Pyro.core import ObjBase, Daemon, getProxyForURI, initClient
    from Pyro.naming import NameServerLocator
    from Pyro.errors import NamingError
    try:
        NameServerLocator().getNS()
    except NamingError:
        enable_processes = False
except ImportError:
    enable_processes = False


#######################
## Executor Interface
#######################
class Executor:
    """ This interface defines what an executor is supposed to do. The executor
    is responsible for maintaining a running instance of a service. Various
    methods of execution such as thread or processes are supported.

    The reason why executor and service interfaces are separate is because