Skip to content

Commit

Permalink
rfc: replace zerorpc with pyro4
Browse files Browse the repository at this point in the history
pyro4 is almost a dropin replacement for zerorpc (at least from a usage
perspective). Further testing (fixing) is needed before we move forward.

Signed-off-by: Cedric Hombourger <[email protected]>
  • Loading branch information
chombourger committed Jan 7, 2025
1 parent cac7345 commit 2c1202d
Show file tree
Hide file tree
Showing 21 changed files with 65 additions and 266 deletions.
8 changes: 0 additions & 8 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ Files: meta-isar/recipes-python/qt5/files/py3qterm-0.4/debian/*
Copyright: 2025 Siemens AG
License: MIT

Files: meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/*
Copyright: 2025 Siemens AG
License: MIT

Files: meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/*
Copyright: 2025 Siemens AG
License: MIT

Files: meta-isar/recipes-bsp/rpi-firmware/files/*
Copyright: 2025 Siemens AG
License: MIT
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Package: mtda-common
Architecture: all
Multi-Arch: foreign
Depends: python3:any (>= 3.7~),
python3-zerorpc
python3-pyro4
Description: common modules for Multi-Tenant Device Access
Modules shared between the service and the client.

Expand Down
1 change: 0 additions & 1 deletion debian/py3dist-overrides
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
kconfiglib python3-kconfiglib
requests python3-requests
zerorpc python3-zerorpc
zstandard python3-zstandard
2 changes: 1 addition & 1 deletion meta-isar/recipes-python/mtda/mtda_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SRC_URI += "${@' '.join(['file://' + d.getVar('LAYERDIR_mtda') + '/../' + file f

S = "${WORKDIR}/working-repo"

DEPENDS += "zerorpc-python py3qterm"
DEPENDS += "py3qterm"

do_gen_working_repo() {
for file in ${MTDA_FILES}; do
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions meta-isar/recipes-python/zerorpc/zerorpc-python_0.6.3.bb

This file was deleted.

9 changes: 1 addition & 8 deletions mtda-cli
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import requests
import time
import sys
import zerorpc
import socket
from argparse import ArgumentParser, RawTextHelpFormatter

Expand Down Expand Up @@ -410,13 +409,7 @@ class Application:
uptime = ""
if tgt_status == "ON":
uptime = f" (up {self.target_uptime()})"
try:
remote_version = client.agent_version()
except (zerorpc.RemoteError) as e:
if e.name == 'NameError':
remote_version = "<=0.5"
else:
raise e
remote_version = client.agent_version()

host = MultiTenantDeviceAccess()
prefix_key = chr(ord(client.console_prefix_key()) + ord('a') - 1)
Expand Down
10 changes: 5 additions & 5 deletions mtda-service
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import lockfile
import netifaces
import os
import os.path
import Pyro4
import signal
import sys
import zerorpc
import socket
import zeroconf
from systemd import daemon as sd
Expand Down Expand Up @@ -75,9 +75,9 @@ class Application:
return False

# Start our RPC server
uri = "tcp://*:%d" % (self.agent.ctrlport)
s = zerorpc.Server(self.agent, heartbeat=20)
s.bind(uri)
Pyro4.config.SERIALIZER = "marshal"
daemon = Pyro4.Daemon(port=self.agent.ctrlport)
daemon.register(self.agent, objectId="mtda.main")

# Initialize ZeroConf
interfaces = zeroconf.InterfaceChoice.All
Expand Down Expand Up @@ -105,7 +105,7 @@ class Application:

try:
sd.notify('READY=1')
s.run()
daemon.requestLoop()
except KeyboardInterrupt:
self.stop()
return True
Expand Down
11 changes: 5 additions & 6 deletions mtda/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@


import os
import Pyro4
import random
import socket
import subprocess
import tempfile
import time
import zerorpc
import zstandard as zstd

from mtda.main import MultiTenantDeviceAccess
Expand All @@ -37,11 +37,10 @@ def __init__(self, host=None, session=None, config_files=None,
agent = MultiTenantDeviceAccess()
agent.load_config(host, config_files=config_files)
if agent.remote is not None:
uri = "tcp://%s:%d" % (agent.remote, agent.ctrlport)
self._impl = zerorpc.Client(
heartbeat=min(timeout, CONSTS.RPC.HEARTBEAT),
timeout=timeout)
self._impl.connect(uri)
uri = f"PYRO:mtda.main@{agent.remote}:{agent.ctrlport}"
Pyro4.config.SERIALIZER = "marshal"
self._impl = Pyro4.Proxy(uri)
self._impl._pyroTimeout = timeout
else:
self._impl = agent
self._agent = agent
Expand Down
1 change: 0 additions & 1 deletion mtda/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class POWER:


class RPC:
HEARTBEAT = 20
TIMEOUT = 2*60


Expand Down
Loading

0 comments on commit 2c1202d

Please sign in to comment.