From 2d1225624c5115491288d53498906226ed53880f Mon Sep 17 00:00:00 2001
From: wanghong <w.wanghong@huawei.com>
Date: Tue, 23 Sep 2014 14:52:44 +0800
Subject: [PATCH] v3 credential set always needs --user option

Change-Id: Ieca76bb6ee2f328f4e33010623c25eb9c18e6952
Closes-Bug: #1372744
---
 openstackclient/identity/v3/credential.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/openstackclient/identity/v3/credential.py b/openstackclient/identity/v3/credential.py
index 43d16c2962..f1e17b8502 100644
--- a/openstackclient/identity/v3/credential.py
+++ b/openstackclient/identity/v3/credential.py
@@ -151,11 +151,12 @@ class SetCredential(command.Command):
     def take_action(self, parsed_args):
         self.log.debug('take_action(%s)', parsed_args)
         identity_client = self.app.client_manager.identity
-        user_id = utils.find_resource(identity_client.users,
-                                      parsed_args.user).id
         kwargs = {}
-        if user_id:
-            kwargs['user'] = user_id
+        if parsed_args.user:
+            user_id = utils.find_resource(identity_client.users,
+                                          parsed_args.user).id
+            if user_id:
+                kwargs['user'] = user_id
         if parsed_args.type:
             kwargs['type'] = parsed_args.type
         if parsed_args.data: