Fix agent plugin configuration handling
This commit is contained in:
@@ -156,18 +156,23 @@ class LifecycleService:
|
||||
plugin = self.client.get_plugin(request.slug)
|
||||
ensure_not_self(plugin.package_name, plugin.import_name)
|
||||
installed = self.version_provider(plugin.package_name)
|
||||
config_editor = PluginConfigurationEditor(
|
||||
self.settings.configuration_path,
|
||||
self.settings.backup_dir,
|
||||
self.settings.backups_to_keep,
|
||||
)
|
||||
requirements_editor = RequirementsEditor(
|
||||
self.settings.requirements_path,
|
||||
self.settings.backup_dir,
|
||||
self.settings.backups_to_keep,
|
||||
)
|
||||
enabled = plugin.import_name in config_editor.enabled_plugins()
|
||||
runtime_active = self.runtime_active_provider(plugin.import_name)
|
||||
config_editor: PluginConfigurationEditor | None = None
|
||||
requirements_editor: RequirementsEditor | None = None
|
||||
if self.settings.execution_mode == "agent":
|
||||
enabled = runtime_active
|
||||
else:
|
||||
config_editor = PluginConfigurationEditor(
|
||||
self.settings.configuration_path,
|
||||
self.settings.backup_dir,
|
||||
self.settings.backups_to_keep,
|
||||
)
|
||||
requirements_editor = RequirementsEditor(
|
||||
self.settings.requirements_path,
|
||||
self.settings.backup_dir,
|
||||
self.settings.backups_to_keep,
|
||||
)
|
||||
enabled = plugin.import_name in config_editor.enabled_plugins()
|
||||
release: Release | None = None
|
||||
if request.action in {"install", "update"}:
|
||||
release = plugin.select_release(self.settings.netbox_version, request.version)
|
||||
@@ -200,10 +205,20 @@ class LifecycleService:
|
||||
)
|
||||
try:
|
||||
if self.settings.execution_mode == "agent":
|
||||
result = self._execute_agent(request, plugin, release, installed, enabled, plan, requested_by)
|
||||
result = self._execute_agent(
|
||||
request, plugin, release, installed, enabled, plan, requested_by
|
||||
)
|
||||
else:
|
||||
assert config_editor is not None and requirements_editor is not None
|
||||
result = self._execute_direct(
|
||||
request, plugin, release, installed, enabled, plan, config_editor, requirements_editor
|
||||
request,
|
||||
plugin,
|
||||
release,
|
||||
installed,
|
||||
enabled,
|
||||
plan,
|
||||
config_editor,
|
||||
requirements_editor,
|
||||
)
|
||||
except Exception as exc:
|
||||
self.repository.update_status(
|
||||
@@ -268,9 +283,19 @@ class LifecycleService:
|
||||
elif action == "update":
|
||||
plan.extend(["Update the persistent requirement pin atomically.", "Upgrade from the verified local artifact."])
|
||||
elif action == "enable":
|
||||
plan.append(f"Add {plugin.import_name} to the static PLUGINS list atomically.")
|
||||
target = (
|
||||
"agent-managed plugin list"
|
||||
if self.settings.execution_mode == "agent"
|
||||
else "static PLUGINS list"
|
||||
)
|
||||
plan.append(f"Add {plugin.import_name} to the {target} atomically.")
|
||||
elif action == "disable":
|
||||
plan.append(f"Remove {plugin.import_name} from the static PLUGINS list atomically.")
|
||||
target = (
|
||||
"agent-managed plugin list"
|
||||
if self.settings.execution_mode == "agent"
|
||||
else "static PLUGINS list"
|
||||
)
|
||||
plan.append(f"Remove {plugin.import_name} from the {target} atomically.")
|
||||
elif action == "uninstall":
|
||||
plan.extend(["Remove the persistent requirement pin atomically.", "Uninstall the distribution with pip."])
|
||||
if action == "enable" or (action == "update" and currently_enabled):
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.1.2"
|
||||
__version__ = "0.1.3"
|
||||
|
||||
Reference in New Issue
Block a user