core (main, config): Component auto-configuration:

New `jid`, `secret` and `autoconnect` field are used for component settings. When used,
backend will automatically create the profile and set its relevant parameters, or check
that existing profile is in sync (and update it if necessary).

This make component installation easier to Libervia, as it is not
necessary anymore to use the CLI frontend to install a component.

rel 476
This commit is contained in:
Goffi 2026-03-24 11:57:16 +01:00
commit a9fa2eeed4

View file

@ -30,7 +30,6 @@ from uuid import uuid4
import shortuuid
from twisted.internet import defer, error, reactor
from twisted.internet.base import DelayedCall
from twisted.python import failure
from twisted.words.protocols.jabber import jid
from libervia.backend.core import exceptions
@ -44,7 +43,6 @@ from libervia.backend.memory.disco import Discovery
from libervia.backend.memory.params import Params
from libervia.backend.memory.persistent import PersistentDict
from libervia.backend.memory.sqla import (
Notification,
NotificationPriority,
NotificationStatus,
NotificationType,
@ -518,15 +516,19 @@ class Memory:
self.memory_data["Profile_default"] = profile
def create_profile(self, name, password, component=None):
def create_profile(
self, name: str, password: str, component: str | None = None
) -> defer.Deferred[None]:
"""Create a new profile
@param name(unicode): profile name
@param password(unicode): profile password
Can be empty to disable password
@param component(None, unicode): set to entry point if this is a component
@return: Deferred
@raise exceptions.NotFound: component is not a known plugin import name
@param name: profile name
@param password: profile password (can be empty to disable password)
@param component: entry point if this is a component
@return: Deferred that fires when the profile is created
@raise ValueError: if profile name is empty, starts with '@', or contains line
feed
@raise exceptions.ConflictError: if a session for this profile exists
@raise exceptions.NotFound: if component is not a known plugin import name
"""
if not name:
raise ValueError("Empty profile name")
@ -547,7 +549,8 @@ class Memory:
)
)
)
# FIXME: PLUGIN_INFO is not currently accessible after import, but type shoul be tested here
# FIXME: PLUGIN_INFO is not currently accessible after import, but type should
# be tested here
#  if self.host.plugins[component].PLUGIN_INFO[u"type"] != C.PLUG_TYPE_ENTRY_POINT:
#   raise ValueError(_(u"Plugin {component} is not an entry point !".format(
#   component = component)))
@ -612,12 +615,12 @@ class Memory:
"""
return self.storage.profile_is_component(profile_name)
def get_entry_point(self, profile_name):
"""Get a component entry point
def get_entry_point(self, profile_name: str) -> str:
"""Get a component entry point for a given profile.
@param profile_name(unicode): name of the profile
@return (bool): True if profile is a component
@raise exceptions.NotFound: profile doesn't exist
@param profile_name: name of the profile
@return: the component entry point (import name) for the profile
@raise exceptions.NotFound: if the profile doesn't exist or is not a component
"""
return self.storage.get_entry_point(profile_name)