Merge "[openstack-hypervisor] Trigger hypervisor config hook" into main
This commit is contained in:
@@ -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
|
||||
|
@@ -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."""
|
||||
|
Reference in New Issue
Block a user