Use `ceph-rbd-mirror` interface, move boilerplate upstream

Make use of newly created `ceph` layer and `CephCharm` class
added to `charms.openstack`.
This commit is contained in:
Frode Nordahl 2019-02-06 08:00:12 +01:00
parent 5537237ea7
commit ededdceecc
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
8 changed files with 110 additions and 50 deletions

View File

@ -1,23 +1 @@
options:
source:
default: distro
type: string
description: |
Repository from which to install Ceph
May be one of the following:
distro (default)
ppa:somecustom/ppa (PPA name must include UCA OpenStack Release name)
deb url sources entry|key id
or a supported Ubuntu Cloud Archive pocket.
Supported Ubuntu Cloud Archive pockets include:
cloud:xenial-pike
cloud:xenial-queens
cloud:bionic-rocky
Note that updating this setting to a source that is known to
provide a later version of Ceph will trigger a software
upgrade.
options: {}

View File

@ -1,16 +1,9 @@
includes:
- layer:leadership
- layer:openstack
- interface:ceph-client
- layer:ceph
- interface:ceph-rbd-mirror
- interface:nrpe-external-master
options:
basic:
use_venv: True
include_system_packages: True
repo: https://github.com/openstack/charm-ceph-rbd-mirror
config:
deletes:
- debug
- verbose
- use-internal-endpoints
- ssl_ca

View File

@ -12,30 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import collections
import charms_openstack.charm
import charms_openstack.adapters
class CephRBDMirrorCharm(charms_openstack.charm.OpenStackCharm):
# Override source config key to be compatible with the other Ceph charms
source_config_key = 'source'
class CephRBDMirrorCharm(charms_openstack.charm.CephCharm):
# We require Ceph 12.2 Luminous or later for HA support in the Ceph
# rbd-mirror daemon. Luminous appears in UCA at pike.
release = 'pike'
name = 'ceph-rbd-mirror'
packages = ['rbd-mirror']
python_version = 3
required_relations = ['ceph-cluster']
release_pkg = 'rbd-mirror'
package_codenames = {
'rbd-mirror': collections.OrderedDict([
('12', 'pike'),
('13', 'rocky'),
]),
}
required_relations = ['ceph-local', 'ceph-remote']
def config_changed(self):
"""Check for upgrade."""
self.upgrade_if_available(None)
def install(self):
"""We override install function to configure source before installing

View File

@ -28,5 +28,7 @@ provides:
interface: nrpe-external-master
scope: container
requires:
ceph-cluster:
interface: ceph-client
ceph-local:
interface: ceph-rbd-mirror
ceph-remote:
interface: ceph-rbd-mirror

View File

@ -26,12 +26,38 @@ charms_openstack.bus.discover()
charm.use_defaults(
'charm.installed',
'config.changed',
'update-status')
'update-status',
'upgrade-charm')
@reactive.when('ceph-cluster.connected')
@reactive.when_all('ceph-local.connected', 'ceph-remote.connected')
@reactive.when_not_all('ceph-local.available', 'ceph-remote.available')
def ceph_connected():
for flag in ('ceph-local.connected', 'ceph-remote.connected'):
endpoint = reactive.relations.endpoint_from_flag(flag)
endpoint.request_key()
with charm.provide_charm_instance() as charm_instance:
ch_core.hookenv.log('Ceph connected, charm_instance @ {}'
.format(charm_instance),
level=ch_core.hookenv.DEBUG)
charm_instance.assess_status()
@reactive.when_all('ceph-local.available', 'ceph-remote.available')
def ceph_available():
mon_hosts = {}
for flag in ('ceph-local.available', 'ceph-remote.available'):
endpoint = reactive.relations.endpoint_from_flag(flag)
mon_hosts[endpoint.endpoint_name] = endpoint.mon_hosts
for relation in endpoint.relations:
for unit in relation.units:
ch_core.hookenv.log('{}: "{}"'.format(flag, unit.received),
level=ch_core.hookenv.INFO)
with charm.provide_charm_instance() as charm_instance:
ch_core.hookenv.log('Ceph available, mon_hosts: "{}" '
'charm_instance @ {}'
.format(mon_hosts, charm_instance),
level=ch_core.hookenv.DEBUG)
charm_instance.assess_status()

View File

@ -0,0 +1,53 @@
series: bionic
applications:
ceph-mon:
charm: cs:~fnordahl/ceph-mon-rbd-mirror
num_units: 3
options:
expected-osd-count: 3
source: distro
ceph-osd:
charm: cs:~openstack-charmers-next/ceph-osd
num_units: 3
options:
source: distro
storage:
osd-devices: cinder,20G
ceph-rbd-mirror:
series: bionic
charm: ../../../ceph-rbd-mirror
num_units: 1
options:
source: distro
ceph-mon-b:
charm: cs:~fnordahl/ceph-mon-rbd-mirror
num_units: 3
options:
expected-osd-count: 3
source: distro
ceph-osd-b:
charm: cs:~openstack-charmers-next/ceph-osd
num_units: 3
options:
source: distro
storage:
osd-devices: cinder,20G
ceph-rbd-mirror-b:
series: bionic
charm: ../../../ceph-rbd-mirror
num_units: 1
options:
source: distro
relations:
- - ceph-mon:osd
- ceph-osd:mon
- - ceph-mon
- ceph-rbd-mirror:ceph-local
- - ceph-mon
- ceph-rbd-mirror-b:ceph-remote
- - ceph-mon-b:osd
- ceph-osd-b:mon
- - ceph-mon-b
- ceph-rbd-mirror-b:ceph-local
- - ceph-mon-b
- ceph-rbd-mirror:ceph-remote

15
src/tests/tests.yaml Normal file
View File

@ -0,0 +1,15 @@
charm_name: ceph-rbd-mirror
smoke_bundles:
- bionic-queens
gate_bundles:
- xenial-pike
- xenial-queens
- bionic-queens
- bionic-rocky
- cosmic-rocky
dev_bundles:
- disco-stein
configure:
- zaza.charm_tests.noop.setup.basic_setup
tests:
- zaza.charm_tests.noop.tests.NoopTest

View File

@ -10,6 +10,7 @@ setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0
TERM=linux
LAYER_PATH={toxinidir}/layers
INTERFACE_PATH={toxinidir}/interfaces
JUJU_REPOSITORY={toxinidir}/build
passenv = http_proxy https_proxy INTERFACE_PATH
install_command =