Re-organise interface
Re-organise interface to allow multiple interfaces to share common code. The idea being to add ceph-mds to this code base. Change-Id: Ie53ef7e5fc7a461dca8e53d9f91b332399a70076
This commit is contained in:
parent
35e3ade214
commit
cd3626b047
1
ceph-client
Symbolic link
1
ceph-client
Symbolic link
@ -0,0 +1 @@
|
||||
src/ceph_client
|
1
src/ceph_client/lib
Symbolic link
1
src/ceph_client/lib
Symbolic link
@ -0,0 +1 @@
|
||||
../lib
|
20
src/ceph_client/provides.py
Normal file
20
src/ceph_client/provides.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
from .lib import base_provides
|
||||
|
||||
|
||||
class CephClientProvider(base_provides.CephProvides):
|
||||
|
||||
pass
|
20
src/ceph_client/requires.py
Normal file
20
src/ceph_client/requires.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
from .lib import base_requires
|
||||
|
||||
|
||||
class CephClientRequires(base_requires.CephRequires):
|
||||
|
||||
pass
|
@ -9,7 +9,7 @@ from charms.reactive import scopes
|
||||
# from charms.reactive import not_unless
|
||||
|
||||
|
||||
class CephClientProvider(RelationBase):
|
||||
class CephProvides(RelationBase):
|
||||
scope = scopes.UNIT
|
||||
|
||||
@hook('{provides:ceph-client}-relation-{joined,changed}')
|
@ -28,7 +28,7 @@ from charmhelpers.contrib.storage.linux.ceph import (
|
||||
)
|
||||
|
||||
|
||||
class CephClientRequires(RelationBase):
|
||||
class CephRequires(RelationBase):
|
||||
scope = scopes.GLOBAL
|
||||
|
||||
auto_accessors = ['auth', 'key']
|
@ -0,0 +1,17 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.append('src')
|
@ -17,11 +17,12 @@ from unittest import mock
|
||||
|
||||
with mock.patch('charmhelpers.core.hookenv.metadata') as _meta:
|
||||
_meta.return_Value = 'ss'
|
||||
import provides
|
||||
from ceph_client import provides
|
||||
|
||||
_hook_args = {}
|
||||
|
||||
TO_PATCH = [
|
||||
TO_PATCH = []
|
||||
TO_PATCH_BASE_PROVIDES = [
|
||||
'relation_set',
|
||||
]
|
||||
|
||||
@ -63,8 +64,9 @@ class TestCephClientProvider(unittest.TestCase):
|
||||
import importlib
|
||||
importlib.reload(provides)
|
||||
|
||||
def patch(self, method):
|
||||
_m = mock.patch.object(self.obj, method)
|
||||
def patch(self, method, obj=None):
|
||||
target_obj = obj or self.obj
|
||||
_m = mock.patch.object(target_obj, method)
|
||||
_mock = _m.start()
|
||||
self.addCleanup(_m.stop)
|
||||
return _mock
|
||||
@ -76,6 +78,8 @@ class TestCephClientProvider(unittest.TestCase):
|
||||
self.obj = provides
|
||||
for method in TO_PATCH:
|
||||
setattr(self, method, self.patch(method))
|
||||
for method in TO_PATCH_BASE_PROVIDES:
|
||||
setattr(self, method, self.patch(method, provides.base_provides))
|
||||
|
||||
def tearDown(self):
|
||||
self.cr = None
|
||||
|
@ -17,14 +17,15 @@ from unittest import mock
|
||||
|
||||
with mock.patch('charmhelpers.core.hookenv.metadata') as _meta:
|
||||
_meta.return_Value = 'ss'
|
||||
import requires
|
||||
from ceph_client import requires
|
||||
|
||||
import charmhelpers
|
||||
|
||||
|
||||
_hook_args = {}
|
||||
|
||||
TO_PATCH = [
|
||||
TO_PATCH = []
|
||||
TO_PATCH_BASE_REQUIRES = [
|
||||
'is_request_complete',
|
||||
'send_request_if_needed',
|
||||
]
|
||||
@ -67,8 +68,9 @@ class TestCephClientRequires(unittest.TestCase):
|
||||
import importlib
|
||||
importlib.reload(requires)
|
||||
|
||||
def patch(self, method):
|
||||
_m = mock.patch.object(self.obj, method)
|
||||
def patch(self, method, obj=None):
|
||||
target_obj = obj or self.obj
|
||||
_m = mock.patch.object(target_obj, method)
|
||||
_mock = _m.start()
|
||||
self.addCleanup(_m.stop)
|
||||
return _mock
|
||||
@ -80,6 +82,8 @@ class TestCephClientRequires(unittest.TestCase):
|
||||
self.obj = requires
|
||||
for method in TO_PATCH:
|
||||
setattr(self, method, self.patch(method))
|
||||
for method in TO_PATCH_BASE_REQUIRES:
|
||||
setattr(self, method, self.patch(method, requires.base_requires))
|
||||
|
||||
def tearDown(self):
|
||||
self.cr = None
|
||||
@ -274,8 +278,8 @@ class TestCephClientRequires(unittest.TestCase):
|
||||
'class-read': ['rbd_children']},
|
||||
'op': 'add-permissions-to-key'}])
|
||||
|
||||
@mock.patch.object(requires.hookenv, 'related_units')
|
||||
@mock.patch.object(requires.hookenv, 'relation_get')
|
||||
@mock.patch.object(requires.base_requires.hookenv, 'related_units')
|
||||
@mock.patch.object(requires.base_requires.hookenv, 'relation_get')
|
||||
def test_get_remote_all(self, relation_get, related_units):
|
||||
unit_data = {
|
||||
'rid:1': {
|
||||
|
Loading…
Reference in New Issue
Block a user