summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/api/object_store_v1.py66
-rw-r--r--openstackclient/common/clientmanager.py4
-rw-r--r--openstackclient/object/v1/account.py2
-rw-r--r--openstackclient/object/v1/container.py2
-rw-r--r--openstackclient/object/v1/object.py2
-rw-r--r--openstackclient/shell.py10
-rw-r--r--openstackclient/tests/api/test_object_store_v1.py9
-rw-r--r--openstackclient/tests/object/v1/test_container_all.py3
-rw-r--r--openstackclient/tests/object/v1/test_object_all.py2
9 files changed, 58 insertions, 42 deletions
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py
index ae03ab7d..b1c78d99 100644
--- a/openstackclient/api/object_store_v1.py
+++ b/openstackclient/api/object_store_v1.py
@@ -15,6 +15,7 @@
import io
import os
+
import six
from six.moves import urllib
@@ -176,13 +177,24 @@ class APIv1(api.BaseAPI):
'x-container-object-count',
None,
),
- 'meta-owner': response.headers.get('x-container-meta-owner', None),
- 'bytes_used': response.headers.get('x-container-bytes-used', None),
- 'read_acl': response.headers.get('x-container-read', None),
- 'write_acl': response.headers.get('x-container-write', None),
- 'sync_to': response.headers.get('x-container-sync-to', None),
- 'sync_key': response.headers.get('x-container-sync-key', None),
+ 'bytes_used': response.headers.get('x-container-bytes-used', None)
}
+
+ if 'x-container-read' in response.headers:
+ data['read_acl'] = response.headers.get('x-container-read', None)
+ if 'x-container-write' in response.headers:
+ data['write_acl'] = response.headers.get('x-container-write', None)
+ if 'x-container-sync-to' in response.headers:
+ data['sync_to'] = response.headers.get('x-container-sync-to', None)
+ if 'x-container-sync-key' in response.headers:
+ data['sync_key'] = response.headers.get('x-container-sync-key',
+ None)
+
+ properties = self._get_properties(response.headers,
+ 'x-container-meta-')
+ if properties:
+ data['properties'] = properties
+
return data
def container_unset(
@@ -434,12 +446,12 @@ class APIv1(api.BaseAPI):
response = self._request('HEAD', "%s/%s" %
(urllib.parse.quote(container),
urllib.parse.quote(object)))
+
data = {
'account': self._find_account_id(),
'container': container,
'object': object,
'content-type': response.headers.get('content-type', None),
- 'meta-owner': response.headers.get('x-container-meta-owner', None),
}
if 'content-length' in response.headers:
data['content-length'] = response.headers.get(
@@ -455,19 +467,10 @@ class APIv1(api.BaseAPI):
'x-object-manifest',
None,
)
- for key, value in six.iteritems(response.headers):
- if key.startswith('x-object-meta-'):
- data[key[len('x-object-meta-'):].lower()] = value
- elif key not in (
- 'content-type',
- 'content-length',
- 'last-modified',
- 'etag',
- 'date',
- 'x-object-manifest',
- 'x-container-meta-owner',
- ):
- data[key.lower()] = value
+
+ properties = self._get_properties(response.headers, 'x-object-meta-')
+ if properties:
+ data['properties'] = properties
return data
@@ -495,12 +498,16 @@ class APIv1(api.BaseAPI):
# catalog should be enough.
response = self._request("HEAD", "")
data = {}
- for k, v in response.headers.iteritems():
- data[k] = v
+
+ properties = self._get_properties(response.headers, 'x-account-meta-')
+ if properties:
+ data['properties'] = properties
+
# Map containers, bytes and objects a bit nicer
- data['Containers'] = data.pop('x-account-container-count', None)
- data['Objects'] = data.pop('x-account-object-count', None)
- data['Bytes'] = data.pop('x-account-bytes-used', None)
+ data['Containers'] = response.headers.get('x-account-container-count',
+ None)
+ data['Objects'] = response.headers.get('x-account-object-count', None)
+ data['Bytes'] = response.headers.get('x-account-bytes-used', None)
# Add in Account info too
data['Account'] = self._find_account_id()
return data
@@ -549,3 +556,12 @@ class APIv1(api.BaseAPI):
header_name = header_tag % k
headers[header_name] = v
return headers
+
+ def _get_properties(self, headers, header_tag):
+ # Add in properties as a top level key, this is consistent with other
+ # OSC commands
+ properties = {}
+ for k, v in six.iteritems(headers):
+ if k.startswith(header_tag):
+ properties[k[len(header_tag):]] = v
+ return properties
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index 55c6fe53..edabf65e 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -20,6 +20,7 @@ import logging
import pkg_resources
import sys
+from oslo_utils import strutils
import requests
from openstackclient.api import auth
@@ -167,7 +168,8 @@ class ClientManager(object):
self._project_name = self._auth_params['tenant_name']
LOG.info('Using auth plugin: %s' % self.auth_plugin_name)
- LOG.debug('Using parameters %s' % self._auth_params)
+ LOG.debug('Using parameters %s' %
+ strutils.mask_password(self._auth_params))
self.auth = auth_plugin.load_from_options(**self._auth_params)
# needed by SAML authentication
request_session = requests.session()
diff --git a/openstackclient/object/v1/account.py b/openstackclient/object/v1/account.py
index 4ff890ce..aa94ff5c 100644
--- a/openstackclient/object/v1/account.py
+++ b/openstackclient/object/v1/account.py
@@ -55,6 +55,8 @@ class ShowAccount(show.ShowOne):
@utils.log_method(log)
def take_action(self, parsed_args):
data = self.app.client_manager.object_store.account_show()
+ if 'properties' in data:
+ data['properties'] = utils.format_dict(data.pop('properties'))
return zip(*sorted(six.iteritems(data)))
diff --git a/openstackclient/object/v1/container.py b/openstackclient/object/v1/container.py
index b8eb4c25..8c8844e2 100644
--- a/openstackclient/object/v1/container.py
+++ b/openstackclient/object/v1/container.py
@@ -229,6 +229,8 @@ class ShowContainer(show.ShowOne):
data = self.app.client_manager.object_store.container_show(
container=parsed_args.container,
)
+ if 'properties' in data:
+ data['properties'] = utils.format_dict(data.pop('properties'))
return zip(*sorted(six.iteritems(data)))
diff --git a/openstackclient/object/v1/object.py b/openstackclient/object/v1/object.py
index a023e3a0..4bd06124 100644
--- a/openstackclient/object/v1/object.py
+++ b/openstackclient/object/v1/object.py
@@ -284,6 +284,8 @@ class ShowObject(show.ShowOne):
container=parsed_args.container,
object=parsed_args.object,
)
+ if 'properties' in data:
+ data['properties'] = utils.format_dict(data.pop('properties'))
return zip(*sorted(six.iteritems(data)))
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index 5b36b8b2..1a5055bd 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -25,6 +25,7 @@ from cliff import app
from cliff import command
from cliff import complete
from cliff import help
+from oslo_utils import strutils
import openstackclient
from openstackclient.common import clientmanager
@@ -201,8 +202,10 @@ class OpenStackShell(app.App):
# Parent __init__ parses argv into self.options
super(OpenStackShell, self).initialize_app(argv)
- self.log.info("START with options: %s", self.command_options)
- self.log.debug("options: %s", self.options)
+ self.log.info("START with options: %s",
+ strutils.mask_password(self.command_options))
+ self.log.debug("options: %s",
+ strutils.mask_password(self.options))
# Set the default plugin to token_endpoint if url and token are given
if (self.options.url and self.options.token):
@@ -246,7 +249,8 @@ class OpenStackShell(app.App):
self.log_configurator.configure(self.cloud)
self.dump_stack_trace = self.log_configurator.dump_trace
self.log.debug("defaults: %s", cc.defaults)
- self.log.debug("cloud cfg: %s", self.cloud.config)
+ self.log.debug("cloud cfg: %s",
+ strutils.mask_password(self.cloud.config))
# Set up client TLS
# NOTE(dtroyer): --insecure is the non-default condition that
diff --git a/openstackclient/tests/api/test_object_store_v1.py b/openstackclient/tests/api/test_object_store_v1.py
index 323bb8e0..0f7c4559 100644
--- a/openstackclient/tests/api/test_object_store_v1.py
+++ b/openstackclient/tests/api/test_object_store_v1.py
@@ -157,11 +157,6 @@ class TestContainer(TestObjectAPIv1):
'container': 'qaz',
'object_count': '1',
'bytes_used': '577',
- 'meta-owner': FAKE_ACCOUNT,
- 'read_acl': None,
- 'write_acl': None,
- 'sync_to': None,
- 'sync_key': None,
}
self.requests_mock.register_uri(
'HEAD',
@@ -323,10 +318,8 @@ class TestObject(TestObjectAPIv1):
'content-type': 'text/alpha',
'content-length': '577',
'last-modified': '20130101',
- 'meta-owner': FAKE_ACCOUNT,
'etag': 'qaz',
- 'wife': 'Wilma',
- 'x-tra-header': 'yabba-dabba-do',
+ 'properties': {'wife': 'Wilma'},
}
self.requests_mock.register_uri(
'HEAD',
diff --git a/openstackclient/tests/object/v1/test_container_all.py b/openstackclient/tests/object/v1/test_container_all.py
index 4477f2e0..69fc0f39 100644
--- a/openstackclient/tests/object/v1/test_container_all.py
+++ b/openstackclient/tests/object/v1/test_container_all.py
@@ -286,7 +286,6 @@ class TestContainerShow(TestContainerAll):
def test_object_show_container(self):
headers = {
- 'x-container-meta-owner': object_fakes.ACCOUNT_ID,
'x-container-object-count': '42',
'x-container-bytes-used': '123',
'x-container-read': 'qaz',
@@ -316,7 +315,6 @@ class TestContainerShow(TestContainerAll):
'account',
'bytes_used',
'container',
- 'meta-owner',
'object_count',
'read_acl',
'sync_key',
@@ -328,7 +326,6 @@ class TestContainerShow(TestContainerAll):
object_fakes.ACCOUNT_ID,
'123',
'ernie',
- object_fakes.ACCOUNT_ID,
'42',
'qaz',
'rfv',
diff --git a/openstackclient/tests/object/v1/test_object_all.py b/openstackclient/tests/object/v1/test_object_all.py
index 41fe6324..7a76ab76 100644
--- a/openstackclient/tests/object/v1/test_object_all.py
+++ b/openstackclient/tests/object/v1/test_object_all.py
@@ -160,7 +160,6 @@ class TestObjectShow(TestObjectAll):
'content-type',
'etag',
'last-modified',
- 'meta-owner',
'object',
'x-object-manifest',
)
@@ -172,7 +171,6 @@ class TestObjectShow(TestObjectAll):
'text/plain',
'4c4e39a763d58392724bccf76a58783a',
'yesterday',
- object_fakes.ACCOUNT_ID,
object_fakes.object_name_1,
'manifest',
)