From 2cd599ac6be7ab1be9f76bcf9f91105b545fdaed Mon Sep 17 00:00:00 2001 From: lisali Date: Thu, 18 Aug 2016 11:39:13 +0800 Subject: [PATCH] Fix the interface to call update_server_volume Currently when calling update_server_volume through nova client, it gives the user id of the used context, which leads failure. As this user may can't access the nova service catalog. This patch sets privileged_user as True and calls nova. Change-Id: I5861b2ca9cc1d10ba83eb088aa9fc073973aee93 Closes-bug: #1614344 --- cinder/compute/nova.py | 7 ++++--- cinder/tests/unit/compute/test_nova.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cinder/compute/nova.py b/cinder/compute/nova.py index e7cc70955..4d93a377b 100644 --- a/cinder/compute/nova.py +++ b/cinder/compute/nova.py @@ -175,9 +175,10 @@ class API(base.Base): def update_server_volume(self, context, server_id, attachment_id, new_volume_id): - novaclient(context).volumes.update_server_volume(server_id, - attachment_id, - new_volume_id) + nova = novaclient(context, admin_endpoint=True, privileged_user=True) + nova.volumes.update_server_volume(server_id, + attachment_id, + new_volume_id) def create_volume_snapshot(self, context, volume_id, create_info): nova = novaclient(context, admin_endpoint=True, privileged_user=True) diff --git a/cinder/tests/unit/compute/test_nova.py b/cinder/tests/unit/compute/test_nova.py index 4d4a6dc47..2c69b6b04 100644 --- a/cinder/tests/unit/compute/test_nova.py +++ b/cinder/tests/unit/compute/test_nova.py @@ -162,7 +162,9 @@ class NovaApiTestCase(test.TestCase): self.api.update_server_volume(self.ctx, 'server_id', 'attach_id', 'new_volume_id') - mock_novaclient.assert_called_once_with(self.ctx) + mock_novaclient.assert_called_once_with(self.ctx, + admin_endpoint=True, + privileged_user=True) mock_update_server_volume.assert_called_once_with( 'server_id', 'attach_id',