Пример #1
0
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.m_entity_id_dict["Url"]
    namVHost = cgiEnv.m_entity_id_dict["VHost"]

    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()

    nodVHost = survol_rabbitmq_vhost.MakeUri(configNam, namVHost)
    grph.add((nodeManager, lib_common.MakeProp("virtual host node"), nodVHost))

    for objExchange in cl.get_exchanges(namVHost):
        namExchange = objExchange["name"]
        sys.stderr.write("namExchange=%s\n" % (namExchange))

        nodeExchange = survol_rabbitmq_exchange.MakeUri(
            configNam, namVHost, namExchange)

        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "exchanges",
                                                     namVHost, namExchange)

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

        grph.add((nodVHost, lib_common.MakeProp("Exchange"), nodeExchange))

    cgiEnv.OutCgiRdf()
Пример #2
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    config_nam = cgiEnv.m_entity_id_dict["Url"]
    nam_v_host = cgiEnv.m_entity_id_dict["VHost"]

    node_manager = survol_rabbitmq_manager.MakeUri(config_nam)

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

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

    grph = cgiEnv.GetGraph()

    nod_v_host = survol_rabbitmq_vhost.MakeUri(config_nam, nam_v_host)
    grph.add(
        (node_manager, lib_common.MakeProp("virtual host node"), nod_v_host))

    for obj_exchange in cl.get_exchanges(nam_v_host):
        nam_exchange = obj_exchange["name"]
        logging.debug("nam_exchange=%s", nam_exchange)

        node_exchange = survol_rabbitmq_exchange.MakeUri(
            config_nam, nam_v_host, nam_exchange)

        management_url = rabbitmq.ManagementUrlPrefix(config_nam, "exchanges",
                                                      nam_v_host, nam_exchange)

        grph.add((node_exchange, lib_common.MakeProp("Management"),
                  lib_common.NodeUrl(management_url)))

        grph.add((nod_v_host, lib_common.MakeProp("Exchange"), node_exchange))

    cgiEnv.OutCgiRdf()
Пример #3
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()
Пример #4
0
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.m_entity_id_dict["Url"]
    namVHost = cgiEnv.m_entity_id_dict["VHost"]

    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()

    nodVHost = survol_rabbitmq_vhost.MakeUri(configNam, namVHost)
    grph.add((nodeManager, lib_common.MakeProp("virtual host node"), nodVHost))

    for quList in cl.get_queues(namVHost):
        namQueue = quList["name"]
        DEBUG("q=%s", namQueue)

        nodeQueue = survol_rabbitmq_queue.MakeUri(configNam, namVHost,
                                                  namQueue)

        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "queues",
                                                     namVHost, namQueue)

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

        grph.add((nodVHost, lib_common.MakeProp("Queue"), nodeQueue))

    cgiEnv.OutCgiRdf()
Пример #5
0
def AddInfo(grph, node, entity_ids_arr):
    namConfig = entity_ids_arr[0]

    nodeManager = survol_rabbitmq_manager.MakeUri(namConfig)

    # Inverted property for nicer display.
    grph.add((node, lib_common.MakeProp("Configuration manager"), nodeManager))
Пример #6
0
def Main():

    cgiEnv = lib_common.ScriptEnvironment()

    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()

    try:
        lstOverview = cl.get_overview()
    except Exception as exc:
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for keyOverview in lstOverview:
        valOverview = lstOverview[keyOverview]

        valClean = valOverview
        # Otherwise it does not work as these chars should be espaced.
        # TODO: Nice display for Python lists and dicts.
        valClean = str(valClean).replace("{", "").replace("}", "")
        grph.add((nodeManager, lib_common.MakeProp(keyOverview),
                  lib_util.NodeLiteral(valClean)))

    cgiEnv.OutCgiRdf()
Пример #7
0
def Main():

    cgiEnv = lib_common.ScriptEnvironment()

    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_all_vhosts()
    # http://localhost:12345/api/vhosts
    # [{u'name': u'/', u'tracing': False, u'messages_details': {u'rate': 0.0}, u'messages': 0, u'message_stats': {u'deliver_no_ack': 0, u'
    # publish_out': 0, u'get_no_ack': 13, u'return_unroutable': 0, u'confirm': 0, u'deliver_get': 13, u'publish': 13, u'confirm_details':
    # {u'rate': 0.0}, u'ack_details': {u'rate': 0.0}, u'get': 0, u'deliver': 0, u'publish_out_details': {u'rate': 0.0}, u'redeliver_detail
    # s': {u'rate': 0.0}, u'deliver_details': {u'rate': 0.0}, u'deliver_get_details': {u'rate': 0.0}, u'publish_details': {u'rate': 0.0},
    # u'publish_in_details': {u'rate': 0.0}, u'ack': 0, u'publish_in': 0, u'return_unroutable_details': {u'rate': 0.0}, u'get_details': {u
    # 'rate': 0.0}, u'get_no_ack_details': {u'rate': 0.0}, u'deliver_no_ack_details': {u'rate': 0.0}, u'redeliver': 0}, u'messages_unackno
    # wledged_details': {u'rate': 0.0}, u'messages_ready_details': {u'rate': 0.0}, u'messages_unacknowledged': 0, u'messages_ready': 0}]

    try:
        #
        listVHosts = cl.get_all_vhosts()
    except Exception as exc:
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for objVHost in listVHosts:
        namVHost = objVHost["name"]
        logging.debug("q=%s", namVHost)

        nodeVHost = survol_rabbitmq_vhost.MakeUri(configNam, namVHost)

        try:
            grph.add((nodeVHost, lib_common.MakeProp("tracing"),
                      lib_util.NodeLiteral(objVHost["tracing"])))
        except KeyError:
            pass

        try:
            grph.add((nodeVHost, lib_common.MakeProp("messages"),
                      lib_util.NodeLiteral(objVHost["messages"])))
        except KeyError:
            pass

        # http://127.0.0.1:12345/#/vhosts//
        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "vhosts",
                                                     namVHost)

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

        grph.add((nodeManager, lib_common.MakeProp("Virtual host"), nodeVHost))

    cgiEnv.OutCgiRdf()
Пример #8
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()
Пример #9
0
def AddInfo(grph,node,entity_ids_arr):
	namConfig = entity_ids_arr[0]
	namConnection = entity_ids_arr[1]

	AddSockets(grph,node,namConnection)

	# Then add the manager node.
	nodeManager = survol_rabbitmq_manager.MakeUri(namConfig)

	# Inverted property for nicer display.
	grph.add( ( node, lib_common.MakeProp("Configuration manager"), nodeManager ) )
Пример #10
0
def AddInfo(grph,node,entity_ids_arr):
	namConfig = entity_ids_arr[0]
	namVHost = entity_ids_arr[1]

	nodeManager = survol_rabbitmq_manager.MakeUri(namConfig)

	nodVHost = survol_rabbitmq_vhost.MakeUri(namConfig,namVHost)
	grph.add( ( nodeManager, lib_common.MakeProp("virtual host node"), nodVHost ) )

	grph.add( ( node, lib_common.MakeProp("Manager"), nodeManager ) )
	grph.add( ( node, lib_common.MakeProp("Virtual host"), nodVHost ) )
Пример #11
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()
    try:
        #
        listQueues = cl.get_queues()
    except:
        #
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught:" + str(exc))

    for quList in listQueues:
        namQueue = quList["name"]
        DEBUG("q=%s", namQueue)

        namVHost = quList["vhost"]
        nodVHost = survol_rabbitmq_vhost.MakeUri(configNam, namVHost)

        nodeQueue = survol_rabbitmq_queue.MakeUri(configNam, namVHost,
                                                  namQueue)

        grph.add((nodeQueue, lib_common.MakeProp("vhost"),
                  lib_common.NodeLiteral(namVHost)))
        grph.add((nodeQueue, lib_common.MakeProp("vhost node"), nodVHost))

        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "queues",
                                                     namVHost, namQueue)

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

        grph.add((nodeManager, lib_common.MakeProp("Queue"), nodeQueue))

    cgiEnv.OutCgiRdf()
Пример #12
0
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.m_entity_id_dict["Url"]
    # namVHost = cgiEnv.m_entity_id_dict["VHost"]

    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()

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

    for objExchange in listExchanges:
        namExchange = objExchange["name"]
        DEBUG("namExchange=%s", namExchange)

        namVHost = objExchange["vhost"]
        nodeExchange = survol_rabbitmq_exchange.MakeUri(
            configNam, namVHost, namExchange)

        nodVHost = survol_rabbitmq_vhost.MakeUri(configNam, namVHost)
        grph.add(
            (nodeExchange, lib_common.MakeProp("virtual host node"), nodVHost))

        managementUrl = rabbitmq.ManagementUrlPrefix(configNam, "exchanges",
                                                     namVHost, namExchange)

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

        grph.add((nodVHost, lib_common.MakeProp("Exchange"), nodeExchange))

    cgiEnv.OutCgiRdf()
Пример #13
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    #"RabbitMQ" : {
    #	"localhost:12345" : [ "guest", "guest" ]
    #	}
    credList = lib_credentials.GetCredentialsNames("RabbitMQ")

    grph = cgiEnv.GetGraph()

    if credList:
        for configNam in credList:

            # Nothing else but a host and a port. The host is case insensitive: RFC4343.
            configNam = configNam.lower()

            DEBUG("configNam=%s", configNam)
            nodeManager = survol_rabbitmq_manager.MakeUri(configNam)

            hostSplit = configNam.split(":")

            if len(hostSplit) < 2:
                lib_common.ErrorMessageHtml(
                    "RabbitMQ configuration. Port number not defined:%s" %
                    (configNam))

            nodeAddr = lib_common.gUriGen.AddrUri(hostSplit[0], hostSplit[1])

            grph.add((nodeAddr, lib_common.MakeProp("RabbitMQ manager"),
                      nodeManager))

            # http://127.0.0.1:12345/#/
            managementUrl = rabbitmq.ManagementUrlPrefix(configNam)
            grph.add((nodeAddr, lib_common.MakeProp("Management"),
                      lib_common.NodeUrl(managementUrl)))

            # TODO: Get and display the log files.
            # Config file 	c:/Users/rchateau/AppData/Roaming/RabbitMQ/rabbitmq.config
            # Database directory 	c:/Users/rchateau/AppData/Roaming/RabbitMQ/db/RABBIT~1
            # Log file 	C:/Users/rchateau/AppData/Roaming/RabbitMQ/log/RABBIT~1.LOG
            # SASL log file 	C:/Users/rchateau/AppData/Roaming/RabbitMQ/log/RABBIT~2.LOG

    cgiEnv.OutCgiRdf()
Пример #14
0
def Main():

    cgiEnv = lib_common.ScriptEnvironment()

    config_nam = cgiEnv.m_entity_id_dict["Url"]
    nam_v_host = cgiEnv.m_entity_id_dict["VHost"]
    nam_queue = cgiEnv.m_entity_id_dict["Queue"]

    node_manager = survol_rabbitmq_manager.MakeUri(config_nam)

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

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

    grph = cgiEnv.GetGraph()

    nod_v_host = survol_rabbitmq_vhost.MakeUri(config_nam, nam_v_host)
    grph.add(
        (node_manager, lib_common.MakeProp("virtual host node"), nod_v_host))

    node_queue = survol_rabbitmq_queue.MakeUri(config_nam, nam_v_host,
                                               nam_queue)
    grph.add((nod_v_host, lib_common.MakeProp("Queue"), node_queue))

    # >>> cl.get_queue_bindings("/","aliveness-test")
    # [{u'vhost': u'/', u'properties_key': u'aliveness-test', u'destination': u'aliveness-test', u'routing_key': u'aliveness-test', u'sour
    # ce': u'', u'arguments': {}, u'destination_type': u'queue'}]
    lst_bindings = cl.get_queue_bindings(nam_v_host, nam_queue)

    for sublst_bindings in lst_bindings:
        for key_bindings in sublst_bindings:
            val_bindings = sublst_bindings[key_bindings]
            str_disp = str(val_bindings).replace("{", "").replace("}", "")
            grph.add((node_queue, lib_common.MakeProp(key_bindings),
                      lib_util.NodeLiteral(str_disp)))
            logging.debug("key_bindings=%s val_bindings=%s", key_bindings,
                          val_bindings)

    cgiEnv.OutCgiRdf()
Пример #15
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))

	if listConnections:
		AddConnections(grph,listConnections,configNam,nodeManager)

	cgiEnv.OutCgiRdf()
Пример #16
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(">","&gt;")
    #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()
Пример #17
0
 def CredUrlRabbitMQ(config_nam):
     from sources_types.rabbitmq import manager as survol_rabbitmq_manager
     node_manager = survol_rabbitmq_manager.MakeUri(config_nam)
     return node_manager
Пример #18
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(">","&gt;")

        # namConnectCgi = namConnect.replace("_","+").replace(">","&gt;")
        #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(">", "&gt;")
        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()