Exemplo n.º 1
0
 def __init__(self, sources):
     self.debug('started rrd monitor')
     self.multi = multi.MultiAdminModel()
     self.scheduler = scheduler.Scheduler()
     self.ensureRRDFiles(sources)
     self.connectToManagers(sources)
     self.startScheduler(sources)
Exemplo n.º 2
0
    def testConnectSuccess(self):
        def connected(_):
            self.assertEqual(len(self.vishnu.adminHeaven.avatars), 1)
            return m.removeManager(str(self.connectionInfo))

        m = multi.MultiAdminModel()
        d = m.addManager(self.connectionInfo, writeConnection=False)
        d.addCallback(connected)
        return d
Exemplo n.º 3
0
    def testConnectFailure(self):
        def connected(_):
            self.fail('should not have connected')

        def failure(f):
            # ok!
            self.assertEqual(len(self.vishnu.adminHeaven.avatars), 0)
            self.assertEqual(m.admins, {})
            self.assertEqual(m._reconnectHandlerIds, {})

        m = multi.MultiAdminModel()
        i = connection.PBConnectionInfo(
            self.connectionInfo.host, self.connectionInfo.port,
            self.connectionInfo.use_ssl,
            pb.Authenticator(username='******', password='******'))
        d = m.addManager(i, writeConnection=False)
        d.addCallbacks(connected, failure)
        return d
Exemplo n.º 4
0
    def testReconnect(self):

        class Listener:

            def __init__(self):
                self.disconnectDeferred = defer.Deferred()
                self.reconnectDeferred = defer.Deferred()

            def model_addPlanet(self, admin, planet):
                self.reconnectDeferred.callback(admin)
                self.reconnectDeferred = None

            def model_removePlanet(self, admin, planet):
                self.disconnectDeferred.callback(admin)
                self.disconnectDeferred = None
        Listener = Listener()

        def connected(_):
            self.assertEqual(len(self.vishnu.adminHeaven.avatars),
                             1)
            a = m.admins[str(self.connectionInfo)]

            m.addListener(Listener)

            a.clientFactory.disconnect()

            return Listener.disconnectDeferred

        def disconnected(_):
            return Listener.reconnectDeferred

        def reconnected(_):
            m.removeListener(Listener)
            return m.removeManager(str(self.connectionInfo))

        m = multi.MultiAdminModel()
        d = m.addManager(self.connectionInfo, writeConnection=False)
        d.addCallback(connected)
        d.addCallback(disconnected)
        d.addCallback(reconnected)
        return d
Exemplo n.º 5
0
 def testConstructor(self):
     model = multi.MultiAdminModel()