Rename cloud-credentials to identity-credentials
Change-Id: Ic7b728bc116447e666481740ced084a7ad75f76b
This commit is contained in:
parent
b19fcbc9fd
commit
9855f91713
@ -164,7 +164,7 @@ relations:
|
|||||||
- - mysql:database
|
- - mysql:database
|
||||||
- horizon:database
|
- horizon:database
|
||||||
- - keystone:identity-credentials
|
- - keystone:identity-credentials
|
||||||
- horizon:cloud-credentials
|
- horizon:identity-credentials
|
||||||
- - traefik:ingress
|
- - traefik:ingress
|
||||||
- horizon:ingress-internal
|
- horizon:ingress-internal
|
||||||
- - traefik-public:ingress
|
- - traefik-public:ingress
|
||||||
|
@ -7,7 +7,7 @@ echo "WARNING: Charm interface libs are excluded from ASO python package."
|
|||||||
charmcraft fetch-lib charms.nginx_ingress_integrator.v0.ingress
|
charmcraft fetch-lib charms.nginx_ingress_integrator.v0.ingress
|
||||||
charmcraft fetch-lib charms.data_platform_libs.v0.database_requires
|
charmcraft fetch-lib charms.data_platform_libs.v0.database_requires
|
||||||
charmcraft fetch-lib charms.keystone_k8s.v1.identity_service
|
charmcraft fetch-lib charms.keystone_k8s.v1.identity_service
|
||||||
charmcraft fetch-lib charms.keystone_k8s.v1.cloud_credentials
|
charmcraft fetch-lib charms.keystone_k8s.v0.identity_credentials
|
||||||
charmcraft fetch-lib charms.rabbitmq_k8s.v0.rabbitmq
|
charmcraft fetch-lib charms.rabbitmq_k8s.v0.rabbitmq
|
||||||
charmcraft fetch-lib charms.ovn_central_k8s.v0.ovsdb
|
charmcraft fetch-lib charms.ovn_central_k8s.v0.ovsdb
|
||||||
charmcraft fetch-lib charms.observability_libs.v0.kubernetes_service_patch
|
charmcraft fetch-lib charms.observability_libs.v0.kubernetes_service_patch
|
||||||
|
@ -171,12 +171,12 @@ class OSBaseOperatorCharm(ops.charm.CharmBase):
|
|||||||
"certificates" in self.mandatory_relations,
|
"certificates" in self.mandatory_relations,
|
||||||
)
|
)
|
||||||
handlers.append(self.certs)
|
handlers.append(self.certs)
|
||||||
if self.can_add_handler("cloud-credentials", handlers):
|
if self.can_add_handler("identity-credentials", handlers):
|
||||||
self.ccreds = sunbeam_rhandlers.CloudCredentialsRequiresHandler(
|
self.ccreds = sunbeam_rhandlers.IdentityCredentialsRequiresHandler(
|
||||||
self,
|
self,
|
||||||
"cloud-credentials",
|
"identity-credentials",
|
||||||
self.configure_charm,
|
self.configure_charm,
|
||||||
"cloud-credentials" in self.mandatory_relations,
|
"identity-credentials" in self.mandatory_relations,
|
||||||
)
|
)
|
||||||
handlers.append(self.ccreds)
|
handlers.append(self.ccreds)
|
||||||
return handlers
|
return handlers
|
||||||
|
@ -950,8 +950,8 @@ class TlsCertificatesHandler(RelationHandler):
|
|||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsRequiresHandler(RelationHandler):
|
class IdentityCredentialsRequiresHandler(RelationHandler):
|
||||||
"""Handles the cloud credentials relation on the requires side."""
|
"""Handles the identity credentials relation on the requires side."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -960,9 +960,9 @@ class CloudCredentialsRequiresHandler(RelationHandler):
|
|||||||
callback_f: Callable,
|
callback_f: Callable,
|
||||||
mandatory: bool = False,
|
mandatory: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create a new cloud-credentials handler.
|
"""Create a new identity-credentials handler.
|
||||||
|
|
||||||
Create a new CloudCredentialsRequiresHandler that handles initial
|
Create a new IdentityCredentialsRequiresHandler that handles initial
|
||||||
events from the relation and invokes the provided callbacks based on
|
events from the relation and invokes the provided callbacks based on
|
||||||
the event raised.
|
the event raised.
|
||||||
|
|
||||||
@ -976,11 +976,11 @@ class CloudCredentialsRequiresHandler(RelationHandler):
|
|||||||
super().__init__(charm, relation_name, callback_f, mandatory)
|
super().__init__(charm, relation_name, callback_f, mandatory)
|
||||||
|
|
||||||
def setup_event_handler(self) -> ops.charm.Object:
|
def setup_event_handler(self) -> ops.charm.Object:
|
||||||
"""Configure event handlers for cloud-credentials relation."""
|
"""Configure event handlers for identity-credentials relation."""
|
||||||
import charms.keystone_k8s.v1.cloud_credentials as cloud_credentials
|
import charms.keystone_k8s.v0.identity_credentials as identity_credentials
|
||||||
|
|
||||||
logger.debug("Setting up the cloud-credentials event handler")
|
logger.debug("Setting up the identity-credentials event handler")
|
||||||
credentials_service = cloud_credentials.CloudCredentialsRequires(
|
credentials_service = identity_credentials.IdentityCredentialsRequires(
|
||||||
self.charm,
|
self.charm,
|
||||||
self.relation_name,
|
self.relation_name,
|
||||||
)
|
)
|
||||||
|
@ -387,9 +387,9 @@ def add_identity_service_relation_response(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_base_cloud_credentials_relation(harness: Harness) -> str:
|
def add_base_identity_credentials_relation(harness: Harness) -> str:
|
||||||
"""Add identity-service relation."""
|
"""Add identity-service relation."""
|
||||||
rel_id = harness.add_relation("cloud-credentials", "keystone")
|
rel_id = harness.add_relation("identity-credentials", "keystone")
|
||||||
harness.add_relation_unit(rel_id, "keystone/0")
|
harness.add_relation_unit(rel_id, "keystone/0")
|
||||||
harness.add_relation_unit(rel_id, "keystone/0")
|
harness.add_relation_unit(rel_id, "keystone/0")
|
||||||
harness.update_relation_data(
|
harness.update_relation_data(
|
||||||
@ -398,7 +398,7 @@ def add_base_cloud_credentials_relation(harness: Harness) -> str:
|
|||||||
return rel_id
|
return rel_id
|
||||||
|
|
||||||
|
|
||||||
def add_cloud_credentials_relation_response(
|
def add_identity_credentials_relation_response(
|
||||||
harness: Harness, rel_id: str
|
harness: Harness, rel_id: str
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Add id service data to identity-service relation."""
|
"""Add id service data to identity-service relation."""
|
||||||
@ -475,10 +475,10 @@ def add_complete_identity_relation(harness: Harness) -> None:
|
|||||||
return rel_id
|
return rel_id
|
||||||
|
|
||||||
|
|
||||||
def add_complete_cloud_credentials_relation(harness: Harness) -> None:
|
def add_complete_identity_credentials_relation(harness: Harness) -> None:
|
||||||
"""Add complete cloud-credentials relation."""
|
"""Add complete identity-credentials relation."""
|
||||||
rel_id = add_base_cloud_credentials_relation(harness)
|
rel_id = add_base_identity_credentials_relation(harness)
|
||||||
add_cloud_credentials_relation_response(harness, rel_id)
|
add_identity_credentials_relation_response(harness, rel_id)
|
||||||
return rel_id
|
return rel_id
|
||||||
|
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ test_relations = {
|
|||||||
"database": add_complete_db_relation,
|
"database": add_complete_db_relation,
|
||||||
"amqp": add_complete_amqp_relation,
|
"amqp": add_complete_amqp_relation,
|
||||||
"identity-service": add_complete_identity_relation,
|
"identity-service": add_complete_identity_relation,
|
||||||
"cloud-credentials": add_complete_cloud_credentials_relation,
|
"identity-credentials": add_complete_identity_credentials_relation,
|
||||||
"peers": add_complete_peer_relation,
|
"peers": add_complete_peer_relation,
|
||||||
"certificates": add_complete_certificates_relation,
|
"certificates": add_complete_certificates_relation,
|
||||||
"ceph": add_complete_ceph_relation,
|
"ceph": add_complete_ceph_relation,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""CloudCredentialsProvides and Requires module.
|
"""IdentityCredentialsProvides and Requires module.
|
||||||
|
|
||||||
|
|
||||||
This library contains the Requires and Provides classes for handling
|
This library contains the Requires and Provides classes for handling
|
||||||
the cloud_credentials interface.
|
the identity_credentials interface.
|
||||||
|
|
||||||
Import `CloudCredentialsRequires` in your charm, with the charm object and the
|
Import `IdentityCredentialsRequires` in your charm, with the charm object and the
|
||||||
relation name:
|
relation name:
|
||||||
- self
|
- self
|
||||||
- "cloud_credentials"
|
- "identity_credentials"
|
||||||
|
|
||||||
Also provide additional parameters to the charm object:
|
Also provide additional parameters to the charm object:
|
||||||
- service
|
- service
|
||||||
@ -26,14 +26,14 @@ Two events are also available to respond to:
|
|||||||
A basic example showing the usage of this relation follows:
|
A basic example showing the usage of this relation follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
from charms.keystone_k8s.v0.cloud_credentials import CloudCredentialsRequires
|
from charms.keystone_k8s.v0.identity_credentials import IdentityCredentialsRequires
|
||||||
|
|
||||||
class CloudCredentialsClientCharm(CharmBase):
|
class IdentityCredentialsClientCharm(CharmBase):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
# CloudCredentials Requires
|
# IdentityCredentials Requires
|
||||||
self.cloud_credentials = CloudCredentialsRequires(
|
self.identity_credentials = IdentityCredentialsRequires(
|
||||||
self, "cloud_credentials",
|
self, "identity_credentials",
|
||||||
service = "my-service"
|
service = "my-service"
|
||||||
internal_url = "http://internal-url"
|
internal_url = "http://internal-url"
|
||||||
public_url = "http://public-url"
|
public_url = "http://public-url"
|
||||||
@ -41,36 +41,36 @@ class CloudCredentialsClientCharm(CharmBase):
|
|||||||
region = "region"
|
region = "region"
|
||||||
)
|
)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.cloud_credentials.on.connected, self._on_cloud_credentials_connected)
|
self.identity_credentials.on.connected, self._on_identity_credentials_connected)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.cloud_credentials.on.ready, self._on_cloud_credentials_ready)
|
self.identity_credentials.on.ready, self._on_identity_credentials_ready)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.cloud_credentials.on.goneaway, self._on_cloud_credentials_goneaway)
|
self.identity_credentials.on.goneaway, self._on_identity_credentials_goneaway)
|
||||||
|
|
||||||
def _on_cloud_credentials_connected(self, event):
|
def _on_identity_credentials_connected(self, event):
|
||||||
'''React to the CloudCredentials connected event.
|
'''React to the IdentityCredentials connected event.
|
||||||
|
|
||||||
This event happens when n CloudCredentials relation is added to the
|
This event happens when IdentityCredentials relation is added to the
|
||||||
model before credentials etc have been provided.
|
model before credentials etc have been provided.
|
||||||
'''
|
'''
|
||||||
# Do something before the relation is complete
|
# Do something before the relation is complete
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _on_cloud_credentials_ready(self, event):
|
def _on_identity_credentials_ready(self, event):
|
||||||
'''React to the CloudCredentials ready event.
|
'''React to the IdentityCredentials ready event.
|
||||||
|
|
||||||
The CloudCredentials interface will use the provided config for the
|
The IdentityCredentials interface will use the provided config for the
|
||||||
request to the identity server.
|
request to the identity server.
|
||||||
'''
|
'''
|
||||||
# CloudCredentials Relation is ready. Do something with the completed relation.
|
# IdentityCredentials Relation is ready. Do something with the completed relation.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _on_cloud_credentials_goneaway(self, event):
|
def _on_identity_credentials_goneaway(self, event):
|
||||||
'''React to the CloudCredentials goneaway event.
|
'''React to the IdentityCredentials goneaway event.
|
||||||
|
|
||||||
This event happens when an CloudCredentials relation is removed.
|
This event happens when an IdentityCredentials relation is removed.
|
||||||
'''
|
'''
|
||||||
# CloudCredentials Relation has goneaway. shutdown services or suchlike
|
# IdentityCredentials Relation has goneaway. shutdown services or suchlike
|
||||||
pass
|
pass
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
@ -90,50 +90,50 @@ from ops.model import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# The unique Charmhub library identifier, never change it
|
# The unique Charmhub library identifier, never change it
|
||||||
LIBID = "a5d96cc2686c47eea554ce2210c2d24e"
|
LIBID = "b5fa18d4427c4ab9a269c3a2fbed545c"
|
||||||
|
|
||||||
# Increment this major API version when introducing breaking changes
|
# Increment this major API version when introducing breaking changes
|
||||||
LIBAPI = 1
|
LIBAPI = 0
|
||||||
|
|
||||||
# Increment this PATCH version before using `charmcraft publish-lib` or reset
|
# Increment this PATCH version before using `charmcraft publish-lib` or reset
|
||||||
# to 0 if you are raising the major API version
|
# to 0 if you are raising the major API version
|
||||||
LIBPATCH = 0
|
LIBPATCH = 1
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsConnectedEvent(EventBase):
|
class IdentityCredentialsConnectedEvent(EventBase):
|
||||||
"""CloudCredentials connected Event."""
|
"""IdentityCredentials connected Event."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsReadyEvent(EventBase):
|
class IdentityCredentialsReadyEvent(EventBase):
|
||||||
"""CloudCredentials ready for use Event."""
|
"""IdentityCredentials ready for use Event."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsGoneAwayEvent(EventBase):
|
class IdentityCredentialsGoneAwayEvent(EventBase):
|
||||||
"""CloudCredentials relation has gone-away Event"""
|
"""IdentityCredentials relation has gone-away Event"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsServerEvents(ObjectEvents):
|
class IdentityCredentialsServerEvents(ObjectEvents):
|
||||||
"""Events class for `on`"""
|
"""Events class for `on`"""
|
||||||
|
|
||||||
connected = EventSource(CloudCredentialsConnectedEvent)
|
connected = EventSource(IdentityCredentialsConnectedEvent)
|
||||||
ready = EventSource(CloudCredentialsReadyEvent)
|
ready = EventSource(IdentityCredentialsReadyEvent)
|
||||||
goneaway = EventSource(CloudCredentialsGoneAwayEvent)
|
goneaway = EventSource(IdentityCredentialsGoneAwayEvent)
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsRequires(Object):
|
class IdentityCredentialsRequires(Object):
|
||||||
"""
|
"""
|
||||||
CloudCredentialsRequires class
|
IdentityCredentialsRequires class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
on = CloudCredentialsServerEvents()
|
on = IdentityCredentialsServerEvents()
|
||||||
_stored = StoredState()
|
_stored = StoredState()
|
||||||
|
|
||||||
def __init__(self, charm, relation_name: str):
|
def __init__(self, charm, relation_name: str):
|
||||||
@ -142,48 +142,48 @@ class CloudCredentialsRequires(Object):
|
|||||||
self.relation_name = relation_name
|
self.relation_name = relation_name
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_joined,
|
self.charm.on[relation_name].relation_joined,
|
||||||
self._on_cloud_credentials_relation_joined,
|
self._on_identity_credentials_relation_joined,
|
||||||
)
|
)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_changed,
|
self.charm.on[relation_name].relation_changed,
|
||||||
self._on_cloud_credentials_relation_changed,
|
self._on_identity_credentials_relation_changed,
|
||||||
)
|
)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_departed,
|
self.charm.on[relation_name].relation_departed,
|
||||||
self._on_cloud_credentials_relation_changed,
|
self._on_identity_credentials_relation_changed,
|
||||||
)
|
)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_broken,
|
self.charm.on[relation_name].relation_broken,
|
||||||
self._on_cloud_credentials_relation_broken,
|
self._on_identity_credentials_relation_broken,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _on_cloud_credentials_relation_joined(self, event):
|
def _on_identity_credentials_relation_joined(self, event):
|
||||||
"""CloudCredentials relation joined."""
|
"""IdentityCredentials relation joined."""
|
||||||
logging.debug("CloudCredentials on_joined")
|
logging.debug("IdentityCredentials on_joined")
|
||||||
self.on.connected.emit()
|
self.on.connected.emit()
|
||||||
self.request_credentials()
|
self.request_credentials()
|
||||||
|
|
||||||
def _on_cloud_credentials_relation_changed(self, event):
|
def _on_identity_credentials_relation_changed(self, event):
|
||||||
"""CloudCredentials relation changed."""
|
"""IdentityCredentials relation changed."""
|
||||||
logging.debug("CloudCredentials on_changed")
|
logging.debug("IdentityCredentials on_changed")
|
||||||
try:
|
try:
|
||||||
self.on.ready.emit()
|
self.on.ready.emit()
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
logger.exception('Error when emitting event')
|
logger.exception('Error when emitting event')
|
||||||
|
|
||||||
def _on_cloud_credentials_relation_broken(self, event):
|
def _on_identity_credentials_relation_broken(self, event):
|
||||||
"""CloudCredentials relation broken."""
|
"""IdentityCredentials relation broken."""
|
||||||
logging.debug("CloudCredentials on_broken")
|
logging.debug("IdentityCredentials on_broken")
|
||||||
self.on.goneaway.emit()
|
self.on.goneaway.emit()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _cloud_credentials_rel(self) -> Relation:
|
def _identity_credentials_rel(self) -> Relation:
|
||||||
"""The CloudCredentials relation."""
|
"""The IdentityCredentials relation."""
|
||||||
return self.framework.model.get_relation(self.relation_name)
|
return self.framework.model.get_relation(self.relation_name)
|
||||||
|
|
||||||
def get_remote_app_data(self, key: str) -> str:
|
def get_remote_app_data(self, key: str) -> str:
|
||||||
"""Return the value for the given key from remote app data."""
|
"""Return the value for the given key from remote app data."""
|
||||||
data = self._cloud_credentials_rel.data[self._cloud_credentials_rel.app]
|
data = self._identity_credentials_rel.data[self._identity_credentials_rel.app]
|
||||||
return data.get(key)
|
return data.get(key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -287,21 +287,21 @@ class CloudCredentialsRequires(Object):
|
|||||||
return self.get_remote_app_data('region')
|
return self.get_remote_app_data('region')
|
||||||
|
|
||||||
def request_credentials(self) -> None:
|
def request_credentials(self) -> None:
|
||||||
"""Request credentials from the CloudCredentials server."""
|
"""Request credentials from the IdentityCredentials server."""
|
||||||
if self.model.unit.is_leader():
|
if self.model.unit.is_leader():
|
||||||
logging.debug(f'Requesting credentials for {self.charm.app.name}')
|
logging.debug(f'Requesting credentials for {self.charm.app.name}')
|
||||||
app_data = self._cloud_credentials_rel.data[self.charm.app]
|
app_data = self._identity_credentials_rel.data[self.charm.app]
|
||||||
app_data['username'] = self.charm.app.name
|
app_data['username'] = self.charm.app.name
|
||||||
|
|
||||||
|
|
||||||
class HasCloudCredentialsClientsEvent(EventBase):
|
class HasIdentityCredentialsClientsEvent(EventBase):
|
||||||
"""Has CloudCredentialsClients Event."""
|
"""Has IdentityCredentialsClients Event."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ReadyCloudCredentialsClientsEvent(EventBase):
|
class ReadyIdentityCredentialsClientsEvent(EventBase):
|
||||||
"""CloudCredentialsClients Ready Event."""
|
"""IdentityCredentialsClients Ready Event."""
|
||||||
|
|
||||||
def __init__(self, handle, relation_id, relation_name, username):
|
def __init__(self, handle, relation_id, relation_name, username):
|
||||||
super().__init__(handle)
|
super().__init__(handle)
|
||||||
@ -323,32 +323,32 @@ class ReadyCloudCredentialsClientsEvent(EventBase):
|
|||||||
self.username = snapshot["username"]
|
self.username = snapshot["username"]
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsClientsGoneAwayEvent(EventBase):
|
class IdentityCredentialsClientsGoneAwayEvent(EventBase):
|
||||||
"""Has CloudCredentialsClientsGoneAwayEvent Event."""
|
"""Has IdentityCredentialsClientsGoneAwayEvent Event."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsClientEvents(ObjectEvents):
|
class IdentityCredentialsClientEvents(ObjectEvents):
|
||||||
"""Events class for `on`"""
|
"""Events class for `on`"""
|
||||||
|
|
||||||
has_cloud_credentials_clients = EventSource(
|
has_identity_credentials_clients = EventSource(
|
||||||
HasCloudCredentialsClientsEvent
|
HasIdentityCredentialsClientsEvent
|
||||||
)
|
)
|
||||||
ready_cloud_credentials_clients = EventSource(
|
ready_identity_credentials_clients = EventSource(
|
||||||
ReadyCloudCredentialsClientsEvent
|
ReadyIdentityCredentialsClientsEvent
|
||||||
)
|
)
|
||||||
cloud_credentials_clients_gone = EventSource(
|
identity_credentials_clients_gone = EventSource(
|
||||||
CloudCredentialsClientsGoneAwayEvent
|
IdentityCredentialsClientsGoneAwayEvent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CloudCredentialsProvides(Object):
|
class IdentityCredentialsProvides(Object):
|
||||||
"""
|
"""
|
||||||
CloudCredentialsProvides class
|
IdentityCredentialsProvides class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
on = CloudCredentialsClientEvents()
|
on = IdentityCredentialsClientEvents()
|
||||||
_stored = StoredState()
|
_stored = StoredState()
|
||||||
|
|
||||||
def __init__(self, charm, relation_name):
|
def __init__(self, charm, relation_name):
|
||||||
@ -357,25 +357,25 @@ class CloudCredentialsProvides(Object):
|
|||||||
self.relation_name = relation_name
|
self.relation_name = relation_name
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_joined,
|
self.charm.on[relation_name].relation_joined,
|
||||||
self._on_cloud_credentials_relation_joined,
|
self._on_identity_credentials_relation_joined,
|
||||||
)
|
)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_changed,
|
self.charm.on[relation_name].relation_changed,
|
||||||
self._on_cloud_credentials_relation_changed,
|
self._on_identity_credentials_relation_changed,
|
||||||
)
|
)
|
||||||
self.framework.observe(
|
self.framework.observe(
|
||||||
self.charm.on[relation_name].relation_broken,
|
self.charm.on[relation_name].relation_broken,
|
||||||
self._on_cloud_credentials_relation_broken,
|
self._on_identity_credentials_relation_broken,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _on_cloud_credentials_relation_joined(self, event):
|
def _on_identity_credentials_relation_joined(self, event):
|
||||||
"""Handle CloudCredentials joined."""
|
"""Handle IdentityCredentials joined."""
|
||||||
logging.debug("CloudCredentialsProvides on_joined")
|
logging.debug("IdentityCredentialsProvides on_joined")
|
||||||
self.on.has_cloud_credentials_clients.emit()
|
self.on.has_identity_credentials_clients.emit()
|
||||||
|
|
||||||
def _on_cloud_credentials_relation_changed(self, event):
|
def _on_identity_credentials_relation_changed(self, event):
|
||||||
"""Handle CloudCredentials changed."""
|
"""Handle IdentityCredentials changed."""
|
||||||
logging.debug("CloudCredentials on_changed")
|
logging.debug("IdentityCredentials on_changed")
|
||||||
REQUIRED_KEYS = ['username']
|
REQUIRED_KEYS = ['username']
|
||||||
|
|
||||||
values = [
|
values = [
|
||||||
@ -385,18 +385,18 @@ class CloudCredentialsProvides(Object):
|
|||||||
# Validate data on the relation
|
# Validate data on the relation
|
||||||
if all(values):
|
if all(values):
|
||||||
username = event.relation.data[event.relation.app]['username']
|
username = event.relation.data[event.relation.app]['username']
|
||||||
self.on.ready_cloud_credentials_clients.emit(
|
self.on.ready_identity_credentials_clients.emit(
|
||||||
event.relation.id,
|
event.relation.id,
|
||||||
event.relation.name,
|
event.relation.name,
|
||||||
username,
|
username,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _on_cloud_credentials_relation_broken(self, event):
|
def _on_identity_credentials_relation_broken(self, event):
|
||||||
"""Handle CloudCredentials broken."""
|
"""Handle IdentityCredentials broken."""
|
||||||
logging.debug("CloudCredentialsProvides on_departed")
|
logging.debug("IdentityCredentialsProvides on_departed")
|
||||||
self.on.cloud_credentials_clients_gone.emit()
|
self.on.identity_credentials_clients_gone.emit()
|
||||||
|
|
||||||
def set_cloud_credentials(self, relation_name: int,
|
def set_identity_credentials(self, relation_name: int,
|
||||||
relation_id: str,
|
relation_id: str,
|
||||||
api_version: str,
|
api_version: str,
|
||||||
auth_host: str,
|
auth_host: str,
|
||||||
@ -413,15 +413,15 @@ class CloudCredentialsProvides(Object):
|
|||||||
project_domain_name: str,
|
project_domain_name: str,
|
||||||
project_domain_id: str,
|
project_domain_id: str,
|
||||||
region: str):
|
region: str):
|
||||||
logging.debug("Setting cloud_credentials connection information.")
|
logging.debug("Setting identity_credentials connection information.")
|
||||||
_cloud_credentials_rel = None
|
_identity_credentials_rel = None
|
||||||
for relation in self.framework.model.relations[relation_name]:
|
for relation in self.framework.model.relations[relation_name]:
|
||||||
if relation.id == relation_id:
|
if relation.id == relation_id:
|
||||||
_cloud_credentials_rel = relation
|
_identity_credentials_rel = relation
|
||||||
if not _cloud_credentials_rel:
|
if not _identity_credentials_rel:
|
||||||
# Relation has disappeared so don't send the data
|
# Relation has disappeared so don't send the data
|
||||||
return
|
return
|
||||||
app_data = _cloud_credentials_rel.data[self.charm.app]
|
app_data = _identity_credentials_rel.data[self.charm.app]
|
||||||
app_data["api-version"] = api_version
|
app_data["api-version"] = api_version
|
||||||
app_data["auth-host"] = auth_host
|
app_data["auth-host"] = auth_host
|
||||||
app_data["auth-port"] = str(auth_port)
|
app_data["auth-port"] = str(auth_port)
|
@ -108,7 +108,7 @@ requires:
|
|||||||
interface: rabbitmq
|
interface: rabbitmq
|
||||||
identity-service:
|
identity-service:
|
||||||
interface: keystone
|
interface: keystone
|
||||||
cloud-credentials:
|
identity-credentials:
|
||||||
interface: keystone-credentials
|
interface: keystone-credentials
|
||||||
limit: 1
|
limit: 1
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class TestOSBaseOperatorAPICharm(_TestOSBaseOperatorAPICharm):
|
|||||||
self.set_pebble_ready()
|
self.set_pebble_ready()
|
||||||
self.harness.charm.leader_set({"foo": "bar"})
|
self.harness.charm.leader_set({"foo": "bar"})
|
||||||
test_utils.add_api_relations(self.harness)
|
test_utils.add_api_relations(self.harness)
|
||||||
test_utils.add_complete_cloud_credentials_relation(self.harness)
|
test_utils.add_complete_identity_credentials_relation(self.harness)
|
||||||
expect_entries = [
|
expect_entries = [
|
||||||
"/bin/wsgi_admin",
|
"/bin/wsgi_admin",
|
||||||
"hardpassword",
|
"hardpassword",
|
||||||
@ -170,7 +170,7 @@ class TestOSBaseOperatorAPICharm(_TestOSBaseOperatorAPICharm):
|
|||||||
test_utils.add_complete_peer_relation(self.harness)
|
test_utils.add_complete_peer_relation(self.harness)
|
||||||
self.harness.charm.leader_set({"foo": "bar"})
|
self.harness.charm.leader_set({"foo": "bar"})
|
||||||
test_utils.add_api_relations(self.harness)
|
test_utils.add_api_relations(self.harness)
|
||||||
test_utils.add_complete_cloud_credentials_relation(self.harness)
|
test_utils.add_complete_identity_credentials_relation(self.harness)
|
||||||
self.harness.set_can_connect("my-service", True)
|
self.harness.set_can_connect("my-service", True)
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
self.harness.charm.status.status, ops.model.ActiveStatus()
|
self.harness.charm.status.status, ops.model.ActiveStatus()
|
||||||
@ -191,7 +191,7 @@ class TestOSBaseOperatorAPICharm(_TestOSBaseOperatorAPICharm):
|
|||||||
self.set_pebble_ready()
|
self.set_pebble_ready()
|
||||||
self.harness.charm.leader_set({"foo": "bar"})
|
self.harness.charm.leader_set({"foo": "bar"})
|
||||||
test_utils.add_api_relations(self.harness)
|
test_utils.add_api_relations(self.harness)
|
||||||
test_utils.add_complete_cloud_credentials_relation(self.harness)
|
test_utils.add_complete_identity_credentials_relation(self.harness)
|
||||||
self.harness.set_can_connect("my-service", True)
|
self.harness.set_can_connect("my-service", True)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.container_calls.started_services("my-service"),
|
self.container_calls.started_services("my-service"),
|
||||||
@ -384,7 +384,7 @@ class TestOSBaseOperatorMultiSVCAPICharm(_TestOSBaseOperatorAPICharm):
|
|||||||
self.set_pebble_ready()
|
self.set_pebble_ready()
|
||||||
self.harness.charm.leader_set({"foo": "bar"})
|
self.harness.charm.leader_set({"foo": "bar"})
|
||||||
test_utils.add_api_relations(self.harness)
|
test_utils.add_api_relations(self.harness)
|
||||||
test_utils.add_complete_cloud_credentials_relation(self.harness)
|
test_utils.add_complete_identity_credentials_relation(self.harness)
|
||||||
self.harness.set_can_connect("my-service", True)
|
self.harness.set_can_connect("my-service", True)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(self.container_calls.started_services("my-service")),
|
sorted(self.container_calls.started_services("my-service")),
|
||||||
|
Loading…
Reference in New Issue
Block a user