Пример #1
0
    def configCORBA(self): # pragma: NO COVER
        '''
        configCORBA is a helper method responsible for initializing the ORB,
        POAs, etc.

        Parameters: None

        Return: None

        Raises: ???
        '''

        #Create the Container's POA
        try:
            cont_policies = []  #CORBA.PolicyList
            cont_policies.append(ACSCorba.getPOARoot().create_id_assignment_policy(PortableServer.USER_ID))
            cont_policies.append(ACSCorba.getPOARoot().create_lifespan_policy(PortableServer.PERSISTENT))
            cont_policies.append(ACSCorba.getPOARoot().create_request_processing_policy(PortableServer.USE_ACTIVE_OBJECT_MAP_ONLY))
            cont_policies.append(ACSCorba.getPOARoot().create_servant_retention_policy(PortableServer.RETAIN))
            self.containerPOA = ACSCorba.getPOARoot().create_POA("ContainerPOA", ACSCorba.getPOAManager(), cont_policies)
            for policy in cont_policies:
                policy.destroy()
        except Exception, e:
            self.logger.logWarning("Unable to create the container's POA - " + str(e))
            print_exc()
            raise CouldntCreateObjectExImpl()
Пример #2
0
    def test_init_fault(self, getrootmock):
        def raiser(*args):
            raise Exception("Boom!")

        rootmock = mock.Mock(spec=omniORB.PortableServer.POA)
        rootmock._get_the_POAManager.side_effect = raiser
        getrootmock.return_value = rootmock
        self.assertEqual(True, ACSCorba.getPOAManager() is None)
Пример #3
0
    def test_init_fault(self, getrootmock):
        def raiser(*args):
            raise Exception("Boom!")

        rootmock = mock.Mock(spec=omniORB.PortableServer.POA)
        rootmock._get_the_POAManager.side_effect = raiser
        getrootmock.return_value = rootmock
        self.assertEqual(True, ACSCorba.getPOAManager() is None)
Пример #4
0
    def createPOAForComponent(self, comp_name): # pragma: NO COVER
        '''
        Creates a new POA that is responsible for exactly one component and
        the new POA is created as a child of the ComponentPOA.

        Parameters: comp_name is the components stringified name.

        Return: a new POA.

        Raises: ???
        '''
        return self.componentPOA.create_POA("ComponentPOA" + comp_name, ACSCorba.getPOAManager(), self.compPolicies)
Пример #5
0
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#
# @(#) $Id: acspyTestAcsCORBA.py,v 1.1.1.1 2012/03/07 17:41:01 acaproni Exp $
###############################################################################
'''
Tests CORBA access.
'''
from Acspy.Util import ACSCorba
###############################################################################
if __name__ == '__main__':
    print 'Manager corbaloc: %s' % ACSCorba.getManagerCorbaloc()
    print 'ORB: %s' % ACSCorba.getORB()
    print 'POA ROOT: %s' % ACSCorba.getPOARoot()
    print 'POA Manager: %s' % ACSCorba.getPOAManager()
    print 'Manager: %s' % ACSCorba.getManager()
    print 'Client: %s' % ACSCorba.getClient()
    print 'Log: %s' % ACSCorba.log()
    print 'LogFactory: %s' % ACSCorba.logFactory()
    print 'NotifyEventChannelFactory: %s' % ACSCorba.notifyEventChannelFactory()
    print 'ArchivingChannel: %s' % ACSCorba.archivingChannel()
    print 'LoggingChannel: %s' % ACSCorba.loggingChannel()
    print 'InterfaceRepository: %s' % ACSCorba.interfaceRepository()
    print 'CDB: %s' % ACSCorba.cdb()
    print 'ACSLogSvc: %s' % ACSCorba.acsLogSvc()
    print 'NameService: %s' % ACSCorba.nameService()
Пример #6
0
 def test_ok(self, getrootmock):
     rootmock = mock.Mock(spec=omniORB.PortableServer.POA)
     getrootmock.return_value = rootmock
     self.assertEqual(False, ACSCorba.getPOAManager() is None)
Пример #7
0
 def test_manager_exists(self):
     ACSCorba.POA_MANAGER = 'foo'
     self.assertEqual('foo', ACSCorba.getPOAManager())
Пример #8
0
    def activate_component(self, h, exeid, name, exe, idl_type):
        '''
        Activates a component (or returns a reference to it if already exists).

        Parameters:
        - h is the handle the component will be given
        - name is simply the components name
        - exe is the name of the Python module that has to be imported for the
        components implementation
        - idl_type is the the IR Location for the component

        Raises: CannotActivateComponentExImpl exception when invalid

        Returns: a ComponentInfo structure for manager to use.

        activate_component(in Handle h,in string name,in string exe,in string idl_type)
        '''
        #Block requests while container is initializing
        self.isReady.wait()

        #Check to see if this Component already exists
        comp = self.getExistingComponent(name)
        if comp != None:
            return comp[COMPONENTINFO]

        #Create a dictionary record for this component
        self.components[name] = None
        temp = {}
        try:
            temp[HANDLE] = h  #Handle of the component that is being activated
            temp[NAME] = name  #Name-redundant but possibly useful
            temp[EXEID] = exeid  #Execution ID number for the component being activated.
            temp[EXE] = exe  #Python module containing servant implementation
            temp[TYPE] = idl_type  #The type of the component to instantiate
            temp[POA] = self.createPOAForComponent(name)  #POA for this component
            temp[POAOFFSHOOT] = temp[POA].create_POA("OffShootPOA", ACSCorba.getPOAManager(), self.offShootPolicies)
            temp[PYCLASS] = None  #Class object used for this component
            temp[PYREF] = None  #Reference to the python object
            temp[CORBAREF] = None  #Reference to the CORBA object
            temp[COMPONENTINFO] = None  #An IDL struct given to manager
            temp[PYCLASS] = temp[TYPE].split(':')[1].split('/').pop() #get class name

            start = time()
            temp[COMPMODULE] = __import__(temp[EXE], globals(), locals(), [temp[PYCLASS]]) #get module
            interval = time() - start

            log = LOG_CompAct_Loading_OK()
            log.setTimeMillis(int(interval*1000))
            log.setCompName(name)
            log.log()

            try:
                temp[PYCLASS] = temp[EXE].split('.').pop() #get class name
                temp[PYCLASS] = temp[COMPMODULE].__dict__.get(temp[PYCLASS]) #get class
                temp[PYREF] = instance(temp[PYCLASS]) #create Python object
            except Exception, e:
                temp[PYCLASS] = temp[COMPMODULE].__dict__.get(temp[PYCLASS]) #get class
                temp[PYREF] = instance(temp[PYCLASS]) #create Python object

        except (TypeError, ImportError), e:
            e2 = CannotActivateComponentExImpl(exception=e)
            if isinstance(e,TypeError):
                e2.setDetailedReason("Verify that the name of implementation class matches the module name *%s*" % temp[EXE].split('.').pop())
            else:
                e2.setDetailedReason("Verify that CDB Code entry and Python install path match for module *%s*" % temp[EXE])

            self.failedActivation(temp)
            e2.log(self.logger)
            raise e2
Пример #9
0
            cont_policies.append(ACSCorba.getPOARoot().create_servant_retention_policy(PortableServer.RETAIN))
            self.containerPOA = ACSCorba.getPOARoot().create_POA("ContainerPOA", ACSCorba.getPOAManager(), cont_policies)
            for policy in cont_policies:
                policy.destroy()
        except Exception, e:
            self.logger.logWarning("Unable to create the container's POA - " + str(e))
            print_exc()
            raise CouldntCreateObjectExImpl()

        #Create the Components POA
        try:
            self.compPolicies.append(ACSCorba.getPOARoot().create_id_assignment_policy(PortableServer.USER_ID))
            self.compPolicies.append(ACSCorba.getPOARoot().create_lifespan_policy(PortableServer.PERSISTENT))
            self.compPolicies.append(ACSCorba.getPOARoot().create_request_processing_policy(PortableServer.USE_SERVANT_MANAGER))
            self.compPolicies.append(ACSCorba.getPOARoot().create_servant_retention_policy(PortableServer.RETAIN))
            self.componentPOA = ACSCorba.getPOARoot().create_POA("ComponentPOA", ACSCorba.getPOAManager(), self.compPolicies)
        except Exception, e:
            self.logger.logWarning("Unable to create the components' POA - " + str(e))
            print_exc()
            raise CouldntCreateObjectExImpl()

        #Create the Offshoot Policies
        try:
            self.offShootPolicies.append(ACSCorba.getPOARoot().create_id_assignment_policy(PortableServer.SYSTEM_ID))
            self.offShootPolicies.append(ACSCorba.getPOARoot().create_lifespan_policy(PortableServer.TRANSIENT))
            self.offShootPolicies.append(ACSCorba.getPOARoot().create_request_processing_policy(PortableServer.USE_ACTIVE_OBJECT_MAP_ONLY))
            self.offShootPolicies.append(ACSCorba.getPOARoot().create_servant_retention_policy(PortableServer.RETAIN))
        except Exception, e:
            self.logger.logWarning("Unable to create the OffShoots' POA - " + str(e))
            print_exc()
            raise CouldntCreateObjectExImpl()
Пример #10
0
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#
# @(#) $Id: acspyTestAcsCORBA.py,v 1.1.1.1 2012/03/07 17:40:45 acaproni Exp $
###############################################################################
'''
Tests CORBA access.
'''
from Acspy.Util import ACSCorba
###############################################################################
if __name__ == '__main__':
    print 'Manager corbaloc: %s' % ACSCorba.getManagerCorbaloc()
    print 'ORB: %s' % ACSCorba.getORB()
    print 'POA ROOT: %s' % ACSCorba.getPOARoot()
    print 'POA Manager: %s' % ACSCorba.getPOAManager()
    print 'Manager: %s' % ACSCorba.getManager()
    print 'Client: %s' % ACSCorba.getClient()
    print 'Log: %s' % ACSCorba.log()
    print 'LogFactory: %s' % ACSCorba.logFactory()
    print 'NotifyEventChannelFactory: %s' % ACSCorba.notifyEventChannelFactory(
    )
    print 'ArchivingChannel: %s' % ACSCorba.archivingChannel()
    print 'LoggingChannel: %s' % ACSCorba.loggingChannel()
    print 'InterfaceRepository: %s' % ACSCorba.interfaceRepository()
    print 'CDB: %s' % ACSCorba.cdb()
    print 'ACSLogSvc: %s' % ACSCorba.acsLogSvc()
    print 'NameService: %s' % ACSCorba.nameService()
Пример #11
0
 def test_ok(self, getrootmock):
     rootmock = mock.Mock(spec=omniORB.PortableServer.POA)
     getrootmock.return_value = rootmock
     self.assertEqual(False, ACSCorba.getPOAManager() is None)
Пример #12
0
 def test_manager_exists(self):
     ACSCorba.POA_MANAGER = 'foo'
     self.assertEqual('foo', ACSCorba.getPOAManager())
Пример #13
0
 def test_manager_exists(self):
     ACSCorba.POA_MANAGER = "foo"
     self.assertEqual("foo", ACSCorba.getPOAManager())