osbuild: auto-generate socket addresses for APIs
Rely on the ability of `BaseAPI` to auto-generate socket addresses when no one was provided. The `BuildRoot` does not rely on the sockets being created in the `BuildRoot.api` directory anymore and will instead bind-mount each individual socket address to the well known location via the `BaseAPI.endpoint` identifier. Convert all API providers to take the `socket_address` as an optional keyword argument.
This commit is contained in:
parent
6f26b49b9f
commit
0c7284572e
6 changed files with 10 additions and 11 deletions
|
|
@ -105,7 +105,7 @@ class API(BaseAPI):
|
|||
|
||||
endpoint = "osbuild"
|
||||
|
||||
def __init__(self, socket_address, args, monitor):
|
||||
def __init__(self, args, monitor, *, socket_address=None):
|
||||
super().__init__(socket_address)
|
||||
self.input = args
|
||||
self._output_data = io.StringIO()
|
||||
|
|
|
|||
|
|
@ -78,11 +78,10 @@ class Stage:
|
|||
|
||||
ro_binds = [f"{sources_output}:/run/osbuild/sources"]
|
||||
|
||||
api = API(f"{build_root.api}/osbuild", args, monitor)
|
||||
api = API(args, monitor)
|
||||
build_root.register_api(api)
|
||||
|
||||
src = sources.SourcesServer(f"{build_root.api}/sources",
|
||||
libdir or "/usr/lib/osbuild",
|
||||
src = sources.SourcesServer(libdir or "/usr/lib/osbuild",
|
||||
self.sources,
|
||||
os.path.join(cache, "sources"),
|
||||
sources_output)
|
||||
|
|
@ -140,10 +139,10 @@ class Assembler:
|
|||
|
||||
ro_binds = [os.fspath(tree) + ":/run/osbuild/tree"]
|
||||
|
||||
api = API(f"{build_root.api}/osbuild", args, monitor)
|
||||
api = API(args, monitor)
|
||||
build_root.register_api(api)
|
||||
|
||||
rls = remoteloop.LoopServer(f"{build_root.api}/remoteloop")
|
||||
rls = remoteloop.LoopServer()
|
||||
build_root.register_api(rls)
|
||||
|
||||
r = build_root.run([f"/run/osbuild/lib/assemblers/{self.name}"],
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class LoopServer(api.BaseAPI):
|
|||
|
||||
endpoint = "remoteloop"
|
||||
|
||||
def __init__(self, socket_address):
|
||||
def __init__(self, *, socket_address=None):
|
||||
super().__init__(socket_address)
|
||||
self.devs = []
|
||||
self.ctl = loop.LoopControl()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class SourcesServer(api.BaseAPI):
|
|||
|
||||
endpoint = "sources"
|
||||
|
||||
def __init__(self, socket_address, libdir, options, cache, output):
|
||||
def __init__(self, libdir, options, cache, output, *, socket_address=None):
|
||||
super().__init__(socket_address)
|
||||
self.libdir = libdir
|
||||
self.cache = cache
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class TestMonitor(unittest.TestCase):
|
|||
logfile = os.path.join(tmpdir, "log.txt")
|
||||
|
||||
with open(logfile, "w") as log, \
|
||||
API(path, args, LogMonitor(log.fileno())) as api:
|
||||
API(args, LogMonitor(log.fileno()), socket_address=path) as api:
|
||||
p = mp.Process(target=echo, args=(path, ))
|
||||
p.start()
|
||||
p.join()
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ class TestSources(test.TestBase):
|
|||
with tempfile.TemporaryDirectory() as tmpdir, \
|
||||
fileServer(self.locate_test_data()), \
|
||||
osbuild.sources.SourcesServer(
|
||||
f"{tmpdir}/sources-api",
|
||||
"./", source_options,
|
||||
f"{tmpdir}/cache", f"{tmpdir}/dst"):
|
||||
f"{tmpdir}/cache", f"{tmpdir}/dst",
|
||||
socket_address=f"{tmpdir}/sources-api"):
|
||||
self.check_case(source, case_options, f"{tmpdir}/sources-api")
|
||||
self.check_case(source, case_options, f"{tmpdir}/sources-api")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue