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()
Exemple #2
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()
Exemple #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()
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()
Exemple #5
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()
Exemple #6
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 ) )
Exemple #7
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()
Exemple #8
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()
Exemple #9
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()
Exemple #10
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()