Remove usage of __getattr__ to proxy onto storage
Change-Id: I5ef5fbb587ca263f1310d538f5e1328fe69701bb
This commit is contained in:
parent
599bffc54b
commit
6cfcec5404
|
@ -13,7 +13,6 @@
|
|||
# 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 functools
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
@ -48,25 +47,6 @@ class Service(rpc_service.Service):
|
|||
super(Service, self).wait()
|
||||
self.conn.consumer_thread.wait()
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""
|
||||
Proxy onto the storage api if there is no local method present..
|
||||
|
||||
For now to avoid to have to write up every method once more here...
|
||||
"""
|
||||
if hasattr(self, name):
|
||||
return getattr(self, name)
|
||||
|
||||
f = getattr(self.storage_conn, name)
|
||||
if not f:
|
||||
raise AttributeError
|
||||
|
||||
@functools.wraps(f)
|
||||
def _wrapper(*args, **kw):
|
||||
return f(*args, **kw)
|
||||
setattr(self, name, _wrapper)
|
||||
return _wrapper
|
||||
|
||||
# Currency
|
||||
def create_currency(self, ctxt, values):
|
||||
return self.storage_conn.create_currency(ctxt, values)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
A service that does calls towards the PGP web endpoint or so
|
||||
"""
|
||||
|
||||
import functools
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
@ -69,25 +68,6 @@ class Service(rpc_service.Service):
|
|||
:param values: The account values
|
||||
"""
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""
|
||||
Proxy onto the storage api if there is no local method present..
|
||||
|
||||
For now to avoid to have to write up every method once more here...
|
||||
"""
|
||||
if hasattr(self, name):
|
||||
return getattr(self, name)
|
||||
|
||||
f = getattr(self.provider, name)
|
||||
if not f:
|
||||
raise AttributeError
|
||||
|
||||
@functools.wraps(f)
|
||||
def _wrapper(*args, **kw):
|
||||
return f(*args, **kw)
|
||||
setattr(self, name, _wrapper)
|
||||
return _wrapper
|
||||
|
||||
|
||||
def launch():
|
||||
bs_service.prepare_service(sys.argv)
|
||||
|
|
|
@ -420,7 +420,8 @@ class ServiceTestCase(TestCase):
|
|||
fixture['methods'] = [self.get_fixture('pg_method')]
|
||||
ctxt = kw.pop('context', self.admin_ctxt)
|
||||
|
||||
data = self.services.central.pg_provider_register(ctxt, fixture, **kw)
|
||||
data = self.services.central.storage_conn.pg_provider_register(
|
||||
ctxt, fixture, **kw)
|
||||
|
||||
return fixture, data
|
||||
|
||||
|
|
Loading…
Reference in New Issue