typing: Add types for empty dicts, tuples
In some cases, simply remove them. Change-Id: I24a311a24eb533325dda83005777bcb2e0afc320 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from osc_lib import clientmanager
|
from osc_lib import clientmanager
|
||||||
from osc_lib import shell
|
from osc_lib import shell
|
||||||
@@ -26,7 +27,7 @@ import stevedore
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
PLUGIN_MODULES = []
|
PLUGIN_MODULES: list[ty.Any] = []
|
||||||
|
|
||||||
USER_AGENT = 'python-openstackclient'
|
USER_AGENT = 'python-openstackclient'
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@ import getpass
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from cliff.formatters import table
|
from cliff.formatters import table
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
@@ -100,7 +101,7 @@ class ProjectCleanup(command.Command):
|
|||||||
project_connect = sdk.connect_as_project(project)
|
project_connect = sdk.connect_as_project(project)
|
||||||
|
|
||||||
if project_connect:
|
if project_connect:
|
||||||
status_queue = queue.Queue()
|
status_queue: queue.Queue[ty.Any] = queue.Queue()
|
||||||
parsed_args.max_width = int(
|
parsed_args.max_width = int(
|
||||||
os.environ.get('CLIFF_MAX_TERM_WIDTH', 0)
|
os.environ.get('CLIFF_MAX_TERM_WIDTH', 0)
|
||||||
)
|
)
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
"""Compute v2 Aggregate action implementations"""
|
"""Compute v2 Aggregate action implementations"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from openstack import utils as sdk_utils
|
from openstack import utils as sdk_utils
|
||||||
from osc_lib.cli import format_columns
|
from osc_lib.cli import format_columns
|
||||||
@@ -321,7 +322,7 @@ class SetAggregate(command.Command):
|
|||||||
if kwargs:
|
if kwargs:
|
||||||
compute_client.update_aggregate(aggregate.id, **kwargs)
|
compute_client.update_aggregate(aggregate.id, **kwargs)
|
||||||
|
|
||||||
properties = {}
|
properties: dict[str, ty.Any] = {}
|
||||||
if parsed_args.no_property:
|
if parsed_args.no_property:
|
||||||
# NOTE(RuiChen): "availability_zone" can not be unset from
|
# NOTE(RuiChen): "availability_zone" can not be unset from
|
||||||
# properties. It is already excluded from show and create output.
|
# properties. It is already excluded from show and create output.
|
||||||
|
@@ -25,10 +25,9 @@ from openstackclient.i18n import _
|
|||||||
def _get_console_columns(item):
|
def _get_console_columns(item):
|
||||||
# To maintain backwards compatibility we need to rename sdk props to
|
# To maintain backwards compatibility we need to rename sdk props to
|
||||||
# whatever OSC was using before
|
# whatever OSC was using before
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['id', 'links', 'location', 'name']
|
hidden_columns = ['id', 'links', 'location', 'name']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -61,14 +61,13 @@ def _generate_keypair():
|
|||||||
def _get_keypair_columns(item, hide_pub_key=False, hide_priv_key=False):
|
def _get_keypair_columns(item, hide_pub_key=False, hide_priv_key=False):
|
||||||
# To maintain backwards compatibility we need to rename sdk props to
|
# To maintain backwards compatibility we need to rename sdk props to
|
||||||
# whatever OSC was using before
|
# whatever OSC was using before
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['links', 'location']
|
hidden_columns = ['links', 'location']
|
||||||
if hide_pub_key:
|
if hide_pub_key:
|
||||||
hidden_columns.append('public_key')
|
hidden_columns.append('public_key')
|
||||||
if hide_priv_key:
|
if hide_priv_key:
|
||||||
hidden_columns.append('private_key')
|
hidden_columns.append('private_key')
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1032,7 +1032,6 @@ class BDMLegacyAction(argparse.Action):
|
|||||||
|
|
||||||
class BDMAction(parseractions.MultiKeyValueAction):
|
class BDMAction(parseractions.MultiKeyValueAction):
|
||||||
def __init__(self, option_strings, dest, **kwargs):
|
def __init__(self, option_strings, dest, **kwargs):
|
||||||
required_keys = []
|
|
||||||
optional_keys = [
|
optional_keys = [
|
||||||
'uuid',
|
'uuid',
|
||||||
'source_type',
|
'source_type',
|
||||||
@@ -1050,7 +1049,7 @@ class BDMAction(parseractions.MultiKeyValueAction):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
option_strings,
|
option_strings,
|
||||||
dest,
|
dest,
|
||||||
required_keys=required_keys,
|
required_keys=[],
|
||||||
optional_keys=optional_keys,
|
optional_keys=optional_keys,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
@@ -3963,14 +3962,12 @@ class RemoveFloatingIP(network_common.NetworkAndComputeCommand):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action_network(self, client, parsed_args):
|
def take_action_network(self, client, parsed_args):
|
||||||
attrs = {}
|
|
||||||
obj = client.find_ip(
|
obj = client.find_ip(
|
||||||
parsed_args.ip_address,
|
parsed_args.ip_address,
|
||||||
ignore_missing=False,
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
attrs['port_id'] = None
|
|
||||||
|
|
||||||
client.update_ip(obj, **attrs)
|
client.update_ip(obj, port_id=None)
|
||||||
|
|
||||||
def take_action_compute(self, client, parsed_args):
|
def take_action_compute(self, client, parsed_args):
|
||||||
server = client.find_server(parsed_args.server, ignore_missing=False)
|
server = client.find_server(parsed_args.server, ignore_missing=False)
|
||||||
|
@@ -65,17 +65,11 @@ class ServerActionEventColumn(columns.FormattableColumn):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def _format_event(self, event):
|
def _format_event(self, event):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['id', 'name', 'location']
|
hidden_columns = ['id', 'name', 'location']
|
||||||
_, columns = utils.get_osc_show_columns_for_sdk_resource(
|
_, columns = utils.get_osc_show_columns_for_sdk_resource(
|
||||||
event,
|
event, {}, hidden_columns
|
||||||
column_map,
|
|
||||||
hidden_columns,
|
|
||||||
)
|
|
||||||
data = utils.get_item_properties(
|
|
||||||
event,
|
|
||||||
columns,
|
|
||||||
)
|
)
|
||||||
|
data = utils.get_item_properties(event, columns)
|
||||||
return dict(zip(columns, data))
|
return dict(zip(columns, data))
|
||||||
|
|
||||||
def human_readable(self):
|
def human_readable(self):
|
||||||
@@ -88,7 +82,6 @@ class ServerActionEventColumn(columns.FormattableColumn):
|
|||||||
|
|
||||||
|
|
||||||
def _get_server_event_columns(item, client):
|
def _get_server_event_columns(item, client):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['name', 'server_id', 'links', 'location']
|
hidden_columns = ['name', 'server_id', 'links', 'location']
|
||||||
|
|
||||||
if not sdk_utils.supports_microversion(client, '2.58'):
|
if not sdk_utils.supports_microversion(client, '2.58'):
|
||||||
@@ -96,9 +89,7 @@ def _get_server_event_columns(item, client):
|
|||||||
hidden_columns.append('updated_at')
|
hidden_columns.append('updated_at')
|
||||||
|
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item,
|
item, {}, hidden_columns
|
||||||
column_map,
|
|
||||||
hidden_columns,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ from base64 import b64encode
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from cinderclient import api_versions
|
from cinderclient import api_versions
|
||||||
from openstack import exceptions as sdk_exceptions
|
from openstack import exceptions as sdk_exceptions
|
||||||
@@ -615,7 +616,10 @@ class CreateImage(command.ShowOne):
|
|||||||
volume_client.volumes,
|
volume_client.volumes,
|
||||||
parsed_args.volume,
|
parsed_args.volume,
|
||||||
)
|
)
|
||||||
kwargs = {}
|
kwargs = {
|
||||||
|
'visibility': None,
|
||||||
|
'protected': None,
|
||||||
|
}
|
||||||
if volume_client.api_version < api_versions.APIVersion('3.1'):
|
if volume_client.api_version < api_versions.APIVersion('3.1'):
|
||||||
if parsed_args.visibility or parsed_args.is_protected is not None:
|
if parsed_args.visibility or parsed_args.is_protected is not None:
|
||||||
msg = _(
|
msg = _(
|
||||||
@@ -625,10 +629,8 @@ class CreateImage(command.ShowOne):
|
|||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
else:
|
else:
|
||||||
kwargs.update(
|
kwargs['visibility'] = parsed_args.visibility or 'private'
|
||||||
visibility=parsed_args.visibility or 'private',
|
kwargs['protected'] = parsed_args.is_protected or False
|
||||||
protected=parsed_args.is_protected or False,
|
|
||||||
)
|
|
||||||
|
|
||||||
response, body = volume_client.volumes.upload_to_image(
|
response, body = volume_client.volumes.upload_to_image(
|
||||||
source_volume.id,
|
source_volume.id,
|
||||||
@@ -1453,7 +1455,6 @@ class UnsetImage(command.Command):
|
|||||||
ignore_missing=False,
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs = {}
|
|
||||||
tagret = 0
|
tagret = 0
|
||||||
propret = 0
|
propret = 0
|
||||||
if parsed_args.tags:
|
if parsed_args.tags:
|
||||||
@@ -1466,6 +1467,7 @@ class UnsetImage(command.Command):
|
|||||||
)
|
)
|
||||||
tagret += 1
|
tagret += 1
|
||||||
|
|
||||||
|
kwargs: dict[str, ty.Any] = {}
|
||||||
if parsed_args.properties:
|
if parsed_args.properties:
|
||||||
for k in parsed_args.properties:
|
for k in parsed_args.properties:
|
||||||
if k in image:
|
if k in image:
|
||||||
|
@@ -22,10 +22,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location']
|
hidden_columns = ['location']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,8 +23,7 @@ class ListMetadefResourceTypes(command.Lister):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
image_client = self.app.client_manager.image
|
image_client = self.app.client_manager.image
|
||||||
kwargs = {}
|
data = image_client.metadef_resource_types()
|
||||||
data = image_client.metadef_resource_types(**kwargs)
|
|
||||||
columns = ['Name']
|
columns = ['Name']
|
||||||
column_headers = columns
|
column_headers = columns
|
||||||
return (
|
return (
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
import abc
|
import abc
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
import openstack.exceptions
|
import openstack.exceptions
|
||||||
from osc_lib.cli import parseractions
|
from osc_lib.cli import parseractions
|
||||||
@@ -295,10 +296,10 @@ class NeutronCommandWithExtraArgs(command.Command):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _get_property_converter(self, _property):
|
def _get_property_converter(self, _property):
|
||||||
if 'type' not in _property:
|
if 'type' in _property:
|
||||||
converter = str
|
|
||||||
else:
|
|
||||||
converter = self._allowed_types_dict.get(_property['type'])
|
converter = self._allowed_types_dict.get(_property['type'])
|
||||||
|
else:
|
||||||
|
converter = str
|
||||||
|
|
||||||
if not converter:
|
if not converter:
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
@@ -311,7 +312,7 @@ class NeutronCommandWithExtraArgs(command.Command):
|
|||||||
return converter
|
return converter
|
||||||
|
|
||||||
def _parse_extra_properties(self, extra_properties):
|
def _parse_extra_properties(self, extra_properties):
|
||||||
result = {}
|
result: dict[str, ty.Any] = {}
|
||||||
if extra_properties:
|
if extra_properties:
|
||||||
for _property in extra_properties:
|
for _property in extra_properties:
|
||||||
converter = self._get_property_converter(_property)
|
converter = self._get_property_converter(_property)
|
||||||
@@ -344,7 +345,7 @@ class NeutronCommandWithExtraArgs(command.Command):
|
|||||||
|
|
||||||
class NeutronUnsetCommandWithExtraArgs(NeutronCommandWithExtraArgs):
|
class NeutronUnsetCommandWithExtraArgs(NeutronCommandWithExtraArgs):
|
||||||
def _parse_extra_properties(self, extra_properties):
|
def _parse_extra_properties(self, extra_properties):
|
||||||
result = {}
|
result: dict[str, ty.Any] = {}
|
||||||
if extra_properties:
|
if extra_properties:
|
||||||
for _property in extra_properties:
|
for _property in extra_properties:
|
||||||
result[_property['name']] = None
|
result[_property['name']] = None
|
||||||
|
@@ -58,12 +58,12 @@ def str2list(strlist):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def str2dict(strdict):
|
def str2dict(strdict: str) -> dict[str, str]:
|
||||||
"""Convert key1:value1;key2:value2;... string into dictionary.
|
"""Convert key1:value1;key2:value2;... string into dictionary.
|
||||||
|
|
||||||
:param strdict: string in the form of key1:value1;key2:value2
|
:param strdict: string in the form of key1:value1;key2:value2
|
||||||
"""
|
"""
|
||||||
result = {}
|
result: dict[str, str] = {}
|
||||||
if not strdict:
|
if not strdict:
|
||||||
return result
|
return result
|
||||||
i = 0
|
i = 0
|
||||||
|
@@ -28,10 +28,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,10 +28,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'name', 'revision_number']
|
hidden_columns = ['location', 'name', 'revision_number']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,10 +27,9 @@ _formatters = {
|
|||||||
|
|
||||||
|
|
||||||
def _get_network_columns(item):
|
def _get_network_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -571,7 +570,7 @@ class UnsetFloatingIP(common.NeutronCommandWithExtraArgs):
|
|||||||
parsed_args.floating_ip,
|
parsed_args.floating_ip,
|
||||||
ignore_missing=False,
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
attrs = {}
|
attrs: dict[str, None] = {}
|
||||||
if parsed_args.port:
|
if parsed_args.port:
|
||||||
attrs['port_id'] = None
|
attrs['port_id'] = None
|
||||||
if parsed_args.qos_policy:
|
if parsed_args.qos_policy:
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
"""Floating IP Port Forwarding action implementations"""
|
"""Floating IP Port Forwarding action implementations"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@@ -85,10 +86,9 @@ def validate_port(port):
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ class CreateFloatingIPPortForwarding(
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
attrs = {}
|
attrs: dict[str, ty.Any] = {}
|
||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
floating_ip = client.find_ip(
|
floating_ip = client.find_ip(
|
||||||
parsed_args.floating_ip,
|
parsed_args.floating_ip,
|
||||||
|
@@ -26,10 +26,9 @@ _formatters = {
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['id', 'name', 'location', 'tenant_id']
|
hidden_columns = ['id', 'name', 'location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -25,10 +25,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,10 +28,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,10 +28,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'name', 'id', 'tenant_id']
|
hidden_columns = ['location', 'name', 'id', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -29,10 +29,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location']
|
hidden_columns = ['location']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -68,8 +68,7 @@ def _get_columns_network(item):
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns_compute(item):
|
def _get_columns_compute(item):
|
||||||
column_map = {}
|
return utils.get_osc_show_columns_for_sdk_resource(item, {})
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(item, column_map)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_attrs_network(client_manager, parsed_args):
|
def _get_attrs_network(client_manager, parsed_args):
|
||||||
|
@@ -25,10 +25,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['name', 'location', 'tenant_id']
|
hidden_columns = ['name', 'location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,10 +27,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -73,10 +73,9 @@ ACTION_SHOW = 'get'
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,10 +26,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@@ -32,10 +33,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ def _is_prop_empty(columns, props, prop_name):
|
|||||||
|
|
||||||
|
|
||||||
def _exchange_dict_keys_with_values(orig_dict):
|
def _exchange_dict_keys_with_values(orig_dict):
|
||||||
updated_dict = dict()
|
updated_dict: dict[str, ty.Any] = {}
|
||||||
for k, v in orig_dict.items():
|
for k, v in orig_dict.items():
|
||||||
k = [k]
|
k = [k]
|
||||||
if not updated_dict.get(v):
|
if not updated_dict.get(v):
|
||||||
@@ -351,8 +351,7 @@ class ListNetworkSegmentRange(command.Lister):
|
|||||||
) % {'e': e}
|
) % {'e': e}
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
filters = {}
|
data = network_client.network_segment_ranges()
|
||||||
data = network_client.network_segment_ranges(**filters)
|
|
||||||
|
|
||||||
headers: tuple[str, ...] = (
|
headers: tuple[str, ...] = (
|
||||||
'ID',
|
'ID',
|
||||||
@@ -396,7 +395,7 @@ class ListNetworkSegmentRange(command.Lister):
|
|||||||
'available',
|
'available',
|
||||||
)
|
)
|
||||||
|
|
||||||
display_props = tuple()
|
display_props: tuple[str, ...] = tuple()
|
||||||
for s in data:
|
for s in data:
|
||||||
props = utils.get_item_properties(s, columns)
|
props = utils.get_item_properties(s, columns)
|
||||||
if (
|
if (
|
||||||
|
@@ -336,10 +336,9 @@ _formatters = {
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return osc_utils.get_osc_show_columns_for_sdk_resource(
|
return osc_utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,10 +30,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
|
||||||
hidden_columns = ['location', 'tenant_id']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, {}, hidden_columns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
|
import typing as ty
|
||||||
|
|
||||||
from cliff import columns as cliff_columns
|
from cliff import columns as cliff_columns
|
||||||
from osc_lib.cli import format_columns
|
from osc_lib.cli import format_columns
|
||||||
@@ -831,7 +832,7 @@ class UnsetSubnet(common.NeutronUnsetCommandWithExtraArgs):
|
|||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
obj = client.find_subnet(parsed_args.subnet, ignore_missing=False)
|
obj = client.find_subnet(parsed_args.subnet, ignore_missing=False)
|
||||||
|
|
||||||
attrs = {}
|
attrs: dict[str, ty.Any] = {}
|
||||||
if parsed_args.gateway:
|
if parsed_args.gateway:
|
||||||
attrs['gateway_ip'] = None
|
attrs['gateway_ip'] = None
|
||||||
if parsed_args.dns_nameservers:
|
if parsed_args.dns_nameservers:
|
||||||
|
@@ -56,7 +56,7 @@ class NetworkTagTests(NetworkTests):
|
|||||||
'set', name1, '--tag red --tag green', ['red', 'green']
|
'set', name1, '--tag red --tag green', ['red', 'green']
|
||||||
)
|
)
|
||||||
|
|
||||||
list_expected = (
|
list_expected: tuple[tuple[str, list[str]]] = (
|
||||||
(name1, ['red', 'green']),
|
(name1, ['red', 'green']),
|
||||||
(name2, ['red', 'blue']),
|
(name2, ['red', 'blue']),
|
||||||
(name3, []),
|
(name3, []),
|
||||||
|
@@ -346,7 +346,13 @@ class TestImageCreate(TestImage):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.volumes_mock.upload_to_image.assert_called_with(
|
self.volumes_mock.upload_to_image.assert_called_with(
|
||||||
fake_vol_id, False, self.new_image.name, 'bare', 'raw'
|
fake_vol_id,
|
||||||
|
False,
|
||||||
|
self.new_image.name,
|
||||||
|
'bare',
|
||||||
|
'raw',
|
||||||
|
visibility=None,
|
||||||
|
protected=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch('osc_lib.utils.find_resource')
|
@mock.patch('osc_lib.utils.find_resource')
|
||||||
|
@@ -85,8 +85,6 @@ class CreateTransferRequest(command.ShowOne):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
volume_client = self.app.client_manager.volume
|
volume_client = self.app.client_manager.volume
|
||||||
|
|
||||||
kwargs = {}
|
|
||||||
|
|
||||||
volume_id = utils.find_resource(
|
volume_id = utils.find_resource(
|
||||||
volume_client.volumes,
|
volume_client.volumes,
|
||||||
parsed_args.volume,
|
parsed_args.volume,
|
||||||
@@ -94,7 +92,6 @@ class CreateTransferRequest(command.ShowOne):
|
|||||||
volume_transfer_request = volume_client.transfers.create(
|
volume_transfer_request = volume_client.transfers.create(
|
||||||
volume_id,
|
volume_id,
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
**kwargs,
|
|
||||||
)
|
)
|
||||||
volume_transfer_request._info.pop("links", None)
|
volume_transfer_request._info.pop("links", None)
|
||||||
|
|
||||||
|
@@ -649,9 +649,7 @@ class SetVolumeType(command.Command):
|
|||||||
)
|
)
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
properties = {}
|
properties: dict[str, str] = {}
|
||||||
|
|
||||||
properties = {}
|
|
||||||
if parsed_args.properties:
|
if parsed_args.properties:
|
||||||
properties.update(parsed_args.properties)
|
properties.update(parsed_args.properties)
|
||||||
if parsed_args.multiattach:
|
if parsed_args.multiattach:
|
||||||
|
@@ -731,9 +731,7 @@ class SetVolumeType(command.Command):
|
|||||||
)
|
)
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
properties = {}
|
properties: dict[str, str] = {}
|
||||||
|
|
||||||
properties = {}
|
|
||||||
if parsed_args.properties:
|
if parsed_args.properties:
|
||||||
properties.update(parsed_args.properties)
|
properties.update(parsed_args.properties)
|
||||||
if parsed_args.multiattach:
|
if parsed_args.multiattach:
|
||||||
|
Reference in New Issue
Block a user