Add a Proxy for the Volume service

Add a Proxy for the Volume service and add the Volume service to the
UserPreferences to make it convenient to use.

Change-Id: I3507dfdfc8b44c51b83ae0d0eaa76c5f84c29fef
This commit is contained in:
Everett Toews
2015-03-27 13:40:03 -05:00
parent 91cec01fc9
commit 2e81c7e42c
4 changed files with 50 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ class TestUserPreference(base.TestCase):
'network',
'object-store',
'orchestration',
'volume',
]
self.assertEqual(expected, pref.service_names)

View File

@@ -0,0 +1,24 @@
# 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 openstack.tests import test_proxy_base
from openstack.volume.v2 import _proxy
class TestVolumeProxy(test_proxy_base.TestProxyBase):
def setUp(self):
super(TestVolumeProxy, self).setUp()
self.proxy = _proxy.Proxy(self.session)
def test_volume_get(self):
self.verify_get('openstack.volume.v2.volume.Volume.get',
self.proxy.get_volume)

View File

@@ -64,6 +64,7 @@ from openstack.network import network_service
from openstack.object_store import object_store_service
from openstack.orchestration import orchestration_service
from openstack.telemetry import telemetry_service
from openstack.volume import volume_service
class UserPreference(object):
@@ -116,6 +117,10 @@ class UserPreference(object):
serv = telemetry_service.TelemetryService()
serv.set_visibility(None)
self._services[serv.service_type] = serv
serv = volume_service.VolumeService()
serv.set_visibility(None)
self._services[serv.service_type] = serv
self.service_names = sorted(self._services.keys())
def __repr__(self):

View File

@@ -0,0 +1,20 @@
# 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 openstack import proxy
from openstack.volume.v2 import volume
class Proxy(proxy.BaseProxy):
def get_volume(self, **data):
return volume.Volume(data).get(self.session)