requires: Provide get_current_request method
Minor refactor to ensure that the get_current_request method actually exists for the requires part of this interface. Misc drive by fixes for CI scaffolding as well. Change-Id: I26e9585df2a84c336d9f01115c6208d7ef994b3c
This commit is contained in:
parent
49f4a1279a
commit
462582e4f3
|
@ -2,3 +2,6 @@
|
|||
*.swp
|
||||
.testrepository
|
||||
.tox
|
||||
.stestr
|
||||
.unit-state.db
|
||||
**/__pycache__
|
||||
|
|
30
requires.py
30
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!
|
||||
|
|
10
tox.ini
10
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
|
||||
|
|
Loading…
Reference in New Issue