summaryrefslogtreecommitdiff
path: root/openstackclient/image
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/image')
-rw-r--r--openstackclient/image/v1/image.py23
-rw-r--r--openstackclient/image/v2/image.py32
2 files changed, 27 insertions, 28 deletions
diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py
index 1644809d..27467b0c 100644
--- a/openstackclient/image/v1/image.py
+++ b/openstackclient/image/v1/image.py
@@ -17,6 +17,7 @@
import argparse
import io
+import logging
import os
import sys
@@ -39,6 +40,9 @@ DEFAULT_CONTAINER_FORMAT = 'bare'
DEFAULT_DISK_FORMAT = 'raw'
+LOG = logging.getLogger(__name__)
+
+
def _format_visibility(data):
"""Return a formatted visibility string
@@ -189,10 +193,8 @@ class CreateImage(command.ShowOne):
image_client = self.app.client_manager.image
if getattr(parsed_args, 'owner', None) is not None:
- self.log.warning(_(
- 'The --owner option is deprecated, '
- 'please use --project instead.'
- ))
+ LOG.warning(_('The --owner option is deprecated, '
+ 'please use --project instead.'))
# Build an attribute dict from the parsed args, only include
# attributes that were actually set on the command line
@@ -608,10 +610,8 @@ class SetImage(command.Command):
image_client = self.app.client_manager.image
if getattr(parsed_args, 'owner', None) is not None:
- self.log.warning(_(
- 'The --owner option is deprecated, '
- 'please use --project instead.'
- ))
+ LOG.warning(_('The --owner option is deprecated, '
+ 'please use --project instead.'))
kwargs = {}
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties',
@@ -684,16 +684,15 @@ class SetImage(command.Command):
# will do a chunked transfer
kwargs["data"] = sys.stdin
else:
- self.log.warning(_('Use --stdin to enable read '
- 'image data from standard '
- 'input'))
+ LOG.warning(_('Use --stdin to enable read image '
+ 'data from standard input'))
if image.properties and parsed_args.properties:
image.properties.update(kwargs['properties'])
kwargs['properties'] = image.properties
if not kwargs:
- self.log.warning('no arguments specified')
+ LOG.warning(_('no arguments specified'))
return
image = image_client.images.update(image.id, **kwargs)
diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py
index 53f9530b..82566ff3 100644
--- a/openstackclient/image/v2/image.py
+++ b/openstackclient/image/v2/image.py
@@ -16,6 +16,7 @@
"""Image V2 Action Implementations"""
import argparse
+import logging
from glanceclient.common import utils as gc_utils
from osc_lib.cli import parseractions
@@ -33,6 +34,9 @@ DEFAULT_CONTAINER_FORMAT = 'bare'
DEFAULT_DISK_FORMAT = 'raw'
+LOG = logging.getLogger(__name__)
+
+
def _format_image(image):
"""Format an image to make it more consistent with OSC operations. """
@@ -280,10 +284,8 @@ class CreateImage(command.ShowOne):
project_arg = parsed_args.project
if parsed_args.owner:
project_arg = parsed_args.owner
- self.log.warning(_(
- 'The --owner option is deprecated, '
- 'please use --project instead.'
- ))
+ LOG.warning(_('The --owner option is deprecated, '
+ 'please use --project instead.'))
if project_arg:
kwargs['owner'] = common.find_project(
identity_client,
@@ -301,7 +303,7 @@ class CreateImage(command.ShowOne):
"the same time"))
if fp is None and parsed_args.file:
- self.log.warning(_("Failed to get an image file."))
+ LOG.warning(_("Failed to get an image file."))
return {}, {}
if parsed_args.owner:
@@ -384,9 +386,9 @@ class DeleteImage(command.Command):
image_client.images.delete(image_obj.id)
except Exception as e:
del_result += 1
- self.app.log.error(_("Failed to delete image with "
- "name or ID '%(image)s': %(e)s")
- % {'image': image, 'e': e})
+ LOG.error(_("Failed to delete image with name or "
+ "ID '%(image)s': %(e)s"),
+ {'image': image, 'e': e})
total = len(parsed_args.images)
if (del_result > 0):
@@ -806,10 +808,8 @@ class SetImage(command.Command):
project_arg = parsed_args.project
if parsed_args.owner:
project_arg = parsed_args.owner
- self.log.warning(_(
- 'The --owner option is deprecated, '
- 'please use --project instead.'
- ))
+ LOG.warning(_('The --owner option is deprecated, '
+ 'please use --project instead.'))
if project_arg:
kwargs['owner'] = common.find_project(
identity_client,
@@ -908,8 +908,8 @@ class UnsetImage(command.Command):
try:
image_client.image_tags.delete(image.id, k)
except Exception:
- self.log.error(_("tag unset failed,"
- " '%s' is a nonexistent tag ") % k)
+ LOG.error(_("tag unset failed, '%s' is a "
+ "nonexistent tag "), k)
tagret += 1
if parsed_args.properties:
@@ -917,8 +917,8 @@ class UnsetImage(command.Command):
try:
assert(k in image.keys())
except AssertionError:
- self.log.error(_("property unset failed,"
- " '%s' is a nonexistent property ") % k)
+ LOG.error(_("property unset failed, '%s' is a "
+ "nonexistent property "), k)
propret += 1
image_client.images.update(
image.id,