summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2013-07-29 11:11:11 -0500
committerDean Troyer <dtroyer@gmail.com>2013-07-31 10:07:50 -0500
commit0aa3c206a38b681e106ca8bfd82cab27cd7e1861 (patch)
tree90d23ca81ef61bbdf4b0e0deaa5d3002575573a9
parent9ec1cf385ee1434ebdb13a9de2f35024925ff50f (diff)
downloadpython-openstackclient-0aa3c206a38b681e106ca8bfd82cab27cd7e1861.tar.gz
Remove tenant round 1 - global options
Change the global auth options to use 'project', leave the original tenant options in place but silent for compatability with the existing project CLI auth options. This is the only compatibility for tenant usage in this changeover. Change-Id: I3cce6e552f18822cc9f445ec5f301b0f5d9003f8
-rw-r--r--README.rst6
-rw-r--r--openstackclient/common/clientmanager.py8
-rw-r--r--openstackclient/compute/client.py2
-rw-r--r--openstackclient/identity/client.py4
-rw-r--r--openstackclient/shell.py34
-rw-r--r--openstackclient/tests/test_shell.py68
-rw-r--r--openstackclient/volume/client.py2
7 files changed, 82 insertions, 42 deletions
diff --git a/README.rst b/README.rst
index 292e0525..8f5b0ab7 100644
--- a/README.rst
+++ b/README.rst
@@ -52,12 +52,12 @@ Configuration
=============
The CLI is configured via environment variables and command-line
-options as listed in http://wiki.openstack.org/UnifiedCLI/Authentication.
+options as listed in https://wiki.openstack.org/wiki/OpenStackClient/Authentication.
The 'password flow' variation is most commonly used::
export OS_AUTH_URL=<url-to-openstack-identity>
- export OS_TENANT_NAME=<tenant-name>
+ export OS_PROJECT_NAME=<project-name>
export OS_USERNAME=<user-name>
export OS_PASSWORD=<password> # (optional)
export OS_USE_KEYRING=true # (optional)
@@ -65,7 +65,7 @@ The 'password flow' variation is most commonly used::
The corresponding command-line options look very similar::
--os-auth-url <url>
- --os-tenant-name <tenant-name>
+ --os-project-name <project-name>
--os-username <user-name>
[--os-password <password>]
[--os-use-keyring]
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index a1b838a2..fdeca139 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -46,14 +46,14 @@ class ClientManager(object):
image = ClientCache(image_client.make_client)
volume = ClientCache(volume_client.make_client)
- def __init__(self, token=None, url=None, auth_url=None, tenant_name=None,
- tenant_id=None, username=None, password=None,
+ def __init__(self, token=None, url=None, auth_url=None, project_name=None,
+ project_id=None, username=None, password=None,
region_name=None, api_version=None):
self._token = token
self._url = url
self._auth_url = auth_url
- self._tenant_name = tenant_name
- self._tenant_id = tenant_id
+ self._project_name = project_name
+ self._project_id = project_id
self._username = username
self._password = password
self._region_name = region_name
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py
index f7ebfe3e..9bd40a4f 100644
--- a/openstackclient/compute/client.py
+++ b/openstackclient/compute/client.py
@@ -36,7 +36,7 @@ def make_client(instance):
client = compute_client(
username=instance._username,
api_key=instance._password,
- project_id=instance._tenant_name,
+ project_id=instance._project_name,
auth_url=instance._auth_url,
# FIXME(dhellmann): add constructor argument for this
insecure=False,
diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py
index 748d1666..ed4882aa 100644
--- a/openstackclient/identity/client.py
+++ b/openstackclient/identity/client.py
@@ -43,8 +43,8 @@ def make_client(instance):
client = identity_client(
username=instance._username,
password=instance._password,
- tenant_name=instance._tenant_name,
- tenant_id=instance._tenant_id,
+ tenant_name=instance._project_name,
+ tenant_id=instance._project_id,
auth_url=instance._auth_url,
region_name=instance._region_name)
return client
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index dad4a693..7bc0a44a 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -15,6 +15,7 @@
"""Command-line interface to the OpenStack APIs"""
+import argparse
import getpass
import logging
import os
@@ -111,15 +112,29 @@ class OpenStackShell(app.App):
default=env('OS_AUTH_URL'),
help='Authentication URL (Env: OS_AUTH_URL)')
parser.add_argument(
+ '--os-project-name',
+ metavar='<auth-project-name>',
+ default=env('OS_PROJECT_NAME', default=env('OS_TENANT_NAME')),
+ help='Authentication project name (Env: OS_PROJECT_NAME)',
+ )
+ parser.add_argument(
'--os-tenant-name',
metavar='<auth-tenant-name>',
- default=env('OS_TENANT_NAME'),
- help='Authentication tenant name (Env: OS_TENANT_NAME)')
+ dest='os_project_name',
+ help=argparse.SUPPRESS,
+ )
+ parser.add_argument(
+ '--os-project-id',
+ metavar='<auth-project-id>',
+ default=env('OS_PROJECT_ID', default=env('OS_TENANT_ID')),
+ help='Authentication project ID (Env: OS_PROJECT_ID)',
+ )
parser.add_argument(
'--os-tenant-id',
metavar='<auth-tenant-id>',
- default=env('OS_TENANT_ID'),
- help='Authentication tenant ID (Env: OS_TENANT_ID)')
+ dest='os_project_id',
+ help=argparse.SUPPRESS,
+ )
parser.add_argument(
'--os-username',
metavar='<auth-username>',
@@ -247,10 +262,11 @@ class OpenStackShell(app.App):
" either --os-password, or env[OS_PASSWORD], "
" or prompted response")
- if not (self.options.os_tenant_id or self.options.os_tenant_name):
+ if not (self.options.os_project_id
+ or self.options.os_project_name):
raise exc.CommandError(
- "You must provide a tenant_id via"
- " either --os-tenant-id or via env[OS_TENANT_ID]")
+ "You must provide a project id via"
+ " either --os-project-id or via env[OS_PROJECT_ID]")
if not self.options.os_auth_url:
raise exc.CommandError(
@@ -261,8 +277,8 @@ class OpenStackShell(app.App):
token=self.options.os_token,
url=self.options.os_url,
auth_url=self.options.os_auth_url,
- tenant_name=self.options.os_tenant_name,
- tenant_id=self.options.os_tenant_id,
+ project_name=self.options.os_project_name,
+ project_id=self.options.os_project_id,
username=self.options.os_username,
password=self.options.os_password,
region_name=self.options.os_region_name,
diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py
index ca87997f..be9c5d49 100644
--- a/openstackclient/tests/test_shell.py
+++ b/openstackclient/tests/test_shell.py
@@ -22,8 +22,8 @@ from openstackclient.tests import utils
DEFAULT_USERNAME = "username"
DEFAULT_PASSWORD = "password"
-DEFAULT_TENANT_ID = "xxxx-yyyy-zzzz"
-DEFAULT_TENANT_NAME = "tenant"
+DEFAULT_PROJECT_ID = "xxxx-yyyy-zzzz"
+DEFAULT_PROJECT_NAME = "project"
DEFAULT_TOKEN = "token"
DEFAULT_REGION_NAME = "ZZ9_Plural_Z_Alpha"
DEFAULT_AUTH_URL = "http://127.0.0.1:5000/v2.0/"
@@ -68,16 +68,16 @@ class TestShell(utils.TestCase):
def _assert_password_auth(self, cmd_options, default_args):
with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
self.app):
- _shell, _cmd = make_shell(), cmd_options + " list tenant"
+ _shell, _cmd = make_shell(), cmd_options + " list project"
fake_execute(_shell, _cmd)
- self.app.assert_called_with(["list", "tenant"])
+ self.app.assert_called_with(["list", "project"])
self.assertEqual(_shell.options.os_auth_url,
default_args["auth_url"])
- self.assertEqual(_shell.options.os_tenant_id,
- default_args["tenant_id"])
- self.assertEqual(_shell.options.os_tenant_name,
- default_args["tenant_name"])
+ self.assertEqual(_shell.options.os_project_id,
+ default_args["project_id"])
+ self.assertEqual(_shell.options.os_project_name,
+ default_args["project_name"])
self.assertEqual(_shell.options.os_username,
default_args["username"])
self.assertEqual(_shell.options.os_password,
@@ -149,8 +149,32 @@ class TestShellPasswordAuth(TestShell):
flag = "--os-auth-url " + DEFAULT_AUTH_URL
kwargs = {
"auth_url": DEFAULT_AUTH_URL,
- "tenant_id": "",
- "tenant_name": "",
+ "project_id": "",
+ "project_name": "",
+ "username": "",
+ "password": "",
+ "region_name": ""
+ }
+ self._assert_password_auth(flag, kwargs)
+
+ def test_only_project_id_flow(self):
+ flag = "--os-project-id " + DEFAULT_PROJECT_ID
+ kwargs = {
+ "auth_url": "",
+ "project_id": DEFAULT_PROJECT_ID,
+ "project_name": "",
+ "username": "",
+ "password": "",
+ "region_name": ""
+ }
+ self._assert_password_auth(flag, kwargs)
+
+ def test_only_project_name_flow(self):
+ flag = "--os-project-name " + DEFAULT_PROJECT_NAME
+ kwargs = {
+ "auth_url": "",
+ "project_id": "",
+ "project_name": DEFAULT_PROJECT_NAME,
"username": "",
"password": "",
"region_name": ""
@@ -158,11 +182,11 @@ class TestShellPasswordAuth(TestShell):
self._assert_password_auth(flag, kwargs)
def test_only_tenant_id_flow(self):
- flag = "--os-tenant-id " + DEFAULT_TENANT_ID
+ flag = "--os-tenant-id " + DEFAULT_PROJECT_ID
kwargs = {
"auth_url": "",
- "tenant_id": DEFAULT_TENANT_ID,
- "tenant_name": "",
+ "project_id": DEFAULT_PROJECT_ID,
+ "project_name": "",
"username": "",
"password": "",
"region_name": ""
@@ -170,11 +194,11 @@ class TestShellPasswordAuth(TestShell):
self._assert_password_auth(flag, kwargs)
def test_only_tenant_name_flow(self):
- flag = "--os-tenant-name " + DEFAULT_TENANT_NAME
+ flag = "--os-tenant-name " + DEFAULT_PROJECT_NAME
kwargs = {
"auth_url": "",
- "tenant_id": "",
- "tenant_name": DEFAULT_TENANT_NAME,
+ "project_id": "",
+ "project_name": DEFAULT_PROJECT_NAME,
"username": "",
"password": "",
"region_name": ""
@@ -185,8 +209,8 @@ class TestShellPasswordAuth(TestShell):
flag = "--os-username " + DEFAULT_USERNAME
kwargs = {
"auth_url": "",
- "tenant_id": "",
- "tenant_name": "",
+ "project_id": "",
+ "project_name": "",
"username": DEFAULT_USERNAME,
"password": "",
"region_name": ""
@@ -197,8 +221,8 @@ class TestShellPasswordAuth(TestShell):
flag = "--os-password " + DEFAULT_PASSWORD
kwargs = {
"auth_url": "",
- "tenant_id": "",
- "tenant_name": "",
+ "project_id": "",
+ "project_name": "",
"username": "",
"password": DEFAULT_PASSWORD,
"region_name": ""
@@ -209,8 +233,8 @@ class TestShellPasswordAuth(TestShell):
flag = "--os-region-name " + DEFAULT_REGION_NAME
kwargs = {
"auth_url": "",
- "tenant_id": "",
- "tenant_name": "",
+ "project_id": "",
+ "project_name": "",
"username": "",
"password": "",
"region_name": DEFAULT_REGION_NAME
diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py
index c1acff2f..92f3b14a 100644
--- a/openstackclient/volume/client.py
+++ b/openstackclient/volume/client.py
@@ -38,7 +38,7 @@ def make_client(instance):
client = volume_client(
username=instance._username,
api_key=instance._password,
- project_id=instance._tenant_name,
+ project_id=instance._project_name,
auth_url=instance._auth_url,
)