summaryrefslogtreecommitdiff
path: root/openstackclient/volume/v2
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/volume/v2')
-rw-r--r--openstackclient/volume/v2/backup_record.py22
-rw-r--r--openstackclient/volume/v2/consistency_group.py141
-rw-r--r--openstackclient/volume/v2/consistency_group_snapshot.py109
-rw-r--r--openstackclient/volume/v2/qos_specs.py138
-rw-r--r--openstackclient/volume/v2/service.py66
-rw-r--r--openstackclient/volume/v2/volume.py417
-rw-r--r--openstackclient/volume/v2/volume_backend.py34
-rw-r--r--openstackclient/volume/v2/volume_backup.py115
-rw-r--r--openstackclient/volume/v2/volume_host.py23
-rw-r--r--openstackclient/volume/v2/volume_snapshot.py239
-rw-r--r--openstackclient/volume/v2/volume_transfer_request.py29
-rw-r--r--openstackclient/volume/v2/volume_type.py384
12 files changed, 1076 insertions, 641 deletions
diff --git a/openstackclient/volume/v2/backup_record.py b/openstackclient/volume/v2/backup_record.py
index 0d3af641..be4b9c69 100644
--- a/openstackclient/volume/v2/backup_record.py
+++ b/openstackclient/volume/v2/backup_record.py
@@ -26,17 +26,19 @@ LOG = logging.getLogger(__name__)
class ExportBackupRecord(command.ShowOne):
- _description = _("""Export volume backup details.
+ _description = _(
+ """Export volume backup details.
Backup information can be imported into a new service instance to be able to
-restore.""")
+restore."""
+ )
def get_parser(self, prog_name):
parser = super(ExportBackupRecord, self).get_parser(prog_name)
parser.add_argument(
"backup",
metavar="<backup>",
- help=_("Backup to export (name or ID)")
+ help=_("Backup to export (name or ID)"),
)
return parser
@@ -55,29 +57,31 @@ restore.""")
class ImportBackupRecord(command.ShowOne):
- _description = _("""Import volume backup details.
+ _description = _(
+ """Import volume backup details.
Exported backup details contain the metadata necessary to restore to a new or
-rebuilt service instance""")
+rebuilt service instance"""
+ )
def get_parser(self, prog_name):
parser = super(ImportBackupRecord, self).get_parser(prog_name)
parser.add_argument(
"backup_service",
metavar="<backup_service>",
- help=_("Backup service containing the backup.")
+ help=_("Backup service containing the backup."),
)
parser.add_argument(
"backup_metadata",
metavar="<backup_metadata>",
- help=_("Encoded backup metadata from export.")
+ help=_("Encoded backup metadata from export."),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
backup_data = volume_client.backups.import_record(
- parsed_args.backup_service,
- parsed_args.backup_metadata)
+ parsed_args.backup_service, parsed_args.backup_metadata
+ )
backup_data.pop('links', None)
return zip(*sorted(backup_data.items()))
diff --git a/openstackclient/volume/v2/consistency_group.py b/openstackclient/volume/v2/consistency_group.py
index 77da6f64..3b4d8803 100644
--- a/openstackclient/volume/v2/consistency_group.py
+++ b/openstackclient/volume/v2/consistency_group.py
@@ -33,14 +33,17 @@ def _find_volumes(parsed_args_volumes, volume_client):
uuid = ''
for volume in parsed_args_volumes:
try:
- volume_id = utils.find_resource(
- volume_client.volumes, volume).id
+ volume_id = utils.find_resource(volume_client.volumes, volume).id
uuid += volume_id + ','
except Exception as e:
result += 1
- LOG.error(_("Failed to find volume with "
- "name or ID '%(volume)s':%(e)s")
- % {'volume': volume, 'e': e})
+ LOG.error(
+ _(
+ "Failed to find volume with "
+ "name or ID '%(volume)s':%(e)s"
+ )
+ % {'volume': volume, 'e': e}
+ )
return result, uuid
@@ -59,8 +62,10 @@ class AddVolumeToConsistencyGroup(command.Command):
'volumes',
metavar='<volume>',
nargs='+',
- help=_('Volume(s) to add to <consistency-group> (name or ID) '
- '(repeat option to add multiple volumes)'),
+ help=_(
+ 'Volume(s) to add to <consistency-group> (name or ID) '
+ '(repeat option to add multiple volumes)'
+ ),
)
return parser
@@ -70,16 +75,19 @@ class AddVolumeToConsistencyGroup(command.Command):
if result > 0:
total = len(parsed_args.volumes)
- LOG.error(_("%(result)s of %(total)s volumes failed "
- "to add.") % {'result': result, 'total': total})
+ LOG.error(
+ _("%(result)s of %(total)s volumes failed " "to add.")
+ % {'result': result, 'total': total}
+ )
if add_uuid:
add_uuid = add_uuid.rstrip(',')
consistency_group_id = utils.find_resource(
- volume_client.consistencygroups,
- parsed_args.consistency_group).id
+ volume_client.consistencygroups, parsed_args.consistency_group
+ ).id
volume_client.consistencygroups.update(
- consistency_group_id, add_volumes=add_uuid)
+ consistency_group_id, add_volumes=add_uuid
+ )
class CreateConsistencyGroup(command.ShowOne):
@@ -143,18 +151,20 @@ class CreateConsistencyGroup(command.ShowOne):
volume_client = self.app.client_manager.volume
if parsed_args.volume_type:
volume_type_id = utils.find_resource(
- volume_client.volume_types,
- parsed_args.volume_type).id
+ volume_client.volume_types, parsed_args.volume_type
+ ).id
consistency_group = volume_client.consistencygroups.create(
volume_type_id,
name=parsed_args.name,
description=parsed_args.description,
- availability_zone=parsed_args.availability_zone
+ availability_zone=parsed_args.availability_zone,
)
else:
if parsed_args.availability_zone:
- msg = _("'--availability-zone' option will not work "
- "if creating consistency group from source")
+ msg = _(
+ "'--availability-zone' option will not work "
+ "if creating consistency group from source"
+ )
LOG.warning(msg)
consistency_group_id = None
@@ -208,19 +218,27 @@ class DeleteConsistencyGroup(command.Command):
for i in parsed_args.consistency_groups:
try:
consistency_group_id = utils.find_resource(
- volume_client.consistencygroups, i).id
+ volume_client.consistencygroups, i
+ ).id
volume_client.consistencygroups.delete(
- consistency_group_id, parsed_args.force)
+ consistency_group_id, parsed_args.force
+ )
except Exception as e:
result += 1
- LOG.error(_("Failed to delete consistency group with "
- "name or ID '%(consistency_group)s':%(e)s")
- % {'consistency_group': i, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete consistency group with "
+ "name or ID '%(consistency_group)s':%(e)s"
+ )
+ % {'consistency_group': i, 'e': e}
+ )
if result > 0:
total = len(parsed_args.consistency_groups)
- msg = (_("%(result)s of %(total)s consistency groups failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s consistency groups failed "
+ "to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -232,41 +250,56 @@ class ListConsistencyGroup(command.Lister):
parser.add_argument(
'--all-projects',
action="store_true",
- help=_('Show details for all projects. Admin only. '
- '(defaults to False)')
+ help=_(
+ 'Show details for all projects. Admin only. '
+ '(defaults to False)'
+ ),
)
parser.add_argument(
'--long',
action="store_true",
- help=_('List additional fields in output')
+ help=_('List additional fields in output'),
)
return parser
def take_action(self, parsed_args):
if parsed_args.long:
- columns = ['ID', 'Status', 'Availability Zone',
- 'Name', 'Description', 'Volume Types']
+ columns = [
+ 'ID',
+ 'Status',
+ 'Availability Zone',
+ 'Name',
+ 'Description',
+ 'Volume Types',
+ ]
else:
columns = ['ID', 'Status', 'Name']
volume_client = self.app.client_manager.volume
consistency_groups = volume_client.consistencygroups.list(
detailed=True,
- search_opts={'all_tenants': parsed_args.all_projects}
+ search_opts={'all_tenants': parsed_args.all_projects},
)
- return (columns, (
- utils.get_item_properties(
- s, columns,
- formatters={'Volume Types': format_columns.ListColumn})
- for s in consistency_groups))
+ return (
+ columns,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
+ formatters={'Volume Types': format_columns.ListColumn},
+ )
+ for s in consistency_groups
+ ),
+ )
class RemoveVolumeFromConsistencyGroup(command.Command):
_description = _("Remove volume(s) from consistency group")
def get_parser(self, prog_name):
- parser = \
- super(RemoveVolumeFromConsistencyGroup, self).get_parser(prog_name)
+ parser = super(RemoveVolumeFromConsistencyGroup, self).get_parser(
+ prog_name
+ )
parser.add_argument(
'consistency_group',
metavar="<consistency-group>",
@@ -276,8 +309,10 @@ class RemoveVolumeFromConsistencyGroup(command.Command):
'volumes',
metavar='<volume>',
nargs='+',
- help=_('Volume(s) to remove from <consistency-group> (name or ID) '
- '(repeat option to remove multiple volumes)'),
+ help=_(
+ 'Volume(s) to remove from <consistency-group> (name or ID) '
+ '(repeat option to remove multiple volumes)'
+ ),
)
return parser
@@ -287,16 +322,19 @@ class RemoveVolumeFromConsistencyGroup(command.Command):
if result > 0:
total = len(parsed_args.volumes)
- LOG.error(_("%(result)s of %(total)s volumes failed "
- "to remove.") % {'result': result, 'total': total})
+ LOG.error(
+ _("%(result)s of %(total)s volumes failed " "to remove.")
+ % {'result': result, 'total': total}
+ )
if remove_uuid:
remove_uuid = remove_uuid.rstrip(',')
consistency_group_id = utils.find_resource(
- volume_client.consistencygroups,
- parsed_args.consistency_group).id
+ volume_client.consistencygroups, parsed_args.consistency_group
+ ).id
volume_client.consistencygroups.update(
- consistency_group_id, remove_volumes=remove_uuid)
+ consistency_group_id, remove_volumes=remove_uuid
+ )
class SetConsistencyGroup(command.Command):
@@ -307,7 +345,7 @@ class SetConsistencyGroup(command.Command):
parser.add_argument(
'consistency_group',
metavar='<consistency-group>',
- help=_('Consistency group to modify (name or ID)')
+ help=_('Consistency group to modify (name or ID)'),
)
parser.add_argument(
'--name',
@@ -330,10 +368,11 @@ class SetConsistencyGroup(command.Command):
kwargs['description'] = parsed_args.description
if kwargs:
consistency_group_id = utils.find_resource(
- volume_client.consistencygroups,
- parsed_args.consistency_group).id
+ volume_client.consistencygroups, parsed_args.consistency_group
+ ).id
volume_client.consistencygroups.update(
- consistency_group_id, **kwargs)
+ consistency_group_id, **kwargs
+ )
class ShowConsistencyGroup(command.ShowOne):
@@ -344,13 +383,13 @@ class ShowConsistencyGroup(command.ShowOne):
parser.add_argument(
"consistency_group",
metavar="<consistency-group>",
- help=_("Consistency group to display (name or ID)")
+ help=_("Consistency group to display (name or ID)"),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
consistency_group = utils.find_resource(
- volume_client.consistencygroups,
- parsed_args.consistency_group)
+ volume_client.consistencygroups, parsed_args.consistency_group
+ )
return zip(*sorted(consistency_group._info.items()))
diff --git a/openstackclient/volume/v2/consistency_group_snapshot.py b/openstackclient/volume/v2/consistency_group_snapshot.py
index 7d5ba82f..fe3c569f 100644
--- a/openstackclient/volume/v2/consistency_group_snapshot.py
+++ b/openstackclient/volume/v2/consistency_group_snapshot.py
@@ -30,24 +30,27 @@ class CreateConsistencyGroupSnapshot(command.ShowOne):
_description = _("Create new consistency group snapshot.")
def get_parser(self, prog_name):
- parser = super(
- CreateConsistencyGroupSnapshot, self).get_parser(prog_name)
+ parser = super(CreateConsistencyGroupSnapshot, self).get_parser(
+ prog_name
+ )
parser.add_argument(
"snapshot_name",
metavar="<snapshot-name>",
nargs="?",
- help=_("Name of new consistency group snapshot (default to None)")
+ help=_("Name of new consistency group snapshot (default to None)"),
)
parser.add_argument(
"--consistency-group",
metavar="<consistency-group>",
- help=_("Consistency group to snapshot (name or ID) "
- "(default to be the same as <snapshot-name>)")
+ help=_(
+ "Consistency group to snapshot (name or ID) "
+ "(default to be the same as <snapshot-name>)"
+ ),
)
parser.add_argument(
"--description",
metavar="<description>",
- help=_("Description of this consistency group snapshot")
+ help=_("Description of this consistency group snapshot"),
)
return parser
@@ -59,8 +62,8 @@ class CreateConsistencyGroupSnapshot(command.ShowOne):
# will be the same as the new consistency group snapshot name
consistency_group = parsed_args.snapshot_name
consistency_group_id = utils.find_resource(
- volume_client.consistencygroups,
- consistency_group).id
+ volume_client.consistencygroups, consistency_group
+ ).id
consistency_group_snapshot = volume_client.cgsnapshots.create(
consistency_group_id,
name=parsed_args.snapshot_name,
@@ -74,13 +77,14 @@ class DeleteConsistencyGroupSnapshot(command.Command):
_description = _("Delete consistency group snapshot(s).")
def get_parser(self, prog_name):
- parser = super(
- DeleteConsistencyGroupSnapshot, self).get_parser(prog_name)
+ parser = super(DeleteConsistencyGroupSnapshot, self).get_parser(
+ prog_name
+ )
parser.add_argument(
"consistency_group_snapshot",
metavar="<consistency-group-snapshot>",
nargs="+",
- help=_("Consistency group snapshot(s) to delete (name or ID)")
+ help=_("Consistency group snapshot(s) to delete (name or ID)"),
)
return parser
@@ -90,20 +94,27 @@ class DeleteConsistencyGroupSnapshot(command.Command):
for snapshot in parsed_args.consistency_group_snapshot:
try:
- snapshot_id = utils.find_resource(volume_client.cgsnapshots,
- snapshot).id
+ snapshot_id = utils.find_resource(
+ volume_client.cgsnapshots, snapshot
+ ).id
volume_client.cgsnapshots.delete(snapshot_id)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete consistency group snapshot "
- "with name or ID '%(snapshot)s': %(e)s")
- % {'snapshot': snapshot, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete consistency group snapshot "
+ "with name or ID '%(snapshot)s': %(e)s"
+ )
+ % {'snapshot': snapshot, 'e': e}
+ )
if result > 0:
total = len(parsed_args.consistency_group_snapshot)
- msg = (_("%(result)s of %(total)s consistency group snapshots "
- "failed to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s consistency group snapshots "
+ "failed to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -111,38 +122,54 @@ class ListConsistencyGroupSnapshot(command.Lister):
_description = _("List consistency group snapshots.")
def get_parser(self, prog_name):
- parser = super(
- ListConsistencyGroupSnapshot, self).get_parser(prog_name)
+ parser = super(ListConsistencyGroupSnapshot, self).get_parser(
+ prog_name
+ )
parser.add_argument(
'--all-projects',
action="store_true",
- help=_('Show detail for all projects (admin only) '
- '(defaults to False)')
+ help=_(
+ 'Show detail for all projects (admin only) '
+ '(defaults to False)'
+ ),
)
parser.add_argument(
'--long',
action="store_true",
- help=_('List additional fields in output')
+ help=_('List additional fields in output'),
)
parser.add_argument(
'--status',
metavar="<status>",
- choices=['available', 'error', 'creating', 'deleting',
- 'error_deleting'],
- help=_('Filters results by a status ("available", "error", '
- '"creating", "deleting" or "error_deleting")')
+ choices=[
+ 'available',
+ 'error',
+ 'creating',
+ 'deleting',
+ 'error_deleting',
+ ],
+ help=_(
+ 'Filters results by a status ("available", "error", '
+ '"creating", "deleting" or "error_deleting")'
+ ),
)
parser.add_argument(
'--consistency-group',
metavar="<consistency-group>",
- help=_('Filters results by a consistency group (name or ID)')
+ help=_('Filters results by a consistency group (name or ID)'),
)
return parser
def take_action(self, parsed_args):
if parsed_args.long:
- columns = ['ID', 'Status', 'ConsistencyGroup ID',
- 'Name', 'Description', 'Created At']
+ columns = [
+ 'ID',
+ 'Status',
+ 'ConsistencyGroup ID',
+ 'Name',
+ 'Description',
+ 'Created At',
+ ]
else:
columns = ['ID', 'Status', 'Name']
volume_client = self.app.client_manager.volume
@@ -162,28 +189,32 @@ class ListConsistencyGroupSnapshot(command.Lister):
search_opts=search_opts,
)
- return (columns, (
- utils.get_item_properties(
- s, columns)
- for s in consistency_group_snapshots))
+ return (
+ columns,
+ (
+ utils.get_item_properties(s, columns)
+ for s in consistency_group_snapshots
+ ),
+ )
class ShowConsistencyGroupSnapshot(command.ShowOne):
_description = _("Display consistency group snapshot details")
def get_parser(self, prog_name):
- parser = super(
- ShowConsistencyGroupSnapshot, self).get_parser(prog_name)
+ parser = super(ShowConsistencyGroupSnapshot, self).get_parser(
+ prog_name
+ )
parser.add_argument(
"consistency_group_snapshot",
metavar="<consistency-group-snapshot>",
- help=_("Consistency group snapshot to display (name or ID)")
+ help=_("Consistency group snapshot to display (name or ID)"),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
consistency_group_snapshot = utils.find_resource(
- volume_client.cgsnapshots,
- parsed_args.consistency_group_snapshot)
+ volume_client.cgsnapshots, parsed_args.consistency_group_snapshot
+ )
return zip(*sorted(consistency_group_snapshot._info.items()))
diff --git a/openstackclient/volume/v2/qos_specs.py b/openstackclient/volume/v2/qos_specs.py
index e6e6b9f8..2c06ee34 100644
--- a/openstackclient/volume/v2/qos_specs.py
+++ b/openstackclient/volume/v2/qos_specs.py
@@ -48,10 +48,12 @@ class AssociateQos(command.Command):
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- qos_spec = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_spec)
- volume_type = utils.find_resource(volume_client.volume_types,
- parsed_args.volume_type)
+ qos_spec = utils.find_resource(
+ volume_client.qos_specs, parsed_args.qos_spec
+ )
+ volume_type = utils.find_resource(
+ volume_client.volume_types, parsed_args.volume_type
+ )
volume_client.qos_specs.associate(qos_spec.id, volume_type.id)
@@ -72,16 +74,22 @@ class CreateQos(command.ShowOne):
metavar='<consumer>',
choices=consumer_choices,
default='both',
- help=(_('Consumer of the QoS. Valid consumers: %s '
- "(defaults to 'both')") %
- utils.format_list(consumer_choices))
+ help=(
+ _(
+ 'Consumer of the QoS. Valid consumers: %s '
+ "(defaults to 'both')"
+ )
+ % utils.format_list(consumer_choices)
+ ),
)
parser.add_argument(
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Set a QoS specification property '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Set a QoS specification property '
+ '(repeat option to set multiple properties)'
+ ),
)
return parser
@@ -96,8 +104,11 @@ class CreateQos(command.ShowOne):
qos_spec = volume_client.qos_specs.create(parsed_args.name, specs)
qos_spec._info.update(
- {'properties':
- format_columns.DictColumn(qos_spec._info.pop('specs'))}
+ {
+ 'properties': format_columns.DictColumn(
+ qos_spec._info.pop('specs')
+ )
+ }
)
return zip(*sorted(qos_spec._info.items()))
@@ -117,7 +128,7 @@ class DeleteQos(command.Command):
'--force',
action='store_true',
default=False,
- help=_("Allow to delete in-use QoS specification(s)")
+ help=_("Allow to delete in-use QoS specification(s)"),
)
return parser
@@ -131,14 +142,20 @@ class DeleteQos(command.Command):
volume_client.qos_specs.delete(qos_spec.id, parsed_args.force)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete QoS specification with "
- "name or ID '%(qos)s': %(e)s")
- % {'qos': i, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete QoS specification with "
+ "name or ID '%(qos)s': %(e)s"
+ )
+ % {'qos': i, 'e': e}
+ )
if result > 0:
total = len(parsed_args.qos_specs)
- msg = (_("%(result)s of %(total)s QoS specifications failed"
- " to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s QoS specifications failed"
+ " to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -169,12 +186,14 @@ class DisassociateQos(command.Command):
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- qos_spec = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_spec)
+ qos_spec = utils.find_resource(
+ volume_client.qos_specs, parsed_args.qos_spec
+ )
if parsed_args.volume_type:
- volume_type = utils.find_resource(volume_client.volume_types,
- parsed_args.volume_type)
+ volume_type = utils.find_resource(
+ volume_client.volume_types, parsed_args.volume_type
+ )
volume_client.qos_specs.disassociate(qos_spec.id, volume_type.id)
elif parsed_args.all:
volume_client.qos_specs.disassociate_all(qos_spec.id)
@@ -204,17 +223,28 @@ class ListQos(command.Lister):
raise
display_columns = (
- 'ID', 'Name', 'Consumer', 'Associations', 'Properties')
+ 'ID',
+ 'Name',
+ 'Consumer',
+ 'Associations',
+ 'Properties',
+ )
columns = ('ID', 'Name', 'Consumer', 'Associations', 'Specs')
- return (display_columns,
- (utils.get_dict_properties(
- s._info, columns,
+ return (
+ display_columns,
+ (
+ utils.get_dict_properties(
+ s._info,
+ columns,
formatters={
'Specs': format_columns.DictColumn,
- 'Associations': format_columns.ListColumn
+ 'Associations': format_columns.ListColumn,
},
- ) for s in qos_specs_list))
+ )
+ for s in qos_specs_list
+ ),
+ )
class SetQos(command.Command):
@@ -231,19 +261,21 @@ class SetQos(command.Command):
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Property to add or modify for this QoS specification '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Property to add or modify for this QoS specification '
+ '(repeat option to set multiple properties)'
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- qos_spec = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_spec)
+ qos_spec = utils.find_resource(
+ volume_client.qos_specs, parsed_args.qos_spec
+ )
if parsed_args.property:
- volume_client.qos_specs.set_keys(qos_spec.id,
- parsed_args.property)
+ volume_client.qos_specs.set_keys(qos_spec.id, parsed_args.property)
class ShowQos(command.ShowOne):
@@ -260,19 +292,25 @@ class ShowQos(command.ShowOne):
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- qos_spec = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_spec)
+ qos_spec = utils.find_resource(
+ volume_client.qos_specs, parsed_args.qos_spec
+ )
qos_associations = volume_client.qos_specs.get_associations(qos_spec)
if qos_associations:
- associations = [association.name
- for association in qos_associations]
- qos_spec._info.update({
- 'associations': format_columns.ListColumn(associations)
- })
+ associations = [
+ association.name for association in qos_associations
+ ]
+ qos_spec._info.update(
+ {'associations': format_columns.ListColumn(associations)}
+ )
qos_spec._info.update(
- {'properties':
- format_columns.DictColumn(qos_spec._info.pop('specs'))})
+ {
+ 'properties': format_columns.DictColumn(
+ qos_spec._info.pop('specs')
+ )
+ }
+ )
return zip(*sorted(qos_spec._info.items()))
@@ -292,16 +330,20 @@ class UnsetQos(command.Command):
metavar='<key>',
action='append',
default=[],
- help=_('Property to remove from the QoS specification. '
- '(repeat option to unset multiple properties)'),
+ help=_(
+ 'Property to remove from the QoS specification. '
+ '(repeat option to unset multiple properties)'
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- qos_spec = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_spec)
+ qos_spec = utils.find_resource(
+ volume_client.qos_specs, parsed_args.qos_spec
+ )
if parsed_args.property:
- volume_client.qos_specs.unset_keys(qos_spec.id,
- parsed_args.property)
+ volume_client.qos_specs.unset_keys(
+ qos_spec.id, parsed_args.property
+ )
diff --git a/openstackclient/volume/v2/service.py b/openstackclient/volume/v2/service.py
index d468c6ff..fb5869d5 100644
--- a/openstackclient/volume/v2/service.py
+++ b/openstackclient/volume/v2/service.py
@@ -29,18 +29,18 @@ class ListService(command.Lister):
parser.add_argument(
"--host",
metavar="<host>",
- help=_("List services on specified host (name only)")
+ help=_("List services on specified host (name only)"),
)
parser.add_argument(
"--service",
metavar="<service>",
- help=_("List only specified service (name only)")
+ help=_("List only specified service (name only)"),
)
parser.add_argument(
"--long",
action="store_true",
default=False,
- help=_("List additional fields in output")
+ help=_("List additional fields in output"),
)
return parser
@@ -55,7 +55,7 @@ class ListService(command.Lister):
"Status",
"State",
"Updated At",
- "Disabled Reason"
+ "Disabled Reason",
]
else:
columns = [
@@ -64,15 +64,22 @@ class ListService(command.Lister):
"Zone",
"Status",
"State",
- "Updated At"
+ "Updated At",
]
- data = service_client.services.list(parsed_args.host,
- parsed_args.service)
- return (columns,
- (utils.get_item_properties(
- s, columns,
- ) for s in data))
+ data = service_client.services.list(
+ parsed_args.host, parsed_args.service
+ )
+ return (
+ columns,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
+ )
+ for s in data
+ ),
+ )
class SetService(command.Command):
@@ -80,51 +87,50 @@ class SetService(command.Command):
def get_parser(self, prog_name):
parser = super(SetService, self).get_parser(prog_name)
- parser.add_argument(
- "host",
- metavar="<host>",
- help=_("Name of host")
- )
+ parser.add_argument("host", metavar="<host>", help=_("Name of host"))
parser.add_argument(
"service",
metavar="<service>",
- help=_("Name of service (Binary name)")
+ help=_("Name of service (Binary name)"),
)
enabled_group = parser.add_mutually_exclusive_group()
enabled_group.add_argument(
- "--enable",
- action="store_true",
- help=_("Enable volume service")
+ "--enable", action="store_true", help=_("Enable volume service")
)
enabled_group.add_argument(
- "--disable",
- action="store_true",
- help=_("Disable volume service")
+ "--disable", action="store_true", help=_("Disable volume service")
)
parser.add_argument(
"--disable-reason",
metavar="<reason>",
- help=_("Reason for disabling the service "
- "(should be used with --disable option)")
+ help=_(
+ "Reason for disabling the service "
+ "(should be used with --disable option)"
+ ),
)
return parser
def take_action(self, parsed_args):
if parsed_args.disable_reason and not parsed_args.disable:
- msg = _("Cannot specify option --disable-reason without "
- "--disable specified.")
+ msg = _(
+ "Cannot specify option --disable-reason without "
+ "--disable specified."
+ )
raise exceptions.CommandError(msg)
service_client = self.app.client_manager.volume
if parsed_args.enable:
service_client.services.enable(
- parsed_args.host, parsed_args.service)
+ parsed_args.host, parsed_args.service
+ )
if parsed_args.disable:
if parsed_args.disable_reason:
service_client.services.disable_log_reason(
parsed_args.host,
parsed_args.service,
- parsed_args.disable_reason)
+ parsed_args.disable_reason,
+ )
else:
service_client.services.disable(
- parsed_args.host, parsed_args.service)
+ parsed_args.host, parsed_args.service
+ )
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py
index a5e5a670..43a64664 100644
--- a/openstackclient/volume/v2/volume.py
+++ b/openstackclient/volume/v2/volume.py
@@ -71,10 +71,13 @@ def _check_size_arg(args):
volume is not specified.
"""
- if ((args.snapshot or args.source or args.backup)
- is None and args.size is None):
- msg = _("--size is a required option if snapshot, backup "
- "or source volume are not specified.")
+ if (
+ args.snapshot or args.source or args.backup
+ ) is None and args.size is None:
+ msg = _(
+ "--size is a required option if snapshot, backup "
+ "or source volume are not specified."
+ )
raise exceptions.CommandError(msg)
@@ -93,8 +96,10 @@ class CreateVolume(command.ShowOne):
"--size",
metavar="<size>",
type=int,
- help=_("Volume size in GB (required unless --snapshot, "
- "--source or --backup is specified)"),
+ help=_(
+ "Volume size in GB (required unless --snapshot, "
+ "--source or --backup is specified)"
+ ),
)
parser.add_argument(
"--type",
@@ -120,8 +125,10 @@ class CreateVolume(command.ShowOne):
source_group.add_argument(
"--backup",
metavar="<backup>",
- help=_("Restore backup to a volume (name or ID) "
- "(supported by --os-volume-api-version 3.47 or later)"),
+ help=_(
+ "Restore backup to a volume (name or ID) "
+ "(supported by --os-volume-api-version 3.47 or later)"
+ ),
)
source_group.add_argument(
"--source-replicated",
@@ -147,37 +154,41 @@ class CreateVolume(command.ShowOne):
"--property",
metavar="<key=value>",
action=parseractions.KeyValueAction,
- help=_("Set a property to this volume "
- "(repeat option to set multiple properties)"),
+ help=_(
+ "Set a property to this volume "
+ "(repeat option to set multiple properties)"
+ ),
)
parser.add_argument(
"--hint",
metavar="<key=value>",
action=parseractions.KeyValueAction,
- help=_("Arbitrary scheduler hint key-value pairs to help boot "
- "an instance (repeat option to set multiple hints)"),
+ help=_(
+ "Arbitrary scheduler hint key-value pairs to help boot "
+ "an instance (repeat option to set multiple hints)"
+ ),
)
bootable_group = parser.add_mutually_exclusive_group()
bootable_group.add_argument(
"--bootable",
action="store_true",
- help=_("Mark volume as bootable")
+ help=_("Mark volume as bootable"),
)
bootable_group.add_argument(
"--non-bootable",
action="store_true",
- help=_("Mark volume as non-bootable (default)")
+ help=_("Mark volume as non-bootable (default)"),
)
readonly_group = parser.add_mutually_exclusive_group()
readonly_group.add_argument(
"--read-only",
action="store_true",
- help=_("Set volume to read-only access mode")
+ help=_("Set volume to read-only access mode"),
)
readonly_group.add_argument(
"--read-write",
action="store_true",
- help=_("Set volume to read-write access mode (default)")
+ help=_("Set volume to read-write access mode (default)"),
)
return parser
@@ -193,35 +204,39 @@ class CreateVolume(command.ShowOne):
image_client = self.app.client_manager.image
if parsed_args.backup and not (
- volume_client.api_version.matches('3.47')):
- msg = _("--os-volume-api-version 3.47 or greater is required "
- "to create a volume from backup.")
+ volume_client.api_version.matches('3.47')
+ ):
+ msg = _(
+ "--os-volume-api-version 3.47 or greater is required "
+ "to create a volume from backup."
+ )
raise exceptions.CommandError(msg)
source_volume = None
if parsed_args.source:
source_volume_obj = utils.find_resource(
- volume_client.volumes,
- parsed_args.source)
+ volume_client.volumes, parsed_args.source
+ )
source_volume = source_volume_obj.id
size = max(size or 0, source_volume_obj.size)
consistency_group = None
if parsed_args.consistency_group:
consistency_group = utils.find_resource(
- volume_client.consistencygroups,
- parsed_args.consistency_group).id
+ volume_client.consistencygroups, parsed_args.consistency_group
+ ).id
image = None
if parsed_args.image:
- image = image_client.find_image(parsed_args.image,
- ignore_missing=False).id
+ image = image_client.find_image(
+ parsed_args.image, ignore_missing=False
+ ).id
snapshot = None
if parsed_args.snapshot:
snapshot_obj = utils.find_resource(
- volume_client.volume_snapshots,
- parsed_args.snapshot)
+ volume_client.volume_snapshots, parsed_args.snapshot
+ )
snapshot = snapshot_obj.id
# Cinder requires a value for size when creating a volume
# even if creating from a snapshot. Cinder will create the
@@ -234,8 +249,8 @@ class CreateVolume(command.ShowOne):
backup = None
if parsed_args.backup:
backup_obj = utils.find_resource(
- volume_client.backups,
- parsed_args.backup)
+ volume_client.backups, parsed_args.backup
+ )
backup = backup_obj.id
# As above
size = max(size or 0, backup_obj.size)
@@ -262,11 +277,10 @@ class CreateVolume(command.ShowOne):
volume.id,
success_status=['available'],
error_status=['error'],
- sleep_time=1
+ sleep_time=1,
):
volume_client.volumes.set_bootable(
- volume.id,
- parsed_args.bootable
+ volume.id, parsed_args.bootable
)
else:
msg = _(
@@ -283,11 +297,10 @@ class CreateVolume(command.ShowOne):
volume.id,
success_status=['available'],
error_status=['error'],
- sleep_time=1
+ sleep_time=1,
):
volume_client.volumes.update_readonly_flag(
- volume.id,
- parsed_args.read_only
+ volume.id, parsed_args.read_only
)
else:
msg = _(
@@ -296,15 +309,21 @@ class CreateVolume(command.ShowOne):
)
raise exceptions.CommandError(msg)
except Exception as e:
- LOG.error(_("Failed to set volume read-only access "
- "mode flag: %s"), e)
+ LOG.error(
+ _(
+ "Failed to set volume read-only access "
+ "mode flag: %s"
+ ),
+ e,
+ )
# Remove key links from being displayed
volume._info.update(
{
- 'properties':
- format_columns.DictColumn(volume._info.pop('metadata')),
- 'type': volume._info.pop('volume_type')
+ 'properties': format_columns.DictColumn(
+ volume._info.pop('metadata')
+ ),
+ 'type': volume._info.pop('volume_type'),
}
)
volume._info.pop("links", None)
@@ -320,20 +339,24 @@ class DeleteVolume(command.Command):
"volumes",
metavar="<volume>",
nargs="+",
- help=_("Volume(s) to delete (name or ID)")
+ help=_("Volume(s) to delete (name or ID)"),
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
"--force",
action="store_true",
- help=_("Attempt forced removal of volume(s), regardless of state "
- "(defaults to False)")
+ help=_(
+ "Attempt forced removal of volume(s), regardless of state "
+ "(defaults to False)"
+ ),
)
group.add_argument(
"--purge",
action="store_true",
- help=_("Remove any snapshots along with volume(s) "
- "(defaults to False)")
+ help=_(
+ "Remove any snapshots along with volume(s) "
+ "(defaults to False)"
+ ),
)
return parser
@@ -343,23 +366,29 @@ class DeleteVolume(command.Command):
for i in parsed_args.volumes:
try:
- volume_obj = utils.find_resource(
- volume_client.volumes, i)
+ volume_obj = utils.find_resource(volume_client.volumes, i)
if parsed_args.force:
volume_client.volumes.force_delete(volume_obj.id)
else:
- volume_client.volumes.delete(volume_obj.id,
- cascade=parsed_args.purge)
+ volume_client.volumes.delete(
+ volume_obj.id, cascade=parsed_args.purge
+ )
except Exception as e:
result += 1
- LOG.error(_("Failed to delete volume with "
- "name or ID '%(volume)s': %(e)s"),
- {'volume': i, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete volume with "
+ "name or ID '%(volume)s': %(e)s"
+ ),
+ {'volume': i, 'e': e},
+ )
if result > 0:
total = len(parsed_args.volumes)
- msg = (_("%(result)s of %(total)s volumes failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _("%(result)s of %(total)s volumes failed " "to delete.") % {
+ 'result': result,
+ 'total': total,
+ }
raise exceptions.CommandError(msg)
@@ -371,13 +400,13 @@ class ListVolume(command.Lister):
parser.add_argument(
'--project',
metavar='<project>',
- help=_('Filter results by project (name or ID) (admin only)')
+ help=_('Filter results by project (name or ID) (admin only)'),
)
identity_common.add_project_domain_option_to_parser(parser)
parser.add_argument(
'--user',
metavar='<user>',
- help=_('Filter results by user (name or ID) (admin only)')
+ help=_('Filter results by user (name or ID) (admin only)'),
)
identity_common.add_user_domain_option_to_parser(parser)
parser.add_argument(
@@ -417,7 +446,6 @@ class ListVolume(command.Lister):
return parser
def take_action(self, parsed_args):
-
volume_client = self.app.client_manager.volume
identity_client = self.app.client_manager.identity
@@ -457,20 +485,22 @@ class ListVolume(command.Lister):
# Just forget it if there's any trouble
pass
AttachmentsColumnWithCache = functools.partial(
- AttachmentsColumn, server_cache=server_cache)
+ AttachmentsColumn, server_cache=server_cache
+ )
project_id = None
if parsed_args.project:
project_id = identity_common.find_project(
identity_client,
parsed_args.project,
- parsed_args.project_domain).id
+ parsed_args.project_domain,
+ ).id
user_id = None
if parsed_args.user:
- user_id = identity_common.find_user(identity_client,
- parsed_args.user,
- parsed_args.user_domain).id
+ user_id = identity_common.find_user(
+ identity_client, parsed_args.user, parsed_args.user_domain
+ ).id
# set value of 'all_tenants' when using project option
all_projects = bool(parsed_args.project) or parsed_args.all_projects
@@ -489,14 +519,23 @@ class ListVolume(command.Lister):
limit=parsed_args.limit,
)
column_headers = utils.backward_compat_col_lister(
- column_headers, parsed_args.columns, {'Display Name': 'Name'})
+ column_headers, parsed_args.columns, {'Display Name': 'Name'}
+ )
- return (column_headers,
- (utils.get_item_properties(
- s, columns,
- formatters={'Metadata': format_columns.DictColumn,
- 'Attachments': AttachmentsColumnWithCache},
- ) for s in data))
+ return (
+ column_headers,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
+ formatters={
+ 'Metadata': format_columns.DictColumn,
+ 'Attachments': AttachmentsColumnWithCache,
+ },
+ )
+ for s in data
+ ),
+ )
class MigrateVolume(command.Command):
@@ -507,35 +546,44 @@ class MigrateVolume(command.Command):
parser.add_argument(
'volume',
metavar="<volume>",
- help=_("Volume to migrate (name or ID)")
+ help=_("Volume to migrate (name or ID)"),
)
parser.add_argument(
'--host',
metavar="<host>",
required=True,
- help=_("Destination host (takes the form: host@backend-name#pool)")
+ help=_(
+ "Destination host (takes the form: host@backend-name#pool)"
+ ),
)
parser.add_argument(
'--force-host-copy',
action="store_true",
- help=_("Enable generic host-based force-migration, "
- "which bypasses driver optimizations")
+ help=_(
+ "Enable generic host-based force-migration, "
+ "which bypasses driver optimizations"
+ ),
)
parser.add_argument(
'--lock-volume',
action="store_true",
- help=_("If specified, the volume state will be locked "
- "and will not allow a migration to be aborted "
- "(possibly by another operation)")
+ help=_(
+ "If specified, the volume state will be locked "
+ "and will not allow a migration to be aborted "
+ "(possibly by another operation)"
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
- volume_client.volumes.migrate_volume(volume.id, parsed_args.host,
- parsed_args.force_host_copy,
- parsed_args.lock_volume,)
+ volume_client.volumes.migrate_volume(
+ volume.id,
+ parsed_args.host,
+ parsed_args.force_host_copy,
+ parsed_args.lock_volume,
+ )
class SetVolume(command.Command):
@@ -568,56 +616,76 @@ class SetVolume(command.Command):
"--no-property",
dest="no_property",
action="store_true",
- help=_("Remove all properties from <volume> "
- "(specify both --no-property and --property to "
- "remove the current properties before setting "
- "new properties.)"),
+ help=_(
+ "Remove all properties from <volume> "
+ "(specify both --no-property and --property to "
+ "remove the current properties before setting "
+ "new properties.)"
+ ),
)
parser.add_argument(
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Set a property on this volume '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Set a property on this volume '
+ '(repeat option to set multiple properties)'
+ ),
)
parser.add_argument(
'--image-property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Set an image property on this volume '
- '(repeat option to set multiple image properties)'),
+ help=_(
+ 'Set an image property on this volume '
+ '(repeat option to set multiple image properties)'
+ ),
)
parser.add_argument(
"--state",
metavar="<state>",
- choices=['available', 'error', 'creating', 'deleting',
- 'in-use', 'attaching', 'detaching', 'error_deleting',
- 'maintenance'],
- help=_('New volume state ("available", "error", "creating", '
- '"deleting", "in-use", "attaching", "detaching", '
- '"error_deleting" or "maintenance") (admin only) '
- '(This option simply changes the state of the volume '
- 'in the database with no regard to actual status, '
- 'exercise caution when using)'),
+ choices=[
+ 'available',
+ 'error',
+ 'creating',
+ 'deleting',
+ 'in-use',
+ 'attaching',
+ 'detaching',
+ 'error_deleting',
+ 'maintenance',
+ ],
+ help=_(
+ 'New volume state ("available", "error", "creating", '
+ '"deleting", "in-use", "attaching", "detaching", '
+ '"error_deleting" or "maintenance") (admin only) '
+ '(This option simply changes the state of the volume '
+ 'in the database with no regard to actual status, '
+ 'exercise caution when using)'
+ ),
)
attached_group = parser.add_mutually_exclusive_group()
attached_group.add_argument(
"--attached",
action="store_true",
- help=_('Set volume attachment status to "attached" '
- '(admin only) '
- '(This option simply changes the state of the volume '
- 'in the database with no regard to actual status, '
- 'exercise caution when using)'),
+ help=_(
+ 'Set volume attachment status to "attached" '
+ '(admin only) '
+ '(This option simply changes the state of the volume '
+ 'in the database with no regard to actual status, '
+ 'exercise caution when using)'
+ ),
)
attached_group.add_argument(
"--detached",
action="store_true",
- help=_('Set volume attachment status to "detached" '
- '(admin only) '
- '(This option simply changes the state of the volume '
- 'in the database with no regard to actual status, '
- 'exercise caution when using)'),
+ help=_(
+ 'Set volume attachment status to "detached" '
+ '(admin only) '
+ '(This option simply changes the state of the volume '
+ 'in the database with no regard to actual status, '
+ 'exercise caution when using)'
+ ),
)
parser.add_argument(
'--type',
@@ -628,31 +696,33 @@ class SetVolume(command.Command):
'--retype-policy',
metavar='<retype-policy>',
choices=['never', 'on-demand'],
- help=_('Migration policy while re-typing volume '
- '("never" or "on-demand", default is "never" ) '
- '(available only when --type option is specified)'),
+ help=_(
+ 'Migration policy while re-typing volume '
+ '("never" or "on-demand", default is "never" ) '
+ '(available only when --type option is specified)'
+ ),
)
bootable_group = parser.add_mutually_exclusive_group()
bootable_group.add_argument(
"--bootable",
action="store_true",
- help=_("Mark volume as bootable")
+ help=_("Mark volume as bootable"),
)
bootable_group.add_argument(
"--non-bootable",
action="store_true",
- help=_("Mark volume as non-bootable")
+ help=_("Mark volume as non-bootable"),
)
readonly_group = parser.add_mutually_exclusive_group()
readonly_group.add_argument(
"--read-only",
action="store_true",
- help=_("Set volume to read-only access mode")
+ help=_("Set volume to read-only access mode"),
)
readonly_group.add_argument(
"--read-write",
action="store_true",
- help=_("Set volume to read-write access mode")
+ help=_("Set volume to read-write access mode"),
)
return parser
@@ -664,14 +734,21 @@ class SetVolume(command.Command):
if parsed_args.size:
try:
if parsed_args.size <= volume.size:
- msg = (_("New size must be greater than %s GB")
- % volume.size)
+ msg = (
+ _("New size must be greater than %s GB") % volume.size
+ )
raise exceptions.CommandError(msg)
- if volume.status != 'available' and \
- not volume_client.api_version.matches('3.42'):
-
- msg = (_("Volume is in %s state, it must be available "
- "before size can be extended") % volume.status)
+ if (
+ volume.status != 'available'
+ and not volume_client.api_version.matches('3.42')
+ ):
+ msg = (
+ _(
+ "Volume is in %s state, it must be available "
+ "before size can be extended"
+ )
+ % volume.status
+ )
raise exceptions.CommandError(msg)
volume_client.volumes.extend(volume.id, parsed_args.size)
except Exception as e:
@@ -681,7 +758,8 @@ class SetVolume(command.Command):
if parsed_args.no_property:
try:
volume_client.volumes.delete_metadata(
- volume.id, volume.metadata.keys())
+ volume.id, volume.metadata.keys()
+ )
except Exception as e:
LOG.error(_("Failed to clean volume properties: %s"), e)
result += 1
@@ -689,55 +767,62 @@ class SetVolume(command.Command):
if parsed_args.property:
try:
volume_client.volumes.set_metadata(
- volume.id, parsed_args.property)
+ volume.id, parsed_args.property
+ )
except Exception as e:
LOG.error(_("Failed to set volume property: %s"), e)
result += 1
if parsed_args.image_property:
try:
volume_client.volumes.set_image_metadata(
- volume.id, parsed_args.image_property)
+ volume.id, parsed_args.image_property
+ )
except Exception as e:
LOG.error(_("Failed to set image property: %s"), e)
result += 1
if parsed_args.state:
try:
- volume_client.volumes.reset_state(
- volume.id, parsed_args.state)
+ volume_client.volumes.reset_state(volume.id, parsed_args.state)
except Exception as e:
LOG.error(_("Failed to set volume state: %s"), e)
result += 1
if parsed_args.attached:
try:
volume_client.volumes.reset_state(
- volume.id, state=None,
- attach_status="attached")
+ volume.id, state=None, attach_status="attached"
+ )
except Exception as e:
LOG.error(_("Failed to set volume attach-status: %s"), e)
result += 1
if parsed_args.detached:
try:
volume_client.volumes.reset_state(
- volume.id, state=None,
- attach_status="detached")
+ volume.id, state=None, attach_status="detached"
+ )
except Exception as e:
LOG.error(_("Failed to set volume attach-status: %s"), e)
result += 1
if parsed_args.bootable or parsed_args.non_bootable:
try:
volume_client.volumes.set_bootable(
- volume.id, parsed_args.bootable)
+ volume.id, parsed_args.bootable
+ )
except Exception as e:
LOG.error(_("Failed to set volume bootable property: %s"), e)
result += 1
if parsed_args.read_only or parsed_args.read_write:
try:
volume_client.volumes.update_readonly_flag(
- volume.id,
- parsed_args.read_only)
+ volume.id, parsed_args.read_only
+ )
except Exception as e:
- LOG.error(_("Failed to set volume read-only access "
- "mode flag: %s"), e)
+ LOG.error(
+ _(
+ "Failed to set volume read-only access "
+ "mode flag: %s"
+ ),
+ e,
+ )
result += 1
if parsed_args.type:
# get the migration policy
@@ -747,20 +832,23 @@ class SetVolume(command.Command):
try:
# find the volume type
volume_type = utils.find_resource(
- volume_client.volume_types,
- parsed_args.type)
+ volume_client.volume_types, parsed_args.type
+ )
# reset to the new volume type
volume_client.volumes.retype(
- volume.id,
- volume_type.id,
- migration_policy)
+ volume.id, volume_type.id, migration_policy
+ )
except Exception as e:
LOG.error(_("Failed to set volume type: %s"), e)
result += 1
elif parsed_args.retype_policy:
# If the "--retype-policy" is specified without "--type"
- LOG.warning(_("'--retype-policy' option will not work "
- "without '--type' option"))
+ LOG.warning(
+ _(
+ "'--retype-policy' option will not work "
+ "without '--type' option"
+ )
+ )
kwargs = {}
if parsed_args.name:
@@ -771,13 +859,19 @@ class SetVolume(command.Command):
try:
volume_client.volumes.update(volume.id, **kwargs)
except Exception as e:
- LOG.error(_("Failed to update volume display name "
- "or display description: %s"), e)
+ LOG.error(
+ _(
+ "Failed to update volume display name "
+ "or display description: %s"
+ ),
+ e,
+ )
result += 1
if result > 0:
- raise exceptions.CommandError(_("One or more of the "
- "set operations failed"))
+ raise exceptions.CommandError(
+ _("One or more of the " "set operations failed")
+ )
class ShowVolume(command.ShowOne):
@@ -788,7 +882,7 @@ class ShowVolume(command.ShowOne):
parser.add_argument(
'volume',
metavar="<volume>",
- help=_("Volume to display (name or ID)")
+ help=_("Volume to display (name or ID)"),
)
return parser
@@ -801,8 +895,9 @@ class ShowVolume(command.ShowOne):
# 'volume_type' --> 'type'
volume._info.update(
{
- 'properties':
- format_columns.DictColumn(volume._info.pop('metadata')),
+ 'properties': format_columns.DictColumn(
+ volume._info.pop('metadata')
+ ),
'type': volume._info.pop('volume_type'),
},
)
@@ -826,28 +921,32 @@ class UnsetVolume(command.Command):
'--property',
metavar='<key>',
action='append',
- help=_('Remove a property from volume '
- '(repeat option to remove multiple properties)'),
+ help=_(
+ 'Remove a property from volume '
+ '(repeat option to remove multiple properties)'
+ ),
)
parser.add_argument(
'--image-property',
metavar='<key>',
action='append',
- help=_('Remove an image property from volume '
- '(repeat option to remove multiple image properties)'),
+ help=_(
+ 'Remove an image property from volume '
+ '(repeat option to remove multiple image properties)'
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- volume = utils.find_resource(
- volume_client.volumes, parsed_args.volume)
+ volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
result = 0
if parsed_args.property:
try:
volume_client.volumes.delete_metadata(
- volume.id, parsed_args.property)
+ volume.id, parsed_args.property
+ )
except Exception as e:
LOG.error(_("Failed to unset volume property: %s"), e)
result += 1
@@ -855,11 +954,13 @@ class UnsetVolume(command.Command):
if parsed_args.image_property:
try:
volume_client.volumes.delete_image_metadata(
- volume.id, parsed_args.image_property)
+ volume.id, parsed_args.image_property
+ )
except Exception as e:
LOG.error(_("Failed to unset image property: %s"), e)
result += 1
if result > 0:
- raise exceptions.CommandError(_("One or more of the "
- "unset operations failed"))
+ raise exceptions.CommandError(
+ _("One or more of the " "unset operations failed")
+ )
diff --git a/openstackclient/volume/v2/volume_backend.py b/openstackclient/volume/v2/volume_backend.py
index c5194d35..5e9eaf48 100644
--- a/openstackclient/volume/v2/volume_backend.py
+++ b/openstackclient/volume/v2/volume_backend.py
@@ -28,7 +28,7 @@ class ShowCapability(command.Lister):
parser.add_argument(
"host",
metavar="<host>",
- help=_("List capabilities of specified host (host@backend-name)")
+ help=_("List capabilities of specified host (host@backend-name)"),
)
return parser
@@ -55,10 +55,16 @@ class ShowCapability(command.Lister):
capability_data['key'] = key
print_data.append(capability_data)
- return (columns,
- (utils.get_dict_properties(
- s, columns,
- ) for s in print_data))
+ return (
+ columns,
+ (
+ utils.get_dict_properties(
+ s,
+ columns,
+ )
+ for s in print_data
+ ),
+ )
class ListPool(command.Lister):
@@ -70,7 +76,7 @@ class ListPool(command.Lister):
"--long",
action="store_true",
default=False,
- help=_("Show detailed information about pools.")
+ help=_("Show detailed information about pools."),
)
# TODO(smcginnis): Starting with Cinder microversion 3.33, user is also
# able to pass in --filters with a <key>=<value> pair to filter on.
@@ -98,7 +104,7 @@ class ListPool(command.Lister):
'Volumes',
'Capacity',
'Allocated',
- 'Max Over Ratio'
+ 'Max Over Ratio',
]
else:
columns = [
@@ -107,7 +113,13 @@ class ListPool(command.Lister):
headers = columns
data = volume_client.pools.list(detailed=parsed_args.long)
- return (headers,
- (utils.get_item_properties(
- s, columns,
- ) for s in data))
+ return (
+ headers,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
+ )
+ for s in data
+ ),
+ )
diff --git a/openstackclient/volume/v2/volume_backup.py b/openstackclient/volume/v2/volume_backup.py
index d96b28e9..7040216a 100644
--- a/openstackclient/volume/v2/volume_backup.py
+++ b/openstackclient/volume/v2/volume_backup.py
@@ -66,44 +66,42 @@ class CreateVolumeBackup(command.ShowOne):
parser.add_argument(
"volume",
metavar="<volume>",
- help=_("Volume to backup (name or ID)")
+ help=_("Volume to backup (name or ID)"),
)
parser.add_argument(
- "--name",
- metavar="<name>",
- help=_("Name of the backup")
+ "--name", metavar="<name>", help=_("Name of the backup")
)
parser.add_argument(
"--description",
metavar="<description>",
- help=_("Description of the backup")
+ help=_("Description of the backup"),
)
parser.add_argument(
"--container",
metavar="<container>",
- help=_("Optional backup container name")
+ help=_("Optional backup container name"),
)
parser.add_argument(
"--snapshot",
metavar="<snapshot>",
- help=_("Snapshot to backup (name or ID)")
+ help=_("Snapshot to backup (name or ID)"),
)
parser.add_argument(
'--force',
action='store_true',
default=False,
- help=_("Allow to back up an in-use volume")
+ help=_("Allow to back up an in-use volume"),
)
parser.add_argument(
'--incremental',
action='store_true',
default=False,
- help=_("Perform an incremental backup")
+ help=_("Perform an incremental backup"),
)
parser.add_argument(
'--no-incremental',
action='store_false',
- help=_("Do not perform an incremental backup")
+ help=_("Do not perform an incremental backup"),
)
parser.add_argument(
'--property',
@@ -131,14 +129,16 @@ class CreateVolumeBackup(command.ShowOne):
volume_client = self.app.client_manager.volume
volume_id = utils.find_resource(
- volume_client.volumes, parsed_args.volume,
+ volume_client.volumes,
+ parsed_args.volume,
).id
kwargs = {}
if parsed_args.snapshot:
kwargs['snapshot_id'] = utils.find_resource(
- volume_client.volume_snapshots, parsed_args.snapshot,
+ volume_client.volume_snapshots,
+ parsed_args.snapshot,
).id
if parsed_args.properties:
@@ -183,13 +183,13 @@ class DeleteVolumeBackup(command.Command):
"backups",
metavar="<backup>",
nargs="+",
- help=_("Backup(s) to delete (name or ID)")
+ help=_("Backup(s) to delete (name or ID)"),
)
parser.add_argument(
'--force',
action='store_true',
default=False,
- help=_("Allow delete in state other than error or available")
+ help=_("Allow delete in state other than error or available"),
)
return parser
@@ -200,19 +200,25 @@ class DeleteVolumeBackup(command.Command):
for i in parsed_args.backups:
try:
backup_id = utils.find_resource(
- volume_client.backups, i,
+ volume_client.backups,
+ i,
).id
volume_client.backups.delete(backup_id, parsed_args.force)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete backup with "
- "name or ID '%(backup)s': %(e)s")
- % {'backup': i, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete backup with "
+ "name or ID '%(backup)s': %(e)s"
+ )
+ % {'backup': i, 'e': e}
+ )
if result > 0:
total = len(parsed_args.backups)
msg = _("%(result)s of %(total)s backups failed to delete.") % {
- 'result': result, 'total': total,
+ 'result': result,
+ 'total': total,
}
raise exceptions.CommandError(msg)
@@ -226,19 +232,23 @@ class ListVolumeBackup(command.Lister):
"--long",
action="store_true",
default=False,
- help=_("List additional fields in output")
+ help=_("List additional fields in output"),
)
parser.add_argument(
"--name",
metavar="<name>",
- help=_("Filters results by the backup name")
+ help=_("Filters results by the backup name"),
)
parser.add_argument(
"--status",
metavar="<status>",
choices=[
- 'creating', 'available', 'deleting',
- 'error', 'restoring', 'error_restoring',
+ 'creating',
+ 'available',
+ 'deleting',
+ 'error',
+ 'restoring',
+ 'error_restoring',
],
help=_(
"Filters results by the backup status, one of: "
@@ -306,26 +316,31 @@ class ListVolumeBackup(command.Lister):
pass
_VolumeIdColumn = functools.partial(
- VolumeIdColumn, volume_cache=volume_cache)
+ VolumeIdColumn, volume_cache=volume_cache
+ )
filter_volume_id = None
if parsed_args.volume:
try:
filter_volume_id = utils.find_resource(
- volume_client.volumes, parsed_args.volume,
+ volume_client.volumes,
+ parsed_args.volume,
).id
except exceptions.CommandError:
# Volume with that ID does not exist, but search for backups
# for that volume nevertheless
- LOG.debug("No volume with ID %s existing, continuing to "
- "search for backups for that volume ID",
- parsed_args.volume)
+ LOG.debug(
+ "No volume with ID %s existing, continuing to "
+ "search for backups for that volume ID",
+ parsed_args.volume,
+ )
filter_volume_id = parsed_args.volume
marker_backup_id = None
if parsed_args.marker:
marker_backup_id = utils.find_resource(
- volume_client.backups, parsed_args.marker,
+ volume_client.backups,
+ parsed_args.marker,
).id
search_opts = {
@@ -344,8 +359,11 @@ class ListVolumeBackup(command.Lister):
column_headers,
(
utils.get_item_properties(
- s, columns, formatters={'volume_id': _VolumeIdColumn},
- ) for s in data
+ s,
+ columns,
+ formatters={'volume_id': _VolumeIdColumn},
+ )
+ for s in data
),
)
@@ -358,7 +376,7 @@ class RestoreVolumeBackup(command.ShowOne):
parser.add_argument(
"backup",
metavar="<backup>",
- help=_("Backup to restore (name or ID)")
+ help=_("Backup to restore (name or ID)"),
)
parser.add_argument(
"volume",
@@ -368,7 +386,7 @@ class RestoreVolumeBackup(command.ShowOne):
"Volume to restore to "
"(name or ID for existing volume, name only for new volume) "
"(default to None)"
- )
+ ),
)
parser.add_argument(
"--force",
@@ -376,7 +394,7 @@ class RestoreVolumeBackup(command.ShowOne):
help=_(
"Restore the backup to an existing volume "
"(default to False)"
- )
+ ),
)
return parser
@@ -401,11 +419,13 @@ class RestoreVolumeBackup(command.ShowOne):
msg = _(
"Volume '%s' already exists; if you want to restore the "
"backup to it you need to specify the '--force' option"
- ) % parsed_args.volume
- raise exceptions.CommandError(msg)
+ )
+ raise exceptions.CommandError(msg % parsed_args.volume)
return volume_client.restores.restore(
- backup.id, volume_id, volume_name,
+ backup.id,
+ volume_id,
+ volume_name,
)
@@ -417,7 +437,7 @@ class SetVolumeBackup(command.Command):
parser.add_argument(
"backup",
metavar="<backup>",
- help=_("Backup to modify (name or ID)")
+ help=_("Backup to modify (name or ID)"),
)
parser.add_argument(
'--name',
@@ -471,14 +491,12 @@ class SetVolumeBackup(command.Command):
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- backup = utils.find_resource(
- volume_client.backups, parsed_args.backup)
+ backup = utils.find_resource(volume_client.backups, parsed_args.backup)
result = 0
if parsed_args.state:
try:
- volume_client.backups.reset_state(
- backup.id, parsed_args.state)
+ volume_client.backups.reset_state(backup.id, parsed_args.state)
except Exception as e:
LOG.error(_("Failed to set backup state: %s"), e)
result += 1
@@ -553,7 +571,7 @@ class UnsetVolumeBackup(command.Command):
parser.add_argument(
'backup',
metavar='<backup>',
- help=_('Backup to modify (name or ID)')
+ help=_('Backup to modify (name or ID)'),
)
parser.add_argument(
'--property',
@@ -577,8 +595,7 @@ class UnsetVolumeBackup(command.Command):
)
raise exceptions.CommandError(msg)
- backup = utils.find_resource(
- volume_client.backups, parsed_args.backup)
+ backup = utils.find_resource(volume_client.backups, parsed_args.backup)
metadata = copy.deepcopy(backup.metadata)
for key in parsed_args.properties:
@@ -586,7 +603,8 @@ class UnsetVolumeBackup(command.Command):
# ignore invalid properties but continue
LOG.warning(
"'%s' is not a valid property for backup '%s'",
- key, parsed_args.backup,
+ key,
+ parsed_args.backup,
)
continue
@@ -607,13 +625,12 @@ class ShowVolumeBackup(command.ShowOne):
parser.add_argument(
"backup",
metavar="<backup>",
- help=_("Backup to display (name or ID)")
+ help=_("Backup to display (name or ID)"),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- backup = utils.find_resource(volume_client.backups,
- parsed_args.backup)
+ backup = utils.find_resource(volume_client.backups, parsed_args.backup)
backup._info.pop("links", None)
return zip(*sorted(backup._info.items()))
diff --git a/openstackclient/volume/v2/volume_host.py b/openstackclient/volume/v2/volume_host.py
index 2fdeb968..df93c059 100644
--- a/openstackclient/volume/v2/volume_host.py
+++ b/openstackclient/volume/v2/volume_host.py
@@ -25,23 +25,24 @@ class FailoverVolumeHost(command.Command):
def get_parser(self, prog_name):
parser = super(FailoverVolumeHost, self).get_parser(prog_name)
parser.add_argument(
- "host",
- metavar="<host-name>",
- help=_("Name of volume host")
+ "host", metavar="<host-name>", help=_("Name of volume host")
)
parser.add_argument(
"--volume-backend",
metavar="<backend-id>",
required=True,
- help=_("The ID of the volume backend replication "
- "target where the host will failover to (required)")
+ help=_(
+ "The ID of the volume backend replication "
+ "target where the host will failover to (required)"
+ ),
)
return parser
def take_action(self, parsed_args):
service_client = self.app.client_manager.volume
- service_client.services.failover_host(parsed_args.host,
- parsed_args.volume_backend)
+ service_client.services.failover_host(
+ parsed_args.host, parsed_args.volume_backend
+ )
class SetVolumeHost(command.Command):
@@ -50,20 +51,18 @@ class SetVolumeHost(command.Command):
def get_parser(self, prog_name):
parser = super(SetVolumeHost, self).get_parser(prog_name)
parser.add_argument(
- "host",
- metavar="<host-name>",
- help=_("Name of volume host")
+ "host", metavar="<host-name>", help=_("Name of volume host")
)
enabled_group = parser.add_mutually_exclusive_group()
enabled_group.add_argument(
"--disable",
action="store_true",
- help=_("Freeze and disable the specified volume host")
+ help=_("Freeze and disable the specified volume host"),
)
enabled_group.add_argument(
"--enable",
action="store_true",
- help=_("Thaw and enable the specified volume host")
+ help=_("Thaw and enable the specified volume host"),
)
return parser
diff --git a/openstackclient/volume/v2/volume_snapshot.py b/openstackclient/volume/v2/volume_snapshot.py
index 53d8d27f..376c2b5e 100644
--- a/openstackclient/volume/v2/volume_snapshot.py
+++ b/openstackclient/volume/v2/volume_snapshot.py
@@ -72,36 +72,44 @@ class CreateVolumeSnapshot(command.ShowOne):
parser.add_argument(
"--volume",
metavar="<volume>",
- help=_("Volume to snapshot (name or ID) "
- "(default is <snapshot-name>)")
+ help=_(
+ "Volume to snapshot (name or ID) "
+ "(default is <snapshot-name>)"
+ ),
)
parser.add_argument(
"--description",
metavar="<description>",
- help=_("Description of the snapshot")
+ help=_("Description of the snapshot"),
)
parser.add_argument(
"--force",
action="store_true",
default=False,
- help=_("Create a snapshot attached to an instance. "
- "Default is False")
+ help=_(
+ "Create a snapshot attached to an instance. "
+ "Default is False"
+ ),
)
parser.add_argument(
"--property",
metavar="<key=value>",
action=parseractions.KeyValueAction,
- help=_("Set a property to this snapshot "
- "(repeat option to set multiple properties)"),
+ help=_(
+ "Set a property to this snapshot "
+ "(repeat option to set multiple properties)"
+ ),
)
parser.add_argument(
"--remote-source",
metavar="<key=value>",
action=parseractions.KeyValueAction,
- help=_("The attribute(s) of the existing remote volume snapshot "
- "(admin required) (repeat option to specify multiple "
- "attributes) e.g.: '--remote-source source-name=test_name "
- "--remote-source source-id=test_id'"),
+ help=_(
+ "The attribute(s) of the existing remote volume snapshot "
+ "(admin required) (repeat option to specify multiple "
+ "attributes) e.g.: '--remote-source source-name=test_name "
+ "--remote-source source-id=test_id'"
+ ),
)
return parser
@@ -110,14 +118,15 @@ class CreateVolumeSnapshot(command.ShowOne):
volume = parsed_args.volume
if not parsed_args.volume:
volume = parsed_args.snapshot_name
- volume_id = utils.find_resource(
- volume_client.volumes, volume).id
+ volume_id = utils.find_resource(volume_client.volumes, volume).id
if parsed_args.remote_source:
# Create a new snapshot from an existing remote snapshot source
if parsed_args.force:
- msg = (_("'--force' option will not work when you create "
- "new volume snapshot from an existing remote "
- "volume snapshot"))
+ msg = _(
+ "'--force' option will not work when you create "
+ "new volume snapshot from an existing remote "
+ "volume snapshot"
+ )
LOG.warning(msg)
snapshot = volume_client.volume_snapshots.manage(
volume_id=volume_id,
@@ -136,8 +145,11 @@ class CreateVolumeSnapshot(command.ShowOne):
metadata=parsed_args.property,
)
snapshot._info.update(
- {'properties':
- format_columns.DictColumn(snapshot._info.pop('metadata'))}
+ {
+ 'properties': format_columns.DictColumn(
+ snapshot._info.pop('metadata')
+ )
+ }
)
return zip(*sorted(snapshot._info.items()))
@@ -151,13 +163,15 @@ class DeleteVolumeSnapshot(command.Command):
"snapshots",
metavar="<snapshot>",
nargs="+",
- help=_("Snapshot(s) to delete (name or ID)")
+ help=_("Snapshot(s) to delete (name or ID)"),
)
parser.add_argument(
'--force',
action='store_true',
- help=_("Attempt forced removal of snapshot(s), "
- "regardless of state (defaults to False)")
+ help=_(
+ "Attempt forced removal of snapshot(s), "
+ "regardless of state (defaults to False)"
+ ),
)
return parser
@@ -168,19 +182,26 @@ class DeleteVolumeSnapshot(command.Command):
for i in parsed_args.snapshots:
try:
snapshot_id = utils.find_resource(
- volume_client.volume_snapshots, i).id
+ volume_client.volume_snapshots, i
+ ).id
volume_client.volume_snapshots.delete(
- snapshot_id, parsed_args.force)
+ snapshot_id, parsed_args.force
+ )
except Exception as e:
result += 1
- LOG.error(_("Failed to delete snapshot with "
- "name or ID '%(snapshot)s': %(e)s")
- % {'snapshot': i, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete snapshot with "
+ "name or ID '%(snapshot)s': %(e)s"
+ )
+ % {'snapshot': i, 'e': e}
+ )
if result > 0:
total = len(parsed_args.snapshots)
- msg = (_("%(result)s of %(total)s snapshots failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s snapshots failed " "to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -198,7 +219,7 @@ class ListVolumeSnapshot(command.Lister):
parser.add_argument(
'--project',
metavar='<project>',
- help=_('Filter results by project (name or ID) (admin only)')
+ help=_('Filter results by project (name or ID) (admin only)'),
)
identity_common.add_project_domain_option_to_parser(parser)
parser.add_argument(
@@ -223,22 +244,29 @@ class ListVolumeSnapshot(command.Lister):
'--name',
metavar='<name>',
default=None,
- help=_('Filters results by a name.')
+ help=_('Filters results by a name.'),
)
parser.add_argument(
'--status',
metavar='<status>',
- choices=['available', 'error', 'creating', 'deleting',
- 'error_deleting'],
- help=_("Filters results by a status. "
- "('available', 'error', 'creating', 'deleting'"
- " or 'error_deleting')")
+ choices=[
+ 'available',
+ 'error',
+ 'creating',
+ 'deleting',
+ 'error_deleting',
+ ],
+ help=_(
+ "Filters results by a status. "
+ "('available', 'error', 'creating', 'deleting'"
+ " or 'error_deleting')"
+ ),
)
parser.add_argument(
'--volume',
metavar='<volume>',
default=None,
- help=_('Filters results by a volume (name or ID).')
+ help=_('Filters results by a volume (name or ID).'),
)
return parser
@@ -247,8 +275,16 @@ class ListVolumeSnapshot(command.Lister):
identity_client = self.app.client_manager.identity
if parsed_args.long:
- columns = ['ID', 'Name', 'Description', 'Status',
- 'Size', 'Created At', 'Volume ID', 'Metadata']
+ columns = [
+ 'ID',
+ 'Name',
+ 'Description',
+ 'Status',
+ 'Size',
+ 'Created At',
+ 'Volume ID',
+ 'Metadata',
+ ]
column_headers = copy.deepcopy(columns)
column_headers[6] = 'Volume'
column_headers[7] = 'Properties'
@@ -264,24 +300,28 @@ class ListVolumeSnapshot(command.Lister):
except Exception:
# Just forget it if there's any trouble
pass
- _VolumeIdColumn = functools.partial(VolumeIdColumn,
- volume_cache=volume_cache)
+ _VolumeIdColumn = functools.partial(
+ VolumeIdColumn, volume_cache=volume_cache
+ )
volume_id = None
if parsed_args.volume:
volume_id = utils.find_resource(
- volume_client.volumes, parsed_args.volume).id
+ volume_client.volumes, parsed_args.volume
+ ).id
project_id = None
if parsed_args.project:
project_id = identity_common.find_project(
identity_client,
parsed_args.project,
- parsed_args.project_domain).id
+ parsed_args.project_domain,
+ ).id
# set value of 'all_tenants' when using project option
- all_projects = True if parsed_args.project else \
- parsed_args.all_projects
+ all_projects = (
+ True if parsed_args.project else parsed_args.all_projects
+ )
search_opts = {
'all_tenants': all_projects,
@@ -296,12 +336,20 @@ class ListVolumeSnapshot(command.Lister):
marker=parsed_args.marker,
limit=parsed_args.limit,
)
- return (column_headers,
- (utils.get_item_properties(
- s, columns,
- formatters={'Metadata': format_columns.DictColumn,
- 'Volume ID': _VolumeIdColumn},
- ) for s in data))
+ return (
+ column_headers,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
+ formatters={
+ 'Metadata': format_columns.DictColumn,
+ 'Volume ID': _VolumeIdColumn,
+ },
+ )
+ for s in data
+ ),
+ )
class SetVolumeSnapshot(command.Command):
@@ -312,51 +360,61 @@ class SetVolumeSnapshot(command.Command):
parser.add_argument(
'snapshot',
metavar='<snapshot>',
- help=_('Snapshot to modify (name or ID)')
+ help=_('Snapshot to modify (name or ID)'),
)
parser.add_argument(
- '--name',
- metavar='<name>',
- help=_('New snapshot name')
+ '--name', metavar='<name>', help=_('New snapshot name')
)
parser.add_argument(
'--description',
metavar='<description>',
- help=_('New snapshot description')
+ help=_('New snapshot description'),
)
parser.add_argument(
"--no-property",
dest="no_property",
action="store_true",
- help=_("Remove all properties from <snapshot> "
- "(specify both --no-property and --property to "
- "remove the current properties before setting "
- "new properties.)"),
+ help=_(
+ "Remove all properties from <snapshot> "
+ "(specify both --no-property and --property to "
+ "remove the current properties before setting "
+ "new properties.)"
+ ),
)
parser.add_argument(
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Property to add/change for this snapshot '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Property to add/change for this snapshot '
+ '(repeat option to set multiple properties)'
+ ),
)
parser.add_argument(
'--state',
metavar='<state>',
- choices=['available', 'error', 'creating', 'deleting',
- 'error_deleting'],
- help=_('New snapshot state. ("available", "error", "creating", '
- '"deleting", or "error_deleting") (admin only) '
- '(This option simply changes the state of the snapshot '
- 'in the database with no regard to actual status, '
- 'exercise caution when using)'),
+ choices=[
+ 'available',
+ 'error',
+ 'creating',
+ 'deleting',
+ 'error_deleting',
+ ],
+ help=_(
+ 'New snapshot state. ("available", "error", "creating", '
+ '"deleting", or "error_deleting") (admin only) '
+ '(This option simply changes the state of the snapshot '
+ 'in the database with no regard to actual status, '
+ 'exercise caution when using)'
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
- snapshot = utils.find_resource(volume_client.volume_snapshots,
- parsed_args.snapshot)
+ snapshot = utils.find_resource(
+ volume_client.volume_snapshots, parsed_args.snapshot
+ )
result = 0
if parsed_args.no_property:
@@ -373,7 +431,8 @@ class SetVolumeSnapshot(command.Command):
if parsed_args.property:
try:
volume_client.volume_snapshots.set_metadata(
- snapshot.id, parsed_args.property)
+ snapshot.id, parsed_args.property
+ )
except Exception as e:
LOG.error(_("Failed to set snapshot property: %s"), e)
result += 1
@@ -381,7 +440,8 @@ class SetVolumeSnapshot(command.Command):
if parsed_args.state:
try:
volume_client.volume_snapshots.reset_state(
- snapshot.id, parsed_args.state)
+ snapshot.id, parsed_args.state
+ )
except Exception as e:
LOG.error(_("Failed to set snapshot state: %s"), e)
result += 1
@@ -393,16 +453,18 @@ class SetVolumeSnapshot(command.Command):
kwargs['description'] = parsed_args.description
if kwargs:
try:
- volume_client.volume_snapshots.update(
- snapshot.id, **kwargs)
+ volume_client.volume_snapshots.update(snapshot.id, **kwargs)
except Exception as e:
- LOG.error(_("Failed to update snapshot name "
- "or description: %s"), e)
+ LOG.error(
+ _("Failed to update snapshot name " "or description: %s"),
+ e,
+ )
result += 1
if result > 0:
- raise exceptions.CommandError(_("One or more of the "
- "set operations failed"))
+ raise exceptions.CommandError(
+ _("One or more of the " "set operations failed")
+ )
class ShowVolumeSnapshot(command.ShowOne):
@@ -413,17 +475,21 @@ class ShowVolumeSnapshot(command.ShowOne):
parser.add_argument(
"snapshot",
metavar="<snapshot>",
- help=_("Snapshot to display (name or ID)")
+ help=_("Snapshot to display (name or ID)"),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
snapshot = utils.find_resource(
- volume_client.volume_snapshots, parsed_args.snapshot)
+ volume_client.volume_snapshots, parsed_args.snapshot
+ )
snapshot._info.update(
- {'properties':
- format_columns.DictColumn(snapshot._info.pop('metadata'))}
+ {
+ 'properties': format_columns.DictColumn(
+ snapshot._info.pop('metadata')
+ )
+ }
)
return zip(*sorted(snapshot._info.items()))
@@ -443,15 +509,18 @@ class UnsetVolumeSnapshot(command.Command):
metavar='<key>',
action='append',
default=[],
- help=_('Property to remove from snapshot '
- '(repeat option to remove multiple properties)'),
+ help=_(
+ 'Property to remove from snapshot '
+ '(repeat option to remove multiple properties)'
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
snapshot = utils.find_resource(
- volume_client.volume_snapshots, parsed_args.snapshot)
+ volume_client.volume_snapshots, parsed_args.snapshot
+ )
if parsed_args.property:
volume_client.volume_snapshots.delete_metadata(
diff --git a/openstackclient/volume/v2/volume_transfer_request.py b/openstackclient/volume/v2/volume_transfer_request.py
index 89199336..e25770e3 100644
--- a/openstackclient/volume/v2/volume_transfer_request.py
+++ b/openstackclient/volume/v2/volume_transfer_request.py
@@ -50,8 +50,7 @@ class AcceptTransferRequest(command.ShowOne):
try:
transfer_request_id = utils.find_resource(
- volume_client.transfers,
- parsed_args.transfer_request
+ volume_client.transfers, parsed_args.transfer_request
).id
except exceptions.CommandError:
# Non-admin users will fail to lookup name -> ID so we just
@@ -160,14 +159,20 @@ class DeleteTransferRequest(command.Command):
volume_client.transfers.delete(transfer_request_id)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete volume transfer request "
- "with name or ID '%(transfer)s': %(e)s")
- % {'transfer': t, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete volume transfer request "
+ "with name or ID '%(transfer)s': %(e)s"
+ )
+ % {'transfer': t, 'e': e}
+ )
if result > 0:
total = len(parsed_args.transfer_request)
- msg = (_("%(result)s of %(total)s volume transfer requests failed"
- " to delete") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s volume transfer requests failed"
+ " to delete"
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -196,9 +201,13 @@ class ListTransferRequest(command.Lister):
search_opts={'all_tenants': parsed_args.all_projects},
)
- return (column_headers, (
- utils.get_item_properties(s, columns)
- for s in volume_transfer_result))
+ return (
+ column_headers,
+ (
+ utils.get_item_properties(s, columns)
+ for s in volume_transfer_result
+ ),
+ )
class ShowTransferRequest(command.ShowOne):
diff --git a/openstackclient/volume/v2/volume_type.py b/openstackclient/volume/v2/volume_type.py
index 483e6dd3..b6813003 100644
--- a/openstackclient/volume/v2/volume_type.py
+++ b/openstackclient/volume/v2/volume_type.py
@@ -63,8 +63,10 @@ class EncryptionInfoColumn(cliff_columns.FormattableColumn):
def _create_encryption_type(volume_client, volume_type, parsed_args):
if not parsed_args.encryption_provider:
- msg = _("'--encryption-provider' should be specified while "
- "creating a new encryption type")
+ msg = _(
+ "'--encryption-provider' should be specified while "
+ "creating a new encryption type"
+ )
raise exceptions.CommandError(msg)
# set the default of control location while creating
control_location = 'front-end'
@@ -74,10 +76,11 @@ def _create_encryption_type(volume_client, volume_type, parsed_args):
'provider': parsed_args.encryption_provider,
'cipher': parsed_args.encryption_cipher,
'key_size': parsed_args.encryption_key_size,
- 'control_location': control_location
+ 'control_location': control_location,
}
encryption = volume_client.volume_encryption_types.create(
- volume_type, body)
+ volume_type, body
+ )
return encryption
@@ -93,10 +96,13 @@ def _set_encryption_type(volume_client, volume_type, parsed_args):
except Exception as e:
if type(e).__name__ == 'NotFound':
# create new encryption type
- LOG.warning(_("No existing encryption type found, creating "
- "new encryption type for this volume type ..."))
- _create_encryption_type(
- volume_client, volume_type, parsed_args)
+ LOG.warning(
+ _(
+ "No existing encryption type found, creating "
+ "new encryption type for this volume type ..."
+ )
+ )
+ _create_encryption_type(volume_client, volume_type, parsed_args)
class CreateVolumeType(command.ShowOne):
@@ -131,50 +137,62 @@ class CreateVolumeType(command.ShowOne):
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Set a property on this volume type '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Set a property on this volume type '
+ '(repeat option to set multiple properties)'
+ ),
)
parser.add_argument(
'--project',
metavar='<project>',
- help=_("Allow <project> to access private type (name or ID) "
- "(Must be used with --private option)"),
+ help=_(
+ "Allow <project> to access private type (name or ID) "
+ "(Must be used with --private option)"
+ ),
)
# TODO(Huanxuan Ao): Add choices for each "--encryption-*" option.
parser.add_argument(
'--encryption-provider',
metavar='<provider>',
- help=_('Set the encryption provider format for '
- 'this volume type (e.g "luks" or "plain") (admin only) '
- '(This option is required when setting encryption type '
- 'of a volume. Consider using other encryption options '
- 'such as: "--encryption-cipher", "--encryption-key-size" '
- 'and "--encryption-control-location")'),
+ help=_(
+ 'Set the encryption provider format for '
+ 'this volume type (e.g "luks" or "plain") (admin only) '
+ '(This option is required when setting encryption type '
+ 'of a volume. Consider using other encryption options '
+ 'such as: "--encryption-cipher", "--encryption-key-size" '
+ 'and "--encryption-control-location")'
+ ),
)
parser.add_argument(
'--encryption-cipher',
metavar='<cipher>',
- help=_('Set the encryption algorithm or mode for this '
- 'volume type (e.g "aes-xts-plain64") (admin only)'),
+ help=_(
+ 'Set the encryption algorithm or mode for this '
+ 'volume type (e.g "aes-xts-plain64") (admin only)'
+ ),
)
parser.add_argument(
'--encryption-key-size',
metavar='<key-size>',
type=int,
- help=_('Set the size of the encryption key of this '
- 'volume type (e.g "128" or "256") (admin only)'),
+ help=_(
+ 'Set the size of the encryption key of this '
+ 'volume type (e.g "128" or "256") (admin only)'
+ ),
)
parser.add_argument(
'--encryption-control-location',
metavar='<control-location>',
choices=['front-end', 'back-end'],
- help=_('Set the notional service where the encryption is '
- 'performed ("front-end" or "back-end") (admin only) '
- '(The default value for this option is "front-end" '
- 'when setting encryption type of a volume. Consider '
- 'using other encryption options such as: '
- '"--encryption-cipher", "--encryption-key-size" and '
- '"--encryption-provider")'),
+ help=_(
+ 'Set the notional service where the encryption is '
+ 'performed ("front-end" or "back-end") (admin only) '
+ '(The default value for this option is "front-end" '
+ 'when setting encryption type of a volume. Consider '
+ 'using other encryption options such as: '
+ '"--encryption-cipher", "--encryption-key-size" and '
+ '"--encryption-provider")'
+ ),
)
identity_common.add_project_domain_option_to_parser(parser)
return parser
@@ -194,9 +212,7 @@ class CreateVolumeType(command.ShowOne):
kwargs['is_public'] = False
volume_type = volume_client.volume_types.create(
- parsed_args.name,
- description=parsed_args.description,
- **kwargs
+ parsed_args.name, description=parsed_args.description, **kwargs
)
volume_type._info.pop('extra_specs')
@@ -208,30 +224,43 @@ class CreateVolumeType(command.ShowOne):
parsed_args.project_domain,
).id
volume_client.volume_type_access.add_project_access(
- volume_type.id, project_id)
+ volume_type.id, project_id
+ )
except Exception as e:
- msg = _("Failed to add project %(project)s access to "
- "type: %(e)s")
+ msg = _(
+ "Failed to add project %(project)s access to "
+ "type: %(e)s"
+ )
LOG.error(msg % {'project': parsed_args.project, 'e': e})
if parsed_args.property:
result = volume_type.set_keys(parsed_args.property)
volume_type._info.update(
- {'properties': format_columns.DictColumn(result)})
- if (parsed_args.encryption_provider or
- parsed_args.encryption_cipher or
- parsed_args.encryption_key_size or
- parsed_args.encryption_control_location):
+ {'properties': format_columns.DictColumn(result)}
+ )
+ if (
+ parsed_args.encryption_provider
+ or parsed_args.encryption_cipher
+ or parsed_args.encryption_key_size
+ or parsed_args.encryption_control_location
+ ):
try:
# create new encryption
encryption = _create_encryption_type(
- volume_client, volume_type, parsed_args)
+ volume_client, volume_type, parsed_args
+ )
except Exception as e:
- LOG.error(_("Failed to set encryption information for this "
- "volume type: %s"), e)
+ LOG.error(
+ _(
+ "Failed to set encryption information for this "
+ "volume type: %s"
+ ),
+ e,
+ )
# add encryption info in result
encryption._info.pop("volume_type_id", None)
volume_type._info.update(
- {'encryption': format_columns.DictColumn(encryption._info)})
+ {'encryption': format_columns.DictColumn(encryption._info)}
+ )
volume_type._info.pop("os-volume-type-access:is_public", None)
return zip(*sorted(volume_type._info.items()))
@@ -246,7 +275,7 @@ class DeleteVolumeType(command.Command):
"volume_types",
metavar="<volume-type>",
nargs="+",
- help=_("Volume type(s) to delete (name or ID)")
+ help=_("Volume type(s) to delete (name or ID)"),
)
return parser
@@ -256,20 +285,26 @@ class DeleteVolumeType(command.Command):
for volume_type in parsed_args.volume_types:
try:
- vol_type = utils.find_resource(volume_client.volume_types,
- volume_type)
+ vol_type = utils.find_resource(
+ volume_client.volume_types, volume_type
+ )
volume_client.volume_types.delete(vol_type)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete volume type with "
- "name or ID '%(volume_type)s': %(e)s")
- % {'volume_type': volume_type, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete volume type with "
+ "name or ID '%(volume_type)s': %(e)s"
+ )
+ % {'volume_type': volume_type, 'e': e}
+ )
if result > 0:
total = len(parsed_args.volume_types)
- msg = (_("%(result)s of %(total)s volume types failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s volume types failed " "to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -282,30 +317,30 @@ class ListVolumeType(command.Lister):
'--long',
action='store_true',
default=False,
- help=_('List additional fields in output')
+ help=_('List additional fields in output'),
)
public_group = parser.add_mutually_exclusive_group()
public_group.add_argument(
"--default",
action='store_true',
default=False,
- help=_('List the default volume type')
+ help=_('List the default volume type'),
)
public_group.add_argument(
- "--public",
- action="store_true",
- help=_("List only public types")
+ "--public", action="store_true", help=_("List only public types")
)
public_group.add_argument(
"--private",
action="store_true",
- help=_("List only private types (admin only)")
+ help=_("List only private types (admin only)"),
)
parser.add_argument(
"--encryption-type",
action="store_true",
- help=_("Display encryption information for each volume type "
- "(admin only)"),
+ help=_(
+ "Display encryption information for each volume type "
+ "(admin only)"
+ ),
)
return parser
@@ -314,7 +349,12 @@ class ListVolumeType(command.Lister):
if parsed_args.long:
columns = ['ID', 'Name', 'Is Public', 'Description', 'Extra Specs']
column_headers = [
- 'ID', 'Name', 'Is Public', 'Description', 'Properties']
+ 'ID',
+ 'Name',
+ 'Is Public',
+ 'Description',
+ 'Properties',
+ ]
else:
columns = ['ID', 'Name', 'Is Public']
column_headers = ['ID', 'Name', 'Is Public']
@@ -326,8 +366,7 @@ class ListVolumeType(command.Lister):
is_public = True
if parsed_args.private:
is_public = False
- data = volume_client.volume_types.list(
- is_public=is_public)
+ data = volume_client.volume_types.list(is_public=is_public)
formatters = {'Extra Specs': format_columns.DictColumn}
@@ -341,7 +380,7 @@ class ListVolumeType(command.Lister):
'created_at',
'updated_at',
'deleted_at',
- 'volume_type_id'
+ 'volume_type_id',
]
for key in del_key:
d._info.pop(key, None)
@@ -354,14 +393,21 @@ class ListVolumeType(command.Lister):
column_headers += ['Encryption']
_EncryptionInfoColumn = functools.partial(
- EncryptionInfoColumn, encryption_data=encryption)
+ EncryptionInfoColumn, encryption_data=encryption
+ )
formatters['id'] = _EncryptionInfoColumn
- return (column_headers,
- (utils.get_item_properties(
- s, columns,
+ return (
+ column_headers,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
formatters=formatters,
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class SetVolumeType(command.Command):
@@ -388,52 +434,64 @@ class SetVolumeType(command.Command):
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Set a property on this volume type '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Set a property on this volume type '
+ '(repeat option to set multiple properties)'
+ ),
)
parser.add_argument(
'--project',
metavar='<project>',
- help=_('Set volume type access to project (name or ID) '
- '(admin only)'),
+ help=_(
+ 'Set volume type access to project (name or ID) '
+ '(admin only)'
+ ),
)
identity_common.add_project_domain_option_to_parser(parser)
# TODO(Huanxuan Ao): Add choices for each "--encryption-*" option.
parser.add_argument(
'--encryption-provider',
metavar='<provider>',
- help=_('Set the encryption provider format for '
- 'this volume type (e.g "luks" or "plain") (admin only) '
- '(This option is required when setting encryption type '
- 'of a volume for the first time. Consider using other '
- 'encryption options such as: "--encryption-cipher", '
- '"--encryption-key-size" and '
- '"--encryption-control-location")'),
+ help=_(
+ 'Set the encryption provider format for '
+ 'this volume type (e.g "luks" or "plain") (admin only) '
+ '(This option is required when setting encryption type '
+ 'of a volume for the first time. Consider using other '
+ 'encryption options such as: "--encryption-cipher", '
+ '"--encryption-key-size" and '
+ '"--encryption-control-location")'
+ ),
)
parser.add_argument(
'--encryption-cipher',
metavar='<cipher>',
- help=_('Set the encryption algorithm or mode for this '
- 'volume type (e.g "aes-xts-plain64") (admin only)'),
+ help=_(
+ 'Set the encryption algorithm or mode for this '
+ 'volume type (e.g "aes-xts-plain64") (admin only)'
+ ),
)
parser.add_argument(
'--encryption-key-size',
metavar='<key-size>',
type=int,
- help=_('Set the size of the encryption key of this '
- 'volume type (e.g "128" or "256") (admin only)'),
+ help=_(
+ 'Set the size of the encryption key of this '
+ 'volume type (e.g "128" or "256") (admin only)'
+ ),
)
parser.add_argument(
'--encryption-control-location',
metavar='<control-location>',
choices=['front-end', 'back-end'],
- help=_('Set the notional service where the encryption is '
- 'performed ("front-end" or "back-end") (admin only) '
- '(The default value for this option is "front-end" '
- 'when setting encryption type of a volume for the '
- 'first time. Consider using other encryption options '
- 'such as: "--encryption-cipher", "--encryption-key-size" '
- 'and "--encryption-provider")'),
+ help=_(
+ 'Set the notional service where the encryption is '
+ 'performed ("front-end" or "back-end") (admin only) '
+ '(The default value for this option is "front-end" '
+ 'when setting encryption type of a volume for the '
+ 'first time. Consider using other encryption options '
+ 'such as: "--encryption-cipher", "--encryption-key-size" '
+ 'and "--encryption-provider")'
+ ),
)
return parser
@@ -442,7 +500,8 @@ class SetVolumeType(command.Command):
identity_client = self.app.client_manager.identity
volume_type = utils.find_resource(
- volume_client.volume_types, parsed_args.volume_type)
+ volume_client.volume_types, parsed_args.volume_type
+ )
result = 0
kwargs = {}
if parsed_args.name:
@@ -452,13 +511,15 @@ class SetVolumeType(command.Command):
if kwargs:
try:
- volume_client.volume_types.update(
- volume_type.id,
- **kwargs
- )
+ volume_client.volume_types.update(volume_type.id, **kwargs)
except Exception as e:
- LOG.error(_("Failed to update volume type name or"
- " description: %s"), e)
+ LOG.error(
+ _(
+ "Failed to update volume type name or"
+ " description: %s"
+ ),
+ e,
+ )
result += 1
if parsed_args.property:
@@ -474,29 +535,40 @@ class SetVolumeType(command.Command):
project_info = identity_common.find_project(
identity_client,
parsed_args.project,
- parsed_args.project_domain)
+ parsed_args.project_domain,
+ )
volume_client.volume_type_access.add_project_access(
- volume_type.id, project_info.id)
+ volume_type.id, project_info.id
+ )
except Exception as e:
- LOG.error(_("Failed to set volume type access to "
- "project: %s"), e)
+ LOG.error(
+ _("Failed to set volume type access to " "project: %s"), e
+ )
result += 1
- if (parsed_args.encryption_provider or
- parsed_args.encryption_cipher or
- parsed_args.encryption_key_size or
- parsed_args.encryption_control_location):
+ if (
+ parsed_args.encryption_provider
+ or parsed_args.encryption_cipher
+ or parsed_args.encryption_key_size
+ or parsed_args.encryption_control_location
+ ):
try:
_set_encryption_type(volume_client, volume_type, parsed_args)
except Exception as e:
- LOG.error(_("Failed to set encryption information for this "
- "volume type: %s"), e)
+ LOG.error(
+ _(
+ "Failed to set encryption information for this "
+ "volume type: %s"
+ ),
+ e,
+ )
result += 1
if result > 0:
- raise exceptions.CommandError(_("Command Failed: One or more of"
- " the operations failed"))
+ raise exceptions.CommandError(
+ _("Command Failed: One or more of" " the operations failed")
+ )
class ShowVolumeType(command.ShowOne):
@@ -507,50 +579,65 @@ class ShowVolumeType(command.ShowOne):
parser.add_argument(
"volume_type",
metavar="<volume-type>",
- help=_("Volume type to display (name or ID)")
+ help=_("Volume type to display (name or ID)"),
)
parser.add_argument(
"--encryption-type",
action="store_true",
- help=_("Display encryption information of this volume type "
- "(admin only)"),
+ help=_(
+ "Display encryption information of this volume type "
+ "(admin only)"
+ ),
)
return parser
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
volume_type = utils.find_resource(
- volume_client.volume_types, parsed_args.volume_type)
+ volume_client.volume_types, parsed_args.volume_type
+ )
properties = format_columns.DictColumn(
- volume_type._info.pop('extra_specs', {}))
+ volume_type._info.pop('extra_specs', {})
+ )
volume_type._info.update({'properties': properties})
access_project_ids = None
if not volume_type.is_public:
try:
volume_type_access = volume_client.volume_type_access.list(
- volume_type.id)
- project_ids = [utils.get_field(item, 'project_id')
- for item in volume_type_access]
+ volume_type.id
+ )
+ project_ids = [
+ utils.get_field(item, 'project_id')
+ for item in volume_type_access
+ ]
# TODO(Rui Chen): This format list case can be removed after
# patch https://review.opendev.org/#/c/330223/ merged.
access_project_ids = format_columns.ListColumn(project_ids)
except Exception as e:
- msg = _('Failed to get access project list for volume type '
- '%(type)s: %(e)s')
+ msg = _(
+ 'Failed to get access project list for volume type '
+ '%(type)s: %(e)s'
+ )
LOG.error(msg % {'type': volume_type.id, 'e': e})
volume_type._info.update({'access_project_ids': access_project_ids})
if parsed_args.encryption_type:
# show encryption type information for this volume type
try:
encryption = volume_client.volume_encryption_types.get(
- volume_type.id)
+ volume_type.id
+ )
encryption._info.pop("volume_type_id", None)
volume_type._info.update(
- {'encryption':
- format_columns.DictColumn(encryption._info)})
+ {'encryption': format_columns.DictColumn(encryption._info)}
+ )
except Exception as e:
- LOG.error(_("Failed to display the encryption information "
- "of this volume type: %s"), e)
+ LOG.error(
+ _(
+ "Failed to display the encryption information "
+ "of this volume type: %s"
+ ),
+ e,
+ )
volume_type._info.pop("os-volume-type-access:is_public", None)
return zip(*sorted(volume_type._info.items()))
@@ -569,21 +656,27 @@ class UnsetVolumeType(command.Command):
'--property',
metavar='<key>',
action='append',
- help=_('Remove a property from this volume type '
- '(repeat option to remove multiple properties)'),
+ help=_(
+ 'Remove a property from this volume type '
+ '(repeat option to remove multiple properties)'
+ ),
)
parser.add_argument(
'--project',
metavar='<project>',
- help=_('Removes volume type access to project (name or ID) '
- '(admin only)'),
+ help=_(
+ 'Removes volume type access to project (name or ID) '
+ '(admin only)'
+ ),
)
identity_common.add_project_domain_option_to_parser(parser)
parser.add_argument(
"--encryption-type",
action="store_true",
- help=_("Remove the encryption type for this volume type "
- "(admin only)"),
+ help=_(
+ "Remove the encryption type for this volume type "
+ "(admin only)"
+ ),
)
return parser
@@ -610,22 +703,35 @@ class UnsetVolumeType(command.Command):
project_info = identity_common.find_project(
identity_client,
parsed_args.project,
- parsed_args.project_domain)
+ parsed_args.project_domain,
+ )
volume_client.volume_type_access.remove_project_access(
- volume_type.id, project_info.id)
+ volume_type.id, project_info.id
+ )
except Exception as e:
- LOG.error(_("Failed to remove volume type access from "
- "project: %s"), e)
+ LOG.error(
+ _(
+ "Failed to remove volume type access from "
+ "project: %s"
+ ),
+ e,
+ )
result += 1
if parsed_args.encryption_type:
try:
volume_client.volume_encryption_types.delete(volume_type)
except Exception as e:
- LOG.error(_("Failed to remove the encryption type for this "
- "volume type: %s"), e)
+ LOG.error(
+ _(
+ "Failed to remove the encryption type for this "
+ "volume type: %s"
+ ),
+ e,
+ )
result += 1
if result > 0:
- raise exceptions.CommandError(_("Command Failed: One or more of"
- " the operations failed"))
+ raise exceptions.CommandError(
+ _("Command Failed: One or more of" " the operations failed")
+ )