charm cleanup

Following changes are done as part of this patch:

rename sunbeam import library to ops_sunbeam
update documentation
add fetch-libs in tox.ini
This commit is contained in:
Hemanth Nakkina 2022-07-19 13:59:21 +05:30
parent d690335b0e
commit a0343c3ca5
10 changed files with 122 additions and 39 deletions

View File

@ -1,4 +1,4 @@
# sunbeam-ovn-relay-operator # ovn-relay-k8s
## Developing ## Developing
@ -10,21 +10,24 @@ Create and activate a virtualenv with the development requirements:
## Code overview ## Code overview
TEMPLATE-TODO: Get familiarise with [Charmed Operator Framework](https://juju.is/docs/sdk)
One of the most important things a consumer of your charm (or library) and [Sunbeam documentation](sunbeam-docs).
needs to know is what set of functionality it provides. Which categories
does it fit into? Which events do you listen to? Which libraries do you ovn-relay-k8s charm uses the ops_sunbeam library and extends
consume? Which ones do you export and how are they used? OSBaseOVNOperatorCharm from the library.
ovn-relay-k8s charm consumes certificates to get generated
certificates from vault and ovsdb-cms relation to get
ovn-central endpoints.
## Intended use case ## Intended use case
TEMPLATE-TODO: ovn-relay-k8s charm deploys and configures OVN OVSDB relay service
Why were these decisions made? What's the scope of your charm? on a kubernetes based environment.
## Roadmap ## Roadmap
If this Charm doesn't fulfill all of the initial functionality you were TODO
hoping for or planning on, please add a Roadmap or TODO here
## Testing ## Testing
@ -32,3 +35,20 @@ The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests`: operator behaviour without full deployment. Just `run_tests`:
./run_tests ./run_tests
## Deployment
This project uses tox for building and managing. To build the charm
run:
tox -e build
To deploy the local test instance:
tox -e build
juju add-model ovn-relay
juju deploy ./ovn-relay-k8s_ubuntu-20.04-amd64.charm --resource ovn-sb-db-server-image=registry.jujucharms.com/charm/kau2b145zhaeuj5ly4w4m30qiq8qzspf93tnd/ovn-sb-db-server-image
<!-- LINKS -->
[sunbeam-docs]: https://github.com/openstack-charmers/advanced-sunbeam-openstack/blob/main/README.rst

View File

@ -1,24 +1,61 @@
# sunbeam-ovn-relay-operator # ovn-relay-k8s
## Description ## Description
TODO: Describe your charm in a few paragraphs of Markdown The ovn-relay-k8s is an operator to manage the OVN ovsdb
relay service on a kubernetes based environment.
## Usage ## Usage
TODO: Provide high-level usage, such as required config or relations ### Deployment
ovn-relay-k8s is deployed using below command:
juju deploy ovn-relay-k8s ovn-relay
Now connect the ovn-relay application to vault to generate
certificates.
juju relate vault:certificates ovn-relay:certificates
### Configuration
This section covers common and/or important configuration options. See file
`config.yaml` for the full list of options, along with their descriptions and
default values. See the [Juju documentation][juju-docs-config-apps] for details
on configuring applications.
### Actions
This section covers Juju [actions][juju-docs-actions] supported by the charm.
Actions allow specific operations to be performed on a per-unit basis. To
display action descriptions run `juju actions ovn-relay`. If the charm is not
deployed then see file `actions.yaml`.
## Relations ## Relations
TODO: Provide any relations which are provided or required by your charm ovn-relay-k8s requires the following relations:
`certificates`: To retrieve generated certificates from vault
`ovsdb-cms`: To retrieve ovn-central IPs from ovn-central
## OCI Images ## OCI Images
TODO: Include a link to the default image your charm uses The charm by default uses `registry.jujucharms.com/charm/kau2b145zhaeuj5ly4w4m30qiq8qzspf93tnd/ovn-sb-db-server-image` image.
## Contributing ## Contributing
Please see the [Juju SDK docs](https://juju.is/docs/sdk) for guidelines Please see the [Juju SDK docs](https://juju.is/docs/sdk) for guidelines
on enhancements to this charm following best practice guidelines, and on enhancements to this charm following best practice guidelines, and
`CONTRIBUTING.md` for developer guidance. [CONTRIBUTING.md](contributors-guide) for developer guidance.
## Bugs
Please report bugs on [Launchpad][lp-bugs-charm-ovn-relay-k8s].
<!-- LINKS -->
[contributors-guide]: https://github.com/openstack-charmers/charm-ovn-relay-operator/blob/main/CONTRIBUTING.md
[juju-docs-actions]: https://jaas.ai/docs/actions
[juju-docs-config-apps]: https://juju.is/docs/configuring-applications
[lp-bugs-charm-ovn-relay-k8s]: https://bugs.launchpad.net/charm-ovn-relay-k8s/+filebug

View File

@ -1,4 +1,4 @@
# Copyright 2022 liam # Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details. # See LICENSE file for licensing details.
# #

5
fetch-libs.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "INFO: Fetching libs from charmhub."
charmcraft fetch-lib charms.observability_libs.v0.kubernetes_service_patch
charmcraft fetch-lib charms.sunbeam_ovn_central_operator.v0.ovsdb

View File

@ -1,8 +1,12 @@
name: sunbeam-ovn-relay-operator name: ovn-relay-k8s
summary: Relay for Open Virtual Network for Open vSwitch summary: Relay for Open Virtual Network for Open vSwitch
maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com> maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com>
description: | description: |
In sert description The charm that deploys OVSDB Relay service.
The OVSDB Relay handles all read-only requests and forwards
transactions that requires database modifications to ovsdb
server.
tags: tags:
- networking - networking

View File

@ -3,10 +3,9 @@ jinja2
# Get resources from github until cacerts issue is charmbuild image is fixed. # Get resources from github until cacerts issue is charmbuild image is fixed.
# git+https://opendev.org/openstack/charm-ops-openstack#egg=ops_openstack # git+https://opendev.org/openstack/charm-ops-openstack#egg=ops_openstack
# git+https://opendev.org/openstack/charm-ops-interface-tls-certificates#egg=interface_tls_certificates # git+https://opendev.org/openstack/charm-ops-interface-tls-certificates#egg=interface_tls_certificates
git+https://github.com/openstack/charm-ops-openstack#egg=ops_openstack
git+https://github.com/openstack/charm-ops-interface-tls-certificates#egg=interface_tls_certificates git+https://github.com/openstack/charm-ops-interface-tls-certificates#egg=interface_tls_certificates
git+https://github.com/openstack-charmers/advanced-sunbeam-openstack@v0.1#egg=advanced_sunbeam_openstack git+https://github.com/openstack-charmers/advanced-sunbeam-openstack#egg=ops_sunbeam
lightkube lightkube
lightkube-models lightkube-models
cryptography < 3.4 cryptography < 3.4

View File

@ -1,5 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
# Copyright 2022 liam # Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details. # See LICENSE file for licensing details.
if [ -z "$VIRTUAL_ENV" -a -d venv/ ]; then if [ -z "$VIRTUAL_ENV" -a -d venv/ ]; then

View File

@ -1,6 +1,18 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright 2022 liam #
# See LICENSE file for licensing details. # 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.
# #
# Learn more at: https://juju.is/docs/sdk # Learn more at: https://juju.is/docs/sdk
@ -18,10 +30,10 @@ from typing import List
from ops.framework import StoredState from ops.framework import StoredState
from ops.main import main from ops.main import main
import advanced_sunbeam_openstack.config_contexts as sunbeam_ctxts import ops_sunbeam.config_contexts as sunbeam_ctxts
import advanced_sunbeam_openstack.ovn.container_handlers as ovn_chandlers import ops_sunbeam.ovn.container_handlers as ovn_chandlers
import advanced_sunbeam_openstack.ovn.config_contexts as ovn_ctxts import ops_sunbeam.ovn.config_contexts as ovn_ctxts
import advanced_sunbeam_openstack.ovn.charm as ovn_charm import ops_sunbeam.ovn.charm as ovn_charm
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -18,7 +18,7 @@ skip_missing_interpreters = False
requires = pip < 20.3 requires = pip < 20.3
virtualenv < 20.0 virtualenv < 20.0
# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci # NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci
minversion = 3.2.0 minversion = 3.18.0
[testenv] [testenv]
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
@ -35,6 +35,12 @@ whitelist_externals =
passenv = HOME TERM CS_* OS_* TEST_* passenv = HOME TERM CS_* OS_* TEST_*
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
[testenv:fetch]
basepython = python3
deps =
commands =
./fetch-libs.sh
[testenv:py3.8] [testenv:py3.8]
basepython = python3.8 basepython = python3.8
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
@ -83,6 +89,7 @@ omit =
.tox/* .tox/*
*/charmhelpers/* */charmhelpers/*
unit_tests/* unit_tests/*
src/templates/*
[testenv:venv] [testenv:venv]
basepython = python3 basepython = python3

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright 2021 Canonical Ltd. # Copyright 2022 Canonical Ltd.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ sys.path.append('lib') # noqa
sys.path.append('src') # noqa sys.path.append('src') # noqa
import charm import charm
import advanced_sunbeam_openstack.test_utils as test_utils import ops_sunbeam.test_utils as test_utils
class _OVNRelayXenaOperatorCharm(charm.OVNRelayXenaOperatorCharm): class _OVNRelayXenaOperatorCharm(charm.OVNRelayXenaOperatorCharm):
@ -59,11 +59,10 @@ class TestOVNRelayXenaOperatorCharm(test_utils.CharmTestCase):
self.assertEqual(self.harness.charm.seen_events, []) self.assertEqual(self.harness.charm.seen_events, [])
test_utils.set_all_pebbles_ready(self.harness) test_utils.set_all_pebbles_ready(self.harness)
test_utils.add_all_relations(self.harness) test_utils.add_all_relations(self.harness)
self.assertEqual( ovsdb_config_files = [
sorted(list(set( '/etc/ovn/cert_host',
self.container_calls.updated_files('ovsdb-server')))), '/etc/ovn/key_host',
[ '/etc/ovn/ovn-central.crt',
'/etc/ovn/cert_host', '/root/ovn-relay-wrapper.sh']
'/etc/ovn/key_host', for f in ovsdb_config_files:
'/etc/ovn/ovn-central.crt', self.check_file('ovsdb-server', f)
'/root/ovn-relay-wrapper.sh'])