Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions OMPython/OMCSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,17 @@ def __del__(self):
self._omc_process = None

def get_port(self) -> Optional[str]:
"""
Get the port to connect to the OMC process.
"""
if not isinstance(self._omc_port, str):
raise OMCSessionException(f"Invalid port to connect to OMC process: {self._omc_port}")
return self._omc_port

def get_log(self) -> str:
"""
Get the log file content of the OMC session.
"""
if self._omc_loghandle is None:
raise OMCSessionException("Log file not available!")

Expand All @@ -509,6 +515,9 @@ def _get_portfile_path(self) -> Optional[pathlib.Path]:


class OMCProcessPort(OMCProcess):
"""
OMCProcess implementation which uses a port to connect to an already running OMC server.
"""

def __init__(
self,
Expand All @@ -519,6 +528,9 @@ def __init__(


class OMCProcessLocal(OMCProcess):
"""
OMCProcess implementation which runs the OMC server locally on the machine (Linux / Windows).
"""

def __init__(
self,
Expand Down Expand Up @@ -600,6 +612,9 @@ def _omc_port_get(self) -> str:


class OMCProcessDockerHelper(OMCProcess):
"""
Base class for OMCProcess implementations which run the OMC server in a Docker container.
"""

def __init__(
self,
Expand Down Expand Up @@ -692,20 +707,29 @@ def _omc_port_get(self) -> str:
return port

def get_server_address(self) -> Optional[str]:
"""
Get the server address of the OMC server running in a Docker container.
"""
if self._dockerNetwork == "separate" and isinstance(self._dockerCid, str):
output = subprocess.check_output(["docker", "inspect", self._dockerCid]).decode().strip()
return json.loads(output)[0]["NetworkSettings"]["IPAddress"]

return None

def get_docker_container_id(self) -> str:
"""
Get the Docker container ID of the Docker container with the OMC server.
"""
if not isinstance(self._dockerCid, str):
raise OMCSessionException(f"Invalid docker container ID: {self._dockerCid}!")

return self._dockerCid


class OMCProcessDocker(OMCProcessDockerHelper):
"""
OMC process running in a Docker container.
"""

def __init__(
self,
Expand Down Expand Up @@ -846,6 +870,9 @@ def _docker_omc_start(self) -> Tuple[subprocess.Popen, DummyPopen, str]:


class OMCProcessDockerContainer(OMCProcessDockerHelper):
"""
OMC process running in a Docker container (by container ID).
"""

def __init__(
self,
Expand Down Expand Up @@ -936,6 +963,9 @@ def _docker_omc_start(self) -> Tuple[subprocess.Popen, DummyPopen]:


class OMCProcessWSL(OMCProcess):
"""
OMC process running in Windows Subsystem for Linux (WSL).
"""

def __init__(
self,
Expand Down
Loading