Ejemplo n.º 1
0
def pull_meta_key(service_url,
                  network_object,
                  measurements_events,
                  start_time=int(time.time()) - 10000,
                  end_time=int(time.time()),
                  meta_key=None):
    """
    Pulls only the metadata keys
    """

    if service_url:
        service = create_service_client(service_url)
    else:
        if not isinstance(network_object, NetworkObject):
            raise CommandError("Please define a service.")

        services = find_service_watch(network_object, measurements_events)
        if not services:
            raise CommandError("Please define a service.")
        service = create_service_client(services[0])

    for event in measurements_events:
        objects_keys = get_meta_keys(service, network_object, event)
        for obj in objects_keys:
            print objects_keys[obj]['key']
Ejemplo n.º 2
0
def pull_measurements_data(service_url,
                           network_object,
                           measurements_events,
                           start_time=int(time.time()) - 10000,
                           end_time=int(time.time()),
                           meta_key=None):
    """
    Generic method to pull perfSONAR measurements
    """
    global SILENT
    if service_url:
        service = create_service_client(service_url)
    else:
        if not isinstance(network_object, NetworkObject):
            raise CommandError("Please define a service.")

        services = find_service_watch(network_object, measurements_events)
        if not services:
            raise CommandError("Please define a service.")
        service = create_service_client(services[0])

    for event in measurements_events:
        if not meta_key:
            objects_keys = get_meta_keys(service, network_object, event)
            keys = []
            for obj in objects_keys:
                keys.append(objects_keys[obj]['key'])
        else:
            keys = meta_key.strip().split()

        if not keys:
            raise CommandError("Network object is not found.")

        results = get_measurements_data(service, keys, event, start_time,
                                        end_time)

        for key, value in results.items():
            if not SILENT:
                print "maKey", key, ":", event
                if not value:
                    print None
                else:
                    for v in value:
                        print v

            meta = get_metadata_by_key(key)
            if not meta:
                continue

            if isinstance(value, list):
                save_measurements_data(meta['_id'], value)
Ejemplo n.º 3
0
def pull_measurements_data(service_url, network_object,
                        measurements_events,
                        start_time=int(time.time()) - 10000,
                        end_time=int(time.time()),
                        meta_key=None):
    """
    Generic method to pull perfSONAR measurements
    """
    global SILENT
    if service_url:
        service = create_service_client(service_url)
    else:
        if not isinstance(network_object, NetworkObject):
            raise CommandError("Please define a service.")
        
        services = find_service_watch(network_object, measurements_events)
        if not services:
            raise CommandError("Please define a service.")
        service = create_service_client(services[0])
    
    for event in measurements_events:
        if not meta_key:
            objects_keys = get_meta_keys(service, network_object, event)
            keys = []
            for obj in objects_keys:
                keys.append(objects_keys[obj]['key'])
        else:
            keys = meta_key.strip().split()
        
        if not keys:
            raise CommandError("Network object is not found.")
        
        results = get_measurements_data(service, keys, event,
                        start_time, end_time)
        
        for key, value in results.items():
            if not SILENT:
                print "maKey", key, ":", event
                if not value:
                    print None
                else:
                    for v in value:
                        print v
            
            meta = get_metadata_by_key(key)
            if not meta:
                continue
            
            if isinstance(value, list):
                save_measurements_data(meta['_id'], value)
Ejemplo n.º 4
0
 def test_create_service_client(self):
     CLIENT_URL = 'http://wwww.example.com:9999/service'
     TEST_DATA = [
         CLIENT_URL,
         PsService(accessPoint=CLIENT_URL),
         ServiceClient(CLIENT_URL),
     ]
     
     for test in TEST_DATA:
         client = create_service_client(test)
         self.assertIsInstance(client, ServiceClient)
         self.assertEqual(client.access_point, CLIENT_URL)
Ejemplo n.º 5
0
def pull_lookup_service(service_url, print_services=True):
    """
    Pulls all registered services from perfSONAR lookup service.
    """
    if service_url is None:
        raise CommandError("Please provide a valid gLS/hLS service "
            "URL: e.g. --url http://example.com:9999/service")

    # Send pull all data to the lookup service
    #try:
    client = create_service_client(service_url)
    query = create_lookup_query()
    result = query_psservice(client, query)
    save_lookup_service_result(result, print_services)
Ejemplo n.º 6
0
def pull_lookup_service(service_url, print_services=True):
    """
    Pulls all registered services from perfSONAR lookup service.
    """
    if service_url is None:
        raise CommandError("Please provide a valid gLS/hLS service "
                           "URL: e.g. --url http://example.com:9999/service")

    # Send pull all data to the lookup service
    #try:
    client = create_service_client(service_url)
    query = create_lookup_query()
    result = query_psservice(client, query)
    save_lookup_service_result(result, print_services)
Ejemplo n.º 7
0
def pull_meta_key(service_url, network_object,
                        measurements_events,
                        start_time=int(time.time()) - 10000,
                        end_time=int(time.time()),
                        meta_key=None):
    """
    Pulls only the metadata keys
    """

    if service_url:
        service = create_service_client(service_url)
    else:
        if not isinstance(network_object, NetworkObject):
            raise CommandError("Please define a service.")
        
        services = find_service_watch(network_object, measurements_events)
        if not services:
            raise CommandError("Please define a service.")
        service = create_service_client(services[0])
    
    for event in measurements_events:
        objects_keys = get_meta_keys(service, network_object, event)
        for obj in objects_keys:
            print objects_keys[obj]['key']