Beispiel #1
0
def AddConnections(grph,listConnections,configNam,nodeManager):
	for objConnect in listConnections:
		namConnect = objConnect["name"]

		DEBUG("namConnect=%s",namConnect)

		nodeConnect = survol_rabbitmq_connection.MakeUri(configNam,namConnect)

		try:
			grph.add( ( nodeConnect, lib_common.MakeProp("Protocol"), lib_common.NodeLiteral(objConnect["protocol"]) ) )
		except KeyError:
			pass

		try:
			grph.add( ( nodeConnect, lib_common.MakeProp("Node"), lib_common.NodeLiteral(objConnect["node"]) ) )
		except KeyError:
			pass

		nodeUser = survol_rabbitmq_user.MakeUri(configNam,objConnect["user"])
		try:
			grph.add( ( nodeConnect, lib_common.MakeProp("User"), nodeUser ) )
		except KeyError:
			pass

		# '127.0.0.1:51532 -> 127.0.0.1:5672'
		# http://localhost:12345/#/connections/127.0.0.1%3A51532%20-%3E%20127.0.0.1%3A5672
		namConnectCgi = namConnect.replace(">",">")
		DEBUG("namConnectCgi=%s",namConnectCgi)
		managementUrl = rabbitmq.ManagementUrlPrefix(configNam,"connections",namConnectCgi)

		grph.add( ( nodeConnect, lib_common.MakeProp("Management"), lib_common.NodeUrl(managementUrl) ) )

		grph.add( ( nodeManager, lib_common.MakeProp("Connection"), nodeConnect ) )
Beispiel #2
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    config_nam = cgiEnv.m_entity_id_dict["Url"]
    nam_connection = cgiEnv.m_entity_id_dict["Connection"]

    node_manager = survol_rabbitmq_manager.MakeUri(config_nam)

    creds = lib_credentials.GetCredentials("RabbitMQ", config_nam)

    cl = Client(config_nam, creds[0], creds[1])

    grph = cgiEnv.GetGraph()

    logging.debug("nam_connection=%s", nam_connection)

    nod_connection = survol_rabbitmq_connection.MakeUri(config_nam, nam_connection)

    grph.add((node_manager, lib_common.MakeProp("Connection"), nod_connection))

    try:
        connect_list = cl.get_connection(nam_connection)
    except Exception as exc:
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for connect_key in connect_list:
        connect_val = connect_list[connect_key]

        if connect_key == "vhost":
            nod_v_host = survol_rabbitmq_vhost.MakeUri(config_nam, connect_val)
            grph.add((nod_connection, lib_common.MakeProp("Virtual host"), nod_v_host))
        elif connect_key == "user":
            nod_user = survol_rabbitmq_user.MakeUri(config_nam, connect_val)
            grph.add((nod_connection, lib_common.MakeProp("User"), nod_user))
        elif connect_key == "host":
            nod_host = lib_uris.gUriGen.HostnameUri(connect_val)
            grph.add((nod_connection, lib_common.MakeProp("Host"), nod_host))
        elif connect_key in ["name", "peer_host", "peer_port"]:
            pass
        else:
            if isinstance(connect_val, six.string_types):
                connect_val = connect_val.replace(">", "@")

                logging.debug("connect_key=%s connect_val=%s", connect_key, connect_val)
            elif isinstance(connect_val, dict):
                pass
            elif isinstance(connect_val, tuple):
                pass
            elif isinstance(connect_val, list):
                pass
            else:
                pass

            logging.debug("Literal=%s", lib_util.NodeLiteral(connect_val))

            grph.add((nod_connection, lib_common.MakeProp(connect_key), lib_util.NodeLiteral(connect_val)))

    survol_rabbitmq_connection.AddSockets(grph, nod_connection, nam_connection)

    cgiEnv.OutCgiRdf()
Beispiel #3
0
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.GetId()

    nodeManager = survol_rabbitmq_manager.MakeUri(configNam)

    creds = lib_credentials.GetCredentials("RabbitMQ", configNam)

    # cl = Client('localhost:12345', 'guest', 'guest')
    cl = Client(configNam, creds[0], creds[1])

    grph = cgiEnv.GetGraph()

    # cl.is_alive()

    #>>> cl.get_users()
    #[{u'hashing_algorithm': u'rabbit_password_hashing_sha256', u'name': u'guest', u'tags': u'administrator', u'password_hash': u'xxxxxx'}]
    try:
        #
        listUsers = cl.get_users()
    except:
        #
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for objUser in listUsers:
        namUser = objUser["name"]
        DEBUG("q=%s", namUser)

        nodeUser = survol_rabbitmq_user.MakeUri(configNam, namUser)

        try:
            grph.add((nodeUser, lib_common.MakeProp("Tags"),
                      lib_common.NodeLiteral(objUser["tags"])))
        except KeyError:
            pass

        try:
            grph.add((nodeUser, lib_common.MakeProp("Hashing algorithm"),
                      lib_common.NodeLiteral(objUser["hashing_algorithm"])))
        except KeyError:
            pass

        # http://127.0.0.1:12345/#/users/guest
        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "users",
                                                     namUser)

        grph.add((nodeUser, lib_common.MakeProp("Management"),
                  lib_common.NodeUrl(managementUrl)))

        grph.add((nodeManager, lib_common.MakeProp("User"), nodeUser))

    cgiEnv.OutCgiRdf()
Beispiel #4
0
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.m_entity_id_dict["Url"]
    namConnection = cgiEnv.m_entity_id_dict["Connection"]

    nodeManager = survol_rabbitmq_manager.MakeUri(configNam)

    creds = lib_credentials.GetCredentials("RabbitMQ", configNam)

    # cl = Client('localhost:12345', 'guest', 'guest')
    cl = Client(configNam, creds[0], creds[1])

    grph = cgiEnv.GetGraph()

    sys.stderr.write("namConnection=%s\n" % (namConnection))

    #namConnectionDisplay = namConnection.replace(">",">")
    #nodConnection = survol_rabbitmq_connection.MakeUri(configNam,namConnectionDisplay)
    nodConnection = survol_rabbitmq_connection.MakeUri(configNam,
                                                       namConnection)

    grph.add((nodeManager, lib_common.MakeProp("Connection"), nodConnection))

    try:
        connectList = cl.get_connection(namConnection)
    except:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for connectKey in connectList:
        connectVal = connectList[connectKey]

        if connectKey == "vhost":
            nodVHost = survol_rabbitmq_vhost.MakeUri(configNam, connectVal)
            grph.add(
                (nodConnection, lib_common.MakeProp("Virtual host"), nodVHost))
        elif connectKey == "user":
            nodUser = survol_rabbitmq_user.MakeUri(configNam, connectVal)
            grph.add((nodConnection, lib_common.MakeProp("User"), nodUser))
        elif connectKey == "host":
            nodHost = lib_common.gUriGen.HostnameUri(connectVal)
            grph.add((nodConnection, lib_common.MakeProp("Host"), nodHost))
        elif connectKey in ["name", "peer_host", "peer_port"]:
            pass
        else:

            if isinstance(connectVal, lib_util.six_string_types):
                connectVal = connectVal.replace(
                    ">", "@")  # .replace("{","@").replace("}","@")

                sys.stderr.write("connectKey=%s connectVal=%s\n" %
                                 (connectKey, connectVal))
            elif isinstance(connectVal, dict):
                pass
            elif isinstance(connectVal, tuple):
                pass
            elif isinstance(connectVal, list):
                pass
            else:
                pass

            sys.stderr.write("Literal=%s\n" %
                             (lib_common.NodeLiteral(connectVal)))

            grph.add((nodConnection, lib_common.MakeProp(connectKey),
                      lib_common.NodeLiteral(connectVal)))

            # Special processing ? Si on fait ca, tout les caracteres speciaux sont escapes.
            # grph.add( ( nodConnection, pc.property_rdf_data_nolist1, lib_common.NodeLiteral(connectVal) ) )

    # This is not useful apparently.
    # peerSocketNode = lib_common.gUriGen.AddrUri( connectList["peer_host"], connectList["peer_port"] )
    # grph.add( ( nodConnection, lib_common.MakeProp("Peer"), peerSocketNode ) )

    survol_rabbitmq_connection.AddSockets(grph, nodConnection, namConnection)

    cgiEnv.OutCgiRdf()
Beispiel #5
0
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.GetId()

    nodeManager = survol_rabbitmq_manager.MakeUri(configNam)

    creds = lib_credentials.GetCredentials("RabbitMQ", configNam)

    # cl = Client('localhost:12345', 'guest', 'guest')
    cl = Client(configNam, creds[0], creds[1])

    grph = cgiEnv.GetGraph()

    # >>> cl.get_connections()[0]
    # http://localhost:12345/api/connections
    # {u'frame_max': 131072, u'send_pend': 0, u'protocol': u'AMQP 0-9-1', u'client_properties': {u'information': u'Licensed under the MPL.
    #   See http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright': u'Copyright (C) 2007-2014 GoPivotal, Inc.', u'capabilities':
    #  {u'exchange_exchange_bindings': True, u'connection.blocked': True, u'authentication_failure_close': True, u'basic.nack': True, u'co
    # nsumer_cancel_notify': True, u'publisher_confirms': True}, u'platform': u'.NET', u'version': u'4.5.2.30002'}, u'reductions': 9840145
    # , u'ssl_protocol': None, u'garbage_collection': {u'min_heap_size': 233, u'fullsweep_after': 65535, u'minor_gcs': 1, u'min_bin_vheap_
    # size': 46422}, u'peer_cert_validity': None, u'channels': 42, u'auth_mechanism': u'PLAIN', u'peer_cert_issuer': None, u'peer_cert_sub
    # ject': None, u'port': 5672, u'recv_oct_details': {u'rate': 29.4}, u'channel_max': 0, u'send_oct_details': {u'rate': 1140.8}, u'recv_
    # cnt': 69333, u'send_oct': 56500718, u'peer_host': u'127.0.0.1', u'state': u'running', u'ssl_cipher': None, u'type': u'network', u'no
    # de': u'rabbit@rchateau-HP', u'send_cnt': 69409, u'peer_port': 51532, u'ssl_hash': None, u'host': u'127.0.0.1', u'connected_at': 1486
    # 974214456L, u'user': u'guest', u'name': u'127.0.0.1:51532 -> 127.0.0.1:5672', u'ssl': False, u'vhost': u'/', u'recv_oct': 1461716, u
    # 'timeout': 60, u'ssl_key_exchange': None, u'reductions_details': {u'rate': 197.4}}

    try:
        #
        listConnections = cl.get_connections()
    except:
        #
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for objConnect in listConnections:
        namConnect = objConnect["name"]

        sys.stderr.write("namConnect=%s\n" % (namConnect))

        #namConnectDisplay = namConnect.replace(">",">")

        # namConnectCgi = namConnect.replace("_","+").replace(">",">")
        #nodeConnect = survol_rabbitmq_connection.MakeUri(configNam,namConnectDisplay)
        nodeConnect = survol_rabbitmq_connection.MakeUri(configNam, namConnect)

        try:
            grph.add((nodeConnect, lib_common.MakeProp("Protocol"),
                      lib_common.NodeLiteral(objConnect["protocol"])))
        except KeyError:
            pass

        try:
            grph.add((nodeConnect, lib_common.MakeProp("Node"),
                      lib_common.NodeLiteral(objConnect["node"])))
        except KeyError:
            pass

        nodeUser = survol_rabbitmq_user.MakeUri(configNam, objConnect["user"])
        try:
            grph.add((nodeConnect, lib_common.MakeProp("User"), nodeUser))
        except KeyError:
            pass

        # '127.0.0.1:51532 -> 127.0.0.1:5672'
        # http://localhost:12345/#/connections/127.0.0.1%3A51532%20-%3E%20127.0.0.1%3A5672
        # namConnectCgi = namConnectDisplay
        namConnectCgi = namConnect.replace(">", ">")
        sys.stderr.write("namConnectCgi=%s\n" % (namConnectCgi))
        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "connections",
                                                     namConnectCgi)

        grph.add((nodeConnect, lib_common.MakeProp("Management"),
                  lib_common.NodeUrl(managementUrl)))

        grph.add((nodeManager, lib_common.MakeProp("Connection"), nodeConnect))

    cgiEnv.OutCgiRdf()