8.5.2. vantage6.node.Node#
- class Node(ctx)#
Bases:
object
Authenticates to the central server, setup encryption, a websocket connection, retrieving task that were posted while offline, preparing dataset for usage and finally setup a local proxy server..
- Parameters:
ctx (NodeContext | DockerNodeContext) – Application context object.
- __init__(ctx)#
Methods
__init__
(ctx)Authenticate with the server using the api-key from the configuration file.
cleanup
()- rtype:
None
Create long-lasting websocket connection with the server.
get_task_and_add_to_queue
(task_id)Fetches (open) task with task_id from the server.
Initialization of the node
kill_containers
(kill_info)Kill containers on instruction from socket event
link_docker_services
()- rtype:
None
Get the path to the private key.
Keep checking queue for incoming tasks (and execute them).
Setup encryption for the node if it is part of an encrypted collaboration.
setup_squid_proxy
(isolated_network_mgr)Initiates a Squid proxy if configured in the config.yml
setup_ssh_tunnels
(isolated_network_mgr)Create a SSH tunnels when they are defined in the configuration file.
setup_vpn_connection
(isolated_network_mgr, ctx)Setup container which has a VPN connection
Share part of the node's configuration with the server.
Get all unprocessed tasks from the server for this node.
- authenticate()#
Authenticate with the server using the api-key from the configuration file. If the server rejects for any reason -other than a wrong API key- serveral attempts are taken to retry.
- Return type:
None
- connect_to_socket()#
Create long-lasting websocket connection with the server. The connection is used to receive status updates, such as new tasks.
- Return type:
None
- get_task_and_add_to_queue(task_id)#
Fetches (open) task with task_id from the server. The task_id is delivered by the websocket-connection.
- Parameters:
task_id (int) – Task identifier
- Return type:
None
- initialize()#
Initialization of the node
- Return type:
None
- kill_containers(kill_info)#
Kill containers on instruction from socket event
- Parameters:
kill_info (dict) – Dictionary received over websocket with instructions for which tasks to kill
- Returns:
List of dictionaries with information on killed task (keys: run_id, task_id and parent_id)
- Return type:
list[dict]
- private_key_filename()#
Get the path to the private key.
- Return type:
Path
- run_forever()#
Keep checking queue for incoming tasks (and execute them).
- Return type:
None
- setup_encryption()#
Setup encryption for the node if it is part of an encrypted collaboration.
This uses the private key file that is specified in the node configuration.
- Return type:
None
- setup_squid_proxy(isolated_network_mgr)#
Initiates a Squid proxy if configured in the config.yml
Expects the configuration in the following format:
whitelist: domains: - domain1 - domain2 ips: - ip1 - ip2 ports: - port1 - port2
- Parameters:
isolated_network_mgr (NetworkManager) – Network manager for isolated network
- Returns:
Squid proxy instance
- Return type:
Squid
- setup_ssh_tunnels(isolated_network_mgr)#
Create a SSH tunnels when they are defined in the configuration file. For each tunnel a new container is created. The image used can be specified in the configuration file as ssh-tunnel in the images section, else the default image is used.
- Parameters:
isolated_network_mgr (NetworkManager) – Manager for the isolated network
- Return type:
list
[SSHTunnel
]
- setup_vpn_connection(isolated_network_mgr, ctx)#
Setup container which has a VPN connection
- Parameters:
isolated_network_mgr (NetworkManager) – Manager for the isolated Docker network
ctx (DockerNodeContext | NodeContext) – Context object for the node
- Returns:
Manages the VPN connection
- Return type:
VPNManager
Share part of the node’s configuration with the server.
This helps the other parties in a collaboration to see e.g. which algorithms they are allowed to run on this node.
- Return type:
None
- sync_task_queue_with_server()#
Get all unprocessed tasks from the server for this node.
- Return type:
None