Standardize logger usage
Use file logger for all command specific logs. This patch also fixes some usage that doesn't follow rules in: http://docs.openstack.org/developer/oslo.i18n/guidelines.html After this patch, all self.log and self.app.log will be standardized to LOG(). NOTE: In shell.py, we got the log in class OpenStackShell, which is also known as self.app.log in other classes. This logger is used to record non-command-specific logs. So we leave it as-is. Change-Id: I114f73ee6c7e84593d71e724bc1ad00d343c1896 Implements: blueprint log-usage
This commit is contained in:
parent
ba825a4d5c
commit
047cb68493
@ -14,6 +14,7 @@
|
|||||||
"""Availability Zone action implementations"""
|
"""Availability Zone action implementations"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import logging
|
||||||
|
|
||||||
from novaclient import exceptions as nova_exceptions
|
from novaclient import exceptions as nova_exceptions
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
@ -23,6 +24,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _xform_common_availability_zone(az, zone_info):
|
def _xform_common_availability_zone(az, zone_info):
|
||||||
if hasattr(az, 'zoneState'):
|
if hasattr(az, 'zoneState'):
|
||||||
zone_info['zone_status'] = ('available' if az.zoneState['available']
|
zone_info['zone_status'] = ('available' if az.zoneState['available']
|
||||||
@ -136,11 +140,11 @@ class ListAvailabilityZone(command.Lister):
|
|||||||
try:
|
try:
|
||||||
data = volume_client.availability_zones.list()
|
data = volume_client.availability_zones.list()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.debug('Volume availability zone exception: ' + str(e))
|
LOG.debug('Volume availability zone exception: %s', e)
|
||||||
if parsed_args.volume:
|
if parsed_args.volume:
|
||||||
message = "Availability zones list not supported by " \
|
message = _("Availability zones list not supported by "
|
||||||
"Block Storage API"
|
"Block Storage API")
|
||||||
self.log.warning(message)
|
LOG.warning(message)
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for zone in data:
|
for zone in data:
|
||||||
@ -154,11 +158,11 @@ class ListAvailabilityZone(command.Lister):
|
|||||||
network_client.find_extension('Availability Zone',
|
network_client.find_extension('Availability Zone',
|
||||||
ignore_missing=False)
|
ignore_missing=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.debug('Network availability zone exception: ' + str(e))
|
LOG.debug('Network availability zone exception: ', e)
|
||||||
if parsed_args.network:
|
if parsed_args.network:
|
||||||
message = "Availability zones list not supported by " \
|
message = _("Availability zones list not supported by "
|
||||||
"Network API"
|
"Network API")
|
||||||
self.log.warning(message)
|
LOG.warning(message)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""Extension action implementations"""
|
"""Extension action implementations"""
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -23,6 +24,9 @@ from osc_lib import utils
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ListExtension(command.Lister):
|
class ListExtension(command.Lister):
|
||||||
"""List API extensions"""
|
"""List API extensions"""
|
||||||
|
|
||||||
@ -80,24 +84,25 @@ class ListExtension(command.Lister):
|
|||||||
try:
|
try:
|
||||||
data += identity_client.extensions.list()
|
data += identity_client.extensions.list()
|
||||||
except Exception:
|
except Exception:
|
||||||
message = "Extensions list not supported by Identity API"
|
message = _("Extensions list not supported by Identity API")
|
||||||
self.log.warning(message)
|
LOG.warning(message)
|
||||||
|
|
||||||
if parsed_args.compute or show_all:
|
if parsed_args.compute or show_all:
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
try:
|
try:
|
||||||
data += compute_client.list_extensions.show_all()
|
data += compute_client.list_extensions.show_all()
|
||||||
except Exception:
|
except Exception:
|
||||||
message = "Extensions list not supported by Compute API"
|
message = _("Extensions list not supported by Compute API")
|
||||||
self.log.warning(message)
|
LOG.warning(message)
|
||||||
|
|
||||||
if parsed_args.volume or show_all:
|
if parsed_args.volume or show_all:
|
||||||
volume_client = self.app.client_manager.volume
|
volume_client = self.app.client_manager.volume
|
||||||
try:
|
try:
|
||||||
data += volume_client.list_extensions.show_all()
|
data += volume_client.list_extensions.show_all()
|
||||||
except Exception:
|
except Exception:
|
||||||
message = "Extensions list not supported by Block Storage API"
|
message = _("Extensions list not supported by "
|
||||||
self.log.warning(message)
|
"Block Storage API")
|
||||||
|
LOG.warning(message)
|
||||||
|
|
||||||
# Resource classes for the above
|
# Resource classes for the above
|
||||||
extension_tuples = (
|
extension_tuples = (
|
||||||
@ -125,7 +130,7 @@ class ListExtension(command.Lister):
|
|||||||
dict_tuples
|
dict_tuples
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
message = "Extensions list not supported by Network API"
|
message = _("Extensions list not supported by Network API")
|
||||||
self.log.warning(message)
|
LOG.warning(message)
|
||||||
|
|
||||||
return (columns, extension_tuples)
|
return (columns, extension_tuples)
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Agent action implementations"""
|
"""Agent action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -23,6 +25,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateAgent(command.ShowOne):
|
class CreateAgent(command.ShowOne):
|
||||||
"""Create compute agent command"""
|
"""Create compute agent command"""
|
||||||
|
|
||||||
@ -96,14 +101,13 @@ class DeleteAgent(command.Command):
|
|||||||
compute_client.agents.delete(id)
|
compute_client.agents.delete(id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result += 1
|
result += 1
|
||||||
self.app.log.error(_("Failed to delete agent with "
|
LOG.error(_("Failed to delete agent with ID '%(id)s': %(e)s"),
|
||||||
"ID '%(id)s': %(e)s")
|
{'id': id, 'e': e})
|
||||||
% {'id': id, 'e': e})
|
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
total = len(parsed_args.id)
|
total = len(parsed_args.id)
|
||||||
msg = (_("%(result)s of %(total)s agents failed "
|
msg = (_("%(result)s of %(total)s agents failed "
|
||||||
"to delete.") % {'result': result, 'total': total})
|
"to delete.") % {'result': result, 'total': total})
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Flavor action implementations"""
|
"""Flavor action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.cli import parseractions
|
from osc_lib.cli import parseractions
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@ -25,6 +27,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common as identity_common
|
from openstackclient.identity import common as identity_common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _find_flavor(compute_client, flavor):
|
def _find_flavor(compute_client, flavor):
|
||||||
try:
|
try:
|
||||||
return compute_client.flavors.get(flavor)
|
return compute_client.flavors.get(flavor)
|
||||||
@ -282,8 +287,7 @@ class SetFlavor(command.Command):
|
|||||||
try:
|
try:
|
||||||
flavor.set_keys(parsed_args.property)
|
flavor.set_keys(parsed_args.property)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.log.error(
|
LOG.error(_("Failed to set flavor property: %s"), e)
|
||||||
_("Failed to set flavor property: %s") % str(e))
|
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
if parsed_args.project:
|
if parsed_args.project:
|
||||||
@ -300,13 +304,12 @@ class SetFlavor(command.Command):
|
|||||||
compute_client.flavor_access.add_tenant_access(
|
compute_client.flavor_access.add_tenant_access(
|
||||||
flavor.id, project_id)
|
flavor.id, project_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.log.error(_("Failed to set flavor access to"
|
LOG.error(_("Failed to set flavor access to project: %s"), e)
|
||||||
" project: %s") % str(e))
|
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
raise exceptions.CommandError(_("Command Failed: One or more of"
|
raise exceptions.CommandError(_("Command Failed: One or more of"
|
||||||
" the operations failed"))
|
" the operations failed"))
|
||||||
|
|
||||||
|
|
||||||
class ShowFlavor(command.ShowOne):
|
class ShowFlavor(command.ShowOne):
|
||||||
@ -373,8 +376,7 @@ class UnsetFlavor(command.Command):
|
|||||||
try:
|
try:
|
||||||
flavor.unset_keys(parsed_args.property)
|
flavor.unset_keys(parsed_args.property)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.log.error(
|
LOG.error(_("Failed to unset flavor property: %s"), e)
|
||||||
_("Failed to unset flavor property: %s") % str(e))
|
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
if parsed_args.project:
|
if parsed_args.project:
|
||||||
@ -391,10 +393,10 @@ class UnsetFlavor(command.Command):
|
|||||||
compute_client.flavor_access.remove_tenant_access(
|
compute_client.flavor_access.remove_tenant_access(
|
||||||
flavor.id, project_id)
|
flavor.id, project_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.log.error(_("Failed to remove flavor access from"
|
LOG.error(_("Failed to remove flavor access from project: %s"),
|
||||||
" project: %s") % str(e))
|
e)
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
raise exceptions.CommandError(_("Command Failed: One or more of"
|
raise exceptions.CommandError(_("Command Failed: One or more of"
|
||||||
" the operations failed"))
|
" the operations failed"))
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import getpass
|
import getpass
|
||||||
import io
|
import io
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -36,6 +37,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common as identity_common
|
from openstackclient.identity import common as identity_common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _format_servers_list_networks(networks):
|
def _format_servers_list_networks(networks):
|
||||||
"""Return a formatted string of a server's networks
|
"""Return a formatted string of a server's networks
|
||||||
|
|
||||||
@ -521,8 +525,8 @@ class CreateServer(command.ShowOne):
|
|||||||
scheduler_hints=hints,
|
scheduler_hints=hints,
|
||||||
config_drive=config_drive)
|
config_drive=config_drive)
|
||||||
|
|
||||||
self.log.debug('boot_args: %s', boot_args)
|
LOG.debug('boot_args: %s', boot_args)
|
||||||
self.log.debug('boot_kwargs: %s', boot_kwargs)
|
LOG.debug('boot_kwargs: %s', boot_kwargs)
|
||||||
|
|
||||||
# Wrap the call to catch exceptions in order to close files
|
# Wrap the call to catch exceptions in order to close files
|
||||||
try:
|
try:
|
||||||
@ -543,8 +547,8 @@ class CreateServer(command.ShowOne):
|
|||||||
):
|
):
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
else:
|
else:
|
||||||
self.log.error(_('Error creating server: %s'),
|
LOG.error(_('Error creating server: %s'),
|
||||||
parsed_args.server_name)
|
parsed_args.server_name)
|
||||||
sys.stdout.write(_('Error creating server\n'))
|
sys.stdout.write(_('Error creating server\n'))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -612,8 +616,8 @@ class DeleteServer(command.Command):
|
|||||||
):
|
):
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
else:
|
else:
|
||||||
self.log.error(_('Error deleting server: %s'),
|
LOG.error(_('Error deleting server: %s'),
|
||||||
server_obj.id)
|
server_obj.id)
|
||||||
sys.stdout.write(_('Error deleting server\n'))
|
sys.stdout.write(_('Error deleting server\n'))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -762,7 +766,7 @@ class ListServer(command.Lister):
|
|||||||
'all_tenants': parsed_args.all_projects,
|
'all_tenants': parsed_args.all_projects,
|
||||||
'user_id': user_id,
|
'user_id': user_id,
|
||||||
}
|
}
|
||||||
self.log.debug('search options: %s', search_opts)
|
LOG.debug('search options: %s', search_opts)
|
||||||
|
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = (
|
columns = (
|
||||||
@ -939,8 +943,8 @@ class MigrateServer(command.Command):
|
|||||||
):
|
):
|
||||||
sys.stdout.write(_('Complete\n'))
|
sys.stdout.write(_('Complete\n'))
|
||||||
else:
|
else:
|
||||||
self.log.error(_('Error migrating server: %s'),
|
LOG.error(_('Error migrating server: %s'),
|
||||||
server.id)
|
server.id)
|
||||||
sys.stdout.write(_('Error migrating server\n'))
|
sys.stdout.write(_('Error migrating server\n'))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -1015,8 +1019,8 @@ class RebootServer(command.Command):
|
|||||||
):
|
):
|
||||||
sys.stdout.write(_('Complete\n'))
|
sys.stdout.write(_('Complete\n'))
|
||||||
else:
|
else:
|
||||||
self.log.error(_('Error rebooting server: %s'),
|
LOG.error(_('Error rebooting server: %s'),
|
||||||
server.id)
|
server.id)
|
||||||
sys.stdout.write(_('Error rebooting server\n'))
|
sys.stdout.write(_('Error rebooting server\n'))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -1068,8 +1072,8 @@ class RebuildServer(command.ShowOne):
|
|||||||
):
|
):
|
||||||
sys.stdout.write(_('Complete\n'))
|
sys.stdout.write(_('Complete\n'))
|
||||||
else:
|
else:
|
||||||
self.log.error(_('Error rebuilding server: %s'),
|
LOG.error(_('Error rebuilding server: %s'),
|
||||||
server.id)
|
server.id)
|
||||||
sys.stdout.write(_('Error rebuilding server\n'))
|
sys.stdout.write(_('Error rebuilding server\n'))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -1222,8 +1226,8 @@ class ResizeServer(command.Command):
|
|||||||
):
|
):
|
||||||
sys.stdout.write(_('Complete\n'))
|
sys.stdout.write(_('Complete\n'))
|
||||||
else:
|
else:
|
||||||
self.log.error(_('Error resizing server: %s'),
|
LOG.error(_('Error resizing server: %s'),
|
||||||
server.id)
|
server.id)
|
||||||
sys.stdout.write(_('Error resizing server\n'))
|
sys.stdout.write(_('Error resizing server\n'))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
elif parsed_args.confirm:
|
elif parsed_args.confirm:
|
||||||
@ -1538,7 +1542,7 @@ class SshServer(command.Command):
|
|||||||
ip_address = _get_ip_address(server.addresses,
|
ip_address = _get_ip_address(server.addresses,
|
||||||
parsed_args.address_type,
|
parsed_args.address_type,
|
||||||
ip_address_family)
|
ip_address_family)
|
||||||
self.log.debug("ssh command: %s", (cmd % (login, ip_address)))
|
LOG.debug("ssh command: %s", (cmd % (login, ip_address)))
|
||||||
os.system(cmd % (login, ip_address))
|
os.system(cmd % (login, ip_address))
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Compute v2 Server Group action implementations"""
|
"""Compute v2 Server Group action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -22,6 +24,9 @@ from osc_lib import utils
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
_formatters = {
|
_formatters = {
|
||||||
'policies': utils.format_list,
|
'policies': utils.format_list,
|
||||||
'members': utils.format_list,
|
'members': utils.format_list,
|
||||||
@ -95,7 +100,7 @@ class DeleteServerGroup(command.Command):
|
|||||||
# Catch all exceptions in order to avoid to block the next deleting
|
# Catch all exceptions in order to avoid to block the next deleting
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result += 1
|
result += 1
|
||||||
self.app.log.error(e)
|
LOG.error(e)
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
total = len(parsed_args.server_group)
|
total = len(parsed_args.server_group)
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""Compute v2 Server action implementations"""
|
"""Compute v2 Server action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
@ -26,6 +27,9 @@ from openstackclient.common import utils
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
sys.stdout.write('\rProgress: %s' % progress)
|
sys.stdout.write('\rProgress: %s' % progress)
|
||||||
@ -90,10 +94,8 @@ class CreateServerImage(command.ShowOne):
|
|||||||
):
|
):
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
else:
|
else:
|
||||||
self.log.error(
|
LOG.error(_('Error creating server image: %s'),
|
||||||
_('Error creating server image: %s') %
|
parsed_args.server)
|
||||||
parsed_args.server,
|
|
||||||
)
|
|
||||||
raise exceptions.CommandError
|
raise exceptions.CommandError
|
||||||
|
|
||||||
if self.app.client_manager._api_version['image'] == '1':
|
if self.app.client_manager._api_version['image'] == '1':
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Service action implementations"""
|
"""Service action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -23,6 +25,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.i18n import _LE
|
from openstackclient.i18n import _LE
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DeleteService(command.Command):
|
class DeleteService(command.Command):
|
||||||
"""Delete service command"""
|
"""Delete service command"""
|
||||||
|
|
||||||
@ -171,7 +176,7 @@ class SetService(command.Command):
|
|||||||
cs.disable(parsed_args.host, parsed_args.service)
|
cs.disable(parsed_args.host, parsed_args.service)
|
||||||
except Exception:
|
except Exception:
|
||||||
status = "enabled" if enabled else "disabled"
|
status = "enabled" if enabled else "disabled"
|
||||||
self.log.error(_LE("Failed to set service status to %s"), status)
|
LOG.error(_LE("Failed to set service status to %s"), status)
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
force_down = None
|
force_down = None
|
||||||
@ -185,7 +190,7 @@ class SetService(command.Command):
|
|||||||
force_down=force_down)
|
force_down=force_down)
|
||||||
except Exception:
|
except Exception:
|
||||||
state = "down" if force_down else "up"
|
state = "down" if force_down else "up"
|
||||||
self.log.error(_LE("Failed to set service state to %s"), state)
|
LOG.error(_LE("Failed to set service state to %s"), state)
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Identity v2 Project action implementations"""
|
"""Identity v2 Project action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
from osc_lib.cli import parseractions
|
from osc_lib.cli import parseractions
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
@ -24,6 +26,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateProject(command.ShowOne):
|
class CreateProject(command.ShowOne):
|
||||||
"""Create new project"""
|
"""Create new project"""
|
||||||
|
|
||||||
@ -87,7 +92,7 @@ class CreateProject(command.ShowOne):
|
|||||||
identity_client.tenants,
|
identity_client.tenants,
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
)
|
)
|
||||||
self.log.info(_('Returning existing project %s'), project.name)
|
LOG.info(_('Returning existing project %s'), project.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Identity v2 Role action implementations"""
|
"""Identity v2 Role action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@ -24,6 +26,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AddRole(command.ShowOne):
|
class AddRole(command.ShowOne):
|
||||||
"""Add role to project:user"""
|
"""Add role to project:user"""
|
||||||
|
|
||||||
@ -94,7 +99,7 @@ class CreateRole(command.ShowOne):
|
|||||||
identity_client.roles,
|
identity_client.roles,
|
||||||
parsed_args.role_name,
|
parsed_args.role_name,
|
||||||
)
|
)
|
||||||
self.log.info(_('Returning existing role %s'), role.name)
|
LOG.info(_('Returning existing role %s'), role.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""Service action implementations"""
|
"""Service action implementations"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@ -26,6 +27,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common
|
from openstackclient.identity import common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateService(command.ShowOne):
|
class CreateService(command.ShowOne):
|
||||||
"""Create new service"""
|
"""Create new service"""
|
||||||
|
|
||||||
@ -69,8 +73,8 @@ class CreateService(command.ShowOne):
|
|||||||
# display deprecation message.
|
# display deprecation message.
|
||||||
elif type:
|
elif type:
|
||||||
name = type_or_name
|
name = type_or_name
|
||||||
self.log.warning(_('The argument --type is deprecated, use service'
|
LOG.warning(_('The argument --type is deprecated, use service'
|
||||||
' create --name <service-name> type instead.'))
|
' create --name <service-name> type instead.'))
|
||||||
# If --name option is present the positional is handled as <type>.
|
# If --name option is present the positional is handled as <type>.
|
||||||
# Making --type optional is new, but back-compatible
|
# Making --type optional is new, but back-compatible
|
||||||
elif name:
|
elif name:
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Identity v2.0 User action implementations"""
|
"""Identity v2.0 User action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -23,6 +25,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateUser(command.ShowOne):
|
class CreateUser(command.ShowOne):
|
||||||
"""Create new user"""
|
"""Create new user"""
|
||||||
|
|
||||||
@ -103,7 +108,7 @@ class CreateUser(command.ShowOne):
|
|||||||
identity_client.users,
|
identity_client.users,
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
)
|
)
|
||||||
self.log.info(_('Returning existing user %s'), user.name)
|
LOG.info(_('Returning existing user %s'), user.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""Identity v3 Domain action implementations"""
|
"""Identity v3 Domain action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
@ -25,6 +26,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateDomain(command.ShowOne):
|
class CreateDomain(command.ShowOne):
|
||||||
"""Create new domain"""
|
"""Create new domain"""
|
||||||
|
|
||||||
@ -75,7 +79,7 @@ class CreateDomain(command.ShowOne):
|
|||||||
if parsed_args.or_show:
|
if parsed_args.or_show:
|
||||||
domain = utils.find_resource(identity_client.domains,
|
domain = utils.find_resource(identity_client.domains,
|
||||||
parsed_args.name)
|
parsed_args.name)
|
||||||
self.log.info(_('Returning existing domain %s'), domain.name)
|
LOG.info(_('Returning existing domain %s'), domain.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
"""Identity v3 Protocols actions implementations"""
|
"""Identity v3 Protocols actions implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
import six
|
import six
|
||||||
@ -21,6 +23,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateProtocol(command.ShowOne):
|
class CreateProtocol(command.ShowOne):
|
||||||
"""Create new federation protocol"""
|
"""Create new federation protocol"""
|
||||||
|
|
||||||
@ -145,7 +150,7 @@ class SetProtocol(command.Command):
|
|||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
if not parsed_args.mapping:
|
if not parsed_args.mapping:
|
||||||
self.app.log.error(_("No changes requested"))
|
LOG.error(_("No changes requested"))
|
||||||
return
|
return
|
||||||
|
|
||||||
protocol = identity_client.federation.protocols.update(
|
protocol = identity_client.federation.protocols.update(
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""Group action implementations"""
|
"""Group action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
@ -26,6 +27,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common
|
from openstackclient.identity import common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AddUserToGroup(command.Command):
|
class AddUserToGroup(command.Command):
|
||||||
"""Add user to group"""
|
"""Add user to group"""
|
||||||
|
|
||||||
@ -161,7 +165,7 @@ class CreateGroup(command.ShowOne):
|
|||||||
group = utils.find_resource(identity_client.groups,
|
group = utils.find_resource(identity_client.groups,
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
domain_id=domain)
|
domain_id=domain)
|
||||||
self.log.info(_('Returning existing group %s'), group.name)
|
LOG.info(_('Returning existing group %s'), group.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
"""Identity v3 IdentityProvider action implementations"""
|
"""Identity v3 IdentityProvider action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
import six
|
import six
|
||||||
@ -20,6 +22,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateIdentityProvider(command.ShowOne):
|
class CreateIdentityProvider(command.ShowOne):
|
||||||
"""Create new identity provider"""
|
"""Create new identity provider"""
|
||||||
|
|
||||||
@ -169,7 +174,7 @@ class SetIdentityProvider(command.Command):
|
|||||||
not parsed_args.remote_id and
|
not parsed_args.remote_id and
|
||||||
not parsed_args.remote_id_file and
|
not parsed_args.remote_id_file and
|
||||||
not parsed_args.description):
|
not parsed_args.description):
|
||||||
self.log.error(_('No changes requested'))
|
LOG.error(_('No changes requested'))
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
# Always set remote_ids if either is passed in
|
# Always set remote_ids if either is passed in
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""Identity v3 federation mapping action implementations"""
|
"""Identity v3 federation mapping action implementations"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@ -25,6 +26,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class _RulesReader(object):
|
class _RulesReader(object):
|
||||||
"""Helper class capable of reading rules from files"""
|
"""Helper class capable of reading rules from files"""
|
||||||
|
|
||||||
@ -159,7 +163,7 @@ class SetMapping(command.Command, _RulesReader):
|
|||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
if not parsed_args.rules:
|
if not parsed_args.rules:
|
||||||
self.app.log.error(_("No changes requested"))
|
LOG.error(_("No changes requested"))
|
||||||
return
|
return
|
||||||
|
|
||||||
rules = self._read_rules(parsed_args.rules)
|
rules = self._read_rules(parsed_args.rules)
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
"""Project action implementations"""
|
"""Project action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
from osc_lib.cli import parseractions
|
from osc_lib.cli import parseractions
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
@ -25,6 +27,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common
|
from openstackclient.identity import common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateProject(command.ShowOne):
|
class CreateProject(command.ShowOne):
|
||||||
"""Create new project"""
|
"""Create new project"""
|
||||||
|
|
||||||
@ -111,7 +116,7 @@ class CreateProject(command.ShowOne):
|
|||||||
project = utils.find_resource(identity_client.projects,
|
project = utils.find_resource(identity_client.projects,
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
domain_id=domain)
|
domain_id=domain)
|
||||||
self.log.info(_('Returning existing project %s'), project.name)
|
LOG.info(_('Returning existing project %s'), project.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""Identity v3 Role action implementations"""
|
"""Identity v3 Role action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
@ -26,6 +27,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common
|
from openstackclient.identity import common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _add_identity_and_resource_options_to_parser(parser):
|
def _add_identity_and_resource_options_to_parser(parser):
|
||||||
domain_or_project = parser.add_mutually_exclusive_group()
|
domain_or_project = parser.add_mutually_exclusive_group()
|
||||||
domain_or_project.add_argument(
|
domain_or_project.add_argument(
|
||||||
@ -165,7 +169,7 @@ class CreateRole(command.ShowOne):
|
|||||||
if parsed_args.or_show:
|
if parsed_args.or_show:
|
||||||
role = utils.find_resource(identity_client.roles,
|
role = utils.find_resource(identity_client.roles,
|
||||||
parsed_args.name)
|
parsed_args.name)
|
||||||
self.log.info(_('Returning existing role %s'), role.name)
|
LOG.info(_('Returning existing role %s'), role.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""Identity v3 User action implementations"""
|
"""Identity v3 User action implementations"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
@ -27,6 +28,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common
|
from openstackclient.identity import common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CreateUser(command.ShowOne):
|
class CreateUser(command.ShowOne):
|
||||||
"""Create new user"""
|
"""Create new user"""
|
||||||
|
|
||||||
@ -122,7 +126,7 @@ class CreateUser(command.ShowOne):
|
|||||||
user = utils.find_resource(identity_client.users,
|
user = utils.find_resource(identity_client.users,
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
domain_id=domain_id)
|
domain_id=domain_id)
|
||||||
self.log.info(_('Returning existing user %s'), user.name)
|
LOG.info(_('Returning existing user %s'), user.name)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import io
|
import io
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -39,6 +40,9 @@ DEFAULT_CONTAINER_FORMAT = 'bare'
|
|||||||
DEFAULT_DISK_FORMAT = 'raw'
|
DEFAULT_DISK_FORMAT = 'raw'
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _format_visibility(data):
|
def _format_visibility(data):
|
||||||
"""Return a formatted visibility string
|
"""Return a formatted visibility string
|
||||||
|
|
||||||
@ -189,10 +193,8 @@ class CreateImage(command.ShowOne):
|
|||||||
image_client = self.app.client_manager.image
|
image_client = self.app.client_manager.image
|
||||||
|
|
||||||
if getattr(parsed_args, 'owner', None) is not None:
|
if getattr(parsed_args, 'owner', None) is not None:
|
||||||
self.log.warning(_(
|
LOG.warning(_('The --owner option is deprecated, '
|
||||||
'The --owner option is deprecated, '
|
'please use --project instead.'))
|
||||||
'please use --project instead.'
|
|
||||||
))
|
|
||||||
|
|
||||||
# Build an attribute dict from the parsed args, only include
|
# Build an attribute dict from the parsed args, only include
|
||||||
# attributes that were actually set on the command line
|
# attributes that were actually set on the command line
|
||||||
@ -608,10 +610,8 @@ class SetImage(command.Command):
|
|||||||
image_client = self.app.client_manager.image
|
image_client = self.app.client_manager.image
|
||||||
|
|
||||||
if getattr(parsed_args, 'owner', None) is not None:
|
if getattr(parsed_args, 'owner', None) is not None:
|
||||||
self.log.warning(_(
|
LOG.warning(_('The --owner option is deprecated, '
|
||||||
'The --owner option is deprecated, '
|
'please use --project instead.'))
|
||||||
'please use --project instead.'
|
|
||||||
))
|
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties',
|
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties',
|
||||||
@ -684,16 +684,15 @@ class SetImage(command.Command):
|
|||||||
# will do a chunked transfer
|
# will do a chunked transfer
|
||||||
kwargs["data"] = sys.stdin
|
kwargs["data"] = sys.stdin
|
||||||
else:
|
else:
|
||||||
self.log.warning(_('Use --stdin to enable read '
|
LOG.warning(_('Use --stdin to enable read image '
|
||||||
'image data from standard '
|
'data from standard input'))
|
||||||
'input'))
|
|
||||||
|
|
||||||
if image.properties and parsed_args.properties:
|
if image.properties and parsed_args.properties:
|
||||||
image.properties.update(kwargs['properties'])
|
image.properties.update(kwargs['properties'])
|
||||||
kwargs['properties'] = image.properties
|
kwargs['properties'] = image.properties
|
||||||
|
|
||||||
if not kwargs:
|
if not kwargs:
|
||||||
self.log.warning('no arguments specified')
|
LOG.warning(_('no arguments specified'))
|
||||||
return
|
return
|
||||||
|
|
||||||
image = image_client.images.update(image.id, **kwargs)
|
image = image_client.images.update(image.id, **kwargs)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""Image V2 Action Implementations"""
|
"""Image V2 Action Implementations"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import logging
|
||||||
|
|
||||||
from glanceclient.common import utils as gc_utils
|
from glanceclient.common import utils as gc_utils
|
||||||
from osc_lib.cli import parseractions
|
from osc_lib.cli import parseractions
|
||||||
@ -33,6 +34,9 @@ DEFAULT_CONTAINER_FORMAT = 'bare'
|
|||||||
DEFAULT_DISK_FORMAT = 'raw'
|
DEFAULT_DISK_FORMAT = 'raw'
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _format_image(image):
|
def _format_image(image):
|
||||||
"""Format an image to make it more consistent with OSC operations. """
|
"""Format an image to make it more consistent with OSC operations. """
|
||||||
|
|
||||||
@ -280,10 +284,8 @@ class CreateImage(command.ShowOne):
|
|||||||
project_arg = parsed_args.project
|
project_arg = parsed_args.project
|
||||||
if parsed_args.owner:
|
if parsed_args.owner:
|
||||||
project_arg = parsed_args.owner
|
project_arg = parsed_args.owner
|
||||||
self.log.warning(_(
|
LOG.warning(_('The --owner option is deprecated, '
|
||||||
'The --owner option is deprecated, '
|
'please use --project instead.'))
|
||||||
'please use --project instead.'
|
|
||||||
))
|
|
||||||
if project_arg:
|
if project_arg:
|
||||||
kwargs['owner'] = common.find_project(
|
kwargs['owner'] = common.find_project(
|
||||||
identity_client,
|
identity_client,
|
||||||
@ -301,7 +303,7 @@ class CreateImage(command.ShowOne):
|
|||||||
"the same time"))
|
"the same time"))
|
||||||
|
|
||||||
if fp is None and parsed_args.file:
|
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 {}, {}
|
return {}, {}
|
||||||
|
|
||||||
if parsed_args.owner:
|
if parsed_args.owner:
|
||||||
@ -384,9 +386,9 @@ class DeleteImage(command.Command):
|
|||||||
image_client.images.delete(image_obj.id)
|
image_client.images.delete(image_obj.id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
del_result += 1
|
del_result += 1
|
||||||
self.app.log.error(_("Failed to delete image with "
|
LOG.error(_("Failed to delete image with name or "
|
||||||
"name or ID '%(image)s': %(e)s")
|
"ID '%(image)s': %(e)s"),
|
||||||
% {'image': image, 'e': e})
|
{'image': image, 'e': e})
|
||||||
|
|
||||||
total = len(parsed_args.images)
|
total = len(parsed_args.images)
|
||||||
if (del_result > 0):
|
if (del_result > 0):
|
||||||
@ -806,10 +808,8 @@ class SetImage(command.Command):
|
|||||||
project_arg = parsed_args.project
|
project_arg = parsed_args.project
|
||||||
if parsed_args.owner:
|
if parsed_args.owner:
|
||||||
project_arg = parsed_args.owner
|
project_arg = parsed_args.owner
|
||||||
self.log.warning(_(
|
LOG.warning(_('The --owner option is deprecated, '
|
||||||
'The --owner option is deprecated, '
|
'please use --project instead.'))
|
||||||
'please use --project instead.'
|
|
||||||
))
|
|
||||||
if project_arg:
|
if project_arg:
|
||||||
kwargs['owner'] = common.find_project(
|
kwargs['owner'] = common.find_project(
|
||||||
identity_client,
|
identity_client,
|
||||||
@ -908,8 +908,8 @@ class UnsetImage(command.Command):
|
|||||||
try:
|
try:
|
||||||
image_client.image_tags.delete(image.id, k)
|
image_client.image_tags.delete(image.id, k)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.error(_("tag unset failed,"
|
LOG.error(_("tag unset failed, '%s' is a "
|
||||||
" '%s' is a nonexistent tag ") % k)
|
"nonexistent tag "), k)
|
||||||
tagret += 1
|
tagret += 1
|
||||||
|
|
||||||
if parsed_args.properties:
|
if parsed_args.properties:
|
||||||
@ -917,8 +917,8 @@ class UnsetImage(command.Command):
|
|||||||
try:
|
try:
|
||||||
assert(k in image.keys())
|
assert(k in image.keys())
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
self.log.error(_("property unset failed,"
|
LOG.error(_("property unset failed, '%s' is a "
|
||||||
" '%s' is a nonexistent property ") % k)
|
"nonexistent property "), k)
|
||||||
propret += 1
|
propret += 1
|
||||||
image_client.images.update(
|
image_client.images.update(
|
||||||
image.id,
|
image.id,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@ -20,6 +21,9 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class NetworkAndComputeCommand(command.Command):
|
class NetworkAndComputeCommand(command.Command):
|
||||||
"""Network and Compute Command
|
"""Network and Compute Command
|
||||||
@ -39,10 +43,10 @@ class NetworkAndComputeCommand(command.Command):
|
|||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
self.log.debug('get_parser(%s)', prog_name)
|
LOG.debug('get_parser(%s)', prog_name)
|
||||||
parser = super(NetworkAndComputeCommand, self).get_parser(prog_name)
|
parser = super(NetworkAndComputeCommand, self).get_parser(prog_name)
|
||||||
parser = self.update_parser_common(parser)
|
parser = self.update_parser_common(parser)
|
||||||
self.log.debug('common parser: %s', parser)
|
LOG.debug('common parser: %s', parser)
|
||||||
if self.app.client_manager.is_network_endpoint_enabled():
|
if self.app.client_manager.is_network_endpoint_enabled():
|
||||||
return self.update_parser_network(parser)
|
return self.update_parser_network(parser)
|
||||||
else:
|
else:
|
||||||
@ -102,7 +106,7 @@ class NetworkAndComputeDelete(NetworkAndComputeCommand):
|
|||||||
"name_or_id": r,
|
"name_or_id": r,
|
||||||
"e": e,
|
"e": e,
|
||||||
}
|
}
|
||||||
self.app.log.error(msg)
|
LOG.error(msg)
|
||||||
ret += 1
|
ret += 1
|
||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
@ -134,10 +138,10 @@ class NetworkAndComputeLister(command.Lister):
|
|||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
self.log.debug('get_parser(%s)', prog_name)
|
LOG.debug('get_parser(%s)', prog_name)
|
||||||
parser = super(NetworkAndComputeLister, self).get_parser(prog_name)
|
parser = super(NetworkAndComputeLister, self).get_parser(prog_name)
|
||||||
parser = self.update_parser_common(parser)
|
parser = self.update_parser_common(parser)
|
||||||
self.log.debug('common parser: %s', parser)
|
LOG.debug('common parser: %s', parser)
|
||||||
if self.app.client_manager.is_network_endpoint_enabled():
|
if self.app.client_manager.is_network_endpoint_enabled():
|
||||||
return self.update_parser_network(parser)
|
return self.update_parser_network(parser)
|
||||||
else:
|
else:
|
||||||
@ -185,10 +189,10 @@ class NetworkAndComputeShowOne(command.ShowOne):
|
|||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
self.log.debug('get_parser(%s)', prog_name)
|
LOG.debug('get_parser(%s)', prog_name)
|
||||||
parser = super(NetworkAndComputeShowOne, self).get_parser(prog_name)
|
parser = super(NetworkAndComputeShowOne, self).get_parser(prog_name)
|
||||||
parser = self.update_parser_common(parser)
|
parser = self.update_parser_common(parser)
|
||||||
self.log.debug('common parser: %s', parser)
|
LOG.debug('common parser: %s', parser)
|
||||||
if self.app.client_manager.is_network_endpoint_enabled():
|
if self.app.client_manager.is_network_endpoint_enabled():
|
||||||
return self.update_parser_network(parser)
|
return self.update_parser_network(parser)
|
||||||
else:
|
else:
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
"""Address scope action implementations"""
|
"""Address scope action implementations"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -21,6 +23,9 @@ from openstackclient.i18n import _
|
|||||||
from openstackclient.identity import common as identity_common
|
from openstackclient.identity import common as identity_common
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
columns = list(item.keys())
|
columns = list(item.keys())
|
||||||
if 'tenant_id' in columns:
|
if 'tenant_id' in columns:
|
||||||
@ -122,9 +127,9 @@ class DeleteAddressScope(command.Command):
|
|||||||
client.delete_address_scope(obj)
|
client.delete_address_scope(obj)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result += 1
|
result += 1
|
||||||
self.app.log.error(_("Failed to delete address scope with "
|
LOG.error(_("Failed to delete address scope with "
|
||||||
"name or ID '%(scope)s': %(e)s")
|
"name or ID '%(scope)s': %(e)s"),
|
||||||
% {'scope': scope, 'e': e})
|
{'scope': scope, 'e': e})
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
total = len(parsed_args.address_scope)
|
total = len(parsed_args.address_scope)
|
||||||
|
@ -293,9 +293,9 @@ class DeletePort(command.Command):
|
|||||||
client.delete_port(obj)
|
client.delete_port(obj)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result += 1
|
result += 1
|
||||||
self.app.log.error(_("Failed to delete port with "
|
LOG.error(_("Failed to delete port with "
|
||||||
"name or ID '%(port)s': %(e)s")
|
"name or ID '%(port)s': %(e)s"),
|
||||||
% {'port': port, 'e': e})
|
{'port': port, 'e': e})
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
total = len(parsed_args.port)
|
total = len(parsed_args.port)
|
||||||
|
@ -330,12 +330,9 @@ class TestServiceSet(TestService):
|
|||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
with mock.patch.object(self.cmd.log, 'error') as mock_log:
|
with mock.patch.object(self.service_mock, 'enable',
|
||||||
with mock.patch.object(self.service_mock, 'enable',
|
side_effect=Exception()):
|
||||||
side_effect=Exception()):
|
self.assertRaises(exceptions.CommandError,
|
||||||
self.assertRaises(exceptions.CommandError,
|
self.cmd.take_action, parsed_args)
|
||||||
self.cmd.take_action, parsed_args)
|
self.service_mock.force_down.assert_called_once_with(
|
||||||
mock_log.assert_called_once_with(
|
self.service.host, self.service.binary, force_down=True)
|
||||||
"Failed to set service status to %s", "enabled")
|
|
||||||
self.service_mock.force_down.assert_called_once_with(
|
|
||||||
self.service.host, self.service.binary, force_down=True)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user