Пример #1
0
    def __init__(self, args):
        self._components = []
        self.uistates = {}
        self.uistates_by_name = {}
        self._translator = Translator()
        log.init()

        parser = optparse.OptionParser()
        parser.add_option('-d', '--debug',
            action="store", type="string", dest="debug",
            help="set debug levels")
        parser.add_option('-u', '--usage',
            action="store_true", dest="usage",
            help="show a usage message")
        parser.add_option('-m', '--manager',
            action="store", type="string", dest="manager",
            help="the manager to connect to, e.g. localhost:7531")
        parser.add_option('', '--no-ssl',
            action="store_true", dest="no_ssl",
            help="disable encryption when connecting to the manager")
        parser.add_option('-s', '--stomp-port', action="store", type="string",
            dest="stomp")
        options, args = parser.parse_args(args)

        if options.debug:
            log.setFluDebug(options.debug)

        if options.usage:
            self.usage(args)

        if not options.manager or not options.stomp:
            self.usage(args)

        print "need to connect to stomp port %s" % (options.stomp,)
        self.options = options
        connection = connections.parsePBConnectionInfo(options.manager,
            use_ssl=not options.no_ssl)
        self.model = model = AdminModel()
        self.stomp_client = StompClient()
        reactor.connectTCP("localhost", int(self.options.stomp), self.stomp_client)
        self.model.connect('connected', self._connected)
        self.model.connect('disconnected', self._disconnected)
        self.model.connect('update', self._update)

        d = model.connectToManager(connection)

        def failed(failure):
            if failure.check(errors.ConnectionRefusedError):
                print "Manager refused connection. Check your user and password."
            elif failure.check(errors.ConnectionFailedError):
                message = "".join(failure.value.args)
                print "Connection to manager failed: %s" % message
            else:
                print ("Exception while connecting to manager: %s"
                       % log.getFailureMessage(failure))
            return failure

        d.addErrback(failed)
        d.addErrback(lambda x: reactor.stop())
Пример #2
0
    def __init__(self, args):
        self._components = []
        self.uistates = {}
        self.uistates_by_name = {}
        self._translator = Translator()
        log.init()

        parser = optparse.OptionParser()
        parser.add_option('-d', '--debug',
                          action="store", type="string", dest="debug",
                          help="set debug levels")
        parser.add_option('-u', '--usage',
                          action="store_true", dest="usage",
                          help="show a usage message")
        parser.add_option('-m', '--manager',
                          action="store", type="string", dest="manager",
                          help="the manager to connect to, e.g. localhost:7531")
        parser.add_option('', '--no-ssl',
                          action="store_true", dest="no_ssl",
                          help="disable encryption when connecting to the manager")
        parser.add_option('-s', '--stomp-port', action="store", type="string",
                          dest="stomp")
        options, args = parser.parse_args(args)

        if options.debug:
            log.setFluDebug(options.debug)

        if options.usage:
            self.usage(args)

        if not options.manager or not options.stomp:
            self.usage(args)
        
        print "need to connect to stomp port %s" % (options.stomp,)
        self.options = options
        connection = connections.parsePBConnectionInfo(options.manager,
                                                       not options.no_ssl)
        self.model = model = AdminModel()
        self.stomp_client = StompClient()
        reactor.connectTCP("localhost", int(self.options.stomp), self.stomp_client)
        self.model.connect('connected', self._connected)
        self.model.connect('disconnected', self._disconnected)
        self.model.connect('update', self._update)

        d = model.connectToManager(connection)

        def failed(failure):
            if failure.check(errors.ConnectionRefusedError):
                print "Manager refused connection. Check your user and password."
            elif failure.check(errors.ConnectionFailedError):
                message = "".join(failure.value.args)
                print "Connection to manager failed: %s" % message
            else:
                print ("Exception while connecting to manager: %s"
                       % log.getFailureMessage(failure))
            return failure

        d.addErrback(failed)
        d.addErrback(lambda x: reactor.stop())
Пример #3
0
    def connect(self, options):
        connection = connections.parsePBConnectionInfo(options.manager,
           use_ssl=options.transport == 'ssl')

        # platform-3/trunk compatibility stuff to guard against
        # gratuitous changes
        try:
            # platform-3
            self.medium = admin.AdminModel(connection.authenticator)
            self.debug("code is platform-3")
        except TypeError:
            # trunk
            self.medium = admin.AdminModel()
            self.debug("code is trunk")

        if hasattr(self.medium, 'connectToHost'):
            # platform-3
            d = self.medium.connectToHost(connection.host,
                connection.port, not connection.use_ssl)
        else:
            d = self.medium.connectToManager(connection)

        d.addCallback(self._connectedCb)
        d.addErrback(self._connectedEb)