Retire repository
Change-Id: I99ff9fb980dff37e58abd4e027204d36ce5aa278
This commit is contained in:
parent
75c0169d47
commit
dcd0b5f2bb
|
@ -1,3 +1,3 @@
|
||||||
- project:
|
- project:
|
||||||
templates:
|
templates:
|
||||||
- python-charm-interface-jobs
|
- noop-jobs
|
||||||
|
|
40
README.md
40
README.md
|
@ -1,39 +1,3 @@
|
||||||
# Overview
|
# Repository Retired
|
||||||
|
|
||||||
This interface layer handles the communication between the Ceph Monitor
|
Merged into https://opendev.org/openstack/charm-interface-ceph-client
|
||||||
and a client that requires an admin key.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
## Requires
|
|
||||||
|
|
||||||
This interface layer will set the following states, as appropriate:
|
|
||||||
|
|
||||||
* `{relation_name}.available` The ceph client has been related to a provider.
|
|
||||||
The following accessors will be available:
|
|
||||||
- key - The mds cephx key
|
|
||||||
- admin_key - The cephx admin key
|
|
||||||
- auth - Whether or not strict auth is supported
|
|
||||||
- mon_hosts - The public addresses list of the monitor cluster
|
|
||||||
|
|
||||||
|
|
||||||
Client example:
|
|
||||||
|
|
||||||
```python
|
|
||||||
@when('ceph-mds.available')
|
|
||||||
def ceph_connected(ceph_info):
|
|
||||||
charm_ceph_conf = os.path.join(os.sep, 'etc', 'ceph', 'ceph.conf')
|
|
||||||
cephx_key = os.path.join(os.sep, 'etc', 'ceph', 'ceph.client.admin.keyring')
|
|
||||||
|
|
||||||
ceph_context = {
|
|
||||||
'auth_supported': ceph_client.auth,
|
|
||||||
'mon_hosts': ceph_client.mon_hosts,
|
|
||||||
}
|
|
||||||
|
|
||||||
with open(charm_ceph_conf, 'w') as cephconf:
|
|
||||||
cephconf.write(render_template('ceph.conf', ceph_context))
|
|
||||||
|
|
||||||
# Write out the cephx_key also
|
|
||||||
with open(cephx_key, 'w') as cephconf:
|
|
||||||
cephconf.write(ceph_client.key)
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
name: ceph-mds
|
|
||||||
summary: Ceph MDS Client Interface
|
|
||||||
version: 1
|
|
126
requires.py
126
requires.py
|
@ -1,126 +0,0 @@
|
||||||
import json
|
|
||||||
import socket
|
|
||||||
|
|
||||||
from charms.reactive import hook
|
|
||||||
from charms.reactive import RelationBase
|
|
||||||
from charms.reactive import scopes
|
|
||||||
from charmhelpers.core import hookenv
|
|
||||||
from charmhelpers.core.hookenv import log, service_name
|
|
||||||
from charmhelpers.contrib.network.ip import format_ipv6_addr
|
|
||||||
|
|
||||||
from charmhelpers.contrib.storage.linux.ceph import (
|
|
||||||
CephBrokerRq,
|
|
||||||
is_request_complete,
|
|
||||||
send_request_if_needed,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CephClient(RelationBase):
|
|
||||||
scope = scopes.GLOBAL
|
|
||||||
|
|
||||||
auto_accessors = ['fsid', 'auth']
|
|
||||||
ceph_pool_app_name = 'cephfs'
|
|
||||||
|
|
||||||
@hook('{requires:ceph-mds}-relation-{joined}')
|
|
||||||
def joined(self):
|
|
||||||
self.set_remote(key='mds-name', value=socket.gethostname())
|
|
||||||
self.set_state('{relation_name}.connected')
|
|
||||||
self.initialize_mds(name=service_name())
|
|
||||||
|
|
||||||
@hook('{requires:ceph-mds}-relation-{changed,departed}')
|
|
||||||
def changed(self):
|
|
||||||
data = {
|
|
||||||
'mds_key': self.mds_key(),
|
|
||||||
'fsid': self.fsid(),
|
|
||||||
'auth': self.auth(),
|
|
||||||
'mon_hosts': self.mon_hosts()
|
|
||||||
}
|
|
||||||
if all(data.values()):
|
|
||||||
self.set_state('{relation_name}.available')
|
|
||||||
|
|
||||||
json_rq = self.get_local(key='broker_req')
|
|
||||||
if json_rq:
|
|
||||||
rq = CephBrokerRq()
|
|
||||||
j = json.loads(json_rq)
|
|
||||||
rq.ops = j['ops']
|
|
||||||
log("changed broker_req: {}".format(rq.ops))
|
|
||||||
|
|
||||||
if rq and is_request_complete(rq,
|
|
||||||
relation=self.relation_name):
|
|
||||||
log("Setting ceph-mds.pools.available")
|
|
||||||
self.set_state('{relation_name}.pools.available')
|
|
||||||
else:
|
|
||||||
log("incomplete request. broker_req not found")
|
|
||||||
|
|
||||||
@hook('{requires:ceph-mds}-relation-{broken}')
|
|
||||||
def broken(self):
|
|
||||||
self.remove_state('{relation_name}.available')
|
|
||||||
self.remove_state('{relation_name}.connected')
|
|
||||||
self.remove_state('{relation_name}.pools.available')
|
|
||||||
|
|
||||||
def initialize_mds(self, name, replicas=3):
|
|
||||||
"""
|
|
||||||
Request pool setup and mds creation
|
|
||||||
|
|
||||||
@param name: name of mds pools to create
|
|
||||||
@param replicas: number of replicas for supporting pools
|
|
||||||
"""
|
|
||||||
# json.dumps of the CephBrokerRq()
|
|
||||||
json_rq = self.get_local(key='broker_req')
|
|
||||||
|
|
||||||
if not json_rq:
|
|
||||||
rq = CephBrokerRq()
|
|
||||||
rq.add_op_create_pool(name="{}_data".format(name),
|
|
||||||
replica_count=replicas,
|
|
||||||
weight=None,
|
|
||||||
app_name=self.ceph_pool_app_name)
|
|
||||||
rq.add_op_create_pool(name="{}_metadata".format(name),
|
|
||||||
replica_count=replicas,
|
|
||||||
weight=None,
|
|
||||||
app_name=self.ceph_pool_app_name)
|
|
||||||
# Create CephFS
|
|
||||||
rq.ops.append({
|
|
||||||
'op': 'create-cephfs',
|
|
||||||
'mds_name': name,
|
|
||||||
'data_pool': "{}_data".format(name),
|
|
||||||
'metadata_pool': "{}_metadata".format(name),
|
|
||||||
})
|
|
||||||
self.set_local(key='broker_req', value=rq.request)
|
|
||||||
send_request_if_needed(rq, relation=self.relation_name)
|
|
||||||
else:
|
|
||||||
rq = CephBrokerRq()
|
|
||||||
try:
|
|
||||||
j = json.loads(json_rq)
|
|
||||||
log("Json request: {}".format(json_rq))
|
|
||||||
rq.ops = j['ops']
|
|
||||||
send_request_if_needed(rq, relation=self.relation_name)
|
|
||||||
except ValueError as err:
|
|
||||||
log("Unable to decode broker_req: {}. Error: {}".format(
|
|
||||||
json_rq, err))
|
|
||||||
|
|
||||||
def get_remote_all(self, key, default=None):
|
|
||||||
"""Return a list of all values presented by remote units for key"""
|
|
||||||
# TODO: might be a nicer way todo this - written a while back!
|
|
||||||
values = []
|
|
||||||
for conversation in self.conversations():
|
|
||||||
for relation_id in conversation.relation_ids:
|
|
||||||
for unit in hookenv.related_units(relation_id):
|
|
||||||
value = hookenv.relation_get(key,
|
|
||||||
unit,
|
|
||||||
relation_id) or default
|
|
||||||
if value:
|
|
||||||
values.append(value)
|
|
||||||
return list(set(values))
|
|
||||||
|
|
||||||
def mon_hosts(self):
|
|
||||||
"""List of all monitor host public addresses"""
|
|
||||||
hosts = []
|
|
||||||
addrs = self.get_remote_all('ceph-public-address')
|
|
||||||
for addr in addrs:
|
|
||||||
hosts.append('{}:6789'.format(format_ipv6_addr(addr) or addr))
|
|
||||||
hosts.sort()
|
|
||||||
return hosts
|
|
||||||
|
|
||||||
def mds_key(self):
|
|
||||||
"""Retrieve the cephx key for the local mds unit"""
|
|
||||||
return self.get_remote('{}_mds_key'.format(socket.gethostname()))
|
|
|
@ -1,2 +0,0 @@
|
||||||
flake8>=2.2.4,<=2.4.1
|
|
||||||
os-testr>=0.4.1
|
|
40
tox.ini
40
tox.ini
|
@ -1,40 +0,0 @@
|
||||||
[tox]
|
|
||||||
envlist = pep8,py34,py35
|
|
||||||
skipsdist = True
|
|
||||||
# NOTE(beisner): Avoid build/test env pollution by not enabling sitepackages.
|
|
||||||
sitepackages = False
|
|
||||||
# NOTE(beisner): Avoid false positives by not skipping missing interpreters.
|
|
||||||
skip_missing_interpreters = False
|
|
||||||
|
|
||||||
[testenv]
|
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
|
||||||
PYTHONHASHSEED=0
|
|
||||||
install_command =
|
|
||||||
pip install {opts} {packages}
|
|
||||||
commands = ostestr {posargs}
|
|
||||||
|
|
||||||
[testenv:py34]
|
|
||||||
basepython = python3.4
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
# TODO: Need to write unit tests then remove the following command.
|
|
||||||
# https://github.com/juju/charm-tools/issues/249
|
|
||||||
commands = /bin/true
|
|
||||||
|
|
||||||
[testenv:py35]
|
|
||||||
basepython = python3.5
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
# TODO: Need to write unit tests then remove the following command.
|
|
||||||
# https://github.com/juju/charm-tools/issues/249
|
|
||||||
commands = /bin/true
|
|
||||||
|
|
||||||
[testenv:pep8]
|
|
||||||
basepython = python3
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = flake8 {posargs}
|
|
||||||
|
|
||||||
[testenv:venv]
|
|
||||||
basepython = python3
|
|
||||||
commands = {posargs}
|
|
||||||
|
|
||||||
[flake8]
|
|
||||||
ignore = E402,E226
|
|
Loading…
Reference in New Issue