Merge "[openstack-hypervisor] Trigger hypervisor config hook" into main

This commit is contained in:
Zuul
2025-09-09 05:26:25 +00:00
committed by Gerrit Code Review
2 changed files with 19 additions and 0 deletions

View File

@@ -30,6 +30,10 @@ import secrets
import socket
import string
import subprocess
from datetime import (
datetime,
timezone,
)
from typing import (
List,
Optional,
@@ -687,10 +691,22 @@ class HypervisorOperatorCharm(sunbeam_charm.OSBaseOperatorCharm):
return
try:
# Temporary manual connection and hook trigger until ownership is transferred
# to Canonical.
hypervisor.connect(EPA_INFO_PLUG, slot=EPA_INFO_SLOT)
logger.info(
"Successfully connected openstack-hypervisor to epa-orchestrator"
)
hypervisor.set(
{
"configure-trigger": int(
datetime.now(timezone.utc).timestamp()
)
}
)
logger.info(
"Triggered configure hook via snap set on openstack-hypervisor"
)
except snap.SnapError as e:
logger.error(f"Failed to connect to epa-orchestrator: {e.message}")
raise

View File

@@ -454,6 +454,9 @@ class TestCharm(test_utils.CharmTestCase):
hypervisor_snap_mock.connect.assert_called_once_with(
charm.EPA_INFO_PLUG, slot=charm.EPA_INFO_SLOT
)
hypervisor_snap_mock.set.assert_called_once()
args, kwargs = hypervisor_snap_mock.set.call_args
self.assertIn("configure-trigger", args[0])
def test_snap_connect_failure_snaperror(self):
"""Test snap connect failure with SnapError."""