trivial: Prepare for pyupgrade pre-commit hook

This change is entirely automated save for the update of some mocks from
'io.open' to '__builtins__.open').

We are keeping this change separate from addition of the actual hook so
that we can ignore the commit later.

Change-Id: I0a9d8736632084473b57b57b693322447d7be519
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-04-23 12:24:23 +01:00
parent 3de6969dbe
commit c5b772db76
274 changed files with 1291 additions and 1325 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# OpenStack Command Line Client documentation build configuration file, created
# by sphinx-quickstart on Wed May 16 12:05:58 2012.

View File

@ -45,7 +45,7 @@ raised that includes the name of the file that was attempted to be opened.
public_key = parsed_args.public_key
if public_key:
try:
with io.open(
with open(
os.path.expanduser(parsed_args.public_key),
"rb"
) as p:

View File

@ -21,7 +21,7 @@ import simplejson as json
from openstackclient.i18n import _
class KeystoneSession(object):
class KeystoneSession:
"""Wrapper for the Keystone Session
Restore some requests.session.Session compatibility;
@ -40,7 +40,7 @@ class KeystoneSession(object):
requests on this API.
"""
super(KeystoneSession, self).__init__()
super().__init__()
# a requests.Session-style interface
self.session = session
@ -95,7 +95,7 @@ class BaseAPI(KeystoneSession):
requests on this API.
"""
super(BaseAPI, self).__init__(session=session, endpoint=endpoint)
super().__init__(session=session, endpoint=endpoint)
self.service_type = service_type
@ -303,7 +303,7 @@ class BaseAPI(KeystoneSession):
"""
try:
ret = self._request('GET', "/%s/%s" % (path, value)).json()
ret = self._request('GET', f"/{path}/{value}").json()
except ks_exceptions.NotFound:
kwargs = {attr: value}
try:

View File

@ -30,7 +30,7 @@ class APIv2(api.BaseAPI):
"""Compute v2 API"""
def __init__(self, **kwargs):
super(APIv2, self).__init__(**kwargs)
super().__init__(**kwargs)
# Overrides
@ -76,7 +76,7 @@ class APIv2(api.BaseAPI):
"""
try:
ret = self._request('GET', "/%s/%s" % (path, value)).json()
ret = self._request('GET', f"/{path}/{value}").json()
if isinstance(ret, dict):
# strip off the enclosing dict
key = list(ret.keys())[0]
@ -136,7 +136,7 @@ class APIv2(api.BaseAPI):
return self._request(
"POST",
"/%s/%s/action" % (url, server['id']),
"/{}/{}/action".format(url, server['id']),
json={'addFloatingIp': body},
)
@ -180,7 +180,7 @@ class APIv2(api.BaseAPI):
url = "/os-floating-ips"
if floating_ip_id is not None:
return self.delete('/%s/%s' % (url, floating_ip_id))
return self.delete(f'/{url}/{floating_ip_id}')
return None
@ -248,7 +248,7 @@ class APIv2(api.BaseAPI):
return self._request(
"POST",
"/%s/%s/action" % (url, server['id']),
"/{}/{}/action".format(url, server['id']),
json={'removeFloatingIp': body},
)
@ -316,7 +316,7 @@ class APIv2(api.BaseAPI):
else:
return self._request(
"PUT",
"/%s/%s" % (url, host),
f"/{url}/{host}",
json=params,
).json()
@ -398,7 +398,7 @@ class APIv2(api.BaseAPI):
value=network,
)['id']
if network is not None:
return self.delete('/%s/%s' % (url, network))
return self.delete(f'/{url}/{network}')
return None
@ -487,7 +487,7 @@ class APIv2(api.BaseAPI):
value=security_group,
)['id']
if security_group is not None:
return self.delete('/%s/%s' % (url, security_group))
return self.delete(f'/{url}/{security_group}')
return None
@ -535,7 +535,7 @@ class APIv2(api.BaseAPI):
params = {}
if search_opts is not None:
params = dict((k, v) for (k, v) in search_opts.items() if v)
params = {k: v for (k, v) in search_opts.items() if v}
if limit:
params['limit'] = limit
if marker:
@ -549,7 +549,7 @@ class APIv2(api.BaseAPI):
security_group=None,
# name=None,
# description=None,
**params
**params,
):
"""Update a security group
@ -579,7 +579,7 @@ class APIv2(api.BaseAPI):
security_group[k] = v
return self._request(
"PUT",
"/%s/%s" % (url, security_group['id']),
"/{}/{}".format(url, security_group['id']),
json={'security_group': security_group},
).json()['security_group']
return None
@ -648,6 +648,6 @@ class APIv2(api.BaseAPI):
url = "/os-security-group-rules"
if security_group_rule_id is not None:
return self.delete('/%s/%s' % (url, security_group_rule_id))
return self.delete(f'/{url}/{security_group_rule_id}')
return None

View File

@ -22,7 +22,7 @@ class APIv1(api.BaseAPI):
_endpoint_suffix = '/v1'
def __init__(self, endpoint=None, **kwargs):
super(APIv1, self).__init__(endpoint=endpoint, **kwargs)
super().__init__(endpoint=endpoint, **kwargs)
self.endpoint = self.endpoint.rstrip('/')
self._munge_url()

View File

@ -13,7 +13,6 @@
"""Object Store v1 API Library"""
import io
import logging
import os
import sys
@ -33,7 +32,7 @@ class APIv1(api.BaseAPI):
"""Object Store v1 API"""
def __init__(self, **kwargs):
super(APIv1, self).__init__(**kwargs)
super().__init__(**kwargs)
def container_create(
self, container=None, public=False, storage_policy=None
@ -257,11 +256,11 @@ class APIv1(api.BaseAPI):
# object's name in the container.
object_name_str = name if name else object
full_url = "%s/%s" % (
full_url = "{}/{}".format(
urllib.parse.quote(container),
urllib.parse.quote(object_name_str),
)
with io.open(object, 'rb') as f:
with open(object, 'rb') as f:
response = self.create(
full_url,
method='PUT',

View File

@ -47,7 +47,7 @@ def _xform_compute_availability_zone(az, include_extra):
for svc, state in services.items():
info = copy.deepcopy(host_info)
info['service_name'] = svc
info['service_status'] = '%s %s %s' % (
info['service_status'] = '{} {} {}'.format(
'enabled' if state['active'] else 'disabled',
':-)' if state['available'] else 'XXX',
state['updated_at'],

View File

@ -51,7 +51,7 @@ class ClientManager(clientmanager.ClientManager):
api_version=None,
pw_func=None,
):
super(ClientManager, self).__init__(
super().__init__(
cli_options=cli_options,
api_version=api_version,
pw_func=pw_func,
@ -94,7 +94,7 @@ class ClientManager(clientmanager.ClientManager):
except TypeError as e:
self._fallback_load_auth_plugin(e)
return super(ClientManager, self).setup_auth()
return super().setup_auth()
def _fallback_load_auth_plugin(self, e):
# NOTES(RuiChen): Hack to avoid auth plugins choking on data they don't
@ -170,7 +170,9 @@ def get_plugin_modules(group):
module = importlib.import_module(module_name)
except Exception as err:
sys.stderr.write(
"WARNING: Failed to import plugin %s: %s.\n" % (ep.name, err)
"WARNING: Failed to import plugin {}: {}.\n".format(
ep.name, err
)
)
continue

View File

@ -27,7 +27,7 @@ class ShowConfiguration(command.ShowOne):
auth_required = False
def get_parser(self, prog_name):
parser = super(ShowConfiguration, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
mask_group = parser.add_mutually_exclusive_group()
mask_group.add_argument(
"--mask",

View File

@ -148,7 +148,7 @@ class ShowExtension(command.ShowOne):
_description = _("Show API extension")
def get_parser(self, prog_name):
parser = super(ShowExtension, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'extension',
metavar='<extension>',

View File

@ -28,7 +28,7 @@ class ShowLimits(command.Lister):
_description = _("Show compute and block storage limits")
def get_parser(self, prog_name):
parser = super(ShowLimits, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
type_group = parser.add_mutually_exclusive_group(required=True)
type_group.add_argument(
"--absolute",

View File

@ -29,7 +29,7 @@ class ListCommand(command.Lister):
auth_required = False
def get_parser(self, prog_name):
parser = super(ListCommand, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'--group',
metavar='<group-keyword>',
@ -72,7 +72,7 @@ class ListModule(command.ShowOne):
auth_required = False
def get_parser(self, prog_name):
parser = super(ListModule, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'--all',
action='store_true',

View File

@ -16,7 +16,7 @@
import sys
class _ProgressBarBase(object):
class _ProgressBarBase:
"""A progress bar provider for a wrapped object.
Base abstract class used by specific class wrapper to show
@ -39,7 +39,7 @@ class _ProgressBarBase(object):
self._percent += size_read / self._totalsize
# Output something like this: [==========> ] 49%
sys.stdout.write(
'\r[{0:<30}] {1:.0%}'.format(
'\r[{:<30}] {:.0%}'.format(
'=' * int(round(self._percent * 29)) + '>', self._percent
)
)

View File

@ -46,7 +46,7 @@ class ProjectCleanup(command.Command):
_description = _("Clean resources associated with a project")
def get_parser(self, prog_name):
parser = super(ProjectCleanup, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
action_group = parser.add_mutually_exclusive_group()
action_group.add_argument(
'--dry-run',

View File

@ -383,7 +383,7 @@ class ListQuota(command.Lister):
and ex.http_status <= 499
):
# Project not found, move on to next one
LOG.warning("Project %s not found: %s" % (p, ex))
LOG.warning(f"Project {p} not found: {ex}")
continue
else:
raise
@ -446,7 +446,7 @@ class ListQuota(command.Lister):
except Exception as ex:
if type(ex).__name__ == 'NotFound':
# Project not found, move on to next one
LOG.warning("Project %s not found: %s" % (p, ex))
LOG.warning(f"Project {p} not found: {ex}")
continue
else:
raise
@ -500,7 +500,7 @@ class ListQuota(command.Lister):
except Exception as ex:
if type(ex).__name__ == 'NotFound':
# Project not found, move on to next one
LOG.warning("Project %s not found: %s" % (p, ex))
LOG.warning(f"Project {p} not found: {ex}")
continue
else:
raise
@ -590,7 +590,7 @@ class SetQuota(common.NetDetectionMixin, command.Command):
return rets
def get_parser(self, prog_name):
parser = super(SetQuota, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'project',
metavar='<project/class>',

View File

@ -23,7 +23,7 @@ class ShowVersions(command.Lister):
_description = _("Show available versions of services")
def get_parser(self, prog_name):
parser = super(ShowVersions, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
interface_group = parser.add_mutually_exclusive_group()
interface_group.add_argument(
"--all-interfaces",

View File

@ -36,7 +36,7 @@ class CreateAgent(command.ShowOne):
"""
def get_parser(self, prog_name):
parser = super(CreateAgent, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument("os", metavar="<os>", help=_("Type of OS"))
parser.add_argument(
"architecture",
@ -77,7 +77,7 @@ class DeleteAgent(command.Command):
"""
def get_parser(self, prog_name):
parser = super(DeleteAgent, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"id", metavar="<id>", nargs='+', help=_("ID of agent(s) to delete")
)
@ -114,7 +114,7 @@ class ListAgent(command.Lister):
"""
def get_parser(self, prog_name):
parser = super(ListAgent, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"--hypervisor",
metavar="<hypervisor>",
@ -155,7 +155,7 @@ class SetAgent(command.Command):
"""
def get_parser(self, prog_name):
parser = super(SetAgent, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument("id", metavar="<id>", help=_("ID of the agent"))
parser.add_argument(
"--agent-version",

View File

@ -55,7 +55,7 @@ class AddAggregateHost(command.ShowOne):
_description = _("Add host to aggregate")
def get_parser(self, prog_name):
parser = super(AddAggregateHost, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'aggregate',
metavar='<aggregate>',
@ -88,7 +88,7 @@ class CreateAggregate(command.ShowOne):
_description = _("Create a new aggregate")
def get_parser(self, prog_name):
parser = super(CreateAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"name", metavar="<name>", help=_("New aggregate name")
)
@ -136,7 +136,7 @@ class DeleteAggregate(command.Command):
_description = _("Delete existing aggregate(s)")
def get_parser(self, prog_name):
parser = super(DeleteAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'aggregate',
metavar='<aggregate>',
@ -178,7 +178,7 @@ class ListAggregate(command.Lister):
_description = _("List all aggregates")
def get_parser(self, prog_name):
parser = super(ListAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'--long',
action='store_true',
@ -232,7 +232,7 @@ class RemoveAggregateHost(command.ShowOne):
_description = _("Remove host from aggregate")
def get_parser(self, prog_name):
parser = super(RemoveAggregateHost, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'aggregate',
metavar='<aggregate>',
@ -265,7 +265,7 @@ class SetAggregate(command.Command):
_description = _("Set aggregate properties")
def get_parser(self, prog_name):
parser = super(SetAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'aggregate',
metavar='<aggregate>',
@ -337,7 +337,7 @@ class ShowAggregate(command.ShowOne):
_description = _("Display aggregate details")
def get_parser(self, prog_name):
parser = super(ShowAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'aggregate',
metavar='<aggregate>',
@ -366,7 +366,7 @@ class UnsetAggregate(command.Command):
_description = _("Unset aggregate properties")
def get_parser(self, prog_name):
parser = super(UnsetAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"aggregate",
metavar="<aggregate>",
@ -403,7 +403,7 @@ class CacheImageForAggregate(command.Command):
# not be anything to return.
def get_parser(self, prog_name):
parser = super(CacheImageForAggregate, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'aggregate',
metavar='<aggregate>',

View File

@ -36,7 +36,7 @@ class ShowConsoleLog(command.Command):
_description = _("Show server's console output")
def get_parser(self, prog_name):
parser = super(ShowConsoleLog, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -78,7 +78,7 @@ class ShowConsoleURL(command.ShowOne):
_description = _("Show server's remote console URL")
def get_parser(self, prog_name):
parser = super(ShowConsoleURL, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',

View File

@ -58,7 +58,7 @@ class CreateFlavor(command.ShowOne):
_description = _("Create new flavor")
def get_parser(self, prog_name):
parser = super(CreateFlavor, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"name", metavar="<flavor-name>", help=_("New flavor name")
)
@ -214,7 +214,7 @@ class DeleteFlavor(command.Command):
_description = _("Delete flavor(s)")
def get_parser(self, prog_name):
parser = super(DeleteFlavor, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"flavor",
metavar="<flavor>",
@ -253,7 +253,7 @@ class ListFlavor(command.Lister):
_description = _("List flavors")
def get_parser(self, prog_name):
parser = super(ListFlavor, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
public_group = parser.add_mutually_exclusive_group()
public_group.add_argument(
"--public",
@ -375,7 +375,7 @@ class SetFlavor(command.Command):
_description = _("Set flavor properties")
def get_parser(self, prog_name):
parser = super(SetFlavor, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"flavor",
metavar="<flavor>",
@ -491,7 +491,7 @@ class ShowFlavor(command.ShowOne):
_description = _("Display flavor details")
def get_parser(self, prog_name):
parser = super(ShowFlavor, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"flavor",
metavar="<flavor>",
@ -540,7 +540,7 @@ class UnsetFlavor(command.Command):
_description = _("Unset flavor properties")
def get_parser(self, prog_name):
parser = super(UnsetFlavor, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"flavor",
metavar="<flavor>",

View File

@ -65,7 +65,7 @@ class SetHost(command.Command):
_description = _("Set host properties")
def get_parser(self, prog_name):
parser = super(SetHost, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"host", metavar="<host>", help=_("Host to modify (name only)")
)

View File

@ -16,7 +16,6 @@
"""Keypair action implementations"""
import collections
import io
import logging
import os
@ -77,7 +76,7 @@ class CreateKeypair(command.ShowOne):
_description = _("Create new public or private key for server ssh access")
def get_parser(self, prog_name):
parser = super(CreateKeypair, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'name', metavar='<name>', help=_("New public or private key name")
)
@ -130,9 +129,9 @@ class CreateKeypair(command.ShowOne):
if parsed_args.public_key:
generated_keypair = None
try:
with io.open(os.path.expanduser(parsed_args.public_key)) as p:
with open(os.path.expanduser(parsed_args.public_key)) as p:
public_key = p.read()
except IOError as e:
except OSError as e:
msg = _("Key file %(public_key)s not found: %(exception)s")
raise exceptions.CommandError(
msg
@ -150,11 +149,11 @@ class CreateKeypair(command.ShowOne):
# If user have us a file, save private key into specified file
if parsed_args.private_key:
try:
with io.open(
with open(
os.path.expanduser(parsed_args.private_key), 'w+'
) as p:
p.write(generated_keypair.private_key)
except IOError as e:
except OSError as e:
msg = _(
"Key file %(private_key)s can not be saved: "
"%(exception)s"
@ -212,7 +211,7 @@ class DeleteKeypair(command.Command):
_description = _("Delete public or private key(s)")
def get_parser(self, prog_name):
parser = super(DeleteKeypair, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'name',
metavar='<key>',
@ -388,7 +387,7 @@ class ShowKeypair(command.ShowOne):
_description = _("Display key details")
def get_parser(self, prog_name):
parser = super(ShowKeypair, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'name',
metavar='<key>',

View File

@ -17,7 +17,6 @@
import argparse
import getpass
import io
import json
import logging
import os
@ -233,7 +232,7 @@ def _prep_server_detail(compute_client, image_client, server, refresh=True):
image_id = image_info.get('id', '')
try:
image = image_client.get_image(image_id)
info['image'] = "%s (%s)" % (image.name, image_id)
info['image'] = f"{image.name} ({image_id})"
except Exception:
info['image'] = image_id
else:
@ -251,7 +250,7 @@ def _prep_server_detail(compute_client, image_client, server, refresh=True):
flavor_id = flavor_info.get('id', '')
try:
flavor = utils.find_resource(compute_client.flavors, flavor_id)
info['flavor'] = "%s (%s)" % (flavor.name, flavor_id)
info['flavor'] = f"{flavor.name} ({flavor_id})"
except Exception:
info['flavor'] = flavor_id
else: # microversion >= 2.47
@ -358,7 +357,7 @@ class AddFixedIP(command.ShowOne):
_description = _("Add fixed IP address to server")
def get_parser(self, prog_name):
parser = super(AddFixedIP, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"server",
metavar="<server>",
@ -551,7 +550,7 @@ class AddPort(command.Command):
_description = _("Add port to server")
def get_parser(self, prog_name):
parser = super(AddPort, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"server",
metavar="<server>",
@ -605,7 +604,7 @@ class AddNetwork(command.Command):
_description = _("Add network to server")
def get_parser(self, prog_name):
parser = super(AddNetwork, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"server",
metavar="<server>",
@ -660,7 +659,7 @@ class AddServerSecurityGroup(command.Command):
_description = _("Add security group to server")
def get_parser(self, prog_name):
parser = super(AddServerSecurityGroup, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -696,7 +695,7 @@ with status ``SHELVED`` or ``SHELVED_OFFLOADED``."""
)
def get_parser(self, prog_name):
parser = super(AddServerVolume, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -1050,7 +1049,7 @@ class CreateServer(command.ShowOne):
_description = _("Create a new server")
def get_parser(self, prog_name):
parser = super(CreateServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server_name',
metavar='<server-name>',
@ -1519,7 +1518,7 @@ class CreateServer(command.ShowOne):
img_dict_items.extend(list(img.properties.items()))
for key, value in img_dict_items:
try:
set([key, value])
{key, value}
except TypeError:
if key != 'properties':
LOG.debug(
@ -1595,8 +1594,8 @@ class CreateServer(command.ShowOne):
for f in parsed_args.file:
dst, src = f.split('=', 1)
try:
files[dst] = io.open(src, 'rb')
except IOError as e:
files[dst] = open(src, 'rb')
except OSError as e:
msg = _("Can't open '%(source)s': %(exception)s")
raise exceptions.CommandError(
msg % {'source': src, 'exception': e}
@ -1617,8 +1616,8 @@ class CreateServer(command.ShowOne):
userdata = None
if parsed_args.user_data:
try:
userdata = io.open(parsed_args.user_data)
except IOError as e:
userdata = open(parsed_args.user_data)
except OSError as e:
msg = _("Can't open '%(data)s': %(exception)s")
raise exceptions.CommandError(
msg % {'data': parsed_args.user_data, 'exception': e}
@ -2065,7 +2064,7 @@ class CreateServerDump(command.Command):
"""
def get_parser(self, prog_name):
parser = super(CreateServerDump, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -2085,7 +2084,7 @@ class DeleteServer(command.Command):
_description = _("Delete server(s)")
def get_parser(self, prog_name):
parser = super(DeleteServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -2190,7 +2189,7 @@ class ListServer(command.Lister):
_description = _("List servers")
def get_parser(self, prog_name):
parser = super(ListServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'--reservation-id',
metavar='<reservation-id>',
@ -2876,11 +2875,11 @@ class ListServer(command.Lister):
# present on microversion 2.47 or later and 'flavor' won't be
# present if there are infra failures
if parsed_args.name_lookup_one_by_one or flavor_id:
for f_id in set(
for f_id in {
s.flavor['id']
for s in data
if s.flavor and s.flavor.get('id')
):
}:
try:
flavors[f_id] = compute_client.find_flavor(
f_id, ignore_missing=False
@ -2988,7 +2987,7 @@ A non-admin user will not be able to execute actions."""
)
def get_parser(self, prog_name):
parser = super(LockServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -3052,7 +3051,7 @@ revert to release the new server and restart the old one."""
)
def get_parser(self, prog_name):
parser = super(MigrateServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -3226,7 +3225,7 @@ class PauseServer(command.Command):
_description = _("Pause server(s)")
def get_parser(self, prog_name):
parser = super(PauseServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -3309,7 +3308,7 @@ class RebuildServer(command.ShowOne):
_description = _("Rebuild server")
def get_parser(self, prog_name):
parser = super(RebuildServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -3564,8 +3563,8 @@ class RebuildServer(command.ShowOne):
raise exceptions.CommandError(msg)
try:
userdata = io.open(parsed_args.user_data)
except IOError as e:
userdata = open(parsed_args.user_data)
except OSError as e:
msg = _("Can't open '%(data)s': %(exception)s")
raise exceptions.CommandError(
msg % {'data': parsed_args.user_data, 'exception': e}
@ -3700,7 +3699,7 @@ host."""
)
def get_parser(self, prog_name):
parser = super(EvacuateServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -3807,7 +3806,7 @@ class RemoveFixedIP(command.Command):
_description = _("Remove fixed IP address from server")
def get_parser(self, prog_name):
parser = super(RemoveFixedIP, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"server",
metavar="<server>",
@ -3869,7 +3868,7 @@ class RemovePort(command.Command):
_description = _("Remove port from server")
def get_parser(self, prog_name):
parser = super(RemovePort, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"server",
metavar="<server>",
@ -3908,7 +3907,7 @@ class RemoveNetwork(command.Command):
_description = _("Remove all ports of a network from server")
def get_parser(self, prog_name):
parser = super(RemoveNetwork, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
"server",
metavar="<server>",
@ -3948,7 +3947,7 @@ class RemoveServerSecurityGroup(command.Command):
_description = _("Remove security group from server")
def get_parser(self, prog_name):
parser = super(RemoveServerSecurityGroup, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -3984,7 +3983,7 @@ volume from a server with status ``SHELVED`` or ``SHELVED_OFFLOADED``."""
)
def get_parser(self, prog_name):
parser = super(RemoveServerVolume, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4026,7 +4025,7 @@ server booted from a volume."""
)
def get_parser(self, prog_name):
parser = super(RescueServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4078,7 +4077,7 @@ release the new server and restart the old one."""
)
def get_parser(self, prog_name):
parser = super(ResizeServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
phase_group = parser.add_mutually_exclusive_group()
parser.add_argument(
'server',
@ -4176,7 +4175,7 @@ Confirm (verify) success of resize operation and release the old server."""
)
def get_parser(self, prog_name):
parser = super(ResizeConfirm, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4225,7 +4224,7 @@ one."""
)
def get_parser(self, prog_name):
parser = super(ResizeRevert, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4269,7 +4268,7 @@ class RestoreServer(command.Command):
_description = _("Restore server(s)")
def get_parser(self, prog_name):
parser = super(RestoreServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4292,7 +4291,7 @@ class ResumeServer(command.Command):
_description = _("Resume server(s)")
def get_parser(self, prog_name):
parser = super(ResumeServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4315,7 +4314,7 @@ class SetServer(command.Command):
_description = _("Set server properties")
def get_parser(self, prog_name):
parser = super(SetServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4589,7 +4588,7 @@ information for the server."""
)
def get_parser(self, prog_name):
parser = super(ShowServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4657,7 +4656,7 @@ class SshServer(command.Command):
_description = _("SSH to server")
def get_parser(self, prog_name):
parser = super(SshServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4809,7 +4808,7 @@ class SshServer(command.Command):
)
cmd = ' '.join(['ssh', ip_address] + args)
LOG.debug("ssh command: {cmd}".format(cmd=cmd))
LOG.debug(f"ssh command: {cmd}")
# we intentionally pass through user-provided arguments and run this in
# the user's shell
os.system(cmd) # nosec: B605
@ -4899,7 +4898,7 @@ class SuspendServer(command.Command):
_description = _("Suspend server(s)")
def get_parser(self, prog_name):
parser = super(SuspendServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4945,7 +4944,7 @@ class UnpauseServer(command.Command):
_description = _("Unpause server(s)")
def get_parser(self, prog_name):
parser = super(UnpauseServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4968,7 +4967,7 @@ class UnrescueServer(command.Command):
_description = _("Restore server from rescue mode")
def get_parser(self, prog_name):
parser = super(UnrescueServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
@ -4988,7 +4987,7 @@ class UnsetServer(command.Command):
_description = _("Unset server properties and tags")
def get_parser(self, prog_name):
parser = super(UnsetServer, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',

View File

@ -33,7 +33,7 @@ class CreateServerBackup(command.ShowOne):
}
def get_parser(self, prog_name):
parser = super(CreateServerBackup, self).get_parser(prog_name)
parser = super().get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',

View File

@ -56,7 +56,7 @@ class CreateServerGroup(command.ShowOne):
_description = _("Create a new server group.")
def get_parser(self, prog_name):
parser = super(CreateServerGroup, self