def populate_roots(): """Save the list of gLS roots to the topology database """ glses = get_glss_list() discoveryEvent = 'http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/summary/2.0' for gls in glses: create_psservice(gls, gls, 'gLS', 'Root Hint', [discoveryEvent])
def populate_roots(): """Save the list of gLS roots to the topology database """ glses = get_glss_list() discoveryEvent = 'http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/summary/2.0' for gls in glses: create_psservice(gls, gls, 'gLS', 'Root Hint', [discoveryEvent])
def populate_hlses(self, gLSService): gls = get_service_accesspoint(gLSService) logger.info("Populating hLSes from gLS: '%s'" % gls) result = look_for_hlses(gls) hlses = [] for meta in result.data: service = meta.subject.contents if meta.event_types is None: events = [] elif isinstance(meta.event_types, str): events = [meta.event_types] else: events = list(set(meta.event_types)) # hLSes are also able to handle discovery events events.append(psevents.SUMMARY) hlses.append({'service':service, 'events':events}) if len(hlses) == 0: raise Exception("No hLSes is found at %s" % gls) for h in hlses: try: serviceName = h['service'].serviceName accessPoint = h['service'].accessPoint serviceDescription = h['service'].serviceDescription service = create_psservice(serviceName, accessPoint, 'hLS', serviceDescription, h['events']) except Exception, ex: logger.error("Found error in '%s': %s" % (serviceName, ex))
def populate_hlses(self, gLSService): gls = get_service_accesspoint(gLSService) logger.info("Populating hLSes from gLS: '%s'" % gls) result = look_for_hlses(gls) hlses = [] for meta in result.data: service = meta.subject.contents if meta.event_types is None: events = [] elif isinstance(meta.event_types, str): events = [meta.event_types] else: events = list(set(meta.event_types)) # hLSes are also able to handle discovery events events.append(psevents.SUMMARY) hlses.append({'service': service, 'events': events}) if len(hlses) == 0: raise Exception("No hLSes is found at %s" % gls) for h in hlses: try: serviceName = h['service'].serviceName accessPoint = h['service'].accessPoint serviceDescription = h['service'].serviceDescription service = create_psservice(serviceName, accessPoint, 'hLS', serviceDescription, h['events']) except Exception, ex: logger.error("Found error in '%s': %s" % (serviceName, ex))
def process_result(self, result): meta = {} data = {} # Organize data and metadata in different dicts for tmp in result.data: if isinstance(tmp, Metadata): meta[tmp.object_id] = tmp elif isinstance(tmp, Data): if tmp.ref_id in data: data[tmp.ref_id].append(tmp) else: data[tmp.ref_id] = [tmp] for key, m in meta.iteritems(): if key not in data: data[key] = None datums = [] continue datums = data[key] event_types = [] for d in datums: if d.data.event_types is not None: if isinstance(d.data.event_types, list): for event in d.data.event_types: event_types.append(event) else: event_types.append(d.data.event_types) # to remove duplicates event_types = list(set(event_types)) logger.info('event types: %s' % event_types) if isinstance(m.subject.contents, PsService): s = m.subject.contents service = create_psservice(s.serviceName, s.accessPoint, s.serviceType, s.serviceDescription, event_types) for d in datums: if isinstance(d.data, Metadata): if isinstance(d.data.subject, NetUtilSubject): self.process_NetUtilSubject(service, d.data) elif isinstance(d.data.subject, PingerSubject) or isinstance( d.data.subject, OWAMPSubject): self.process_EndpointpairSubject(service, d.data) else: logger.error( "Undefined data type '%s' at service '%s'" % (type(d.data.subject), get_service_accesspoint(service))) else: logger.error( "Undefined data type '%s' at service '%s'" % (type(d.data), get_service_accesspoint(service)))
def process_result(self, result): meta = {} data = {} # Organize data and metadata in different dicts for tmp in result.data: if isinstance(tmp, Metadata): meta[tmp.object_id] = tmp elif isinstance(tmp, Data): if tmp.ref_id in data: data[tmp.ref_id].append(tmp) else: data[tmp.ref_id] = [tmp] for key, m in meta.iteritems(): if key not in data: data[key] = None datums = [] continue datums = data[key] event_types = [] for d in datums: if d.data.event_types is not None: if isinstance(d.data.event_types, list): for event in d.data.event_types: event_types.append(event) else: event_types.append(d.data.event_types) # to remove duplicates event_types = list(set(event_types)) logger.info('event types: %s' % event_types) if isinstance(m.subject.contents, PsService): s = m.subject.contents service = create_psservice(s.serviceName, s.accessPoint, s.serviceType, s.serviceDescription, event_types) for d in datums: if isinstance(d.data, Metadata): if isinstance(d.data.subject, NetUtilSubject): self.process_NetUtilSubject(service, d.data) elif isinstance(d.data.subject, PingerSubject) or isinstance(d.data.subject, OWAMPSubject): self.process_EndpointpairSubject(service, d.data) else: logger.error("Undefined data type '%s' at service '%s'" % (type(d.data.subject), get_service_accesspoint(service))) else: logger.error("Undefined data type '%s' at service '%s'" % (type(d.data), get_service_accesspoint(service)))