diff --git a/.gitignore b/.gitignore index 3a6afa9..31e7eea 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.swp .testrepository .tox +.stestr +.unit-state.db +**/__pycache__ diff --git a/requires.py b/requires.py index 839100a..665b526 100644 --- a/requires.py +++ b/requires.py @@ -83,19 +83,7 @@ class CephClientRequires(RelationBase): @param namespace: A group can optionally have a namespace defined that will be used to further restrict pool access. """ - # json.dumps of the CephBrokerRq() - rq = CephBrokerRq() - - json_rq = self.get_local(key='broker_req') - if json_rq: - try: - j = json.loads(json_rq) - log("Json request: {}".format(json_rq)) - rq.set_ops(j['ops']) - except ValueError as err: - log("Unable to decode broker_req: {}. Error {}".format( - json_rq, err)) - + rq = self.get_current_request() rq.add_op_create_replicated_pool(name=name, replica_count=replicas, pg_num=pg_num, @@ -155,6 +143,22 @@ class CephClientRequires(RelationBase): self.set_local(key='broker_req', value=current_request.request) send_request_if_needed(current_request, relation=self.relation_name) + def get_current_request(self): + """Return the current broker request for the interface.""" + # json.dumps of the CephBrokerRq() + rq = CephBrokerRq() + + json_rq = self.get_local(key='broker_req') + if json_rq: + try: + j = json.loads(json_rq) + log("Json request: {}".format(json_rq)) + rq.set_ops(j['ops']) + except ValueError as err: + log("Unable to decode broker_req: {}. Error {}".format( + json_rq, err)) + return rq + 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! diff --git a/tox.ini b/tox.ini index 451b674..e1c896a 100644 --- a/tox.ini +++ b/tox.ini @@ -25,6 +25,16 @@ basepython = python3.6 deps = -r{toxinidir}/test-requirements.txt commands = ostestr {posargs} +[testenv:py37] +basepython = python3.7 +deps = -r{toxinidir}/test-requirements.txt +commands = ostestr {posargs} + +[testenv:py38] +basepython = python3.8 +deps = -r{toxinidir}/test-requirements.txt +commands = ostestr {posargs} + [testenv:pep8] basepython = python3 deps = -r{toxinidir}/test-requirements.txt