Jakub Ruzicka fcc2a65
From bc1b7808bb937a414217396b2aca7d03cacd166f Mon Sep 17 00:00:00 2001
Jakub Ruzicka fcc2a65
From: Haiwei Xu <xu-haiwei@mxw.nes.nec.co.jp>
Jakub Ruzicka fcc2a65
Date: Sat, 8 Feb 2014 03:45:47 +0900
Jakub Ruzicka fcc2a65
Subject: [PATCH] Fix authentication bug when booting an server in V3
Jakub Ruzicka fcc2a65
Jakub Ruzicka fcc2a65
Currently when booting a server with V3, novaclient sends an empty
Jakub Ruzicka fcc2a65
os_password to image_cs. This will cause 401(Unauthorized: Invalid
Jakub Ruzicka fcc2a65
user/password) when trying to find image. This is is a result of
Jakub Ruzicka fcc2a65
changes nova's V3 API: nova is no longer used as a proxy for the
Jakub Ruzicka fcc2a65
image service. So novaclient uses two Client instances: one for
Jakub Ruzicka fcc2a65
nova, the other for image service. This patch checks os_password
Jakub Ruzicka fcc2a65
before creating the image Client and assigns it if it's empty.
Jakub Ruzicka fcc2a65
Jakub Ruzicka fcc2a65
Change-Id: Ic54cef93e9b823fb98b1edd78776c9a1fc06ba46
Jakub Ruzicka fcc2a65
Closes-Bug: #1277425
Jakub Ruzicka fcc2a65
---
Jakub Ruzicka fcc2a65
 novaclient/shell.py | 6 ++++++
Jakub Ruzicka fcc2a65
 1 file changed, 6 insertions(+)
Jakub Ruzicka fcc2a65
Jakub Ruzicka fcc2a65
diff --git a/novaclient/shell.py b/novaclient/shell.py
Jakub Ruzicka fcc2a65
index 919aa21..f751f21 100644
Jakub Ruzicka fcc2a65
--- a/novaclient/shell.py
Jakub Ruzicka fcc2a65
+++ b/novaclient/shell.py
Jakub Ruzicka fcc2a65
@@ -694,6 +694,12 @@ class OpenStackComputeShell(object):
Jakub Ruzicka fcc2a65
             # sometimes need to be able to look up images information
Jakub Ruzicka fcc2a65
             # via glance when connected to the nova api.
Jakub Ruzicka fcc2a65
             image_service_type = 'image'
Jakub Ruzicka fcc2a65
+            # NOTE(hdd): the password is needed again because creating a new
Jakub Ruzicka fcc2a65
+            # Client without specifying bypass_url will force authentication.
Jakub Ruzicka fcc2a65
+            # We can't reuse self.cs's bypass_url, because that's the URL for
Jakub Ruzicka fcc2a65
+            # the nova service; we need to get glance's URL for this Client
Jakub Ruzicka fcc2a65
+            if not os_password:
Jakub Ruzicka fcc2a65
+                os_password = helper.password
Jakub Ruzicka fcc2a65
             self.cs.image_cs = client.Client(
Jakub Ruzicka fcc2a65
                 options.os_compute_api_version, os_username,
Jakub Ruzicka fcc2a65
                 os_password, os_tenant_name, tenant_id=os_tenant_id,