rename package names and code cleanup
Following changes are done as part of this patch * Rename package name to ops_sunbeam * Rename shared_code/aso_charm to shared_code/sunbeam_charm * Modify rest of scripts as per above changes * Code cleanup
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
========================================
|
===============================
|
||||||
Advanced Sunbeam OpenStack Documentation
|
Sunbeam OpenStack Documentation
|
||||||
========================================
|
===============================
|
||||||
|
|
||||||
Tutorials
|
Tutorials
|
||||||
#########
|
#########
|
||||||
|
|
||||||
`Writing an OpenStack API charm with ASO <writing-OS-API-charm.rst>`_.
|
`Writing an OpenStack API charm with Sunbeam <doc/writing-OS-API-charm.rst>`_.
|
||||||
|
|
||||||
How-Tos
|
How-Tos
|
||||||
#######
|
#######
|
||||||
|
|
||||||
|
|
||||||
`How-To write a pebble handler <howto-pebble-handler.rst>`_.
|
`How-To write a pebble handler <doc/howto-pebble-handler.rst>`_.
|
||||||
|
|
||||||
`How-To write a relation handler <howto-relation-handler.rst>`_.
|
`How-To write a relation handler <doc/howto-relation-handler.rst>`_.
|
||||||
|
|
||||||
`How-To write a charm context <howto-config-context.rst>`_.
|
`How-To write a charm context <doc/howto-config-context.rst>`_.
|
||||||
|
|
||||||
`How-To expose services outside of K8S <howto-expose-services.rst>`_.
|
`How-To expose services outside of K8S <doc/howto-expose-services.rst>`_.
|
||||||
|
|
||||||
|
|
||||||
Reference
|
Reference
|
||||||
@@ -29,4 +29,4 @@ Concepts
|
|||||||
########
|
########
|
||||||
|
|
||||||
|
|
||||||
`ASO Concepts <concepts.rst>`_.
|
`Sunbeam Concepts <doc/concepts.rst>`_.
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
============================================
|
===================================
|
||||||
Advanced Sunbeam OpenStack OPS Charm Anatomy
|
Sunbeam OpenStack OPS Charm Anatomy
|
||||||
============================================
|
===================================
|
||||||
|
|
||||||
Overview
|
Overview
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Advanced Sunbeam OpenStack is designed to help with writing charms that
|
Sunbeam OpenStack is designed to help with writing charms that use the
|
||||||
use the `Charmed Operator Framework <https://juju.is/docs/sdk>`__ and are
|
`Charmed Operator Framework <https://juju.is/docs/sdk>`__ and are
|
||||||
deployed on Kubernetes. For the rest of this document when a charm is referred
|
deployed on Kubernetes. For the rest of this document when a charm is referred
|
||||||
to it is implied that it is a Charmed Operator framework charm on Kubernetes.
|
to it is implied that it is a Charmed Operator framework charm on Kubernetes.
|
||||||
|
|
||||||
It general a charm interacts with relations, renders configuration files and manages
|
It general a charm interacts with relations, renders configuration files and
|
||||||
services. ASO gives a charm a consistent way of doing this by implementing
|
manages services. Sunbeam Ops gives a charm a consistent way of doing this by
|
||||||
Container handlers and Relation handlers.
|
implementing Container handlers and Relation handlers.
|
||||||
|
|
||||||
Relation Handlers
|
Relation Handlers
|
||||||
-----------------
|
-----------------
|
||||||
@@ -43,6 +43,8 @@ The charm can append the new context onto those provided by the base class.
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
|
import ops_sunbeam.charm as sunbeam_charm
|
||||||
|
|
||||||
class MyCharm(sunbeam_charm.OSBaseOperatorAPICharm):
|
class MyCharm(sunbeam_charm.OSBaseOperatorAPICharm):
|
||||||
"""Charm the service."""
|
"""Charm the service."""
|
||||||
|
|
||||||
@@ -16,11 +16,10 @@ is required to the API endpoints from outside of Kubernetes - this
|
|||||||
is used by both end-users of the cloud as well as from machine
|
is used by both end-users of the cloud as well as from machine
|
||||||
based charms supporting OpenStack Hypervisors.
|
based charms supporting OpenStack Hypervisors.
|
||||||
|
|
||||||
Operator charms for API or other web services written using Advanced
|
Operator charms for API or other web services written using Sunbeam
|
||||||
Sunbeam OpenStack will automatically patch the Juju created service
|
OpenStack will automatically patch the Juju created service entry to
|
||||||
entry to be of type LoadBalancer, enabling Kubernetes to expose the
|
be of type LoadBalancer, enabling Kubernetes to expose the service to
|
||||||
service to the outside world using a suitable Load Balancer
|
the outside world using a suitable Load Balancer implementation.
|
||||||
implementation.
|
|
||||||
|
|
||||||
++++++++
|
++++++++
|
||||||
MicroK8S
|
MicroK8S
|
||||||
@@ -20,9 +20,9 @@ other container) then `PebbleHandler` should be used.
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import container_handlers
|
import ops_sunbeam.container_handlers as sunbeam_chandlers
|
||||||
|
|
||||||
class MyServicePebbleHandler(container_handlers.ServicePebbleHandler):
|
class MyServicePebbleHandler(sunbeam_chandlers.ServicePebbleHandler):
|
||||||
"""Manage MyService Container."""
|
"""Manage MyService Container."""
|
||||||
|
|
||||||
The handlers can create directories in the container once the pebble is
|
The handlers can create directories in the container once the pebble is
|
||||||
@@ -25,8 +25,8 @@ Add ASO common files to new charm. The script will ask a few basic questions:
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
git clone https://github.com/openstack-charmers/advanced-sunbeam-openstack
|
git clone https://github.com/openstack-charmers/advanced-sunbeam-openstack
|
||||||
cd advanced-sunbeam-openstack/shared_code
|
cd advanced-sunbeam-openstack
|
||||||
./aso-charm-init.sh ~/branches/charm-ironic-operator
|
./sunbeam-charm-init.sh ~/branches/charm-ironic-operator
|
||||||
|
|
||||||
This tool is designed to be used after 'charmcraft init' was initially run
|
This tool is designed to be used after 'charmcraft init' was initially run
|
||||||
service_name [ironic]: ironic
|
service_name [ironic]: ironic
|
||||||
@@ -151,4 +151,4 @@ preset. Then check the ironic api service is reponding.
|
|||||||
"version": "1.72"
|
"version": "1.72"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -15,19 +15,18 @@
|
|||||||
"""Base classes for defining a charm using the Operator framework.
|
"""Base classes for defining a charm using the Operator framework.
|
||||||
|
|
||||||
This library provided OSBaseOperatorCharm and OSBaseOperatorAPICharm. The
|
This library provided OSBaseOperatorCharm and OSBaseOperatorAPICharm. The
|
||||||
charm classes use advanced_sunbeam_openstack.relation_handlers.RelationHandler
|
charm classes use ops_sunbeam.relation_handlers.RelationHandler objects
|
||||||
objects to interact with relations. These objects also provide contexts which
|
to interact with relations. These objects also provide contexts which
|
||||||
can be used when defining templates.
|
can be used when defining templates.
|
||||||
|
|
||||||
In addition to the Relation handlers the charm class can also use
|
In addition to the Relation handlers the charm class can also use
|
||||||
advanced_sunbeam_openstack.config_contexts.ConfigContext objects which
|
ops_sunbeam.config_contexts.ConfigContext objects which can be
|
||||||
can be used when rendering templates, these are not specific to a relation.
|
used when rendering templates, these are not specific to a relation.
|
||||||
|
|
||||||
The charm class interacts with the containers it is managing via
|
The charm class interacts with the containers it is managing via
|
||||||
advanced_sunbeam_openstack.container_handlers.PebbleHandler. The
|
ops_sunbeam.container_handlers.PebbleHandler. The PebbleHandler
|
||||||
PebbleHandler defines the pebble layers, manages pushing
|
defines the pebble layers, manages pushing configuration to the
|
||||||
configuration to the containers and managing the service running
|
containers and managing the service running in the container.
|
||||||
in the container.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
@@ -42,10 +41,10 @@ import ops.pebble
|
|||||||
from lightkube import Client
|
from lightkube import Client
|
||||||
from lightkube.resources.core_v1 import Service
|
from lightkube.resources.core_v1 import Service
|
||||||
|
|
||||||
import advanced_sunbeam_openstack.config_contexts as sunbeam_config_contexts
|
import ops_sunbeam.config_contexts as sunbeam_config_contexts
|
||||||
import advanced_sunbeam_openstack.container_handlers as sunbeam_chandlers
|
import ops_sunbeam.container_handlers as sunbeam_chandlers
|
||||||
import advanced_sunbeam_openstack.core as sunbeam_core
|
import ops_sunbeam.core as sunbeam_core
|
||||||
import advanced_sunbeam_openstack.relation_handlers as sunbeam_rhandlers
|
import ops_sunbeam.relation_handlers as sunbeam_rhandlers
|
||||||
|
|
||||||
import charms.observability_libs.v0.kubernetes_service_patch as kube_svc_patch
|
import charms.observability_libs.v0.kubernetes_service_patch as kube_svc_patch
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ import logging
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import advanced_sunbeam_openstack.charm
|
import ops_sunbeam.charm
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ class ConfigContext:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
charm: "advanced_sunbeam_openstack.charm.OSBaseOperatorCharm",
|
charm: "ops_sunbeam.charm.OSBaseOperatorCharm",
|
||||||
namespace: str,
|
namespace: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run constructor."""
|
"""Run constructor."""
|
||||||
@@ -22,8 +22,8 @@ in the container.
|
|||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import advanced_sunbeam_openstack.core as sunbeam_core
|
import ops_sunbeam.core as sunbeam_core
|
||||||
import advanced_sunbeam_openstack.templating as sunbeam_templating
|
import ops_sunbeam.templating as sunbeam_templating
|
||||||
import ops.charm
|
import ops.charm
|
||||||
import ops.pebble
|
import ops.pebble
|
||||||
|
|
||||||
@@ -18,9 +18,9 @@ import collections
|
|||||||
from typing import Generator, List, TYPE_CHECKING, Tuple, Union
|
from typing import Generator, List, TYPE_CHECKING, Tuple, Union
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from advanced_sunbeam_openstack.charm import OSBaseOperatorCharm
|
from ops_sunbeam.charm import OSBaseOperatorCharm
|
||||||
from advanced_sunbeam_openstack.config_contexts import ConfigContext
|
from ops_sunbeam.config_contexts import ConfigContext
|
||||||
from advanced_sunbeam_openstack.relation_handlers import RelationHandler
|
from ops_sunbeam.relation_handlers import RelationHandler
|
||||||
|
|
||||||
ContainerConfigFile = collections.namedtuple(
|
ContainerConfigFile = collections.namedtuple(
|
||||||
"ContainerConfigFile",
|
"ContainerConfigFile",
|
||||||
@@ -23,7 +23,7 @@ from urllib.parse import urlparse
|
|||||||
import ops.charm
|
import ops.charm
|
||||||
import ops.framework
|
import ops.framework
|
||||||
|
|
||||||
import advanced_sunbeam_openstack.interfaces as sunbeam_interfaces
|
import ops_sunbeam.interfaces as sunbeam_interfaces
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ from pathlib import Path
|
|||||||
from typing import List, TYPE_CHECKING
|
from typing import List, TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import advanced_sunbeam_openstack.core as sunbeam_core
|
import ops_sunbeam.core as sunbeam_core
|
||||||
import ops.model
|
import ops.model
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack.templating import get_loader
|
from charmhelpers.contrib.openstack.templating import get_loader
|
||||||
@@ -3,7 +3,6 @@ jinja2
|
|||||||
kubernetes
|
kubernetes
|
||||||
ops
|
ops
|
||||||
python-keystoneclient
|
python-keystoneclient
|
||||||
git+https://opendev.org/openstack/charm-ops-openstack#egg=ops_openstack
|
|
||||||
git+https://github.com/openstack/charm-ops-interface-ceph-client#egg=interface_ceph_client
|
git+https://github.com/openstack/charm-ops-interface-ceph-client#egg=interface_ceph_client
|
||||||
lightkube
|
lightkube
|
||||||
lightkube-models
|
lightkube-models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = advanced_sunbeam_openstack
|
name = ops_sunbeam
|
||||||
summary = Charm lib for OpenStack Charms using operator framework
|
summary = Charm lib for OpenStack Charms using operator framework
|
||||||
version = 0.0.1.dev1
|
version = 0.0.1.dev1
|
||||||
description-file =
|
description-file =
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Module used to setup the advanced_sunbeam_openstack framework."""
|
"""Module used to setup the ops_sunbeam framework."""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def start_msg():
|
|||||||
|
|
||||||
def cookie(output_dir, extra_context):
|
def cookie(output_dir, extra_context):
|
||||||
cookiecutter(
|
cookiecutter(
|
||||||
'aso_charm/',
|
'sunbeam_charm/',
|
||||||
extra_context=extra_context,
|
extra_context=extra_context,
|
||||||
output_dir=output_dir)
|
output_dir=output_dir)
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
ops
|
ops
|
||||||
jinja2
|
jinja2
|
||||||
git+https://opendev.org/openstack/charm-ops-openstack#egg=ops_openstack
|
git+https://github.com/openstack-charmers/advanced-sunbeam-openstack#egg=ops_sunbeam
|
||||||
git+https://github.com/openstack-charmers/advanced-sunbeam-openstack#egg=advanced_sunbeam_openstack
|
|
||||||
lightkube
|
lightkube
|
||||||
# These are only needeed if the charm relates to ceph
|
# These are only needeed if the charm relates to ceph
|
||||||
git+https://github.com/openstack/charm-ops-interface-ceph-client#egg=interface_ceph_client
|
git+https://github.com/openstack/charm-ops-interface-ceph-client#egg=interface_ceph_client
|
||||||
@@ -9,7 +9,7 @@ import logging
|
|||||||
from ops.framework import StoredState
|
from ops.framework import StoredState
|
||||||
from ops.main import main
|
from ops.main import main
|
||||||
|
|
||||||
import advanced_sunbeam_openstack.charm as sunbeam_charm
|
import ops_sunbeam.charm as sunbeam_charm
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
[ -e .tox/cookie/bin/activate ] || tox -e cookie
|
[ -e .tox/cookie/bin/activate ] || tox -e cookie
|
||||||
source .tox/cookie/bin/activate
|
source .tox/cookie/bin/activate
|
||||||
shared_code/aso-charm-init.py $@
|
shared_code/sunbeam-charm-init.py $@
|
||||||
@@ -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}
|
||||||
@@ -71,7 +71,22 @@ deps = -r{toxinidir}/requirements.txt
|
|||||||
basepython = python3
|
basepython = python3
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands = flake8 {posargs} src unit_tests tests advanced_sunbeam_openstack --exclude unit_tests/lib
|
commands = flake8 {posargs} src unit_tests tests ops_sunbeam --exclude unit_tests/lib
|
||||||
|
|
||||||
|
[testenv:cover]
|
||||||
|
basepython = python3
|
||||||
|
deps = -r{toxinidir}/requirements.txt
|
||||||
|
-r{toxinidir}/test-requirements.txt
|
||||||
|
setenv =
|
||||||
|
{[testenv]setenv}
|
||||||
|
PYTHON=coverage run
|
||||||
|
commands =
|
||||||
|
coverage erase
|
||||||
|
stestr run --slowest {posargs}
|
||||||
|
coverage combine
|
||||||
|
coverage html -d cover
|
||||||
|
coverage xml -o cover/coverage.xml
|
||||||
|
coverage report
|
||||||
|
|
||||||
[coverage:run]
|
[coverage:run]
|
||||||
branch = True
|
branch = True
|
||||||
@@ -81,7 +96,6 @@ source =
|
|||||||
.
|
.
|
||||||
omit =
|
omit =
|
||||||
.tox/*
|
.tox/*
|
||||||
*/charmhelpers/*
|
|
||||||
unit_tests/*
|
unit_tests/*
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ if TYPE_CHECKING:
|
|||||||
sys.path.append("unit_tests/lib") # noqa
|
sys.path.append("unit_tests/lib") # noqa
|
||||||
sys.path.append("src") # noqa
|
sys.path.append("src") # noqa
|
||||||
|
|
||||||
import advanced_sunbeam_openstack.charm as sunbeam_charm
|
import ops_sunbeam.charm as sunbeam_charm
|
||||||
|
|
||||||
CHARM_CONFIG = """
|
CHARM_CONFIG = """
|
||||||
options:
|
options:
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import sys
|
|||||||
sys.path.append('lib') # noqa
|
sys.path.append('lib') # noqa
|
||||||
sys.path.append('src') # noqa
|
sys.path.append('src') # noqa
|
||||||
|
|
||||||
import advanced_sunbeam_openstack.charm as sunbeam_charm
|
import ops_sunbeam.charm as sunbeam_charm
|
||||||
import advanced_sunbeam_openstack.test_utils as test_utils
|
import ops_sunbeam.test_utils as test_utils
|
||||||
from . import test_charms
|
from . import test_charms
|
||||||
|
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ class TestOSBaseOperatorAPICharm(test_utils.CharmTestCase):
|
|||||||
self.harness.charm.public_url,
|
self.harness.charm.public_url,
|
||||||
'http://public-url')
|
'http://public-url')
|
||||||
|
|
||||||
@mock.patch('advanced_sunbeam_openstack.charm.Client')
|
@mock.patch('ops_sunbeam.charm.Client')
|
||||||
def test_endpoint_urls_no_ingress(self, mock_client: mock.patch) -> None:
|
def test_endpoint_urls_no_ingress(self, mock_client: mock.patch) -> None:
|
||||||
"""Test public_url and internal_url with no ingress defined."""
|
"""Test public_url and internal_url with no ingress defined."""
|
||||||
class mock_service:
|
class mock_service:
|
||||||
|
|||||||
Reference in New Issue
Block a user