vantage6.node.context.DockerNodeContext#
- class DockerNodeContext(*args, **kwargs)#
Bases:
NodeContext
Node context for the dockerized version of the node.
- __init__(*args, **kwargs)#
Display node version number.
Methods
__init__
(*args, **kwargs)Display node version number.
available_configurations
([system_folders])Find all available server configurations in the default folders.
config_exists
(instance_name[, system_folders])Check if a configuration file exists.
configure_logger
(name, level)Set the logging level of a logger.
docker_temporary_volume_name
(job_id)Docker volume in which temporary data is stored.
find_config_file
(instance_type, ...[, ...])Find a configuration file.
from_external_config_file
(path[, system_folders])Create a node context from an external configuration file.
get_data_file
(filename)Return the path to a data file.
get_database_uri
([label])Obtain the database URI for a specific database.
initialize
(instance_type, instance_name[, ...])Initialize the AppContext instance.
instance_folders
(instance_type, ...)Log, data and config folders are always mounted.
log_file_name
(type_)Return a path to a log file for a given log file type
Print the log file header.
set_folders
(instance_type, instance_name, ...)In case of the dockerized version we do not want to use user specified directories within the container.
Setup a basic logging mechanism.
type_data_folder
([system_folders])Obtain OS specific data folder where to store node specific data.
Attributes
LOGGING_ENABLED
Return the path to the configuration file.
Return the name of the configuration file.
Dictionary of local databases that are available for this node.
Docker container name of the node.
Private Docker network name which is unique for this node.
Docker volume in which the SSH configuration is stored.
Docker volume in which the SSH configuration is stored.
Docker volume in which task data is stored.
Docker volume in which the VPN configuration is stored.
Return the path to the log file.
proxy_log_file
running_in_docker
- INST_CONFIG_MANAGER#
alias of
NodeConfigurationManager
- classmethod available_configurations(system_folders=False)#
Find all available server configurations in the default folders.
- Parameters:
system_folders (bool, optional) – System wide or user configuration, by default N_FOL
- Returns:
The first list contains validated configuration files, the second list contains invalid configuration files.
- Return type:
tuple[list, list]
- classmethod config_exists(instance_name, system_folders=False)#
Check if a configuration file exists.
- Parameters:
instance_name (str) – Name of the configuration instance, corresponds to the filename of the configuration file.
system_folders (bool, optional) – System wide or user configuration, by default N_FOL
- Returns:
Whether the configuration file exists or not
- Return type:
bool
- property config_file: Path#
Return the path to the configuration file.
- Returns:
Path to the configuration file
- Return type:
Path
- property config_file_name: str#
Return the name of the configuration file.
- Returns:
Name of the configuration file
- Return type:
str
- static configure_logger(name, level)#
Set the logging level of a logger.
- Parameters:
name (str) – Name of the logger to configure. If None, the root logger is configured.
level (str) – Logging level to set. Must be one of ‘debug’, ‘info’, ‘warning’, ‘error’, ‘critical’.
- Returns:
The logger object and the logging level that was set.
- Return type:
Tuple[Logger, int]
- property databases: dict#
Dictionary of local databases that are available for this node.
- Returns:
dictionary with database names as keys and their corresponding paths as values.
- Return type:
dict
- property docker_container_name: str#
Docker container name of the node.
- Returns:
Node’s Docker container name
- Return type:
str
- property docker_network_name: str#
Private Docker network name which is unique for this node.
- Returns:
Docker network name
- Return type:
str
- property docker_squid_volume_name: str#
Docker volume in which the SSH configuration is stored.
- Returns:
Docker volume name
- Return type:
str
- property docker_ssh_volume_name: str#
Docker volume in which the SSH configuration is stored.
- Returns:
Docker volume name
- Return type:
str
- docker_temporary_volume_name(job_id)#
Docker volume in which temporary data is stored. Temporary data is linked to a specific run. Multiple algorithm containers can have the same run id, and therefore the share same temporary volume.
- Parameters:
job_id (int) – run id provided by the server
- Returns:
Docker volume name
- Return type:
str
- property docker_volume_name: str#
Docker volume in which task data is stored. In case a file based database is used, this volume contains the database file as well.
- Returns:
Docker volume name
- Return type:
str
- property docker_vpn_volume_name: str#
Docker volume in which the VPN configuration is stored.
- Returns:
Docker volume name
- Return type:
str
- classmethod find_config_file(instance_type, instance_name, system_folders, config_file=None, verbose=True)#
Find a configuration file.
- Parameters:
instance_type (InstanceType) – Type of instance that is checked
instance_name (str) – Name of the configuration
system_folders (bool) – Use system folders rather than user folders
config_file (str | None) – Name of the configuration file. If None, the name of the configuration is used.
verbose (bool) – Print the directories that are searched for the configuration file.
- Returns:
Path to the configuration file
- Return type:
str
- Raises:
Exception – If the configuration file is not found
- classmethod from_external_config_file(path, system_folders=False)#
Create a node context from an external configuration file. External means that the configuration file is not located in the default folders but its location is specified by the user.
- Parameters:
path (str) – Path of the configuration file
system_folders (bool, optional) – System wide or user configuration, by default N_FOL
- Returns:
Node context object
- Return type:
- get_data_file(filename)#
Return the path to a data file.
- Parameters:
filename (str) – Name of the data file
- Returns:
Path to the data file
- Return type:
str
- get_database_uri(label='default')#
Obtain the database URI for a specific database.
- Parameters:
label (str, optional) – Database label, by default “default”
- Returns:
URI to the database
- Return type:
str
- initialize(instance_type, instance_name, system_folders=False, config_file=None, print_log_header=True)#
Initialize the AppContext instance.
- Parameters:
instance_type (str) – ‘server’ or ‘node’
instance_name (str) – Name of the configuration
system_folders (bool) – Use system folders rather than user folders
config_file (str) – Path to a specific config file. If left as None, OS specific folder will be used to find the configuration file specified by instance_name.
print_log_header (bool) – Print a banner to the log file.
- Return type:
None
- static instance_folders(instance_type, instance_name, system_folders)#
Log, data and config folders are always mounted. The node manager should take care of this.
- property log_file: Path#
Return the path to the log file.
- Returns:
Path to the log file
- Return type:
Path
- log_file_name(type_)#
Return a path to a log file for a given log file type
- Parameters:
type (str) – The type of log file to return.
- Returns:
The path to the log file.
- Return type:
Path
- Raises:
AssertionError – If the configuration manager is not initialized.
- print_log_header()#
Print the log file header.
- Return type:
None
- set_folders(instance_type, instance_name, system_folders)#
In case of the dockerized version we do not want to use user specified directories within the container.
- setup_logging()#
Setup a basic logging mechanism.
Exits if the log file can’t be created.
- Return type:
None
- static type_data_folder(system_folders=False)#
Obtain OS specific data folder where to store node specific data.
- Parameters:
system_folders (bool, optional) – System wide or user configuration
- Returns:
Path to the data folder
- Return type:
Path