Skip to content

Commit 90dd52f

Browse files
Add patch
1 parent 01cc3aa commit 90dd52f

File tree

8 files changed

+192
-29
lines changed

8 files changed

+192
-29
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = ["setuptools>=61.0.0", "wheel"]
55
[project]
66
# Check https://setuptools.pypa.io/en/stable/userguide/quickstart.html for all available sections
77
name = "ansys-dpf-core"
8-
version = "0.13.8"
8+
version = "0.13.9"
99
description = "Data Processing Framework - Python Core "
1010
readme = "README.md"
1111
requires-python = ">=3.9, <4"

src/ansys/dpf/core/runtime_config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ def return_arrays(self):
137137
def return_arrays(self, value):
138138
self._data_tree.add(return_arrays=int(value))
139139

140+
@property
141+
def grpc_mode(self):
142+
return str(self._data_tree.get_as("grpc_mode", types.string))
143+
144+
@grpc_mode.setter
145+
def grpc_mode(self, value: str):
146+
self._data_tree.add(grpc_mode=str(value))
147+
148+
@property
149+
def grpc_certs_dir(self):
150+
return str(self._data_tree.get_as("grpc_certs_dir", types.string))
151+
152+
@grpc_certs_dir.setter
153+
def grpc_certs_dir(self, value: str):
154+
self._data_tree.add(grpc_certs_dir=str(value))
155+
140156
def copy_config(self, config):
141157
"""Add config to data tree."""
142158
config._data_tree.add(self._data_tree.to_dict())

src/ansys/dpf/core/server.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
CommunicationProtocols,
4646
ServerConfig,
4747
ServerFactory,
48+
GrpcMode
4849
)
4950
from ansys.dpf.core.server_types import DPF_DEFAULT_PORT, LOCALHOST, RUNNING_DOCKER, BaseServer
5051

@@ -252,6 +253,11 @@ def start_local_server(
252253
"ip" in server_init_signature.parameters.keys()
253254
and "port" in server_init_signature.parameters.keys()
254255
):
256+
grpc_mode=GrpcMode.mTLS
257+
certs_dir=""
258+
if config is not None:
259+
grpc_mode = config.grpc_mode
260+
certs_dir = config.certificates_dir
255261
server = server_type(
256262
ansys_path,
257263
ip,
@@ -263,6 +269,8 @@ def start_local_server(
263269
timeout=timeout,
264270
use_pypim=use_pypim,
265271
context=context,
272+
grpc_mode=grpc_mode,
273+
certificates_dir=certs_dir
266274
)
267275
else:
268276
server = server_type(
@@ -361,13 +369,20 @@ def connect():
361369
"ip" in server_init_signature.parameters.keys()
362370
and "port" in server_init_signature.parameters.keys()
363371
):
372+
grpc_mode=GrpcMode.mTLS
373+
certs_dir=""
374+
if config is not None:
375+
grpc_mode = config.grpc_mode
376+
certs_dir = config.certificates_dir
364377
server = server_type(
365378
ip=ip,
366379
port=port,
367380
as_global=as_global,
368381
launch_server=False,
369382
context=context,
370383
timeout=timeout,
384+
grpc_mode=grpc_mode,
385+
certificates_dir=certs_dir
371386
)
372387
else:
373388
server = server_type(as_global=as_global, context=context)

src/ansys/dpf/core/server_factory.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import subprocess
3434
import time
3535

36+
from pathlib import Path
37+
3638
from ansys.dpf.gate.load_api import (
3739
_find_outdated_ansys_version,
3840
_get_path_in_install,
@@ -54,9 +56,14 @@ class CommunicationProtocols:
5456
gRPC = "gRPC"
5557
InProcess = "InProcess"
5658

59+
class GrpcMode:
60+
Insecure = "insecure"
61+
mTLS = "mtls"
62+
5763

5864
DEFAULT_COMMUNICATION_PROTOCOL = CommunicationProtocols.InProcess
5965
DEFAULT_LEGACY = False
66+
DEFAULT_GRPC_MODE=GrpcMode.mTLS
6067

6168

6269
class DockerConfig:
@@ -297,13 +304,21 @@ def __init__(
297304
self,
298305
protocol: str = DEFAULT_COMMUNICATION_PROTOCOL,
299306
legacy: bool = DEFAULT_LEGACY,
307+
grpc_mode: str = DEFAULT_GRPC_MODE,
308+
certificates_dir: Path = None
300309
):
301310
self.legacy = legacy
302311
if not protocol:
303312
self.protocol = CommunicationProtocols.InProcess
304313
else:
305314
self.protocol = protocol
306315

316+
if not grpc_mode:
317+
self.grpc_mode = DEFAULT_GRPC_MODE
318+
else:
319+
self.grpc_mode = grpc_mode
320+
self.certificates_dir = certificates_dir
321+
307322
def __str__(self):
308323
"""Return a string representation of the ServerConfig instance.
309324
@@ -337,7 +352,12 @@ def __eq__(self, other: "ServerConfig"):
337352
True if the instances have the same protocol and legacy status, False otherwise.
338353
"""
339354
if isinstance(other, ServerConfig):
340-
return self.legacy == other.legacy and self.protocol == other.protocol
355+
return (
356+
self.legacy == other.legacy
357+
and self.protocol == other.protocol
358+
and self.grpc_mode == other.grpc_mode
359+
and self.certificates_dir == other.certificates_dir
360+
)
341361
return False
342362

343363
def __ne__(self, other):
@@ -453,6 +473,8 @@ class AvailableServerConfigs:
453473
LegacyGrpcServer = ServerConfig(CommunicationProtocols.gRPC, legacy=True)
454474
InProcessServer = ServerConfig(CommunicationProtocols.InProcess, legacy=False)
455475
GrpcServer = ServerConfig(CommunicationProtocols.gRPC, legacy=False)
476+
InsecureGrpcServer = ServerConfig(CommunicationProtocols.gRPC, legacy=False, grpc_mode=GrpcMode.Insecure)
477+
InsecureLegacyGrpcServer = ServerConfig(CommunicationProtocols.gRPC, legacy=True, grpc_mode=GrpcMode.Insecure)
456478

457479

458480
class RunningDockerConfig:

0 commit comments

Comments
 (0)