Allow ClusterNode.__init__ with missing services

Not all component test environments will provide full set of services.
It's ok for gateways and even storage nodes to be completely missing.

Signed-off-by: Vitaliy Potyarkin <v.potyarkin@yadro.com>
This commit is contained in:
Vitaliy Potyarkin 2025-05-06 16:55:24 +03:00
parent 9261d46ed5
commit 1fbd7b7de1

View file

@ -161,17 +161,24 @@ class Cluster:
This class represents a Cluster object for the whole storage based on provided hosting This class represents a Cluster object for the whole storage based on provided hosting
""" """
default_rpc_endpoint: str default_rpc_endpoint: str = "not deployed"
default_s3_gate_endpoint: str default_s3_gate_endpoint: str = "not deployed"
default_http_gate_endpoint: str default_http_gate_endpoint: str = "not deployed"
def __init__(self, hosting: Hosting) -> None: def __init__(self, hosting: Hosting) -> None:
self._hosting = hosting self._hosting = hosting
self.class_registry = get_service_registry() self.class_registry = get_service_registry()
self.default_rpc_endpoint = self.services(StorageNode)[0].get_rpc_endpoint()
self.default_s3_gate_endpoint = self.services(S3Gate)[0].get_endpoint() storage = self.services(StorageNode)
self.default_http_gate_endpoint = self.services(HTTPGate)[0].get_endpoint() if storage:
self.default_rpc_endpoint = storage[0].get_rpc_endpoint()
s3gate = self.services(S3Gate)
if s3gate:
self.default_s3_gate_endpoint = s3gate[0].get_endpoint()
http_gate = self.services(HTTPGate)
if http_gate:
self.default_http_gate_endpoint = http_gate[0].get_endpoint()
@property @property
def hosts(self) -> list[Host]: def hosts(self) -> list[Host]: