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:
@@ -29,6 +29,7 @@ class TestUserPreference(base.TestCase):
|
||||
'network',
|
||||
'object-store',
|
||||
'orchestration',
|
||||
'volume',
|
||||
]
|
||||
self.assertEqual(expected, pref.service_names)
|
||||
|
||||
|
||||
24
openstack/tests/volume/v2/test_proxy.py
Normal file
24
openstack/tests/volume/v2/test_proxy.py
Normal 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)
|
||||
@@ -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):
|
||||
|
||||
20
openstack/volume/v2/_proxy.py
Normal file
20
openstack/volume/v2/_proxy.py
Normal 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)
|
||||
Reference in New Issue
Block a user