Add mandatory relations

Add mandatory relations to charm

Depends-On: https://review.opendev.org/c/openstack/charm-ops-sunbeam/+/854508
Change-Id: Ie39f8cd0e8dc4d7dee8ecb330ed26933a427dea6
This commit is contained in:
Hemanth Nakkina 2022-09-21 18:11:55 +05:30
parent eb5bd31093
commit 586bde5e9d
2 changed files with 13 additions and 2 deletions

View File

@ -50,10 +50,10 @@ resources:
requires:
ingress-internal:
interface: ingress
optional: true
limit: 1
ingress-public:
interface: ingress
optional: true
limit: 1
database:
interface: mysql_client

View File

@ -111,6 +111,7 @@ class CloudComputeRequiresHandler(sunbeam_rhandlers.RelationHandler):
relation_name: str,
region: str,
callback_f: Callable,
mandatory: bool = False,
):
"""Creates a new CloudComputeRequiresHandler that handles initial
events from the relation and invokes the provided callbacks based on
@ -124,9 +125,11 @@ class CloudComputeRequiresHandler(sunbeam_rhandlers.RelationHandler):
:type region: str
:param callback_f: the function to call when the nodes are connected
:type callback_f: Callable
:param mandatory: flag to determine if relation handler is mandatory
:type mandatory: bool
"""
self.region = region
super().__init__(charm, relation_name, callback_f)
super().__init__(charm, relation_name, callback_f, mandatory)
def setup_event_handler(self):
"""Configure event handlers for the cloud-compute service relation."""
@ -164,6 +167,14 @@ class NovaOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
wsgi_admin_script = '/usr/bin/nova-api-wsgi'
wsgi_public_script = '/usr/bin/nova-api-wsgi'
shared_metadata_secret_key = 'shared-metadata-secret'
mandatory_relations = {
'database',
'api-database',
'cell-database',
'amqp',
'identity-service',
'ingress-public',
}
@property
def db_sync_cmds(self) -> List[List[str]]: