Beispiel #1
0
    def write_topology(self, asid, as_obj, tp):
        """
        Creates the usual gen folder structure for an ISD/AS under gen
        :param str asid: ISD-AS as a string
        :param obj as_obj: An object that stores crypto information for AS
        :param dict tp: the topology parameter file as a dict of dicts
        """
        ia = TopoID(asid)

        as_path = get_elem_dir(self.gen_path, ia, "")
        rmtree(as_path, True)
        os.chdir(os.path.dirname(self.gen_path)
                 )  # functions from $SC/python/topology use relative paths
        write_dispatcher_config(self.gen_path)
        write_toml_files(tp, ia)
        for service_type, type_key in TYPES_TO_KEYS.items():
            executable_name = TYPES_TO_EXECUTABLES[service_type]
            if type_key not in tp:
                continue
            instances = tp[type_key].keys()
            for instance_name in instances:
                config = prep_supervisord_conf(tp[type_key][instance_name],
                                               executable_name, service_type,
                                               instance_name, ia)
                instance_path = get_elem_dir(self.gen_path, ia, instance_name)
                write_certs_trc_keys(ia, as_obj, instance_path)
                write_as_conf_and_path_policy(ia, as_obj, instance_path)
                write_supervisord_config(config, instance_path)
                write_topology_file(tp, type_key, instance_path)
                write_zlog_file(service_type, instance_name, instance_path)
        # We don't need to create zk configration for existing ASes
        # generate_zk_config(tp, ia, GEN_PATH, simple_conf_mode=False)
        generate_sciond_config(ia, as_obj, tp, self.gen_path)
        generate_prom_config(ia, tp, self.gen_path)
Beispiel #2
0
def create_scionlab_as_local_gen(args, tp):
    """
    Creates the usual gen folder structure for an ISD/AS under web_scion/gen,
    ready for Ansible deployment
    :param str isdas: ISD-AS as a string
    :param dict tp: the topology parameter file as a dict of dicts
    """
    new_ia = ISD_AS(args.joining_ia)
    core_ia = ISD_AS(args.core_ia)
    local_gen_path = os.path.join(args.package_path, args.user_id, 'gen')
    as_obj = generate_certificate(
        new_ia, core_ia, args.core_sign_priv_key_file, args.core_cert_file, args.trc_file)
    write_dispatcher_config(local_gen_path)
    for service_type, type_key in TYPES_TO_KEYS.items():
        executable_name = TYPES_TO_EXECUTABLES[service_type]
        instances = tp[type_key].keys()
        for instance_name in instances:
            config = prep_supervisord_conf(tp[type_key][instance_name], executable_name,
                                           service_type, instance_name, new_ia)
            instance_path = get_elem_dir(local_gen_path, new_ia, instance_name)
            # TODO(ercanucan): pass the TRC file as a parameter
            write_certs_trc_keys(new_ia, as_obj, instance_path)
            write_as_conf_and_path_policy(new_ia, as_obj, instance_path)
            write_supervisord_config(config, instance_path)
            write_topology_file(tp, type_key, instance_path)
            write_zlog_file(service_type, instance_name, instance_path)
    generate_zk_config(tp, new_ia, local_gen_path, simple_conf_mode=True)
    generate_sciond_config(TopoID(args.joining_ia), as_obj, tp, local_gen_path)
    # We don't initiate the prometheous service for user ASes.
    # generate_prom_config(ia, tp, gen_path)
    write_overlay_config(local_gen_path)
Beispiel #3
0
def generate_local_gen(my_asid, as_obj, tp):
    """
    Creates the usual gen folder structure for an ISD/AS under gen
    :param str my_asid: ISD-AS as a string
    :param obj as_obj: An object that stores crypto information for AS
    :param dict tp: the topology parameter file as a dict of dicts
    """
    ia = TopoID(my_asid)
    gen_path = os.path.join(PROJECT_ROOT, GEN_PATH)
    write_dispatcher_config(gen_path)
    as_path = get_elem_dir(gen_path, ia, "")
    rmtree(as_path, True)
    for service_type, type_key in TYPES_TO_KEYS.items():
        executable_name = TYPES_TO_EXECUTABLES[service_type]
        instances = tp[type_key].keys()
        for instance_name in instances:
            config = prep_supervisord_conf(tp[type_key][instance_name],
                                           executable_name, service_type,
                                           instance_name, ia)
            instance_path = get_elem_dir(gen_path, ia, instance_name)
            write_certs_trc_keys(ia, as_obj, instance_path)
            write_as_conf_and_path_policy(ia, as_obj, instance_path)
            write_supervisord_config(config, instance_path)
            write_topology_file(tp, type_key, instance_path)
            write_zlog_file(service_type, instance_name, instance_path)
    # We don't need to create zk configration for existing ASes
    # generate_zk_config(tp, ia, GEN_PATH, simple_conf_mode=False)
    generate_sciond_config(ia, as_obj, tp, gen_path)
    generate_prom_config(ia, tp, gen_path)