Example #1
0
    def shutdown(self, action):
        '''
        Shutdown the Container.

        Normally invoked via CORBA but can also "self terminate" so to speak.

        Parameters:
        - action is an encrypted value that tells the container what action to take

        oneway void shutdown (in unsigned long action)
        '''
        action = (action >> 8) & 0xFF

        if (action == ACTIVATOR_EXIT) or (action == ACTIVATOR_REBOOT) or (action == ACTIVATOR_RELOAD):

            self.logger.logTrace("Shutting down container: " + self.name)

            #Logout from manager
            ACSCorba.getManager().logout(self.token.h)

            if (action == ACTIVATOR_REBOOT) or (action == ACTIVATOR_RELOAD):
                print "Container.shutdown(): Action may not work correctly...-", str(action)
                self.__init__(self.name)
            else:
                #tell the main thread of execution to stop
                self.running = 0
                Log.stopPeriodicFlush()
        else:
            self.logger.logWarning("Unable to process 'shutdown' request at this time: " + str(action))
        
        # Close the alarm interface factory
        Acsalarmpy.AlarmSystemInterfaceFactory.done()
Example #2
0
 def test_ok(self, getorbmock, nilmock, corbalocmock):
     nilmock.return_value = False
     objmock = mock.Mock(spec=ACSCorba.CORBA.Object)
     orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
     orbmock.string_to_object.return_value = objmock
     getorbmock.return_value = orbmock
     self.assertEqual(False, ACSCorba.getManager() is None)
Example #3
0
 def test_ok(self, getorbmock, nilmock, corbalocmock):
     nilmock.return_value = False
     objmock = mock.Mock(spec=ACSCorba.CORBA.Object)
     orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
     orbmock.string_to_object.return_value = objmock
     getorbmock.return_value = orbmock
     self.assertEqual(False, ACSCorba.getManager() is None)
Example #4
0
    def test_orb_fault(self, getorbmock, corbalocmock):
        def raiser(*args):
            raise Exception("Boom!")

        orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
        orbmock.string_to_object.side_effect = raiser
        getorbmock.return_value = orbmock
        self.assertEqual(True, ACSCorba.getManager() is None)
Example #5
0
    def test_orb_fault(self, getorbmock, corbalocmock):
        def raiser(*args):
            raise Exception("Boom!")

        orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
        orbmock.string_to_object.side_effect = raiser
        getorbmock.return_value = orbmock
        self.assertEqual(True, ACSCorba.getManager() is None)
Example #6
0
    def test_obj_fault(self, getorbmock, nilmock, corbalocmock):
        def raiser(*args):
            raise Exception("Boom!")

        nilmock.return_value = False
        objmock = mock.Mock(spec=ACSCorba.CORBA.Object)
        objmock._non_existent.side_effect = raiser
        orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
        orbmock.string_to_object.return_value = objmock
        getorbmock.return_value = orbmock
        self.assertEqual(True, ACSCorba.getManager() is None)
Example #7
0
    def test_obj_fault(self, getorbmock, nilmock, corbalocmock):
        def raiser(*args):
            raise Exception("Boom!")

        nilmock.return_value = False
        objmock = mock.Mock(spec=ACSCorba.CORBA.Object)
        objmock._non_existent.side_effect = raiser
        orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
        orbmock.string_to_object.return_value = objmock
        getorbmock.return_value = orbmock
        self.assertEqual(True, ACSCorba.getManager() is None)
Example #8
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()
Example #9
0
 def test_orb_no_object(self, corbalocmock, getorbmock):
     orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
     orbmock.string_to_object.return_value = None
     getorbmock.return_value = orbmock
     self.assertEqual(True, ACSCorba.getManager() is None)
Example #10
0
 def test_manager_exists(self):
     ACSCorba.MGR_REF = 'foo'
     self.assertEqual('foo', ACSCorba.getManager())
Example #11
0
    def __init__ (self, name):
        '''
        Constructor.

        Initializes member variables and CORBA

        Parameters: name is the stringified name of this container.

        Raises: ???
        '''

        print maci.Container.ContainerStatusStartupBeginMsg
        #Member variables
        self.isReady = Event()
        self.running = 1  #As long as this is true, container is not shutdown
        self.name = name  #Container Name
        self.canRecover = True  #Whether this container is capable of recovery
        self.components = {}  #A dict where components are referenced by name
        self.compHandles = {}  #A dict where comp names are referenced by handles
        self.shutdownHandles = []
        self.containerPOA = None  #POA to activate this container
        self.componentPOA = None  #POA to create POAs for components
        self.compPolicies = []  #Policy[] for components
        self.offShootPolicies = []  #Policy[] for offshoots
        self.corbaRef = None  #reference to this object's CORBA reference
        self.logger = Log.getLogger(name) # Container's logger
        self.client_type = maci.CONTAINER_TYPE
        self.cdbContainerInfo = {}
        self.autoLoadPackages = []
        #dictionary which maps package names to the number of active components
        #using said package
        self.compModuleCount = {}
        
        # Initialize the alarm factory
        Acsalarmpy.AlarmSystemInterfaceFactory.init(ACSCorba.getManager())
        # The alarm source
        self.alarmSource = None
        
        # The interface to receive notification from the LogThrottle 
        # for sending alarms
        self.clta=ContainerLogThrottleAlarmer(self)

        #Configure CORBA
        print maci.Container.ContainerStatusORBInitBeginMsg
        self.configCORBA()
        print maci.Container.ContainerStatusORBInitEndMsg

        #call superclass constructor
        print maci.Container.ContainerStatusMgrInitBeginMsg
        BaseClient.__init__(self, self.name)
        print maci.Container.ContainerStatusMgrInitEndMsg

        self.logger.logTrace('CORBA configured for Container: ' + self.name)

        self.cdbAccess = CDBaccess()

        self.logger.logTrace('Starting Container: ' + self.name)

        #get info from the CDB
        self.getCDBInfo()
        self.refresh_logging_config()
        self.configureComponentLogger(name)

        #Run everything
        self.logger.logInfo('Container ' + self.name + ' waiting for requests')
        self.isReady.set()
        print maci.Container.ContainerStatusStartupEndMsg
        sys.stdout.flush()
Example #12
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()
Example #13
0
 def test_orb_no_object(self, corbalocmock, getorbmock):
     orbmock = mock.Mock(spec=ACSCorba.CORBA.ORB)
     orbmock.string_to_object.return_value = None
     getorbmock.return_value = orbmock
     self.assertEqual(True, ACSCorba.getManager() is None)
Example #14
0
 def test_manager_exists(self):
     ACSCorba.MGR_REF = 'foo'
     self.assertEqual('foo', ACSCorba.getManager())
Example #15
0
 def test_manager_exists(self):
     ACSCorba.MGR_REF = "foo"
     self.assertEqual("foo", ACSCorba.getManager())