From 60dd96b2f9c717529508b21d369919038a757374 Mon Sep 17 00:00:00 2001 From: Guillaume Boutry Date: Wed, 2 Oct 2024 15:18:13 +0200 Subject: [PATCH] Support changing project network underlay via spaces Add a new pair of config option / extra binding to allow configuring the project networking underlay via space binding. At the this time of implementation, configuring this binding will have the snap update the geneve encapsulation ip. Change-Id: I67b00981a539d2070baf917bc1081020c469def3 Signed-off-by: Guillaume Boutry --- charms/openstack-hypervisor/config.yaml | 3 +++ charms/openstack-hypervisor/metadata.yaml | 1 + charms/openstack-hypervisor/src/charm.py | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/charms/openstack-hypervisor/config.yaml b/charms/openstack-hypervisor/config.yaml index 73499ef..e54b558 100644 --- a/charms/openstack-hypervisor/config.yaml +++ b/charms/openstack-hypervisor/config.yaml @@ -25,3 +25,6 @@ options: use-migration-binding: default: False type: boolean + use-data-binding: + default: False + type: boolean diff --git a/charms/openstack-hypervisor/metadata.yaml b/charms/openstack-hypervisor/metadata.yaml index d49dd20..a7c2709 100644 --- a/charms/openstack-hypervisor/metadata.yaml +++ b/charms/openstack-hypervisor/metadata.yaml @@ -39,6 +39,7 @@ provides: extra-bindings: migration: + data: # this binding will be used to support project networking between hypervisors # This charm has no peer relation by design. This charm needs to scale to # hundreds of units and this is limited by the peer relation. diff --git a/charms/openstack-hypervisor/src/charm.py b/charms/openstack-hypervisor/src/charm.py index faf9d1d..c2a385b 100755 --- a/charms/openstack-hypervisor/src/charm.py +++ b/charms/openstack-hypervisor/src/charm.py @@ -68,6 +68,7 @@ logger = logging.getLogger(__name__) MIGRATION_BINDING = "migration" +DATA_BINDING = "data" MTLS_USAGES = {x509.OID_SERVER_AUTH, x509.OID_CLIENT_AUTH} @@ -213,6 +214,20 @@ def migration_address(self) -> Optional[str]: return None return str(address) + @property + def data_address(self) -> Optional[str]: + """Get address from data binding.""" + use_binding = self.model.config.get("use-data-binding") + if not use_binding: + return None + binding = self.model.get_binding(DATA_BINDING) + if binding is None: + return None + address = binding.network.bind_address + if address is None: + return None + return str(address) + def check_relation_exists(self, relation_name: str) -> bool: """Check if a relation exists or not.""" if self.model.get_relation(relation_name): @@ -418,7 +433,9 @@ def configure_unit(self, event) -> None: "external-bridge-address" ) or "10.20.20.1/24", - "network.ip-address": config("ip-address") or local_ip, + "network.ip-address": self.data_address + or config("ip-address") + or local_ip, "network.ovn-key": base64.b64encode( contexts.certificates.key.encode() ).decode(),