Exemple #1
0
    def connect(self, options):
        # code from main.py in this directory

        def _connectedCb(model):
            self.model = model
            self.debug('Connected to manager.')
            planet = model.planet
            components = planet.get('atmosphere').get('components')
            for c in components:
                ctype = c.get('type')
                # check if this component is a bouncer
                if 'bouncer' in ctype:
                    if c.get('name') == self.options.bouncer:
                        self.check_bouncer(c, ctype)

        def _connectedEb(failure):
            reactor.stop()
            if failure.check(errors.ConnectionFailedError):
                return self.unknown('Unable to connect to manager.')
            if failure.check(errors.ConnectionRefusedError):
                return self.critical('Manager refused connection.')

        connection = connections.parsePBConnectionInfoRecent(options.manager,
                                                 options.transport == 'ssl')

        # platform-3/trunk compatibility stuff
        try:
            # platform-3
            self.adminModel = admin.AdminModel(connection.authenticator)
            self.debug('code is platform-3')
            d = self.adminModel.connectToHost(connection.host, \
                connection.port, not connection.use_ssl)
        except TypeError:
            # trunk
            self.adminModel = admin.AdminModel()
            self.debug('code is trunk')
            d = self.adminModel.connectToManager(connection)
        except:
            self.debug('error connecting with manager')

        d.addCallback(_connectedCb)
        d.addErrback(_connectedEb)
Exemple #2
0
    def connect(self, options):
        # code from main.py in this directory

        def _connectedCb(model):
            self.model = model
            self.debug('Connected to manager.')
            planet = model.planet
            components = planet.get('atmosphere').get('components')
            for c in components:
                ctype = c.get('type')
                # check if this component is a bouncer
                if 'bouncer' in ctype:
                    if c.get('name') == self.options.bouncer:
                        self.check_bouncer(c, ctype)

        def _connectedEb(failure):
            reactor.stop()
            if failure.check(errors.ConnectionFailedError):
                return self.unknown('Unable to connect to manager.')
            if failure.check(errors.ConnectionRefusedError):
                return self.critical('Manager refused connection.')

        connection = connections.parsePBConnectionInfoRecent(
            options.manager, options.transport == 'ssl')

        # platform-3/trunk compatibility stuff
        try:
            # platform-3
            self.adminModel = admin.AdminModel(connection.authenticator)
            self.debug('code is platform-3')
            d = self.adminModel.connectToHost(connection.host, \
                connection.port, not connection.use_ssl)
        except TypeError:
            # trunk
            self.adminModel = admin.AdminModel()
            self.debug('code is trunk')
            d = self.adminModel.connectToManager(connection)
        except:
            self.debug('error connecting with manager')

        d.addCallback(_connectedCb)
        d.addErrback(_connectedEb)
Exemple #3
0
    def connect(self, options):
        connection = connections.parsePBConnectionInfoRecent(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)
Exemple #4
0
    def connect(self, options):
        connection = connections.parsePBConnectionInfoRecent(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)
Exemple #5
0
def _connectToManager(win, manager, ssl):
    try:
        info = parsePBConnectionInfoRecent(manager, use_ssl=ssl)
    except OptionError, e:
        raise SystemExit("ERROR: %s" % (e, ))
Exemple #6
0
def _connectToManager(win, manager, ssl):
    try:
        info = parsePBConnectionInfoRecent(manager, use_ssl=ssl)
    except OptionError, e:
        raise SystemExit("ERROR: %s" % (e, ))