nvflare.lighter.utils module

class Identity(name: str, org: str | None = None, role: str | None = None)[source]

Bases: object

generate_cert(subject: Identity, issuer: Identity, signing_pri_key, subject_pub_key, valid_days=360, ca=False, server_default_host=None, server_additional_hosts=None)[source]
generate_keys()[source]
generate_password(passlen=16)[source]
load_crt(path)[source]
load_crt_bytes(data: bytes)[source]
load_private_key(data: str)[source]
load_private_key_file(file_path)[source]
load_yaml(file)[source]
load_yaml_include(root, yaml_data)[source]
make_dirs(dirs)[source]
serialize_cert(cert)[source]
serialize_pri_key(pri_key, passphrase=None)[source]
sh_replace(src, mapping_dict)[source]
sign_all(content_folder, signing_pri_key)[source]
sign_content(content, signing_pri_key, return_str=True)[source]
sign_folders(folder, signing_pri_key, crt_path, max_depth=9999)[source]
update_participant_server_name(project_config, old_server_name, new_server_name)[source]
update_project_server_name(project_file: str, old_server_name, server_name)[source]
update_project_server_name_config(project_config: dict, old_server_name, server_name) dict[source]
update_server_default_host(project_config, default_host)[source]

Update the default_host property of the Server in the project config. If a client does not explicitly specify “connect_to”, it will use the default_host to connect to server. This is mainly used for POC, where the default_host is set to localhost.

Parameters:
  • project_config – the project config dict

  • default_host – value of the default host

Returns: the updated project_config

update_storage_locations(local_dir: str, workspace: str, default_resource_name: str = 'resources.json.default', job_storage_name: str = 'jobs-storage', snapshot_storage_name: str = 'snapshot-storage')[source]

Creates resources.json with snapshot-storage and jobs-storage set as folders directly under the workspace for the provided local_dir.

verify_cert(cert_to_be_verified, root_ca_public_key)[source]
verify_content(content, signature, public_key)[source]
verify_folder_signature(src_folder, root_ca_path)[source]
write(file_full_path, content, mode, exe=False)[source]
x509_name(cn_name, org_name=None, role=None)[source]