Skip to content

Commit

Permalink
Merge "Support changing project network underlay via spaces" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Oct 3, 2024
2 parents a72d0c5 + 60dd96b commit 18361b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions charms/openstack-hypervisor/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ options:
use-migration-binding:
default: False
type: boolean
use-data-binding:
default: False
type: boolean
1 change: 1 addition & 0 deletions charms/openstack-hypervisor/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 18 additions & 1 deletion charms/openstack-hypervisor/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
logger = logging.getLogger(__name__)

MIGRATION_BINDING = "migration"
DATA_BINDING = "data"
MTLS_USAGES = {x509.OID_SERVER_AUTH, x509.OID_CLIENT_AUTH}


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 18361b0

Please sign in to comment.