sunbeam-charms/ops-sunbeam/ops_sunbeam/ovn/config_contexts.py
Guillaume Boutry e5fb16d6b9
Implement tracing
Implement tracing relation for all the charms.
Instrument most of ops.Object objects, including relation handlers,
pebble handlers, and relation objects.

Change-Id: I967ff858a63aa7d30094cf5a46491fce11195060
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2024-07-31 11:57:32 +02:00

38 lines
1.4 KiB
Python

# Copyright 2022 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Base classes for defining a config context using the Operator framework.
ConfigContext objects can be used when rendering templates. They idea is to
create reusable contexts which translate charm config, deployment state etc.
These are not specific to a relation.
"""
from .. import config_contexts as sunbeam_ccontexts
from .. import tracing as sunbeam_tracing
@sunbeam_tracing.trace_type
class OVNDBConfigContext(sunbeam_ccontexts.ConfigContext):
"""Context for OVN charms."""
def context(self) -> dict:
"""Context for OVN certs and leadership."""
return {
"is_charm_leader": self.charm.unit.is_leader(),
"ovn_key": "/etc/ovn/key_host",
"ovn_cert": "/etc/ovn/cert_host",
"ovn_ca_cert": "/etc/ovn/ovn-central.crt",
}