summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-06-07 11:43:23 +0000
committerGerrit Code Review <review@openstack.org>2018-06-07 11:43:23 +0000
commitb118c2f043b8d6567a9d02170b202be13a3792ea (patch)
treecf8c7be058736b943b43cc8d324afe727e87d622
parentb3690124c4260aaf97b7acd75d2f00c6bf94fe69 (diff)
parent8ce6b37e5c626f717ce703721496dae9dfb5449b (diff)
Merge "Remove Cinder API v1 compatibility"14.0.0.0b2
-rw-r--r--openstack_dashboard/api/cinder.py14
-rw-r--r--openstack_dashboard/test/test_data/cinder_data.py12
-rw-r--r--openstack_dashboard/test/unit/api/test_cinder.py16
-rw-r--r--releasenotes/notes/remove-cinder-v1-api-support-7cec9a556945a5c5.yaml7
4 files changed, 14 insertions, 35 deletions
diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py
index 7cf18ca..4fe9792 100644
--- a/openstack_dashboard/api/cinder.py
+++ b/openstack_dashboard/api/cinder.py
@@ -74,7 +74,6 @@ class BaseCinderAPIResourceWrapper(base.APIResourceWrapper):
74 def name(self): 74 def name(self):
75 # If a volume doesn't have a name, use its id. 75 # If a volume doesn't have a name, use its id.
76 return (getattr(self._apiresource, 'name', None) or 76 return (getattr(self._apiresource, 'name', None) or
77 getattr(self._apiresource, 'display_name', None) or
78 getattr(self._apiresource, 'id', None)) 77 getattr(self._apiresource, 'id', None))
79 78
80 @property 79 @property
@@ -249,15 +248,6 @@ def get_microversion(request, features):
249 'cinder', features, api_versions.APIVersion, min_ver, max_ver)) 248 'cinder', features, api_versions.APIVersion, min_ver, max_ver))
250 249
251 250
252def _replace_v2_parameters(data):
253 if VERSIONS.active < 2:
254 data['display_name'] = data['name']
255 data['display_description'] = data['description']
256 del data['name']
257 del data['description']
258 return data
259
260
261def version_get(): 251def version_get():
262 api_version = VERSIONS.get_active_version() 252 api_version = VERSIONS.get_active_version()
263 return api_version['version'] 253 return api_version['version']
@@ -365,7 +355,6 @@ def volume_create(request, size, name, description, volume_type,
365 'imageRef': image_id, 355 'imageRef': image_id,
366 'availability_zone': availability_zone, 356 'availability_zone': availability_zone,
367 'source_volid': source_volid} 357 'source_volid': source_volid}
368 data = _replace_v2_parameters(data)
369 358
370 volume = cinderclient(request).volumes.create(size, **data) 359 volume = cinderclient(request).volumes.create(size, **data)
371 return Volume(volume) 360 return Volume(volume)
@@ -398,7 +387,6 @@ def volume_set_bootable(request, volume_id, bootable):
398def volume_update(request, volume_id, name, description): 387def volume_update(request, volume_id, name, description):
399 vol_data = {'name': name, 388 vol_data = {'name': name,
400 'description': description} 389 'description': description}
401 vol_data = _replace_v2_parameters(vol_data)
402 return cinderclient(request).volumes.update(volume_id, 390 return cinderclient(request).volumes.update(volume_id,
403 **vol_data) 391 **vol_data)
404 392
@@ -493,7 +481,6 @@ def volume_snapshot_create(request, volume_id, name,
493 data = {'name': name, 481 data = {'name': name,
494 'description': description, 482 'description': description,
495 'force': force} 483 'force': force}
496 data = _replace_v2_parameters(data)
497 484
498 return VolumeSnapshot(cinderclient(request).volume_snapshots.create( 485 return VolumeSnapshot(cinderclient(request).volume_snapshots.create(
499 volume_id, **data)) 486 volume_id, **data))
@@ -508,7 +495,6 @@ def volume_snapshot_delete(request, snapshot_id):
508def volume_snapshot_update(request, snapshot_id, name, description): 495def volume_snapshot_update(request, snapshot_id, name, description):
509 snapshot_data = {'name': name, 496 snapshot_data = {'name': name,
510 'description': description} 497 'description': description}
511 snapshot_data = _replace_v2_parameters(snapshot_data)
512 return cinderclient(request).volume_snapshots.update(snapshot_id, 498 return cinderclient(request).volume_snapshots.update(snapshot_id,
513 **snapshot_data) 499 **snapshot_data)
514 500
diff --git a/openstack_dashboard/test/test_data/cinder_data.py b/openstack_dashboard/test/test_data/cinder_data.py
index 0e028db..d6b57d1 100644
--- a/openstack_dashboard/test/test_data/cinder_data.py
+++ b/openstack_dashboard/test/test_data/cinder_data.py
@@ -87,7 +87,7 @@ def data(TEST):
87 {'id': "11023e92-8008-4c8b-8059-7f2293ff3887", 87 {'id': "11023e92-8008-4c8b-8059-7f2293ff3887",
88 'status': 'available', 88 'status': 'available',
89 'size': 40, 89 'size': 40,
90 'display_name': 'Volume name', 90 'name': 'Volume name',
91 'display_description': 'Volume description', 91 'display_description': 'Volume description',
92 'created_at': '2014-01-27 10:30:00', 92 'created_at': '2014-01-27 10:30:00',
93 'volume_type': None, 93 'volume_type': None,
@@ -97,7 +97,7 @@ def data(TEST):
97 {"id": "4b069dd0-6eaa-4272-8abc-5448a68f1cce", 97 {"id": "4b069dd0-6eaa-4272-8abc-5448a68f1cce",
98 "status": 'available', 98 "status": 'available',
99 "size": 10, 99 "size": 10,
100 "display_name": '', 100 "name": '',
101 "display_description": '', 101 "display_description": '',
102 "device": "/dev/hda", 102 "device": "/dev/hda",
103 "created_at": '2010-11-21 18:34:25', 103 "created_at": '2010-11-21 18:34:25',
@@ -108,7 +108,7 @@ def data(TEST):
108 {'id': "21023e92-8008-1234-8059-7f2293ff3889", 108 {'id': "21023e92-8008-1234-8059-7f2293ff3889",
109 'status': 'in-use', 109 'status': 'in-use',
110 'size': 10, 110 'size': 10,
111 'display_name': u'my_volume', 111 'name': u'my_volume',
112 'display_description': '', 112 'display_description': '',
113 'created_at': '2013-04-01 10:30:00', 113 'created_at': '2013-04-01 10:30:00',
114 'volume_type': None, 114 'volume_type': None,
@@ -120,7 +120,7 @@ def data(TEST):
120 'name': 'my_volume2', 120 'name': 'my_volume2',
121 'status': 'in-use', 121 'status': 'in-use',
122 'size': 10, 122 'size': 10,
123 'display_name': u'my_volume2', 123 'name': u'my_volume2',
124 'display_description': '', 124 'display_description': '',
125 'created_at': '2013-04-01 10:30:00', 125 'created_at': '2013-04-01 10:30:00',
126 'volume_type': 'vol_type_2', 126 'volume_type': 'vol_type_2',
@@ -131,7 +131,7 @@ def data(TEST):
131 {'id': "21023e92-8008-1234-8059-7f2293ff3890", 131 {'id': "21023e92-8008-1234-8059-7f2293ff3890",
132 'status': 'in-use', 132 'status': 'in-use',
133 'size': 10, 133 'size': 10,
134 'display_name': u'my_volume', 134 'name': u'my_volume',
135 'display_description': '', 135 'display_description': '',
136 'created_at': '2013-04-01 10:30:00', 136 'created_at': '2013-04-01 10:30:00',
137 'volume_type': None, 137 'volume_type': None,
@@ -471,7 +471,7 @@ def data(TEST):
471 {'id': "11023e92-8008-4c8b-8059-7f2293ff3881", 471 {'id': "11023e92-8008-4c8b-8059-7f2293ff3881",
472 'status': 'available', 472 'status': 'available',
473 'size': 40, 473 'size': 40,
474 'display_name': 'Volume name', 474 'name': 'Volume name',
475 'display_description': 'Volume description', 475 'display_description': 'Volume description',
476 'created_at': '2014-01-27 10:30:00', 476 'created_at': '2014-01-27 10:30:00',
477 'volume_type': 'vol_type_1', 477 'volume_type': 'vol_type_1',
diff --git a/openstack_dashboard/test/unit/api/test_cinder.py b/openstack_dashboard/test/unit/api/test_cinder.py
index 1376206..491bec7 100644
--- a/openstack_dashboard/test/unit/api/test_cinder.py
+++ b/openstack_dashboard/test/unit/api/test_cinder.py
@@ -496,7 +496,6 @@ class CinderApiVersionTests(test.TestCase):
496 # Get a v2 volume 496 # Get a v2 volume
497 volume = self.cinder_volumes.get(name="v2_volume") 497 volume = self.cinder_volumes.get(name="v2_volume")
498 self.assertTrue(hasattr(volume._apiresource, 'name')) 498 self.assertTrue(hasattr(volume._apiresource, 'name'))
499 self.assertFalse(hasattr(volume._apiresource, 'display_name'))
500 499
501 name = "A v2 test volume name" 500 name = "A v2 test volume name"
502 description = "A v2 volume description" 501 description = "A v2 volume description"
@@ -534,17 +533,4 @@ class CinderApiVersionTests(test.TestCase):
534 533
535 def test_get_id_for_nameless_volume(self): 534 def test_get_id_for_nameless_volume(self):
536 volume = self.cinder_volumes.first() 535 volume = self.cinder_volumes.first()
537 setattr(volume._apiresource, 'display_name', "") 536 self.assertEqual('Volume name', volume.name)
538 self.assertEqual(volume.id, volume.name)
539
540 def test_adapt_dictionary_to_v2(self):
541 volume = self.cinder_volumes.first()
542 data = {'name': volume.name,
543 'description': volume.description,
544 'size': volume.size}
545
546 ret_data = api.cinder._replace_v2_parameters(data)
547 self.assertIn('name', ret_data.keys())
548 self.assertIn('description', ret_data.keys())
549 self.assertNotIn('display_name', ret_data.keys())
550 self.assertNotIn('display_description', ret_data.keys())
diff --git a/releasenotes/notes/remove-cinder-v1-api-support-7cec9a556945a5c5.yaml b/releasenotes/notes/remove-cinder-v1-api-support-7cec9a556945a5c5.yaml
new file mode 100644
index 0000000..2acd53f
--- /dev/null
+++ b/releasenotes/notes/remove-cinder-v1-api-support-7cec9a556945a5c5.yaml
@@ -0,0 +1,7 @@
1---
2upgrade:
3 - |
4 Remove deprecated Cinder API V1 support. Cinder V1 API was deprecated for
5 a while and removed in Queens release. If you need to enable Cinder support
6 you should update the `OPENSTACK_API_VERSIONS` configuration option to use
7 Cinder V2 or V3 API.