Ejemplo n.º 1
0
def list_dsf():
    """
    Print information about DSF services
    """
    try:
        services = get_all_dsf_services()
    except Exception as e:
        errordie("failed to get DSF services: {}".format(e))

    # build and output yaml document
    services_dict = []
    for service in services:
        service_dict = {
            'label': service.label,
            'nodes': service.nodes,
            'records': [],
        }

        # get records for this DSF service
        try:
            records = get_all_records(service)
        except Exception as e:
            errordie("failed to get records for DSF service '{}': {}".format(
                service.label, e))

        for record in records:
            service_dict['records'].append({
                "label": record.label,
                "record": str(record)
            })

        services_dict.append({'trafficdirector': service_dict})

    print(yaml.safe_dump(services_dict))
Ejemplo n.º 2
0
    def traffic_directors(self):
        if self._traffic_directors is None:
            self._check_dyn_sess()

            tds = defaultdict(dict)
            for td in get_all_dsf_services():
                try:
                    fqdn, _type = td.label.split(':', 1)
                except ValueError:
                    continue
                tds[fqdn][_type] = td
            self._traffic_directors = dict(tds)

        return self._traffic_directors
Ejemplo n.º 3
0
    def traffic_directors(self):
        if self._traffic_directors is None:
            self._check_dyn_sess()

            tds = defaultdict(dict)
            for td in get_all_dsf_services():
                try:
                    fqdn, _type = td.label.split(':', 1)
                except ValueError as e:
                    self.log.warn("Failed to load TrafficDirector '%s': %s",
                                  td.label, e.message)
                    continue
                tds[fqdn][_type] = td
            self._traffic_directors = dict(tds)

        return self._traffic_directors