Ejemplo n.º 1
0
def look_for_hlses(gls):
    query_text = """
        declare namespace nmwg="http://ggf.org/ns/nmwg/base/2.0/";
        declare namespace perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
        declare namespace psservice="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/";
        declare namespace summary="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/";
        
        for $metadata in /nmwg:store[@type="LSStore"]/nmwg:metadata
            let $metadata_id := $metadata/@id 
            let $data := /nmwg:store[@type="LSStore"]/nmwg:data[@metadataIdRef=$metadata_id]
            return
                element {"nmwg:metadata"} {
                    attribute id {$metadata_id},
                    element {"perfsonar:subject"} {    
                        $metadata/perfsonar:subject/psservice:service        
                    },
                    $data/nmwg:metadata/nmwg:eventType
                }
    """

    xquery = XQuery(query_text)
    client = ServiceClient(gls)
    logger.info("Send query to gLS: '%s'" % gls) 
    response = client.query(xquery)
    logger.info("Received result from gLS: '%s'" % gls) 
    return response
Ejemplo n.º 2
0
def look_for_hlses(gls):
    query_text = """
        declare namespace nmwg="http://ggf.org/ns/nmwg/base/2.0/";
        declare namespace perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
        declare namespace psservice="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/";
        declare namespace summary="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/";
        
        for $metadata in /nmwg:store[@type="LSStore"]/nmwg:metadata
            let $metadata_id := $metadata/@id 
            let $data := /nmwg:store[@type="LSStore"]/nmwg:data[@metadataIdRef=$metadata_id]
            return
                element {"nmwg:metadata"} {
                    attribute id {$metadata_id},
                    element {"perfsonar:subject"} {    
                        $metadata/perfsonar:subject/psservice:service        
                    },
                    $data/nmwg:metadata/nmwg:eventType
                }
    """

    xquery = XQuery(query_text)
    client = ServiceClient(gls)
    logger.info("Send query to gLS: '%s'" % gls)
    response = client.query(xquery)
    logger.info("Received result from gLS: '%s'" % gls)
    return response
Ejemplo n.º 3
0
def query_hls(hls):
    query_text = """
        declare namespace nmwg="http://ggf.org/ns/nmwg/base/2.0/";
        declare namespace perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
        declare namespace psservice="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/";
        declare namespace summary="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/";
        
        for $metadata in /nmwg:store[@type="LSStore"]/nmwg:metadata
            let $metadata_id := $metadata/@id 
            let $data := /nmwg:store[@type="LSStore"]/nmwg:data[@metadataIdRef=$metadata_id]
            return 
                ($metadata, $data)
    """

    xquery = XQuery(query_text)
    client = ServiceClient(hls)
    logger.info("Send query to hLS: '%s'" % hls) 
    response = client.query(xquery)
    logger.info("Received result from hLS: '%s'" % hls) 
    return response
Ejemplo n.º 4
0
def query_hls(hls):
    query_text = """
        declare namespace nmwg="http://ggf.org/ns/nmwg/base/2.0/";
        declare namespace perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
        declare namespace psservice="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/";
        declare namespace summary="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/";
        
        for $metadata in /nmwg:store[@type="LSStore"]/nmwg:metadata
            let $metadata_id := $metadata/@id 
            let $data := /nmwg:store[@type="LSStore"]/nmwg:data[@metadataIdRef=$metadata_id]
            return 
                ($metadata, $data)
    """

    xquery = XQuery(query_text)
    client = ServiceClient(hls)
    logger.info("Send query to hLS: '%s'" % hls)
    response = client.query(xquery)
    logger.info("Received result from hLS: '%s'" % hls)
    return response
Ejemplo n.º 5
0
# This purely using python objects and needs min knowledge of the
# perfSONAR protocol because all params are part of the constructor

# To query for specific (src, dst) pair
endpointpair = EndPointPair(src='bandwidth.cs.utah.edu', dst='bandwidth.chpc.utah.edu')

# To query for everything
#endpointpair = EndPointPair()

query = IPerfQuery(endpointpair=endpointpair, protocol='TCP',
                   start_time=calendar.timegm(
                       datetime.datetime(2013, 11, 14, 3, 30, 15).utctimetuple()),
                   end_time=calendar.timegm(
                       datetime.datetime(2013, 12, 15, 15, 30, 50).utctimetuple()))

r = c.query(query)

#read the metadata
if isinstance(r.meta, dict):
    for metaKey in r.meta:
        meta = r.meta[metaKey]
        data = r.data[metaKey]
        print ""
        print "IPERF data for: src=%s dst=%s" % (meta.subject.src, meta.subject.dst)
        if isinstance(data, list):
            for datum in data:
                print datum
        else:
            print data

Ejemplo n.º 6
0
# Service access point
url = 'http://ps1.es.net:9990/perfSONAR_PS/services/gLS'
c = ServiceClient(url)

query_text = """
declare namespace nmwg="http://ggf.org/ns/nmwg/base/2.0/";
declare namespace perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
declare namespace psservice="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/";
declare namespace summary="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/";

for $metadata in /nmwg:store[@type="LSStore"]/nmwg:metadata
    let $metadata_id := $metadata/@id 
    let $data := /nmwg:store[@type="LSStore"]/nmwg:data[@metadataIdRef=$metadata_id]
    return
        element {"nmwg:metadata"} {
            attribute id {$metadata_id},
            element {"perfsonar:subject"} {    
                $metadata/perfsonar:subject/psservice:service        
            },
            $data/nmwg:metadata/nmwg:eventType
        }
"""

xquery = XQuery(query_text)
r = c.query(xquery)

for metaKey in r.meta:
    for service in r.data[metaKey]:
        print service.subject.accessPoint 
Ejemplo n.º 7
0
start = calendar.timegm(datetime.datetime(2014, 02, 13, 3, 30, 15).utctimetuple())
end = calendar.timegm(datetime.datetime(2014, 02, 14, 3, 30, 15).utctimetuple())

###############################
# Endpoint query
###############################
select = {
    'filter_type': 'select',
    'startTime': start,
    'endTime': end,
}

q = Query(events.TRACEROUTE, data_filter=select)
#print q.to_xml()
r = c.query(q, message_type=Message.METADATA_KEY_REQUEST)


# read the data
for key, value in r.meta.iteritems():
    if value.subject is None:
        continue
    print "Endpoint:  (src: %s, dst:%s)" % (value.subject.src, value.subject.dst)
    print value.event_types
    #print value.to_xml()
    print r.data[key]
    print "\n"

################################
# making a single query
################################
Ejemplo n.º 8
0
from psapi.client import ServiceClient
from psapi.query import EchoRequest


################################
# Create new client
################################

# Service access point
url = 'http://pnwg-pt1.es.net:8085/perfSONAR_PS/services/pSB'
c = ServiceClient(url)


q = EchoRequest()
r = c.query(q)

print r.meta
print r.data
Ejemplo n.º 9
0
"""
Sample Run of PsAPI Client for Lookup Service
"""

from psapi.client import ServiceClient
from psapi.query import LookupQuery
from psapi.protocol import Address
from psapi.protocol import events

################################
# Create new client
################################

# Service access point
url = 'http://ps1.es.net:9990/perfSONAR_PS/services/gLS'
c = ServiceClient(url)

src = Address('198.124.252.117')
dst = Address('198.129.254.46')

gls_query = LookupQuery([src, dst], events.IPERF2)

r = c.query(gls_query)

for meta in r.meta:
    for result in r.data[meta]:
        print result.accessPoint