Beispiel #1
0
 def _write_ca_files(self, topo_dicts, ca_files):
     isds = set()
     for topo_id, as_topo in topo_dicts.items():
         isds.add(topo_id[0])
     for isd in isds:
         base = os.path.join(self.args.output_dir, "CAS")
         for path, value in ca_files[int(isd)].items():
             write_file(os.path.join(base, path), value.decode())
Beispiel #2
0
Datei: go.py Projekt: shitz/scion
 def generate_control_service(self):
     for topo_id, topo in self.args.topo_dicts.items():
         ca = 'issuing' in topo.get("attributes", [])
         for elem_id, elem in topo.get("control_service", {}).items():
             # only a single Go-BS per AS is currently supported
             if elem_id.endswith("-1"):
                 base = topo_id.base_dir(self.args.output_dir)
                 bs_conf = self._build_control_service_conf(
                     topo_id, topo["isd_as"], base, elem_id, elem, ca)
                 write_file(os.path.join(base, "%s.toml" % elem_id),
                            toml.dumps(bs_conf))
Beispiel #3
0
 def _write_disp_file(self):
     if self.args.docker:
         return
     targets_path = os.path.join(self.args.output_dir, "dispatcher",
                                 PrometheusGenerator.PROM_DIR, "disp.yml")
     target_config = [{
         'targets':
         [prom_addr_dispatcher(False, None, None, DISP_PROM_PORT, None)]
     }]
     write_file(targets_path,
                yaml.dump(target_config, default_flow_style=False))
Beispiel #4
0
    def _sig_json(self, topo_id):
        sig_cfg = {"ConfigVersion": 1, "ASes": {}}
        for t_id, topo in self.args.topo_dicts.items():
            if topo_id == t_id:
                continue
            sig_cfg['ASes'][str(t_id)] = {"Nets": []}
            net = self.args.networks['sig%s' % t_id.file_fmt()][0]
            sig_cfg['ASes'][str(t_id)]['Nets'].append(net['net'])

        cfg = os.path.join(topo_id.base_dir(self.args.output_dir), "sig.json")
        contents_json = json.dumps(sig_cfg, default=json_default, indent=2)
        write_file(cfg, contents_json + '\n')
Beispiel #5
0
 def _write_networks_conf(self,
                          networks: Mapping[IPNetwork, NetworkDescription],
                          out_file: str):
     config = configparser.ConfigParser(interpolation=None)
     for net, net_desc in networks.items():
         sub_conf = {}
         for prog, ip_net in net_desc.ip_net.items():
             sub_conf[prog] = str(ip_net.ip)
         config[str(net)] = sub_conf
     text = StringIO()
     config.write(text)
     write_file(os.path.join(self.args.output_dir, out_file), text.getvalue())
Beispiel #6
0
Datei: go.py Projekt: shitz/scion
 def _gen_disp_docker(self):
     for topo_id, topo in self.args.topo_dicts.items():
         base = topo_id.base_dir(self.args.output_dir)
         elem_ids = ['sig_%s' % topo_id.file_fmt()] + \
             list(topo.get("border_routers", {})) + \
             list(topo.get("control_service", {})) + \
             ['tester_%s' % topo_id.file_fmt()]
         for k in elem_ids:
             disp_id = 'disp_%s' % k
             disp_conf = self._build_disp_conf(disp_id, topo_id)
             write_file(os.path.join(base, '%s.toml' % disp_id),
                        toml.dumps(disp_conf))
Beispiel #7
0
    def generate(self):
        self._create_networks()
        for topo_id, topo in self.args.topo_dicts.items():
            base = os.path.join(self.output_base,
                                topo_id.base_dir(self.args.output_dir))
            self._gen_topo(topo_id, topo, base)
        if self.args.sig:
            self._gen_sig()
        docker_utils_gen = DockerUtilsGenerator(self._docker_utils_args())
        self.dc_conf = docker_utils_gen.generate()

        write_file(os.path.join(self.args.output_dir, DOCKER_CONF),
                   yaml.dump(self.dc_conf, default_flow_style=False))
Beispiel #8
0
 def _write_dc_file(self):
     name = 'prometheus'
     prom_dc = {
         'version': DOCKER_COMPOSE_CONFIG_VERSION,
         'services': {
             name: {
                 'image': 'prom/prometheus:v2.6.0',
                 'container_name': name,
                 'network_mode': 'host',
                 'volumes': [self.output_base + '/gen:/prom-config:ro'],
                 'command':
                 ['--config.file', '/prom-config/prometheus.yml'],
             }
         }
     }
     write_file(os.path.join(self.args.output_dir, PROM_DC_FILE),
                yaml.dump(prom_dc, default_flow_style=False))
Beispiel #9
0
 def _write_config_file(self, config_path, job_dict):
     scrape_configs = []
     for job_name, file_paths in job_dict.items():
         scrape_configs.append({
             'job_name': job_name,
             'file_sd_configs': [{
                 'files': file_paths
             }],
         })
     config = {
         'global': {
             'scrape_interval': '1s',
             'evaluation_interval': '1s',
             'external_labels': {
                 'monitor': 'scion-monitor'
             }
         },
         'scrape_configs': scrape_configs,
     }
     write_file(config_path, yaml.dump(config, default_flow_style=False))
Beispiel #10
0
    def _sig_toml(self, topo_id, topo):
        name = 'sig%s' % topo_id.file_fmt()
        net = self.args.networks[name][0]
        log_level = 'debug'
        ipv = 'ipv4'
        if ipv not in net:
            ipv = 'ipv6'

        sciond_net = self.args.networks["sd" + topo_id.file_fmt()][0]
        ipv = 'ipv4'
        if ipv not in sciond_net:
            ipv = 'ipv6'
        sciond_ip = sciond_net[ipv]

        sig_conf = {
            'gateway': {
                'id': name,
                'traffic_policy_file': 'conf/sig.json',
                'ctrl_addr': str(net[ipv]),
            },
            'sciond_connection': {
                'address': socket_address_str(sciond_ip, SD_API_PORT),
            },
            'log': {
                'console': {
                    'level': log_level,
                }
            },
            'metrics': {
                'prometheus': '0.0.0.0:%s' % SIG_PROM_PORT
            },
            'api': {
                'addr': '0.0.0.0:%s' % (SIG_PROM_PORT + 700)
            },
            'features': translate_features(self.args.features),
        }
        path = os.path.join(topo_id.base_dir(self.args.output_dir),
                            SIG_CONFIG_NAME)
        write_file(path, toml.dumps(sig_conf))
Beispiel #11
0
Datei: go.py Projekt: shitz/scion
 def generate_co(self):
     if not self.args.colibri:
         return
     for topo_id, topo in self.args.topo_dicts.items():
         for elem_id, elem in topo.get("colibri_service", {}).items():
             # only a single Go-CO per AS is currently supported
             if elem_id.endswith("-1"):
                 base = topo_id.base_dir(self.args.output_dir)
                 co_conf = self._build_co_conf(topo_id, topo["isd_as"],
                                               base, elem_id, elem)
                 write_file(os.path.join(base, elem_id, CO_CONFIG_NAME),
                            toml.dumps(co_conf))
                 traffic_matrix = self._build_co_traffic_matrix(topo_id)
                 write_file(
                     os.path.join(base, elem_id, 'matrix.yml'),
                     yaml.dump(traffic_matrix, default_flow_style=False))
                 rsvps = self._build_co_reservations(topo_id)
                 write_file(os.path.join(base, elem_id, 'reservations.yml'),
                            yaml.dump(rsvps, default_flow_style=False))
Beispiel #12
0
 def _write_as_topo(self, topo_id, _as_conf):
     path = os.path.join(topo_id.base_dir(self.args.output_dir), TOPO_FILE)
     contents_json = json.dumps(self.topo_dicts[topo_id],
                                default=json_default,
                                indent=2)
     write_file(path, contents_json + '\n')
Beispiel #13
0
 def generate(self):
     dc_conf = self._generate_dc()
     os.makedirs(os.path.join(self.local_jaeger_dir, 'data'), exist_ok=True)
     os.makedirs(os.path.join(self.local_jaeger_dir, 'key'), exist_ok=True)
     write_file(os.path.join(self.args.output_dir, JAEGER_DC),
                yaml.dump(dc_conf, default_flow_style=False))
Beispiel #14
0
 def _write_target_file(self, base_path, target_addrs, ele_type):
     targets_path = os.path.join(base_path, self.PROM_DIR,
                                 self.TARGET_FILES[ele_type])
     target_config = [{'targets': target_addrs}]
     write_file(targets_path,
                yaml.dump(target_config, default_flow_style=False))
Beispiel #15
0
 def _write_config(self, config, path):
     text = StringIO()
     config.write(text)
     write_file(path, text.getvalue())
Beispiel #16
0
 def _write_ifids(self):
     list_path = os.path.join(self.args.output_dir, IFIDS_FILE)
     write_file(list_path, yaml.dump(self.ifid_map,
                                     default_flow_style=False))
Beispiel #17
0
 def _write_as_list(self):
     list_path = os.path.join(self.args.output_dir, AS_LIST_FILE)
     write_file(list_path, yaml.dump(dict(self.as_list)))