Exemple #1
0
    def doStart(self):
        ServerFactory.doStart(self)

        # Wait for AMQP to get ready
        self.log.info("Waiting for AMQP to get ready")
        yield self.pb['smppcm'].amqpBroker.channelReady

        # Load configuration profile
        proto = self.buildProtocol(('127.0.0.1', 0))
        tr = proto_helpers.StringTransport()
        proto.makeConnection(tr)

        if (self.config.authentication and self.loadConfigProfileWithCreds['username'] is not None
            and self.loadConfigProfileWithCreds['password'] is not None):
            self.log.info(
                "OnStart loading configuration default profile with username: '******'",
                self.loadConfigProfileWithCreds['username'])

            if (self.loadConfigProfileWithCreds['username'] != self.config.admin_username or
                        md5(self.loadConfigProfileWithCreds['password'].encode(
                            'ascii')).digest() != self.config.admin_password):
                self.log.error(
                    "Authentication error, cannot load configuration profile with provided username: '******'",
                    self.loadConfigProfileWithCreds['username'])
                proto.connectionLost(None)
                defer.returnValue(False)

            proto.dataReceived(('%s\r\n' % self.loadConfigProfileWithCreds['username']).encode())
            proto.dataReceived(('%s\r\n' % self.loadConfigProfileWithCreds['password']).encode())
        elif self.config.authentication:
            self.log.error(
                'Authentication is required and no credentials given, config. profile will not be loaded')
            proto.connectionLost(None)
            defer.returnValue(False)
        else:
            self.log.info(
                "OnStart loading configuration default profile without credentials (auth. is not required)")

        proto.dataReceived(b'load\r\n')

        # Wait some more time till all configurations are loaded
        pending_load = ['mtrouter', 'morouter', 'filter', 'group', 'smppcc', 'httpcc', 'user']
        while True:
            for _pl in pending_load:
                if re.match(r'.*%s configuration loaded.*' % _pl, tr.value(), re.DOTALL):
                    self.log.info("%s configuration loaded.", _pl)
                    pending_load.remove(_pl)

            if len(pending_load) > 0:
                waitDeferred = defer.Deferred()
                reactor.callLater(0.3, waitDeferred.callback, None)
                yield waitDeferred
            else:
                break

        proto.dataReceived(b'quit\r\n')
        proto.connectionLost(None)
        defer.returnValue(False)
Exemple #2
0
    def doStart(self):
        ServerFactory.doStart(self)

        # Wait for AMQP to get ready
        self.log.info("Waiting for AMQP to get ready")
        yield self.pb['smppcm'].amqpBroker.channelReady

        # Load configuration profile
        proto = self.buildProtocol(('127.0.0.1', 0))
        tr = proto_helpers.StringTransport()
        proto.makeConnection(tr)

        if (self.config.authentication and self.loadConfigProfileWithCreds['username'] is not None
                and self.loadConfigProfileWithCreds['password'] is not None):
            self.log.info(
                "OnStart loading configuration default profile with username: '******'",
                self.loadConfigProfileWithCreds['username'])

            if (self.loadConfigProfileWithCreds['username'] != self.config.admin_username or
                    md5(self.loadConfigProfileWithCreds['password']).digest() != self.config.admin_password):
                self.log.error(
                    "Authentication error, cannot load configuration profile with provided username: '******'",
                    self.loadConfigProfileWithCreds['username'])
                proto.connectionLost(None)
                defer.returnValue(False)

            proto.dataReceived('%s\r\n' % self.loadConfigProfileWithCreds['username'])
            proto.dataReceived('%s\r\n' % self.loadConfigProfileWithCreds['password'])
        elif self.config.authentication:
            self.log.error(
                'Authentication is required and no credentials given, config. profile will not be loaded')
            proto.connectionLost(None)
            defer.returnValue(False)
        else:
            self.log.info(
                "OnStart loading configuration default profile without credentials (auth. is not required)")

        proto.dataReceived('load\r\n')

        # Wait some more time till all configurations are loaded
        pending_load = ['mtrouter', 'morouter', 'filter', 'group', 'smppcc', 'httpcc', 'user']
        while True:
            for _pl in pending_load:
                if re.match(r'.*%s configuration loaded.*' % _pl, tr.value(), re.DOTALL):
                    self.log.info("%s configuration loaded.", _pl)
                    pending_load.remove(_pl)

            if len(pending_load) > 0:
                waitDeferred = defer.Deferred()
                reactor.callLater(0.3, waitDeferred.callback, None)
                yield waitDeferred
            else:
                break

        proto.dataReceived('quit\r\n')
        proto.connectionLost(None)
        defer.returnValue(False)
Exemple #3
0
	def doStart(self):
		debug( "Starting factory." )
		ServerFactory.doStart(self)
Exemple #4
0
 def doStart(self):
     self.wrappedFactory.doStart()
     ServerFactory.doStart(self)
 def doStart(self):
     self.wrappedFactory.doStart()
     ServerFactory.doStart(self)