summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/common/extension.py28
-rw-r--r--openstackclient/common/utils.py4
-rw-r--r--openstackclient/compute/client.py9
-rw-r--r--openstackclient/identity/client.py6
-rw-r--r--openstackclient/image/client.py1
-rw-r--r--openstackclient/network/client.py6
-rw-r--r--openstackclient/network/v2/__init__.py (renamed from openstackclient/network/v2_0/__init__.py)0
-rw-r--r--openstackclient/network/v2/network.py (renamed from openstackclient/network/v2_0/network.py)0
-rw-r--r--openstackclient/object/client.py3
-rw-r--r--openstackclient/tests/network/v2/__init__.py (renamed from openstackclient/tests/network/v2_0/__init__.py)0
-rw-r--r--openstackclient/tests/network/v2/test_network.py (renamed from openstackclient/tests/network/v2_0/test_network.py)12
-rw-r--r--openstackclient/tests/test_shell.py4
-rw-r--r--openstackclient/volume/client.py3
13 files changed, 46 insertions, 30 deletions
diff --git a/openstackclient/common/extension.py b/openstackclient/common/extension.py
index a8b1a6b0..a3f94c09 100644
--- a/openstackclient/common/extension.py
+++ b/openstackclient/common/extension.py
@@ -19,16 +19,14 @@ import logging
from cliff import lister
-from openstackclient.common import exceptions as exc
from openstackclient.common import utils
class ListExtension(lister.Lister):
"""List extension command"""
- # TODO(mfisch): add support for volume and compute
- # when the underlying APIs support it. Add support
- # for network when it's added to openstackclient.
+ # TODO(mfisch): add support for volume and network
+ # when the underlying APIs support it.
log = logging.getLogger(__name__ + '.ListExtension')
@@ -44,6 +42,11 @@ class ListExtension(lister.Lister):
action='store_true',
default=False,
help='List extensions for the Identity API')
+ parser.add_argument(
+ '--compute',
+ action='store_true',
+ default=False,
+ help='List extensions for the Compute API')
return parser
def take_action(self, parsed_args):
@@ -59,17 +62,24 @@ class ListExtension(lister.Lister):
# by default we want to show everything, unless the
# user specifies one or more of the APIs to show
- # for now, only identity is supported
- show_all = (not parsed_args.identity)
+ # for now, only identity and compute are supported.
+ show_all = (not parsed_args.identity and not parsed_args.compute)
if parsed_args.identity or show_all:
identity_client = self.app.client_manager.identity
try:
data += identity_client.extensions.list()
except Exception:
- raise exc.CommandError(
- "Extensions list not supported by"
- " identity API")
+ message = "Extensions list not supported by Identity API"
+ self.log.warning(message)
+
+ if parsed_args.compute or show_all:
+ compute_client = self.app.client_manager.compute
+ try:
+ data += compute_client.list_extensions.show_all()
+ except Exception:
+ message = "Extensions list not supported by Compute API"
+ self.log.warning(message)
return (columns,
(utils.get_item_properties(
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index 0258f931..51c3ed4b 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -23,7 +23,6 @@ import sys
import time
from openstackclient.common import exceptions
-from openstackclient.openstack.common import strutils
def find_resource(manager, name_or_id):
@@ -79,8 +78,7 @@ def format_dict(data):
output = ""
for s in data:
- output = output + s + "='" + \
- strutils.safe_encode(six.text_type(data[s])) + "', "
+ output = output + s + "='" + six.text_type(data[s]) + "', "
return output[:-2]
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py
index 3dacee88..36391c6d 100644
--- a/openstackclient/compute/client.py
+++ b/openstackclient/compute/client.py
@@ -15,6 +15,9 @@
import logging
+from novaclient import extension
+from novaclient.v1_1.contrib import list_extensions
+
from openstackclient.common import utils
LOG = logging.getLogger(__name__)
@@ -34,11 +37,12 @@ def make_client(instance):
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS)
- LOG.debug('instantiating compute client: %s', compute_client)
+ LOG.debug('Instantiating compute client: %s', compute_client)
# Set client http_log_debug to True if verbosity level is high enough
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
+ extensions = [extension.Extension('list_extensions', list_extensions)]
client = compute_client(
username=instance._username,
api_key=instance._password,
@@ -49,8 +53,7 @@ def make_client(instance):
region_name=instance._region_name,
# FIXME(dhellmann): get endpoint_type from option?
endpoint_type='publicURL',
- # FIXME(dhellmann): add extension discovery
- extensions=[],
+ extensions=extensions,
service_type=API_NAME,
# FIXME(dhellmann): what is service_name?
service_name='',
diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py
index 32a2c23b..72e8bfae 100644
--- a/openstackclient/identity/client.py
+++ b/openstackclient/identity/client.py
@@ -36,8 +36,10 @@ def make_client(instance):
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS)
+ LOG.debug('Instantiating identity client: %s' % identity_client)
+
if instance._url:
- LOG.debug('instantiating identity client: token flow')
+ LOG.debug('Using token auth')
client = identity_client(
endpoint=instance._url,
token=instance._token,
@@ -46,7 +48,7 @@ def make_client(instance):
trust_id=instance._trust_id,
)
else:
- LOG.debug('instantiating identity client: password flow')
+ LOG.debug('Using password auth')
client = identity_client(
username=instance._username,
password=instance._password,
diff --git a/openstackclient/image/client.py b/openstackclient/image/client.py
index ba48a0e9..a23d349e 100644
--- a/openstackclient/image/client.py
+++ b/openstackclient/image/client.py
@@ -38,6 +38,7 @@ def make_client(instance):
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS)
+ LOG.debug('Instantiating image client: %s', image_client)
if not instance._url:
instance._url = instance.get_endpoint_for_service_type(API_NAME)
diff --git a/openstackclient/network/client.py b/openstackclient/network/client.py
index 3c87e135..d3102da1 100644
--- a/openstackclient/network/client.py
+++ b/openstackclient/network/client.py
@@ -18,11 +18,11 @@ from openstackclient.common import utils
LOG = logging.getLogger(__name__)
-DEFAULT_NETWORK_API_VERSION = '2.0'
+DEFAULT_NETWORK_API_VERSION = '2'
API_VERSION_OPTION = 'os_network_api_version'
API_NAME = "network"
API_VERSIONS = {
- "2.0": "neutronclient.v2_0.client.Client",
+ "2": "neutronclient.v2_0.client.Client",
}
@@ -32,6 +32,8 @@ def make_client(instance):
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS)
+ LOG.debug('Instantiating network client: %s', network_client)
+
if not instance._url:
instance._url = instance.get_endpoint_for_service_type("network")
return network_client(
diff --git a/openstackclient/network/v2_0/__init__.py b/openstackclient/network/v2/__init__.py
index e69de29b..e69de29b 100644
--- a/openstackclient/network/v2_0/__init__.py
+++ b/openstackclient/network/v2/__init__.py
diff --git a/openstackclient/network/v2_0/network.py b/openstackclient/network/v2/network.py
index c0c25e71..c0c25e71 100644
--- a/openstackclient/network/v2_0/network.py
+++ b/openstackclient/network/v2/network.py
diff --git a/openstackclient/object/client.py b/openstackclient/object/client.py
index 273bea6e..4fe59794 100644
--- a/openstackclient/object/client.py
+++ b/openstackclient/object/client.py
@@ -35,11 +35,12 @@ def make_client(instance):
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS)
+ LOG.debug('Instantiating object client: %s' % object_client)
+
if instance._url:
endpoint = instance._url
else:
endpoint = instance.get_endpoint_for_service_type(API_NAME)
- LOG.debug('instantiating object client')
client = object_client(
endpoint=endpoint,
token=instance._token,
diff --git a/openstackclient/tests/network/v2_0/__init__.py b/openstackclient/tests/network/v2/__init__.py
index e69de29b..e69de29b 100644
--- a/openstackclient/tests/network/v2_0/__init__.py
+++ b/openstackclient/tests/network/v2/__init__.py
diff --git a/openstackclient/tests/network/v2_0/test_network.py b/openstackclient/tests/network/v2/test_network.py
index ef7d24ee..08b61a0a 100644
--- a/openstackclient/tests/network/v2_0/test_network.py
+++ b/openstackclient/tests/network/v2/test_network.py
@@ -15,7 +15,7 @@ import copy
import mock
from openstackclient.common import exceptions
-from openstackclient.network.v2_0 import network
+from openstackclient.network.v2 import network
from openstackclient.tests.network import common
RESOURCE = 'network'
@@ -49,7 +49,7 @@ class TestCreateNetwork(common.TestNetworkBase):
cmd = network.CreateNetwork(self.app, self.namespace)
parsed_args = self.check_parser(cmd, arglist, verifylist)
- result = cmd.take_action(parsed_args)
+ result = list(cmd.take_action(parsed_args))
mocker.assert_called_with({
RESOURCE: {
@@ -75,7 +75,7 @@ class TestCreateNetwork(common.TestNetworkBase):
cmd = network.CreateNetwork(self.app, self.namespace)
parsed_args = self.check_parser(cmd, arglist, verifylist)
- result = cmd.take_action(parsed_args)
+ result = list(cmd.take_action(parsed_args))
mocker.assert_called_with({
RESOURCE: {
@@ -102,7 +102,7 @@ class TestCreateNetwork(common.TestNetworkBase):
cmd = network.CreateNetwork(self.app, self.namespace)
parsed_args = self.check_parser(cmd, arglist, verifylist)
- result = cmd.take_action(parsed_args)
+ result = list(cmd.take_action(parsed_args))
mocker.assert_called_with({
RESOURCE: {
@@ -298,7 +298,7 @@ class TestShowNetwork(common.TestNetworkBase):
cmd = network.ShowNetwork(self.app, self.namespace)
parsed_args = self.check_parser(cmd, arglist, verifylist)
- result = cmd.take_action(parsed_args)
+ result = list(cmd.take_action(parsed_args))
mocker.assert_called_with(FAKE_ID)
self.assertEqual(FILTERED, result)
@@ -313,7 +313,7 @@ class TestShowNetwork(common.TestNetworkBase):
cmd = network.ShowNetwork(self.app, self.namespace)
parsed_args = self.check_parser(cmd, arglist, verifylist)
- result = cmd.take_action(parsed_args)
+ result = list(cmd.take_action(parsed_args))
mocker.assert_called_with(FAKE_ID)
self.assertEqual(FILTERED, result)
diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py
index dfb8021a..c180289e 100644
--- a/openstackclient/tests/test_shell.py
+++ b/openstackclient/tests/test_shell.py
@@ -39,13 +39,13 @@ DEFAULT_COMPUTE_API_VERSION = "2"
DEFAULT_IDENTITY_API_VERSION = "2.0"
DEFAULT_IMAGE_API_VERSION = "v2"
DEFAULT_VOLUME_API_VERSION = "1"
-DEFAULT_NETWORK_API_VERSION = "2.0"
+DEFAULT_NETWORK_API_VERSION = "2"
LIB_COMPUTE_API_VERSION = "2"
LIB_IDENTITY_API_VERSION = "2.0"
LIB_IMAGE_API_VERSION = "1"
LIB_VOLUME_API_VERSION = "1"
-LIB_NETWORK_API_VERSION = "2.0"
+LIB_NETWORK_API_VERSION = "2"
def make_shell():
diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py
index 9b37b8f5..f630f9f5 100644
--- a/openstackclient/volume/client.py
+++ b/openstackclient/volume/client.py
@@ -40,8 +40,7 @@ def make_client(instance):
instance._api_version[API_NAME],
API_VERSIONS
)
-
- LOG.debug('instantiating volume client')
+ LOG.debug('Instantiating volume client: %s', volume_client)
# Set client http_log_debug to True if verbosity level is high enough
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG