diff options
author | Steve Baker <sbaker@redhat.com> | 2020-01-22 16:46:47 +1300 |
---|---|---|
committer | Steve Baker <sbaker@redhat.com> | 2020-01-22 16:46:47 +1300 |
commit | cc7a9c29c21627b8d605113988fc3227bf29b253 (patch) | |
tree | a0cc56dc504f54523e8c97823cf2d7afba59ef0d | |
parent | 443e0b10934f435b5504fcf7b32daeaf0f8ee23b (diff) | |
download | ironic-cc7a9c29c21627b8d605113988fc3227bf29b253.tar.gz |
Use str type instead of wsme.types.text
wsme.type.text maps to six.text_type, which for py3 is str.
Ironic is py3 only, and wsme is being removed, so this change
replaces all wsme.types.text uses with str.
Change-Id: Ie39f049840980d0595be3620f35f14eb4b0198af
Story: 1651346
-rw-r--r-- | ironic/api/controllers/link.py | 6 | ||||
-rw-r--r-- | ironic/api/controllers/root.py | 5 | ||||
-rw-r--r-- | ironic/api/controllers/v1/__init__.py | 7 | ||||
-rw-r--r-- | ironic/api/controllers/v1/allocation.py | 22 | ||||
-rw-r--r-- | ironic/api/controllers/v1/bios.py | 6 | ||||
-rw-r--r-- | ironic/api/controllers/v1/chassis.py | 6 | ||||
-rw-r--r-- | ironic/api/controllers/v1/collection.py | 2 | ||||
-rw-r--r-- | ironic/api/controllers/v1/conductor.py | 10 | ||||
-rw-r--r-- | ironic/api/controllers/v1/deploy_template.py | 14 | ||||
-rw-r--r-- | ironic/api/controllers/v1/driver.py | 69 | ||||
-rw-r--r-- | ironic/api/controllers/v1/node.py | 128 | ||||
-rw-r--r-- | ironic/api/controllers/v1/port.py | 12 | ||||
-rw-r--r-- | ironic/api/controllers/v1/portgroup.py | 14 | ||||
-rw-r--r-- | ironic/api/controllers/v1/ramdisk.py | 7 | ||||
-rw-r--r-- | ironic/api/controllers/v1/state.py | 8 | ||||
-rw-r--r-- | ironic/api/controllers/v1/types.py | 28 | ||||
-rw-r--r-- | ironic/api/controllers/v1/volume_connector.py | 8 | ||||
-rw-r--r-- | ironic/api/controllers/v1/volume_target.py | 10 | ||||
-rw-r--r-- | ironic/api/controllers/version.py | 10 | ||||
-rw-r--r-- | ironic/tests/unit/api/controllers/v1/test_types.py | 7 |
20 files changed, 185 insertions, 194 deletions
diff --git a/ironic/api/controllers/link.py b/ironic/api/controllers/link.py index 007e29273..a19e3b2ad 100644 --- a/ironic/api/controllers/link.py +++ b/ironic/api/controllers/link.py @@ -34,13 +34,13 @@ def build_url(resource, resource_args, bookmark=False, base_url=None): class Link(base.APIBase): """A link representation.""" - href = wtypes.text + href = str """The url of a link.""" - rel = wtypes.text + rel = str """The name of a link.""" - type = wtypes.text + type = str """Indicates the type of document/link.""" @staticmethod diff --git a/ironic/api/controllers/root.py b/ironic/api/controllers/root.py index 574d1fc4b..ece2b6dc4 100644 --- a/ironic/api/controllers/root.py +++ b/ironic/api/controllers/root.py @@ -16,7 +16,6 @@ import pecan from pecan import rest -from wsme import types as wtypes from ironic.api.controllers import base from ironic.api.controllers import v1 @@ -26,10 +25,10 @@ from ironic.api import expose class Root(base.APIBase): - name = wtypes.text + name = str """The name of the API""" - description = wtypes.text + description = str """Some information about this API""" versions = [version.Version] diff --git a/ironic/api/controllers/v1/__init__.py b/ironic/api/controllers/v1/__init__.py index 262de4417..ee26308fe 100644 --- a/ironic/api/controllers/v1/__init__.py +++ b/ironic/api/controllers/v1/__init__.py @@ -21,7 +21,6 @@ Specification can be found at doc/source/webapi/v1.rst import pecan from pecan import rest from webob import exc -from wsme import types as wtypes from ironic import api from ironic.api.controllers import base @@ -61,8 +60,8 @@ def max_version(): class MediaType(base.APIBase): """A media type representation.""" - base = wtypes.text - type = wtypes.text + base = str + type = str def __init__(self, base, type): self.base = base @@ -72,7 +71,7 @@ class MediaType(base.APIBase): class V1(base.APIBase): """The representation of the version 1 of the API.""" - id = wtypes.text + id = str """The ID of the version, also acts as the release number""" media_types = [MediaType] diff --git a/ironic/api/controllers/v1/allocation.py b/ironic/api/controllers/v1/allocation.py index 0e305dc3d..871181ea1 100644 --- a/ironic/api/controllers/v1/allocation.py +++ b/ironic/api/controllers/v1/allocation.py @@ -54,39 +54,39 @@ class Allocation(base.APIBase): uuid = types.uuid """Unique UUID for this allocation""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """This allocation's meta data""" node_uuid = wsme.wsattr(types.uuid, readonly=True) """The UUID of the node this allocation belongs to""" - node = wsme.wsattr(wtypes.text) + node = wsme.wsattr(str) """The node to backfill the allocation for (POST only)""" - name = wsme.wsattr(wtypes.text) + name = wsme.wsattr(str) """The logical name for this allocation""" links = wsme.wsattr([link.Link], readonly=True) """A list containing a self link and associated allocation links""" - state = wsme.wsattr(wtypes.text, readonly=True) + state = wsme.wsattr(str, readonly=True) """The current state of the allocation""" - last_error = wsme.wsattr(wtypes.text, readonly=True) + last_error = wsme.wsattr(str, readonly=True) """Last error that happened to this allocation""" resource_class = wsme.wsattr(wtypes.StringType(max_length=80)) """Requested resource class for this allocation""" - owner = wsme.wsattr(wtypes.text) + owner = wsme.wsattr(str) """Owner of allocation""" # NOTE(dtantsur): candidate_nodes is a list of UUIDs on the database level, # but the API level also accept names, converting them on fly. - candidate_nodes = wsme.wsattr([wtypes.text]) + candidate_nodes = wsme.wsattr([str]) """Candidate nodes for this allocation""" - traits = wsme.wsattr([wtypes.text]) + traits = wsme.wsattr([str]) """Requested traits for the allocation""" def __init__(self, **kwargs): @@ -311,9 +311,9 @@ class AllocationsController(pecan.rest.RestController): raise exception.NotAcceptable() @METRICS.timer('AllocationsController.get_all') - @expose.expose(AllocationCollection, types.uuid_or_name, wtypes.text, - wtypes.text, types.uuid, int, wtypes.text, wtypes.text, - types.listtype, wtypes.text) + @expose.expose(AllocationCollection, types.uuid_or_name, str, + str, types.uuid, int, str, str, + types.listtype, str) def get_all(self, node=None, resource_class=None, state=None, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, owner=None): diff --git a/ironic/api/controllers/v1/bios.py b/ironic/api/controllers/v1/bios.py index dc150cbba..11ef23cb2 100644 --- a/ironic/api/controllers/v1/bios.py +++ b/ironic/api/controllers/v1/bios.py @@ -34,9 +34,9 @@ METRICS = metrics_utils.get_metrics_logger(__name__) class BIOSSetting(base.APIBase): """API representation of a BIOS setting.""" - name = wsme.wsattr(wtypes.text) + name = wsme.wsattr(str) - value = wsme.wsattr(wtypes.text) + value = wsme.wsattr(str) links = wsme.wsattr([link.Link], readonly=True) @@ -106,7 +106,7 @@ class NodeBiosController(rest.RestController): settings) @METRICS.timer('NodeBiosController.get_one') - @expose.expose({wtypes.text: BIOSSetting}, types.name) + @expose.expose({str: BIOSSetting}, types.name) def get_one(self, setting_name): """Retrieve information about the given bios setting. diff --git a/ironic/api/controllers/v1/chassis.py b/ironic/api/controllers/v1/chassis.py index 91c776e8e..719dc0614 100644 --- a/ironic/api/controllers/v1/chassis.py +++ b/ironic/api/controllers/v1/chassis.py @@ -56,7 +56,7 @@ class Chassis(base.APIBase): description = wtypes.StringType(max_length=255) """The description of the chassis""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """The metadata of the chassis""" links = wsme.wsattr([link.Link], readonly=True) @@ -219,7 +219,7 @@ class ChassisController(rest.RestController): @METRICS.timer('ChassisController.get_all') @expose.expose(ChassisCollection, types.uuid, int, - wtypes.text, wtypes.text, types.listtype, types.boolean) + str, str, types.listtype, types.boolean) def get_all(self, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, detail=None): """Retrieve a list of chassis. @@ -247,7 +247,7 @@ class ChassisController(rest.RestController): @METRICS.timer('ChassisController.detail') @expose.expose(ChassisCollection, types.uuid, int, - wtypes.text, wtypes.text) + str, str) def detail(self, marker=None, limit=None, sort_key='id', sort_dir='asc'): """Retrieve a list of chassis with detail. diff --git a/ironic/api/controllers/v1/collection.py b/ironic/api/controllers/v1/collection.py index 335e874c1..873621b12 100644 --- a/ironic/api/controllers/v1/collection.py +++ b/ironic/api/controllers/v1/collection.py @@ -22,7 +22,7 @@ from ironic.api.controllers import link class Collection(base.APIBase): - next = wtypes.text + next = str """A link to retrieve the next subset of the collection""" @property diff --git a/ironic/api/controllers/v1/conductor.py b/ironic/api/controllers/v1/conductor.py index 6ce7fa912..ab88b9b59 100644 --- a/ironic/api/controllers/v1/conductor.py +++ b/ironic/api/controllers/v1/conductor.py @@ -42,16 +42,16 @@ _DEFAULT_RETURN_FIELDS = ('hostname', 'conductor_group', 'alive') class Conductor(base.APIBase): """API representation of a bare metal conductor.""" - hostname = wsme.wsattr(wtypes.text) + hostname = wsme.wsattr(str) """The hostname for this conductor""" - conductor_group = wsme.wsattr(wtypes.text) + conductor_group = wsme.wsattr(str) """The conductor group this conductor belongs to""" alive = types.boolean """Indicates whether this conductor is considered alive""" - drivers = wsme.wsattr([wtypes.text]) + drivers = wsme.wsattr([str]) """The drivers enabled on this conductor""" links = wsme.wsattr([link.Link]) @@ -194,8 +194,8 @@ class ConductorsController(rest.RestController): **parameters) @METRICS.timer('ConductorsController.get_all') - @expose.expose(ConductorCollection, types.name, int, wtypes.text, - wtypes.text, types.listtype, types.boolean) + @expose.expose(ConductorCollection, types.name, int, str, + str, types.listtype, types.boolean) def get_all(self, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, detail=None): """Retrieve a list of conductors. diff --git a/ironic/api/controllers/v1/deploy_template.py b/ironic/api/controllers/v1/deploy_template.py index ccd0b74b3..1cfaa5ec6 100644 --- a/ironic/api/controllers/v1/deploy_template.py +++ b/ironic/api/controllers/v1/deploy_template.py @@ -45,7 +45,7 @@ METRICS = metrics_utils.get_metrics_logger(__name__) _DEFAULT_RETURN_FIELDS = ('uuid', 'name') _DEPLOY_INTERFACE_TYPE = wtypes.Enum( - wtypes.text, *conductor_steps.DEPLOYING_INTERFACE_PRIORITY) + str, *conductor_steps.DEPLOYING_INTERFACE_PRIORITY) class DeployStepType(wtypes.Base, base.AsDictMixin): @@ -53,9 +53,9 @@ class DeployStepType(wtypes.Base, base.AsDictMixin): interface = wsme.wsattr(_DEPLOY_INTERFACE_TYPE, mandatory=True) - step = wsme.wsattr(wtypes.text, mandatory=True) + step = wsme.wsattr(str, mandatory=True) - args = wsme.wsattr({wtypes.text: types.jsontype}, mandatory=True) + args = wsme.wsattr({str: types.jsontype}, mandatory=True) priority = wsme.wsattr(wtypes.IntegerType(0), mandatory=True) @@ -77,7 +77,7 @@ class DeployTemplate(base.APIBase): uuid = types.uuid """Unique UUID for this deploy template.""" - name = wsme.wsattr(wtypes.text, mandatory=True) + name = wsme.wsattr(str, mandatory=True) """The logical name for this deploy template.""" steps = wsme.wsattr([DeployStepType], mandatory=True) @@ -86,7 +86,7 @@ class DeployTemplate(base.APIBase): links = wsme.wsattr([link.Link]) """A list containing a self link and associated deploy template links.""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """This deploy template's meta data""" def __init__(self, **kwargs): @@ -285,8 +285,8 @@ class DeployTemplatesController(rest.RestController): rpc_template[field] = patch_val @METRICS.timer('DeployTemplatesController.get_all') - @expose.expose(DeployTemplateCollection, types.name, int, wtypes.text, - wtypes.text, types.listtype, types.boolean) + @expose.expose(DeployTemplateCollection, types.name, int, str, + str, types.listtype, types.boolean) def get_all(self, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, detail=None): """Retrieve a list of deploy templates. diff --git a/ironic/api/controllers/v1/driver.py b/ironic/api/controllers/v1/driver.py index c4e4c936d..c6a3f6675 100644 --- a/ironic/api/controllers/v1/driver.py +++ b/ironic/api/controllers/v1/driver.py @@ -18,7 +18,6 @@ from http import client as http_client from ironic_lib import metrics_utils from pecan import rest import wsme -from wsme import types as wtypes from ironic import api from ironic.api.controllers import base @@ -88,13 +87,13 @@ def hide_fields_in_newer_versions(obj): class Driver(base.APIBase): """API representation of a driver.""" - name = wtypes.text + name = str """The name of the driver""" - hosts = [wtypes.text] + hosts = [str] """A list of active conductors that support this driver""" - type = wtypes.text + type = str """Whether the driver is classic or dynamic (hardware type)""" links = wsme.wsattr([link.Link], readonly=True) @@ -104,32 +103,32 @@ class Driver(base.APIBase): """A list containing links to driver properties""" """Default interface for a hardware type""" - default_bios_interface = wtypes.text - default_boot_interface = wtypes.text - default_console_interface = wtypes.text - default_deploy_interface = wtypes.text - default_inspect_interface = wtypes.text - default_management_interface = wtypes.text - default_network_interface = wtypes.text - default_power_interface = wtypes.text - default_raid_interface = wtypes.text - default_rescue_interface = wtypes.text - default_storage_interface = wtypes.text - default_vendor_interface = wtypes.text + default_bios_interface = str + default_boot_interface = str + default_console_interface = str + default_deploy_interface = str + default_inspect_interface = str + default_management_interface = str + default_network_interface = str + default_power_interface = str + default_raid_interface = str + default_rescue_interface = str + default_storage_interface = str + default_vendor_interface = str """A list of enabled interfaces for a hardware type""" - enabled_bios_interfaces = [wtypes.text] - enabled_boot_interfaces = [wtypes.text] - enabled_console_interfaces = [wtypes.text] - enabled_deploy_interfaces = [wtypes.text] - enabled_inspect_interfaces = [wtypes.text] - enabled_management_interfaces = [wtypes.text] - enabled_network_interfaces = [wtypes.text] - enabled_power_interfaces = [wtypes.text] - enabled_raid_interfaces = [wtypes.text] - enabled_rescue_interfaces = [wtypes.text] - enabled_storage_interfaces = [wtypes.text] - enabled_vendor_interfaces = [wtypes.text] + enabled_bios_interfaces = [str] + enabled_boot_interfaces = [str] + enabled_console_interfaces = [str] + enabled_deploy_interfaces = [str] + enabled_inspect_interfaces = [str] + enabled_management_interfaces = [str] + enabled_network_interfaces = [str] + enabled_power_interfaces = [str] + enabled_raid_interfaces = [str] + enabled_rescue_interfaces = [str] + enabled_storage_interfaces = [str] + enabled_vendor_interfaces = [str] @staticmethod def convert_with_links(name, hosts, detail=False, interface_info=None): @@ -269,7 +268,7 @@ class DriverPassthruController(rest.RestController): } @METRICS.timer('DriverPassthruController.methods') - @expose.expose(wtypes.text, wtypes.text) + @expose.expose(str, str) def methods(self, driver_name): """Retrieve information about vendor methods of the given driver. @@ -291,8 +290,8 @@ class DriverPassthruController(rest.RestController): return _VENDOR_METHODS[driver_name] @METRICS.timer('DriverPassthruController._default') - @expose.expose(wtypes.text, wtypes.text, wtypes.text, - body=wtypes.text) + @expose.expose(str, str, str, + body=str) def _default(self, driver_name, method, data=None): """Call a driver API extension. @@ -316,7 +315,7 @@ class DriverRaidController(rest.RestController): } @METRICS.timer('DriverRaidController.logical_disk_properties') - @expose.expose(types.jsontype, wtypes.text) + @expose.expose(types.jsontype, str) def logical_disk_properties(self, driver_name): """Returns the logical disk properties for the driver. @@ -365,7 +364,7 @@ class DriversController(rest.RestController): } @METRICS.timer('DriversController.get_all') - @expose.expose(DriverList, wtypes.text, types.boolean) + @expose.expose(DriverList, str, types.boolean) def get_all(self, type=None, detail=None): """Retrieve a list of drivers.""" # FIXME(deva): formatting of the auto-generated REST API docs @@ -391,7 +390,7 @@ class DriversController(rest.RestController): return DriverList.convert_with_links(hw_type_dict, detail=detail) @METRICS.timer('DriversController.get_one') - @expose.expose(Driver, wtypes.text) + @expose.expose(Driver, str) def get_one(self, driver_name): """Retrieve a single driver.""" # NOTE(russell_h): There is no way to make this more efficient than @@ -410,7 +409,7 @@ class DriversController(rest.RestController): raise exception.DriverNotFound(driver_name=driver_name) @METRICS.timer('DriversController.properties') - @expose.expose(wtypes.text, wtypes.text) + @expose.expose(str, str) def properties(self, driver_name): """Retrieve property information of the given driver. diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py index 60ed090be..c72a7bbde 100644 --- a/ironic/api/controllers/v1/node.py +++ b/ironic/api/controllers/v1/node.py @@ -205,7 +205,7 @@ class BootDeviceController(rest.RestController): rpc_node.uuid, topic) @METRICS.timer('BootDeviceController.put') - @expose.expose(None, types.uuid_or_name, wtypes.text, types.boolean, + @expose.expose(None, types.uuid_or_name, str, types.boolean, status_code=http_client.NO_CONTENT) def put(self, node_ident, boot_device, persistent=False): """Set the boot device for a node. @@ -231,7 +231,7 @@ class BootDeviceController(rest.RestController): topic=topic) @METRICS.timer('BootDeviceController.get') - @expose.expose(wtypes.text, types.uuid_or_name) + @expose.expose(str, types.uuid_or_name) def get(self, node_ident): """Get the current boot device for a node. @@ -250,7 +250,7 @@ class BootDeviceController(rest.RestController): return self._get_boot_device(rpc_node) @METRICS.timer('BootDeviceController.supported') - @expose.expose(wtypes.text, types.uuid_or_name) + @expose.expose(str, types.uuid_or_name) def supported(self, node_ident): """Get a list of the supported boot devices. @@ -315,7 +315,7 @@ class ConsoleInfo(base.APIBase): console_enabled = types.boolean """The console state: if the console is enabled or not.""" - console_info = {wtypes.text: types.jsontype} + console_info = {str: types.jsontype} """The console information. It typically includes the url to access the console and the type of the application that hosts the console.""" @@ -376,29 +376,29 @@ class NodeStates(base.APIBase): """Indicates whether the console access is enabled or disabled on the node.""" - power_state = wtypes.text + power_state = str """Represent the current (not transition) power state of the node""" - provision_state = wtypes.text + provision_state = str """Represent the current (not transition) provision state of the node""" provision_updated_at = datetime.datetime """The UTC date and time of the last provision state change""" - target_power_state = wtypes.text + target_power_state = str """The user modified desired power state of the node.""" - target_provision_state = wtypes.text + target_provision_state = str """The user modified desired provision state of the node.""" - last_error = wtypes.text + last_error = str """Any error from the most recent (last) asynchronous transaction that started but failed to finish.""" - raid_config = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True) + raid_config = wsme.wsattr({str: types.jsontype}, readonly=True) """Represents the RAID configuration that the node is configured with.""" - target_raid_config = wsme.wsattr({wtypes.text: types.jsontype}, + target_raid_config = wsme.wsattr({str: types.jsontype}, readonly=True) """The desired RAID configuration, to be used the next time the node is configured.""" @@ -488,7 +488,7 @@ class NodeStatesController(rest.RestController): raise @METRICS.timer('NodeStatesController.power') - @expose.expose(None, types.uuid_or_name, wtypes.text, + @expose.expose(None, types.uuid_or_name, str, wtypes.IntegerType(minimum=1), status_code=http_client.ACCEPTED) def power(self, node_ident, target, timeout=None): @@ -592,8 +592,8 @@ class NodeStatesController(rest.RestController): raise exception.InvalidStateRequested(message=msg) @METRICS.timer('NodeStatesController.provision') - @expose.expose(None, types.uuid_or_name, wtypes.text, - types.jsontype, types.jsontype, wtypes.text, + @expose.expose(None, types.uuid_or_name, str, + types.jsontype, types.jsontype, str, status_code=http_client.ACCEPTED) def provision(self, node_ident, target, configdrive=None, clean_steps=None, rescue_password=None): @@ -775,7 +775,7 @@ class NodeTraitsController(rest.RestController): return Traits(traits=traits.get_trait_names()) @METRICS.timer('NodeTraitsController.put') - @expose.expose(None, wtypes.text, wtypes.ArrayType(str), + @expose.expose(None, str, wtypes.ArrayType(str), status_code=http_client.NO_CONTENT) def put(self, trait=None, traits=None): """Add a trait to a node. @@ -834,7 +834,7 @@ class NodeTraitsController(rest.RestController): api.response.location = link.build_url('nodes', url_args) @METRICS.timer('NodeTraitsController.delete') - @expose.expose(None, wtypes.text, + @expose.expose(None, str, status_code=http_client.NO_CONTENT) def delete(self, trait=None): """Remove one or all traits from a node. @@ -908,23 +908,23 @@ class Node(base.APIBase): instance_uuid = types.uuid """The UUID of the instance in nova-compute""" - name = wsme.wsattr(wtypes.text) + name = wsme.wsattr(str) """The logical name for this node""" - power_state = wsme.wsattr(wtypes.text, readonly=True) + power_state = wsme.wsattr(str, readonly=True) """Represent the current (not transition) power state of the node""" - target_power_state = wsme.wsattr(wtypes.text, readonly=True) + target_power_state = wsme.wsattr(str, readonly=True) """The user modified desired power state of the node.""" - last_error = wsme.wsattr(wtypes.text, readonly=True) + last_error = wsme.wsattr(str, readonly=True) """Any error from the most recent (last) asynchronous transaction that started but failed to finish.""" - provision_state = wsme.wsattr(wtypes.text, readonly=True) + provision_state = wsme.wsattr(str, readonly=True) """Represent the current (not transition) provision state of the node""" - reservation = wsme.wsattr(wtypes.text, readonly=True) + reservation = wsme.wsattr(str, readonly=True) """The hostname of the conductor that holds an exclusive lock on the node.""" @@ -941,46 +941,46 @@ class Node(base.APIBase): maintenance = types.boolean """Indicates whether the node is in maintenance mode.""" - maintenance_reason = wsme.wsattr(wtypes.text, readonly=True) + maintenance_reason = wsme.wsattr(str, readonly=True) """Indicates reason for putting a node in maintenance mode.""" - fault = wsme.wsattr(wtypes.text, readonly=True) + fault = wsme.wsattr(str, readonly=True) """Indicates the active fault of a node.""" - target_provision_state = wsme.wsattr(wtypes.text, readonly=True) + target_provision_state = wsme.wsattr(str, readonly=True) """The user modified desired provision state of the node.""" console_enabled = types.boolean """Indicates whether the console access is enabled or disabled on the node.""" - instance_info = {wtypes.text: types.jsontype} + instance_info = {str: types.jsontype} """This node's instance info.""" - driver = wsme.wsattr(wtypes.text, mandatory=True) + driver = wsme.wsattr(str, mandatory=True) """The driver responsible for controlling the node""" - driver_info = {wtypes.text: types.jsontype} + driver_info = {str: types.jsontype} """This node's driver configuration""" - driver_internal_info = wsme.wsattr({wtypes.text: types.jsontype}, + driver_internal_info = wsme.wsattr({str: types.jsontype}, readonly=True) """This driver's internal configuration""" - clean_step = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True) + clean_step = wsme.wsattr({str: types.jsontype}, readonly=True) """The current clean step""" - deploy_step = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True) + deploy_step = wsme.wsattr({str: types.jsontype}, readonly=True) """The current deploy step""" - raid_config = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True) + raid_config = wsme.wsattr({str: types.jsontype}, readonly=True) """Represents the current RAID configuration of the node """ - target_raid_config = wsme.wsattr({wtypes.text: types.jsontype}, + target_raid_config = wsme.wsattr({str: types.jsontype}, readonly=True) """The user modified RAID configuration of the node """ - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """This node's meta data""" resource_class = wsme.wsattr(wtypes.StringType(max_length=80)) @@ -990,7 +990,7 @@ class Node(base.APIBase): # NOTE: properties should use a class to enforce required properties # current list: arch, cpus, disk, ram, image - properties = {wtypes.text: types.jsontype} + properties = {str: types.jsontype} """The physical characteristics of this node""" chassis_uuid = wsme.wsproperty(types.uuid, _get_chassis_uuid, @@ -1012,46 +1012,46 @@ class Node(base.APIBase): states = wsme.wsattr([link.Link], readonly=True) """Links to endpoint for retrieving and setting node states""" - boot_interface = wsme.wsattr(wtypes.text) + boot_interface = wsme.wsattr(str) """The boot interface to be used for this node""" - console_interface = wsme.wsattr(wtypes.text) + console_interface = wsme.wsattr(str) """The console interface to be used for this node""" - deploy_interface = wsme.wsattr(wtypes.text) + deploy_interface = wsme.wsattr(str) """The deploy interface to be used for this node""" - inspect_interface = wsme.wsattr(wtypes.text) + inspect_interface = wsme.wsattr(str) """The inspect interface to be used for this node""" - management_interface = wsme.wsattr(wtypes.text) + management_interface = wsme.wsattr(str) """The management interface to be used for this node""" - network_interface = wsme.wsattr(wtypes.text) + network_interface = wsme.wsattr(str) """The network interface to be used for this node""" - power_interface = wsme.wsattr(wtypes.text) + power_interface = wsme.wsattr(str) """The power interface to be used for this node""" - raid_interface = wsme.wsattr(wtypes.text) + raid_interface = wsme.wsattr(str) """The raid interface to be used for this node""" - rescue_interface = wsme.wsattr(wtypes.text) + rescue_interface = wsme.wsattr(str) """The rescue interface to be used for this node""" - storage_interface = wsme.wsattr(wtypes.text) + storage_interface = wsme.wsattr(str) """The storage interface to be used for this node""" - vendor_interface = wsme.wsattr(wtypes.text) + vendor_interface = wsme.wsattr(str) """The vendor interface to be used for this node""" traits = wtypes.ArrayType(str) """The traits associated with this node""" - bios_interface = wsme.wsattr(wtypes.text) + bios_interface = wsme.wsattr(str) """The bios interface to be used for this node""" - conductor_group = wsme.wsattr(wtypes.text) + conductor_group = wsme.wsattr(str) """The conductor group to manage this node""" automated_clean = types.boolean @@ -1060,16 +1060,16 @@ class Node(base.APIBase): protected = types.boolean """Indicates whether the node is protected from undeploying/rebuilding.""" - protected_reason = wsme.wsattr(wtypes.text) + protected_reason = wsme.wsattr(str) """Indicates reason for protecting the node.""" - conductor = wsme.wsattr(wtypes.text, readonly=True) + conductor = wsme.wsattr(str, readonly=True) """Represent the conductor currently serving the node""" - owner = wsme.wsattr(wtypes.text) + owner = wsme.wsattr(str) """Field for storage of physical node owner""" - description = wsme.wsattr(wtypes.text) + description = wsme.wsattr(str) """Field for node description""" allocation_uuid = wsme.wsattr(types.uuid, readonly=True) @@ -1364,7 +1364,7 @@ class NodeVendorPassthruController(rest.RestController): } @METRICS.timer('NodeVendorPassthruController.methods') - @expose.expose(wtypes.text, types.uuid_or_name) + @expose.expose(str, types.uuid_or_name) def methods(self, node_ident): """Retrieve information about vendor methods of the given node. @@ -1386,8 +1386,8 @@ class NodeVendorPassthruController(rest.RestController): return _VENDOR_METHODS[rpc_node.driver] @METRICS.timer('NodeVendorPassthruController._default') - @expose.expose(wtypes.text, types.uuid_or_name, wtypes.text, - body=wtypes.text) + @expose.expose(str, types.uuid_or_name, str, + body=str) def _default(self, node_ident, method, data=None): """Call a vendor extension. @@ -1424,7 +1424,7 @@ class NodeMaintenanceController(rest.RestController): notify.emit_end_notification(context, new_node, 'maintenance_set') @METRICS.timer('NodeMaintenanceController.put') - @expose.expose(None, types.uuid_or_name, wtypes.text, + @expose.expose(None, types.uuid_or_name, str, status_code=http_client.ACCEPTED) def put(self, node_ident, reason=None): """Put the node in maintenance mode. @@ -1773,10 +1773,10 @@ class NodesController(rest.RestController): @METRICS.timer('NodesController.get_all') @expose.expose(NodeCollection, types.uuid, types.uuid, types.boolean, - types.boolean, wtypes.text, types.uuid, int, wtypes.text, - wtypes.text, wtypes.text, types.listtype, wtypes.text, - wtypes.text, wtypes.text, types.boolean, wtypes.text, - wtypes.text, wtypes.text) + types.boolean, str, types.uuid, int, str, + str, str, types.listtype, str, + str, str, types.boolean, str, + str, str) def get_all(self, chassis_uuid=None, instance_uuid=None, associated=None, maintenance=None, provision_state=None, marker=None, limit=None, sort_key='id', sort_dir='asc', driver=None, @@ -1853,9 +1853,9 @@ class NodesController(rest.RestController): @METRICS.timer('NodesController.detail') @expose.expose(NodeCollection, types.uuid, types.uuid, types.boolean, - types.boolean, wtypes.text, types.uuid, int, wtypes.text, - wtypes.text, wtypes.text, wtypes.text, wtypes.text, - wtypes.text, wtypes.text, wtypes.text, wtypes.text) + types.boolean, str, types.uuid, int, str, + str, str, str, str, + str, str, str, str) def detail(self, chassis_uuid=None, instance_uuid=None, associated=None, maintenance=None, provision_state=None, marker=None, limit=None, sort_key='id', sort_dir='asc', driver=None, @@ -1927,7 +1927,7 @@ class NodesController(rest.RestController): **extra_args) @METRICS.timer('NodesController.validate') - @expose.expose(wtypes.text, types.uuid_or_name, types.uuid) + @expose.expose(str, types.uuid_or_name, types.uuid) def validate(self, node=None, node_uuid=None): """Validate the driver interfaces, using the node's UUID or name. diff --git a/ironic/api/controllers/v1/port.py b/ironic/api/controllers/v1/port.py index 982ac6572..e2c845d57 100644 --- a/ironic/api/controllers/v1/port.py +++ b/ironic/api/controllers/v1/port.py @@ -133,10 +133,10 @@ class Port(base.APIBase): address = wsme.wsattr(types.macaddress, mandatory=True) """MAC Address for this port""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """This port's meta data""" - internal_info = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True) + internal_info = wsme.wsattr({str: types.jsontype}, readonly=True) """This port's internal information maintained by ironic""" node_uuid = wsme.wsproperty(types.uuid, _get_node_uuid, _set_node_uuid, @@ -439,8 +439,8 @@ class PortsController(rest.RestController): @METRICS.timer('PortsController.get_all') @expose.expose(PortCollection, types.uuid_or_name, types.uuid, - types.macaddress, types.uuid, int, wtypes.text, - wtypes.text, types.listtype, types.uuid_or_name, + types.macaddress, types.uuid, int, str, + str, types.listtype, types.uuid_or_name, types.boolean) def get_all(self, node=None, node_uuid=None, address=None, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, @@ -497,8 +497,8 @@ class PortsController(rest.RestController): @METRICS.timer('PortsController.detail') @expose.expose(PortCollection, types.uuid_or_name, types.uuid, - types.macaddress, types.uuid, int, wtypes.text, - wtypes.text, types.uuid_or_name) + types.macaddress, types.uuid, int, str, + str, types.uuid_or_name) def detail(self, node=None, node_uuid=None, address=None, marker=None, limit=None, sort_key='id', sort_dir='asc', portgroup=None): """Retrieve a list of ports with detail. diff --git a/ironic/api/controllers/v1/portgroup.py b/ironic/api/controllers/v1/portgroup.py index 6fa1dec44..3f6df9e1d 100644 --- a/ironic/api/controllers/v1/portgroup.py +++ b/ironic/api/controllers/v1/portgroup.py @@ -78,17 +78,17 @@ class Portgroup(base.APIBase): address = wsme.wsattr(types.macaddress) """MAC Address for this portgroup""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """This portgroup's meta data""" - internal_info = wsme.wsattr({wtypes.text: types.jsontype}, readonly=True) + internal_info = wsme.wsattr({str: types.jsontype}, readonly=True) """This portgroup's internal info""" node_uuid = wsme.wsproperty(types.uuid, _get_node_uuid, _set_node_uuid, mandatory=True) """The UUID of the node this portgroup belongs to""" - name = wsme.wsattr(wtypes.text) + name = wsme.wsattr(str) """The logical name for this portgroup""" links = wsme.wsattr([link.Link], readonly=True) @@ -98,12 +98,12 @@ class Portgroup(base.APIBase): """Indicates whether ports of this portgroup may be used as single NIC ports""" - mode = wsme.wsattr(wtypes.text) + mode = wsme.wsattr(str) """The mode for this portgroup. See linux bonding documentation for details: https://www.kernel.org/doc/Documentation/networking/bonding.txt""" - properties = {wtypes.text: types.jsontype} + properties = {str: types.jsontype} """This portgroup's properties""" ports = wsme.wsattr([link.Link], readonly=True) @@ -359,7 +359,7 @@ class PortgroupsController(pecan.rest.RestController): @METRICS.timer('PortgroupsController.get_all') @expose.expose(PortgroupCollection, types.uuid_or_name, types.macaddress, - types.uuid, int, wtypes.text, wtypes.text, types.listtype, + types.uuid, int, str, str, types.listtype, types.boolean) def get_all(self, node=None, address=None, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, @@ -400,7 +400,7 @@ class PortgroupsController(pecan.rest.RestController): @METRICS.timer('PortgroupsController.detail') @expose.expose(PortgroupCollection, types.uuid_or_name, types.macaddress, - types.uuid, int, wtypes.text, wtypes.text) + types.uuid, int, str, str) def detail(self, node=None, address=None, marker=None, limit=None, sort_key='id', sort_dir='asc'): """Retrieve a list of portgroups with detail. diff --git a/ironic/api/controllers/v1/ramdisk.py b/ironic/api/controllers/v1/ramdisk.py index 56c182e8b..6fa778a33 100644 --- a/ironic/api/controllers/v1/ramdisk.py +++ b/ironic/api/controllers/v1/ramdisk.py @@ -17,7 +17,6 @@ from http import client as http_client from oslo_config import cfg from oslo_log import log from pecan import rest -from wsme import types as wtypes from ironic import api from ironic.api.controllers import base @@ -63,7 +62,7 @@ class LookupResult(base.APIBase): node = node_ctl.Node """The short node representation.""" - config = {wtypes.text: types.jsontype} + config = {str: types.jsontype} """The configuration to pass to the ramdisk.""" @classmethod @@ -156,8 +155,8 @@ class LookupController(rest.RestController): class HeartbeatController(rest.RestController): """Controller handling heartbeats from deploy ramdisk.""" - @expose.expose(None, types.uuid_or_name, wtypes.text, - wtypes.text, status_code=http_client.ACCEPTED) + @expose.expose(None, types.uuid_or_name, str, + str, status_code=http_client.ACCEPTED) def post(self, node_ident, callback_url, agent_version=None): """Process a heartbeat from the deploy ramdisk. diff --git a/ironic/api/controllers/v1/state.py b/ironic/api/controllers/v1/state.py index ec5753f23..3fa3f7a10 100644 --- a/ironic/api/controllers/v1/state.py +++ b/ironic/api/controllers/v1/state.py @@ -13,21 +13,19 @@ # License for the specific language governing permissions and limitations # under the License. -from wsme import types as wtypes - from ironic.api.controllers import base from ironic.api.controllers import link class State(base.APIBase): - current = wtypes.text + current = str """The current state""" - target = wtypes.text + target = str """The user modified desired state""" - available = [wtypes.text] + available = [str] """A list of available states it is able to transition to""" links = [link.Link] diff --git a/ironic/api/controllers/v1/types.py b/ironic/api/controllers/v1/types.py index d7cf999fe..07b59819a 100644 --- a/ironic/api/controllers/v1/types.py +++ b/ironic/api/controllers/v1/types.py @@ -36,7 +36,7 @@ LOG = log.getLogger(__name__) class MacAddressType(wtypes.UserType): """A simple MAC address type.""" - basetype = wtypes.text + basetype = str name = 'macaddress' @staticmethod @@ -53,7 +53,7 @@ class MacAddressType(wtypes.UserType): class UuidOrNameType(wtypes.UserType): """A simple UUID or logical name type.""" - basetype = wtypes.text + basetype = str name = 'uuid_or_name' @staticmethod @@ -73,7 +73,7 @@ class UuidOrNameType(wtypes.UserType): class NameType(wtypes.UserType): """A simple logical name type.""" - basetype = wtypes.text + basetype = str name = 'name' @staticmethod @@ -92,7 +92,7 @@ class NameType(wtypes.UserType): class UuidType(wtypes.UserType): """A simple UUID type.""" - basetype = wtypes.text + basetype = str name = 'uuid' @staticmethod @@ -111,7 +111,7 @@ class UuidType(wtypes.UserType): class BooleanType(wtypes.UserType): """A simple boolean type.""" - basetype = wtypes.text + basetype = str name = 'boolean' @staticmethod @@ -132,12 +132,12 @@ class BooleanType(wtypes.UserType): class JsonType(wtypes.UserType): """A simple JSON type.""" - basetype = wtypes.text + basetype = str name = 'json' def __str__(self): # These are the json serializable native types - return ' | '.join(map(str, (wtypes.text, int, float, + return ' | '.join(map(str, (str, int, float, BooleanType, list, dict, None))) @staticmethod @@ -157,7 +157,7 @@ class JsonType(wtypes.UserType): class ListType(wtypes.UserType): """A simple list type.""" - basetype = wtypes.text + basetype = str name = 'list' @staticmethod @@ -303,7 +303,7 @@ class LocalLinkConnectionType(wtypes.UserType): :raises: Invalid if some of the keys in the dictionary being validated are unknown, invalid, or some required ones are missing. """ - wtypes.DictType(wtypes.text, wtypes.text).validate(value) + wtypes.DictType(str, str).validate(value) keys = set(value) @@ -364,7 +364,7 @@ class LocalLinkConnectionType(wtypes.UserType): :return: True if both fields 'port_id' and 'hostname' are present in 'value', False otherwise. """ - wtypes.DictType(wtypes.text, wtypes.text).validate(value) + wtypes.DictType(str, str).validate(value) keys = set(value) if LocalLinkConnectionType.smart_nic_mandatory_fields <= keys: @@ -377,7 +377,7 @@ locallinkconnectiontype = LocalLinkConnectionType() class VifType(JsonType): - basetype = wtypes.text + basetype = str name = 'viftype' mandatory_fields = {'id'} @@ -422,10 +422,10 @@ class EventType(wtypes.UserType): validators = { 'port_id': UuidType.validate, 'mac_address': MacAddressType.validate, - 'status': wtypes.text, + 'status': str, 'device_id': UuidType.validate, 'binding:host_id': UuidType.validate, - 'binding:vnic_type': wtypes.text + 'binding:vnic_type': str } keys = set(value) @@ -473,7 +473,7 @@ class EventType(wtypes.UserType): :raises: Invalid if event not in proper format """ - wtypes.DictType(wtypes.text, wtypes.text).validate(value) + wtypes.DictType(str, str).validate(value) keys = set(value) # Check all mandatory fields are present diff --git a/ironic/api/controllers/v1/volume_connector.py b/ironic/api/controllers/v1/volume_connector.py index af19f1922..120b10740 100644 --- a/ironic/api/controllers/v1/volume_connector.py +++ b/ironic/api/controllers/v1/volume_connector.py @@ -75,13 +75,13 @@ class VolumeConnector(base.APIBase): uuid = types.uuid """Unique UUID for this volume connector""" - type = wsme.wsattr(wtypes.text, mandatory=True) + type = wsme.wsattr(str, mandatory=True) """The type of volume connector""" - connector_id = wsme.wsattr(wtypes.text, mandatory=True) + connector_id = wsme.wsattr(str, mandatory=True) """The connector_id for this volume connector""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """The metadata for this volume connector""" node_uuid = wsme.wsproperty(types.uuid, _get_node_uuid, @@ -265,7 +265,7 @@ class VolumeConnectorsController(rest.RestController): @METRICS.timer('VolumeConnectorsController.get_all') @expose.expose(VolumeConnectorCollection, types.uuid_or_name, types.uuid, - int, wtypes.text, wtypes.text, types.listtype, + int, str, str, types.listtype, types.boolean) def get_all(self, node=None, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, detail=None): diff --git a/ironic/api/controllers/v1/volume_target.py b/ironic/api/controllers/v1/volume_target.py index b4c2f89f6..9a2e1e8c4 100644 --- a/ironic/api/controllers/v1/volume_target.py +++ b/ironic/api/controllers/v1/volume_target.py @@ -76,19 +76,19 @@ class VolumeTarget(base.APIBase): uuid = types.uuid """Unique UUID for this volume target""" - volume_type = wsme.wsattr(wtypes.text, mandatory=True) + volume_type = wsme.wsattr(str, mandatory=True) """The volume_type of volume target""" - properties = {wtypes.text: types.jsontype} + properties = {str: types.jsontype} """The properties for this volume target""" boot_index = wsme.wsattr(int, mandatory=True) """The boot_index of volume target""" - volume_id = wsme.wsattr(wtypes.text, mandatory=True) + volume_id = wsme.wsattr(str, mandatory=True) """The volume_id for this volume target""" - extra = {wtypes.text: types.jsontype} + extra = {str: types.jsontype} """The metadata for this volume target""" node_uuid = wsme.wsproperty(types.uuid, _get_node_uuid, @@ -279,7 +279,7 @@ class VolumeTargetsController(rest.RestController): @METRICS.timer('VolumeTargetsController.get_all') @expose.expose(VolumeTargetCollection, types.uuid_or_name, types.uuid, - int, wtypes.text, wtypes.text, types.listtype, + int, str, str, types.listtype, types.boolean) def get_all(self, node=None, marker=None, limit=None, sort_key='id', sort_dir='asc', fields=None, detail=None): diff --git a/ironic/api/controllers/version.py b/ironic/api/controllers/version.py index 46472acd8..f83243da5 100644 --- a/ironic/api/controllers/version.py +++ b/ironic/api/controllers/version.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from wsme import types as wtypes - from ironic import api from ironic.api.controllers import base from ironic.api.controllers import link @@ -26,13 +24,13 @@ class Version(base.APIBase): maximum minor versions that are supported within the major version. """ - id = wtypes.text + id = str """The ID of the (major) version, also acts as the release number""" links = [link.Link] """A Link that point to a specific version of the API""" - status = wtypes.text + status = str """Status of the version. One of: @@ -41,10 +39,10 @@ class Version(base.APIBase): * DEPRECATED - supported, but deprecated, version of API. """ - version = wtypes.text + version = str """The current, maximum supported (major.minor) version of API.""" - min_version = wtypes.text + min_version = str """Minimum supported (major.minor) version of API.""" def __init__(self, id, min_version, version, status='CURRENT'): diff --git a/ironic/tests/unit/api/controllers/v1/test_types.py b/ironic/tests/unit/api/controllers/v1/test_types.py index a16dd40a4..5f8cc0e2e 100644 --- a/ironic/tests/unit/api/controllers/v1/test_types.py +++ b/ironic/tests/unit/api/controllers/v1/test_types.py @@ -21,7 +21,6 @@ import platform import mock import webtest import wsme -from wsme import types as wtypes from ironic.api.controllers.v1 import types from ironic.common import exception @@ -89,7 +88,7 @@ class TestUuidOrNameType(base.TestCase): class MyBaseType(object): """Helper class, patched by objects of type MyPatchType""" - mandatory = wsme.wsattr(wtypes.text, mandatory=True) + mandatory = wsme.wsattr(str, mandatory=True) class MyPatchType(types.JsonPatchType): @@ -105,7 +104,7 @@ class MyPatchType(types.JsonPatchType): class MyRoot(wsme.WSRoot): """Helper class for TestJsonPatchType tests.""" - @wsme.expose([wsme.types.text], body=[MyPatchType]) + @wsme.expose([str], body=[MyPatchType]) @wsme.validate([MyPatchType]) def test(self, patch): return patch @@ -263,7 +262,7 @@ class TestJsonType(base.TestCase): def test_apimultitype_tostring(self): vts = str(types.jsontype) - self.assertIn(str(wtypes.text), vts) + self.assertIn(str(str), vts) self.assertIn(str(int), vts) self.assertIn(str(float), vts) self.assertIn(str(types.BooleanType), vts) |