SIENTIAPDE-1325

SIENTIAPDE-1325 Add OPC server name configuration and update repository handling

- Introduced a new environment variable `OPC_SERVER_NAME` in values.yaml with a default value.
- Updated the OPC class to include `server_name` when initializing OpcRepository.
- Enhanced the configuration builder to retrieve `OPC_SERVER_NAME` from the environment.
- Adjusted OpcRepository to store and utilize the `server_name` for metric emissions.
This commit is contained in:
vitor-aignosi
2025-11-07 09:20:48 -03:00
parent 2245baae62
commit 8d402fb156
4 changed files with 7 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ class OPC(SientiaMonitoring):
for opc_id, server in self.opc_servers.items(): for opc_id, server in self.opc_servers.items():
self.opc_repository[opc_id] = OpcRepository( self.opc_repository[opc_id] = OpcRepository(
opc_id=server['id'], opc_id=server['id'],
server_name=server['server_name'],
url=server['url'], url=server['url'],
logger=self.logger, logger=self.logger,
server_uri=server['server_uri'], server_uri=server['server_uri'],

View File

@@ -88,6 +88,7 @@ def build_opc_config() -> dict[str, Any]:
return { return {
getenv('OPC_ID', '1'): { getenv('OPC_ID', '1'): {
'id': getenv('OPC_ID', '1'), 'id': getenv('OPC_ID', '1'),
'server_name': getenv('OPC_SERVER_NAME', 'default_server'),
'url': getenv('OPC_URL', 'opc.tcp://localhost:4840'), 'url': getenv('OPC_URL', 'opc.tcp://localhost:4840'),
'server_uri': getenv('OPC_SERVER_URI', 'opc.tcp://localhost:4840'), 'server_uri': getenv('OPC_SERVER_URI', 'opc.tcp://localhost:4840'),
'cert_path': getenv('OPC_CERT_PATH', None), 'cert_path': getenv('OPC_CERT_PATH', None),

View File

@@ -46,6 +46,7 @@ class OpcRepository(SientiaMonitoring):
self, self,
opc_id: str, opc_id: str,
url: str, url: str,
server_name: str,
logger: Logger, logger: Logger,
notification_handler: NotificationHandler, notification_handler: NotificationHandler,
metrics_controller: MetricsController, metrics_controller: MetricsController,
@@ -57,6 +58,7 @@ class OpcRepository(SientiaMonitoring):
): ):
self.url = url self.url = url
self.id = opc_id self.id = opc_id
self.server_name = server_name
self.server_uri = server_uri self.server_uri = server_uri
self.cert_path = cert_path self.cert_path = cert_path
self.private_key_path = private_key_path self.private_key_path = private_key_path
@@ -172,7 +174,7 @@ class OpcRepository(SientiaMonitoring):
tags = { tags = {
'pod_id': self.pod_id, 'pod_id': self.pod_id,
'opc_server_id': self.id, 'server_name': self.server_name,
} }
await self.emit_metric( await self.emit_metric(

View File

@@ -182,6 +182,8 @@ env:
- name: OPC_ID - name: OPC_ID
value: "1" value: "1"
- name: OPC_SERVER_NAME
value: "default_server"
- name: OPC_URL - name: OPC_URL
value: "opc.tcp://sientia-opc-simulator-opc.sientia.svc.cluster.local:4840" value: "opc.tcp://sientia-opc-simulator-opc.sientia.svc.cluster.local:4840"