Example #1
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 = my_asid
    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)
    write_endhost_config(tp, ia, as_obj, GEN_PATH)
    generate_sciond_config(tp, ia, GEN_PATH, as_obj)
Example #2
0
def create_local_gen(isdas, 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
    """
    ia = ISD_AS(isdas)
    as_obj = _get_as_obj(ia)
    check_simple_conf_mode(tp, ia[0], ia[1])
    local_gen_path = os.path.join(WEB_ROOT, 'gen')
    write_dispatcher_config(local_gen_path)
    as_path = 'ISD%s/AS%s/' % (ia[0], ia[1])
    as_path = get_elem_dir(local_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(local_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)
    write_endhost_config(tp, ia, as_obj, local_gen_path)
    generate_zk_config(tp, ia, local_gen_path, as_obj.simple_conf_mode)
    generate_prometheus_config(tp, local_gen_path, as_path)
Example #3
0
def create_scionlab_vm_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)
    write_endhost_config(tp, new_ia, as_obj, local_gen_path)
    generate_zk_config(tp, new_ia, local_gen_path, simple_conf_mode=True)
    generate_sciond_config(tp, new_ia, local_gen_path, as_obj)
Example #4
0
def generate_sciond_config(tp, ia, local_gen_path, as_obj):
    executable_name = "sciond"
    instance_name = "sd%s" % str(ia)
    service_type = "sciond"
    processes = []
    for svc_type in ["BorderRouters", "BeaconService", "CertificateService",
                     "HiddenPathService", "PathService"]:
        if svc_type not in tp:
            continue
        for elem_id, elem in tp[svc_type].items():
            processes.append(elem_id)
    processes.append(instance_name)
    config = prep_supervisord_conf(None, executable_name, service_type, instance_name, ia)
    config['group:'  "as%s" % str(ia)] = {'programs': ",".join(processes)}
    sciond_conf_path = get_elem_dir(local_gen_path, ia, "")
    write_supervisord_config(config, sciond_conf_path)