rtems-proxy 1.3.0b4__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/Dockerfile +1 -0
  2. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/PKG-INFO +1 -1
  3. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/rtems-proxy.code-workspace +3 -0
  4. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/__main__.py +16 -7
  5. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/_version.py +3 -3
  6. rtems_proxy-2.0.0/src/rtems_proxy/configure.py +91 -0
  7. rtems_proxy-2.0.0/src/rtems_proxy/copy.py +75 -0
  8. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/globals.py +60 -29
  9. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/trace.py +1 -1
  10. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy.egg-info/PKG-INFO +1 -1
  11. rtems_proxy-1.3.0b4/src/rtems_proxy/configure.py +0 -89
  12. rtems_proxy-1.3.0b4/src/rtems_proxy/copy.py +0 -44
  13. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.copier-answers.yml +0 -0
  14. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.devcontainer/devcontainer.json +0 -0
  15. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/CONTRIBUTING.md +0 -0
  16. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  17. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/ISSUE_TEMPLATE/issue.md +0 -0
  18. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -0
  19. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/copilot-instructions.md +0 -0
  20. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/pages/index.html +0 -0
  21. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/pages/make_switcher.py +0 -0
  22. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/_container.yml +0 -0
  23. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/_dist.yml +0 -0
  24. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/_pypi.yml +0 -0
  25. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/_release.yml +0 -0
  26. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/_test.yml +0 -0
  27. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/_tox.yml +0 -0
  28. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.github/workflows/ci.yml +0 -0
  29. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.gitignore +0 -0
  30. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.gitleaks.toml +0 -0
  31. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.pre-commit-config.yaml +0 -0
  32. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.python-version +0 -0
  33. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.vscode/extensions.json +0 -0
  34. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.vscode/launch.json +0 -0
  35. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.vscode/settings.json +0 -0
  36. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/.vscode/tasks.json +0 -0
  37. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/LICENSE +0 -0
  38. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/README.md +0 -0
  39. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/pyproject.toml +0 -0
  40. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/renovate.json +0 -0
  41. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/requirements.txt +0 -0
  42. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/setup.cfg +0 -0
  43. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/__init__.py +0 -0
  44. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/rsync.sh.jinja +0 -0
  45. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/telnet.py +0 -0
  46. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy/utils.py +0 -0
  47. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy.egg-info/SOURCES.txt +0 -0
  48. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy.egg-info/dependency_links.txt +0 -0
  49. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy.egg-info/entry_points.txt +0 -0
  50. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy.egg-info/requires.txt +0 -0
  51. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/src/rtems_proxy.egg-info/top_level.txt +0 -0
  52. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/tests/conftest.py +0 -0
  53. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/tests/test_cli.py +0 -0
  54. {rtems_proxy-1.3.0b4 → rtems_proxy-2.0.0}/uv.lock +0 -0
@@ -5,6 +5,7 @@ FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer
5
5
  # Add any system dependencies for the developer/build environment here
6
6
  RUN apt-get update -y && apt-get install -y --no-install-recommends \
7
7
  rsync \
8
+ telnet \
8
9
  && apt-get dist-clean
9
10
 
10
11
  # The build stage installs the context into the venv
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rtems-proxy
3
- Version: 1.3.0b4
3
+ Version: 2.0.0
4
4
  Summary: Support for a K8S proxy container in controlling and monitoring RTEMS EPICS IOCs
5
5
  Author-email: Giles Knap <giles.knap@diamond.ac.uk>
6
6
  License: Apache License
@@ -8,6 +8,9 @@
8
8
  },
9
9
  {
10
10
  "path": "../i04-services"
11
+ },
12
+ {
13
+ "path": "../rf-services"
11
14
  }
12
15
  ],
13
16
  "settings": {}
@@ -172,6 +172,9 @@ def configure(
172
172
  attach: bool = typer.Option(
173
173
  False, help="attach to the IOC console after configuration"
174
174
  ),
175
+ dry_run: bool = typer.Option(
176
+ False, help="print the configuration commands without applying them"
177
+ ),
175
178
  use_console: bool = typer.Option(
176
179
  False, help="use conserver console instead of telnet"
177
180
  ),
@@ -180,13 +183,19 @@ def configure(
180
183
  Configure the RTEMS IOC boot parameters
181
184
  """
182
185
 
183
- assert GLOBALS.RTEMS_CONSOLE, "No RTEMS console defined"
184
- telnet = motboot_connect(GLOBALS.RTEMS_CONSOLE, use_console=use_console)
185
- config = Configure(telnet, debug)
186
- config.apply_settings()
187
- telnet.close()
188
- if attach:
189
- run_command(telnet.command)
186
+ if dry_run:
187
+ config = Configure(None, debug=debug, dry_run=True)
188
+ config.apply_settings()
189
+ else:
190
+ assert GLOBALS.RTEMS_CONSOLE, "No RTEMS console defined"
191
+
192
+ config = Configure(None, debug=debug)
193
+ telnet = motboot_connect(GLOBALS.RTEMS_CONSOLE, use_console=use_console)
194
+ config = Configure(telnet, debug=debug, dry_run=dry_run)
195
+ config.apply_settings()
196
+ telnet.close()
197
+ if attach:
198
+ run_command(telnet.command)
190
199
 
191
200
 
192
201
  @cli.command()
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '1.3.0b4'
32
- __version_tuple__ = version_tuple = (1, 3, 0, 'b4')
31
+ __version__ = version = '2.0.0'
32
+ __version_tuple__ = version_tuple = (2, 0, 0)
33
33
 
34
- __commit_id__ = commit_id = 'gbe0562251'
34
+ __commit_id__ = commit_id = 'g9b4243c59'
@@ -0,0 +1,91 @@
1
+ """
2
+ Class to apply MOTBoot configuration to a VME crate.
3
+ """
4
+
5
+ from time import sleep
6
+
7
+ from .globals import GLOBALS
8
+ from .telnet import TelnetRTEMS
9
+
10
+
11
+ class Configure:
12
+ def __init__(
13
+ self, telnet: TelnetRTEMS | None, debug: bool = False, dry_run: bool = False
14
+ ):
15
+ self.telnet = telnet
16
+ self.debug = debug
17
+ self.dry_run = dry_run
18
+ if dry_run:
19
+ self.cr = "\n "
20
+ else:
21
+ self.cr = "\r"
22
+
23
+ def apply_nvm(self, variable: str, value: str | None):
24
+ if self.dry_run:
25
+ print(f"{variable}={value}")
26
+ return
27
+
28
+ assert self.telnet is not None, (
29
+ "Telnet connection is required to apply settings"
30
+ )
31
+ if value is None or value == "":
32
+ self.telnet.sendline(f"gevDel {variable}")
33
+ self.telnet.expect(r"\?")
34
+ self.telnet.sendline("Y")
35
+ else:
36
+ self.telnet.sendline(f"gevE {variable}")
37
+ self.telnet.expect(r"\(Blank line terminates input.\)")
38
+ self.telnet.sendline(value or "")
39
+ self.telnet.sendline("")
40
+ self.telnet.expect(r"\?")
41
+ self.telnet.sendline("Y")
42
+
43
+ def apply_settings(self):
44
+ if not self.dry_run:
45
+ for v in [
46
+ GLOBALS.RTEMS_IOC_NETMASK,
47
+ GLOBALS.RTEMS_IOC_GATEWAY,
48
+ GLOBALS.RTEMS_IOC_IP,
49
+ GLOBALS.RTEMS_NFS_IP,
50
+ GLOBALS.RTEMS_TFTP_IP,
51
+ ]:
52
+ if v is None or v == "":
53
+ raise ValueError(
54
+ "RTEMS_IOC_NETMASK, RTEMS_IOC_GATEWAY, RTEMS_IOC_IP, "
55
+ "RTEMS_NFS_IP, and RTEMS_TFTP_IP must be set"
56
+ )
57
+
58
+ mot_boot = (
59
+ f"dla=malloc 0x4000000{self.cr}"
60
+ f"tftpGet -d/dev/enet1"
61
+ f" -f{GLOBALS.RTEMS_EPICS_BINARY}"
62
+ f" -m{GLOBALS.RTEMS_IOC_NETMASK}"
63
+ f" -g{GLOBALS.RTEMS_IOC_GATEWAY}"
64
+ f" -s{GLOBALS.RTEMS_TFTP_IP}"
65
+ f" -c{GLOBALS.RTEMS_IOC_IP}"
66
+ f" -adla -r3 -v{self.cr}"
67
+ f"go -a04000000{self.cr}"
68
+ f"reset"
69
+ )
70
+
71
+ self.apply_nvm("mot-/dev/enet0-cipa", GLOBALS.RTEMS_IOC_IP)
72
+ self.apply_nvm("mot-/dev/enet0-snma", GLOBALS.RTEMS_IOC_NETMASK)
73
+ self.apply_nvm("mot-/dev/enet0-gipa", GLOBALS.RTEMS_IOC_GATEWAY)
74
+ self.apply_nvm("mot-/dev/enet0-sipa", GLOBALS.RTEMS_NFS_IP)
75
+ self.apply_nvm("mot-boot-device", "/dev/em1")
76
+ self.apply_nvm("mot-script-boot", mot_boot)
77
+ self.apply_nvm("rtems-client-name", GLOBALS.IOC_NAME)
78
+ self.apply_nvm("epics-script", GLOBALS.RTEMS_EPICS_SCRIPT)
79
+
80
+ if GLOBALS.RTEMS_EPICS_NFS_MOUNT:
81
+ self.apply_nvm(
82
+ "epics-nfsmount",
83
+ f"{GLOBALS.RTEMS_NFS_IP}:"
84
+ f"{GLOBALS.RTEMS_EPICS_NFS_MOUNT}/{GLOBALS.IOC_NAME.lower()}:"
85
+ f"{GLOBALS.RTEMS_NFS_ROOT_PATH}",
86
+ )
87
+
88
+ if GLOBALS.RTEMS_EPICS_NTP_SERVER:
89
+ self.apply_nvm("epics-ntpserver", GLOBALS.RTEMS_EPICS_NTP_SERVER)
90
+
91
+ sleep(1)
@@ -0,0 +1,75 @@
1
+ """
2
+ functions for moving IOC assets into position for a remote IOC to access
3
+ """
4
+
5
+ import os
6
+ import subprocess
7
+ from pathlib import Path
8
+
9
+ from .globals import GLOBALS
10
+
11
+
12
+ def copy_rtems(debug: bool = False):
13
+ """
14
+ Copy RTEMS IOC binary and startup assets to a location where the RTEMS IOC
15
+ can access them
16
+ """
17
+
18
+ # TODO - this function is currently specific to legacy built IOCs
19
+ # TODO - once IOCs are built in containers review this function to make it
20
+ # TODO work for both legacy and container built IOCs (it might just work?)
21
+
22
+ # these represent where the rtems-proxy container mounts the IOC NFS and TFTP
23
+ # shares
24
+ local_tftp_root = GLOBALS.RTEMS_TFTP_ROOT_PATH
25
+ local_nfs_root = f"{GLOBALS.RTEMS_NFS_ROOT_PATH}"
26
+
27
+ sts = list(Path(GLOBALS.IOC_ORIGINAL_LOCATION).glob("bin/RTEMS-beatnik/st*"))
28
+ if len(sts) == 0:
29
+ raise FileNotFoundError(
30
+ f"No RTEMS startup script found at "
31
+ f"{GLOBALS.IOC_ORIGINAL_LOCATION}/bin/RTEMS-beatnik/st*"
32
+ )
33
+ ioc_script_name = sts[0].name
34
+
35
+ # copy the IOC runtime files to the NFS root
36
+ os.chdir(GLOBALS.IOC_ORIGINAL_LOCATION)
37
+ subprocess.run(
38
+ [
39
+ "rsync",
40
+ "--delete",
41
+ "-r",
42
+ "data",
43
+ "db",
44
+ "dbd",
45
+ f"bin/RTEMS-beatnik/{ioc_script_name}",
46
+ f"{local_nfs_root}",
47
+ ],
48
+ check=True,
49
+ )
50
+
51
+ # symlink the ioc startup script to a fixed name 'st.cmd'
52
+ ioc_script_path = Path(local_nfs_root) / GLOBALS.RTEMS_SCRIPT_DEFAULT_NAME
53
+ ioc_script_path.unlink(missing_ok=True)
54
+ ioc_script_path.symlink_to(Path(local_nfs_root) / ioc_script_name)
55
+
56
+ # TODO for container built IOCs the name will be ioc or ioc.boot
57
+ if debug:
58
+ ioc_bin = GLOBALS.IOC_NAME.upper()
59
+ else:
60
+ ioc_bin = f"{GLOBALS.IOC_NAME.upper()}.boot"
61
+
62
+ # copy the .boot files to the TFTP root
63
+ subprocess.run(
64
+ [
65
+ "rsync",
66
+ f"bin/RTEMS-beatnik/{ioc_bin}",
67
+ f"{local_tftp_root}",
68
+ ],
69
+ check=True,
70
+ )
71
+
72
+ # move the ioc_bin to a fixed name 'rtems.ioc.bin' in the TFTP root
73
+ tftp_ioc_boot = Path(local_tftp_root) / GLOBALS.RTEMS_BINARY_DEFAULT_NAME
74
+ tftp_ioc_boot.unlink(missing_ok=True)
75
+ (Path(local_tftp_root) / ioc_bin).rename(tftp_ioc_boot)
@@ -12,31 +12,21 @@ class _Globals:
12
12
  """Helper class for accessing global constants."""
13
13
 
14
14
  def __init__(self) -> None:
15
- self.EPICS_ROOT = Path(os.getenv("EPICS_ROOT", "/epics/"))
16
- """Root of epics directory tree"""
17
-
18
- self.SUPPORT = Path(os.getenv("SUPPORT", self.EPICS_ROOT / "support"))
19
- """ The root folder for support modules """
20
-
21
- self.RUNTIME = self.EPICS_ROOT / "runtime"
22
-
23
- self.EPICS_HOST_ARCH = os.getenv("EPICS_HOST_ARCH", DEFAULT_ARCH)
24
- """ Host architecture """
25
-
26
- self.EPICS_TARGET_ARCH = os.getenv("EPICS_TARGET_ARCH", DEFAULT_ARCH)
27
- """ Cross compilation target architecture """
28
-
29
- self.IOC = Path(os.getenv("IOC", self.EPICS_ROOT / "ioc"))
30
- """ The root folder for IOC source and binaries """
15
+ ########################################################################
16
+ ## Constants
17
+ ########################################################################
31
18
 
32
- # TODO in future, shall we drop the RTEMS prefix and make this module
33
- # generic?
19
+ self.RTEMS_BINARY_DEFAULT_NAME = "rtems.ioc.bin"
20
+ self.RTEMS_SCRIPT_DEFAULT_NAME = "st.cmd"
34
21
 
35
- self.RTEMS_TFTP_PATH = Path(os.getenv("RTEMS_TFTP_PATH", "/nfsv2-tftp"))
22
+ self.RTEMS_TFTP_ROOT_PATH = Path("/ioc_tftp")
36
23
  """ root folder of a mounted PVC in which to place IOC binaries """
24
+ self.RTEMS_NFS_ROOT_PATH = Path("/ioc_nfs")
25
+ """ root folder of a mounted NFS folder in which to place IOC binaries """
37
26
 
38
- self.RTEMS_IOC_IP = os.getenv("RTEMS_IOC_IP")
39
- """ address of the real RTEMS IOC hardware """
27
+ ########################################################################
28
+ ## Beamline level config from global.env in services/values.yaml
29
+ ########################################################################
40
30
 
41
31
  self.RTEMS_IOC_GATEWAY = os.getenv("RTEMS_IOC_GATEWAY")
42
32
  """ gateway address for the RTEMS IOC hardware """
@@ -50,26 +40,67 @@ class _Globals:
50
40
  self.RTEMS_TFTP_IP = os.getenv("RTEMS_TFTP_IP")
51
41
  """ address of a TFTP server that the RTEMS IOC can access """
52
42
 
43
+ self.RTEMS_EPICS_NTP_SERVER = os.getenv("RTEMS_EPICS_NTP_SERVER")
44
+ """ ip address for the ntp server """
45
+
46
+ self.RTEMS_EPICS_NFS_MOUNT = os.getenv("RTEMS_EPICS_NFS_MOUNT")
47
+ """ NFS mount point for the EPICS IOC """
48
+
49
+ ########################################################################
50
+ ## IOC config from ioc-instance.env in services/ioc_name/values.yaml
51
+ ########################################################################
52
+
53
+ self.RTEMS_IOC_IP = os.getenv("RTEMS_IOC_IP")
54
+ """ address of the real RTEMS IOC hardware """
55
+
53
56
  self.RTEMS_CONSOLE = os.getenv("RTEMS_CONSOLE")
54
57
  """ address:port to connect to the IOC console """
55
58
 
59
+ ########################################################################
60
+ ## IOC config with defaults supplied by the helm chart
61
+ ########################################################################
62
+
56
63
  self.IOC_NAME = os.getenv("IOC_NAME", "NO_IOC_NAME")
57
- """ the name of this IOC """
64
+ """ the lowercase name of this IOC """
58
65
 
59
66
  self.IOC_GROUP = os.getenv("IOC_GROUP", "NO_IOC_GROUP")
60
67
  """ the name of the repository that this IOC is grouped into """
61
68
 
62
- self.RTEMS_EPICS_SCRIPT = os.getenv("RTEMS_EPICS_SCRIPT")
69
+ ########################################################################
70
+ ## IOC config with defaults supplied here
71
+ ########################################################################
72
+
73
+ self.RTEMS_EPICS_SCRIPT = os.getenv("RTEMS_EPICS_SCRIPT", "/ioc_nfs/st.cmd")
63
74
  """ override for the EPICS startup script """
64
75
 
65
- self.RTEMS_EPICS_BINARY = os.getenv("RTEMS_EPICS_BINARY")
66
- """ override for the EPICS binary """
76
+ self.RTEMS_EPICS_BINARY = os.getenv(
77
+ "RTEMS_EPICS_BINARY",
78
+ f"/iocs/{self.IOC_NAME.lower()}/{self.RTEMS_BINARY_DEFAULT_NAME}",
79
+ )
80
+ """ override for the EPICS binary TFTP path """
67
81
 
68
- self.RTEMS_EPICS_NTP_SERVER = os.getenv("RTEMS_EPICS_NTP_SERVER")
69
- """ ip address for the ntp server """
82
+ ########################################################################
83
+ ## The remaining values relate to IOCs built inside containers
84
+ ########################################################################
70
85
 
71
- self.RTEMS_EPICS_NFS_MOUNT = os.getenv("RTEMS_EPICS_NFS_MOUNT")
72
- """ NFS mount point for the EPICS IOC """
86
+ self.EPICS_ROOT = Path(os.getenv("EPICS_ROOT", "/epics/"))
87
+ """Root of epics directory tree"""
88
+
89
+ self.SUPPORT = Path(os.getenv("SUPPORT", self.EPICS_ROOT / "support"))
90
+ """ The root folder for support modules """
91
+
92
+ self.RUNTIME = self.EPICS_ROOT / "runtime"
93
+
94
+ self.EPICS_HOST_ARCH = os.getenv("EPICS_HOST_ARCH", DEFAULT_ARCH)
95
+ """ Host architecture """
96
+
97
+ self.EPICS_TARGET_ARCH = os.getenv("EPICS_TARGET_ARCH", DEFAULT_ARCH)
98
+ """ Cross compilation target architecture """
99
+
100
+ self.IOC_ORIGINAL_LOCATION = Path(
101
+ os.getenv("IOC_ORIGINAL_LOCATION", self.EPICS_ROOT / "ioc")
102
+ )
103
+ """ The root folder for IOC source and binaries """
73
104
 
74
105
 
75
106
  GLOBALS = _Globals()
@@ -9,7 +9,7 @@ from .utils import run_command
9
9
 
10
10
  IP = re.compile(r"Stack Trace:\n *IP: *(0x[0-9a-f]*)")
11
11
  STACK = re.compile(r"--\^ (0x[0-9a-f]*)")
12
- symbols = GLOBALS.IOC / "bin" / "RTEMS-beatnik" / "ioc"
12
+ symbols = GLOBALS.IOC_ORIGINAL_LOCATION / "bin" / "RTEMS-beatnik" / "ioc"
13
13
 
14
14
 
15
15
  def parse_stack_trace(trace: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rtems-proxy
3
- Version: 1.3.0b4
3
+ Version: 2.0.0
4
4
  Summary: Support for a K8S proxy container in controlling and monitoring RTEMS EPICS IOCs
5
5
  Author-email: Giles Knap <giles.knap@diamond.ac.uk>
6
6
  License: Apache License
@@ -1,89 +0,0 @@
1
- """
2
- Class to apply MOTBoot configuration to a VME crate.
3
- """
4
-
5
- from time import sleep
6
-
7
- from .globals import GLOBALS
8
- from .telnet import TelnetRTEMS
9
-
10
-
11
- class Configure:
12
- def __init__(self, telnet: TelnetRTEMS, debug: bool = False):
13
- self.telnet = telnet
14
- self.debug = debug
15
-
16
- def apply_nvm(self, variable: str, value: str):
17
- self.telnet.sendline(f"gevE {variable}")
18
- self.telnet.expect(r"\(Blank line terminates input.\)")
19
- self.telnet.sendline(value + "\r")
20
- self.telnet.sendline("\r")
21
- self.telnet.expect(r"\?")
22
- self.telnet.sendline("Y\r")
23
-
24
- def apply_settings(self):
25
- for v in [
26
- GLOBALS.RTEMS_IOC_NETMASK,
27
- GLOBALS.RTEMS_IOC_GATEWAY,
28
- GLOBALS.RTEMS_IOC_IP,
29
- GLOBALS.RTEMS_NFS_IP,
30
- GLOBALS.RTEMS_TFTP_IP,
31
- ]:
32
- if v is None or v == "":
33
- raise ValueError(
34
- "RTEMS_IOC_NETMASK, RTEMS_IOC_GATEWAY, RTEMS_IOC_IP, "
35
- "RTEMS_NFS_IP, and RTEMS_TFTP_IP must be set"
36
- )
37
-
38
- ioc_bin = "ioc" if self.debug else "ioc.boot"
39
-
40
- if GLOBALS.RTEMS_EPICS_NFS_MOUNT:
41
- nfs_mount = GLOBALS.RTEMS_EPICS_NFS_MOUNT
42
- else:
43
- nfs_mount = f"{GLOBALS.RTEMS_NFS_IP}:/iocs/{GLOBALS.IOC_NAME}:/epics"
44
-
45
- if GLOBALS.RTEMS_EPICS_SCRIPT:
46
- epics_script = GLOBALS.RTEMS_EPICS_SCRIPT
47
- else:
48
- epics_script = "/epics/runtime/st.cmd"
49
-
50
- if GLOBALS.RTEMS_EPICS_BINARY:
51
- epics_binary = GLOBALS.RTEMS_EPICS_BINARY
52
- else:
53
- epics_binary = f"{GLOBALS.IOC_NAME.lower()}/ioc/bin/RTEMS-beatnik/{ioc_bin}"
54
-
55
- mot_boot = (
56
- f"dla=malloc 0x4000000\r"
57
- f"tftpGet -d/dev/enet1"
58
- f" -f{epics_binary}"
59
- f" -m{GLOBALS.RTEMS_IOC_NETMASK}"
60
- f" -g{GLOBALS.RTEMS_IOC_GATEWAY}"
61
- f" -s{GLOBALS.RTEMS_TFTP_IP}"
62
- f" -c{GLOBALS.RTEMS_IOC_IP}"
63
- f" -adla -r3 -v\r"
64
- f"go -a04000000\r"
65
- f"reset"
66
- )
67
-
68
- if GLOBALS.RTEMS_EPICS_NTP_SERVER:
69
- self.apply_nvm("epics-ntpserver", GLOBALS.RTEMS_EPICS_NTP_SERVER)
70
-
71
- # These checks were performed above, so we can safely assert non-None
72
- assert GLOBALS.RTEMS_IOC_NETMASK is not None
73
- assert GLOBALS.RTEMS_IOC_GATEWAY is not None
74
- assert GLOBALS.RTEMS_NFS_IP is not None
75
- assert GLOBALS.RTEMS_IOC_IP is not None
76
-
77
- self.apply_nvm("mot-/dev/enet0-snma", GLOBALS.RTEMS_IOC_NETMASK)
78
- self.apply_nvm("mot-/dev/enet0-gipa", GLOBALS.RTEMS_IOC_GATEWAY)
79
- self.apply_nvm("mot-/dev/enet0-sipa", GLOBALS.RTEMS_NFS_IP)
80
- self.apply_nvm("mot-/dev/enet0-cipa", GLOBALS.RTEMS_IOC_IP)
81
- self.apply_nvm("mot-boot-device", "/dev/em1")
82
- self.apply_nvm("mot-script-boot", mot_boot)
83
- self.apply_nvm("rtems-client-name", GLOBALS.IOC_NAME)
84
- self.apply_nvm("epics-script", epics_script)
85
- self.apply_nvm("epics-nfsmount", nfs_mount)
86
- # self.apply_nvm_variable("epics-ntpserver", "EPICS_TS_NTP_INET")
87
- self.apply_nvm("mot-/dev/enet0-snma", GLOBALS.RTEMS_IOC_NETMASK)
88
-
89
- sleep(1)
@@ -1,44 +0,0 @@
1
- """
2
- functions for moving IOC assets into position for a remote IOC to access
3
- """
4
-
5
- import shutil
6
-
7
- from .globals import GLOBALS
8
-
9
-
10
- def copy_rtems():
11
- """
12
- Copy RTEMS IOC binary and startup assets to a location where the RTEMS IOC
13
- can access them
14
-
15
- IMPORTANT: local_root and nfs_root are different perspectives on the same
16
- folder.
17
- local_root: where the IOC files will be placed from the
18
- perspective of this IOC proxy service. This IOC proxy will
19
- populate the folder for use by the RTEMS crate.
20
- nfs_root: where the IOC files will be found from the perspective of a
21
- a client to the nfsv2-tftp service. i.e. where the RTEMS crate
22
- will look for them using NFS.
23
- """
24
- local_root = GLOBALS.RTEMS_TFTP_PATH
25
-
26
- # where to copy the Generic IOC folder to. This will contain the IOC binary
27
- # and the files
28
- dest_ioc = local_root / "ioc"
29
- # where to copy the generated runtime assets to. This will contain
30
- # st.cmd and ioc.db
31
- dest_runtime = local_root / "runtime"
32
-
33
- # make sure all files are writable - by default some products are read-only
34
- for folder in [dest_ioc, dest_runtime]:
35
- for file in folder.glob("**/*"):
36
- file.chmod(0o666)
37
-
38
- # copy all the files needed for runtime into the PVC that is being shared
39
- # over nfs/tftp by the nfsv2-tftp service
40
- for folder in ["bin", "dbd"]:
41
- shutil.copytree(
42
- GLOBALS.IOC.readlink() / folder, dest_ioc / folder, dirs_exist_ok=True
43
- )
44
- shutil.copytree(GLOBALS.RUNTIME, dest_runtime, dirs_exist_ok=True)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes