diff --git a/openstack/connection.py b/openstack/connection.py index f208bf4be..f76a9b765 100644 --- a/openstack/connection.py +++ b/openstack/connection.py @@ -333,11 +333,19 @@ class Connection(six.with_metaclass(_meta.ConnectionMeta, # we get an adapter. if isinstance(service, six.string_types): service = service_description.ServiceDescription(service) - service_proxy = service._make_proxy(self) - # Register the proxy class with every known alias + # Directly invoke descriptor of the ServiceDescription + def getter(self): + return service.__get__(self, service) + + # Register the ServiceDescription class (as property) + # with every known alias for a "runtime descriptor" for attr_name in service.all_types: - setattr(self, attr_name.replace('-', '_'), service_proxy) + setattr( + self.__class__, + attr_name.replace('-', '_'), + property(fget=getter) + ) def authorize(self): """Authorize this Connection diff --git a/openstack/tests/unit/test_connection.py b/openstack/tests/unit/test_connection.py index e9b6691d9..ce2320cc6 100644 --- a/openstack/tests/unit/test_connection.py +++ b/openstack/tests/unit/test_connection.py @@ -260,6 +260,13 @@ class TestNewService(base.TestCase): self.use_keystone_v3(catalog='catalog-v3-fake-v1.json') conn = self.cloud + service = fake_service.FakeService('fake') + + conn.add_service(service) + + # Ensure no discovery calls made + self.assertEqual(0, len(self.adapter.request_history)) + self.register_uris([ dict(method='GET', uri='https://fake.example.com', @@ -272,10 +279,6 @@ class TestNewService(base.TestCase): status_code=404), ]) - service = fake_service.FakeService('fake') - - conn.add_service(service) - self.assertEqual( 'openstack.tests.unit.fake.v1._proxy', conn.fake.__class__.__module__)