示例#1
0
def create_session(host, port, user, pwd):
    print "Trying to connect to %s:%s as %s ..." % (host, port, user)
    session = None
    try:
        session = DocbaseClient(
            host=host, port=int(port),
            username=user, password=pwd)
    except socket.error, e:
        if e.errno == 54:
            session = DocbaseClient(
                host=host, port=int(port),
                username=user, password=pwd,
                secure=True, ciphers=CIPHERS)
        else:
            raise e
示例#2
0
 def checkLogin(self):
     try:
         session = DocbaseClient(host=self.host,
                                 port=self.port,
                                 docbaseid=self.docbaseid)
     except Exception, e:
         message = "Unable to connect to docbase: %s" % str(e)
         self.addResult(Critical, message)
         return
示例#3
0
def checkRegistration(docbroker, docbasename, servername=None, checkall=True):
    docbasemap = docbroker.getDocbaseMap()
    if not docbasename in docbasemap['r_docbase_name']:
        raise CheckError("docbase %s is not registered on %s" % (docbasename, parseAddr(docbasemap['i_host_addr'])))
    servermap = docbroker.getServerMap(docbasename)
    if servername is not None and not servername in servermap['r_server_name']:
        raise CheckError(
            "%s.%s is not registered on %s" % (docbasename, servername, parseAddr(servermap['i_host_addr'])))
    elif servername is None and not checkall:
        return "docbase %s is registered on %s" % (docbasename, parseAddr(docbasemap['i_host_addr']))
    message = ""
    success = True
    for (srv, status, docbaseid, connaddr) in zip(servermap['r_server_name'], servermap['r_last_status'],
                                                  servermap['i_docbase_id'],
                                                  servermap['i_server_connection_address']):
        if servername is not None and not srv == servername:
            continue
        if status != "Open":
            message += "%s.%s has status %s on %s, " % (
                docbasename, srv, status, parseAddr(servermap['i_host_addr']))
            success = False
        else:
            chunks = connaddr.split(" ")
            host = chunks[4]
            port = int(chunks[2], 16)
            session = None
            try:
                session = DocbaseClient(host=host, port=port, docbaseid=docbaseid)
                message += "%s.%s has status %s on %s, " % (
                    docbasename, srv, status, parseAddr(servermap['i_host_addr']))
            except Exception, e:
                message += "%s.%s has status %s on %s, but error occurred during connection %s, " % (
                    docbasename, srv, status, parseAddr(servermap['i_host_addr']), str(e))
                success = False
                if session is not None:
                    try:
                        session.disconnect()
                    except Exception, e:
                        pass
示例#4
0
        if status != "Open":
            message = "%s.%s has status %s on %s:%d, " % \
                      (docbaseame, servername, status,
                       docbrokerhost, docbrokerport)
            self.add_result(Critical, message)
            return

        chunks = connaddr.split(" ")
        host = chunks[5]
        port = int(chunks[2], 16)

        session = None
        try:
            session = DocbaseClient(
                host=host, port=port + [0, 1][self.args.secure],
                docbaseid=docbaseid, secure=self.args.secure,
                ciphers=CIPHERS)
        except Exception, e:
            message = "%s.%s has status %s on %s:%d, " \
                      "but error occurred whilst connecting to %s" % \
                      (docbaseame, servername, status,
                       docbrokerhost, docbrokerport, str(e))
            self.add_result(Critical, message)
            return
        if session:
            message = "%s.%s has status %s on %s:%d" % \
                      (docbaseame, servername, status,
                       docbrokerhost, docbrokerport)
            self.add_result(Ok, message)
            try:
                session.disconnect()
示例#5
0
        docbaseid = servermap['i_docbase_id'][index]
        connaddr = servermap['i_server_connection_address'][index]

        if status != "Open":
            message = "%s.%s has status %s on %s:%d, " % (
                docbaseame, servername, status, docbrokerhost, docbrokerport)
            self.addResult(Critical, message)
            return

        chunks = connaddr.split(" ")
        host = chunks[5]
        port = int(chunks[2], 16)

        session = None
        try:
            session = DocbaseClient(host=host, port=port, docbaseid=docbaseid)
            message = "%s.%s has status %s on %s:%d" % (
                docbaseame, servername, status, docbrokerhost, docbrokerport)
            self.addResult(Ok, message)
        except Exception, e:
            message = "%s.%s has status %s on %s:%d, but error occurred during connection to %s" % (
                docbaseame, servername, status, docbrokerhost, docbrokerport,
                str(e))
            self.addResult(Critical, message)
            return
        if session is not None:
            try:
                session.disconnect()
            except Exception, e:
                pass
示例#6
0
def checkProjectionTargets(host, port, docbaseid, username, password):
    return checkProjectionTargets(
        DocbaseClient(host=host, port=port, docbaseid=docbaseid, username=username, password=password))