Use MultiType and types.text instead of str

The goal of this is to fix python3 compatibility issues.


story: 2003236
task: 23698
Change-Id: I555c7faecfcccaaa3649ef8c631b99a01e747c0b
This commit is contained in:
Erik Olof Gunnar Andersson 2019-01-14 20:50:18 -08:00 committed by Spyros Trigazis
parent 54bea06b5a
commit 41cd85794f
8 changed files with 33 additions and 20 deletions

View File

@ -18,6 +18,7 @@ import uuid
from oslo_log import log as logging
from oslo_utils import timeutils
import pecan
import six
import wsme
from wsme import types as wtypes
@ -92,7 +93,10 @@ class Bay(base.APIBase):
docker_volume_size = wtypes.IntegerType(minimum=1)
"""The size in GB of the docker volume"""
labels = wtypes.DictType(str, str)
labels = wtypes.DictType(wtypes.text, types.MultiType(wtypes.text,
six.integer_types,
bool,
float))
"""One or more key/value pairs"""
master_flavor_id = wtypes.StringType(min_length=1, max_length=255)
@ -110,7 +114,7 @@ class Bay(base.APIBase):
stack_id = wsme.wsattr(wtypes.text, readonly=True)
"""Stack id of the heat stack"""
status = wtypes.Enum(str, *fields.ClusterStatus.ALL)
status = wtypes.Enum(wtypes.text, *fields.ClusterStatus.ALL)
"""Status of the bay from the heat stack"""
status_reason = wtypes.text
@ -135,7 +139,7 @@ class Bay(base.APIBase):
master_addresses = wsme.wsattr([wtypes.text], readonly=True)
"""IP addresses of cluster master nodes"""
bay_faults = wsme.wsattr(wtypes.DictType(str, wtypes.text))
bay_faults = wsme.wsattr(wtypes.DictType(wtypes.text, wtypes.text))
"""Fault info collected from the heat resources of this bay"""
def __init__(self, **kwargs):

View File

@ -46,7 +46,7 @@ class BayModel(base.APIBase):
name = wtypes.StringType(min_length=1, max_length=255)
"""The name of the Baymodel"""
coe = wtypes.Enum(str, *fields.ClusterType.ALL, mandatory=True)
coe = wtypes.Enum(wtypes.text, *fields.ClusterType.ALL, mandatory=True)
"""The Container Orchestration Engine for this bay model"""
image_id = wsme.wsattr(wtypes.StringType(min_length=1, max_length=255),
@ -111,7 +111,7 @@ class BayModel(base.APIBase):
registry_enabled = wsme.wsattr(types.boolean, default=False)
"""Indicates whether the docker registry is enabled"""
labels = wtypes.DictType(str, str)
labels = wtypes.DictType(wtypes.text, wtypes.text)
"""One or more key/value pairs"""
tls_disabled = wsme.wsattr(types.boolean, default=False)
@ -120,7 +120,7 @@ class BayModel(base.APIBase):
public = wsme.wsattr(types.boolean, default=False)
"""Indicates whether the Baymodel is public or not."""
server_type = wsme.wsattr(wtypes.Enum(str, *fields.ServerType.ALL),
server_type = wsme.wsattr(wtypes.Enum(wtypes.text, *fields.ServerType.ALL),
default='vm')
"""Server type for this bay model"""

View File

@ -18,6 +18,7 @@ import uuid
from oslo_log import log as logging
from oslo_utils import timeutils
import pecan
import six
import wsme
from wsme import types as wtypes
@ -110,7 +111,10 @@ class Cluster(base.APIBase):
docker_volume_size = wtypes.IntegerType(minimum=1)
"""The size in GB of the docker volume"""
labels = wtypes.DictType(str, str)
labels = wtypes.DictType(wtypes.text, types.MultiType(wtypes.text,
six.integer_types,
bool,
float))
"""One or more key/value pairs"""
master_flavor_id = wtypes.StringType(min_length=1, max_length=255)
@ -128,16 +132,16 @@ class Cluster(base.APIBase):
stack_id = wsme.wsattr(wtypes.text, readonly=True)
"""Stack id of the heat stack"""
status = wtypes.Enum(str, *fields.ClusterStatus.ALL)
status = wtypes.Enum(wtypes.text, *fields.ClusterStatus.ALL)
"""Status of the cluster from the heat stack"""
status_reason = wtypes.text
"""Status reason of the cluster from the heat stack"""
health_status = wtypes.Enum(str, *fields.ClusterStatus.ALL)
health_status = wtypes.Enum(wtypes.text, *fields.ClusterStatus.ALL)
"""Health status of the cluster from the native COE API"""
health_status_reason = wtypes.DictType(str, str)
health_status_reason = wtypes.DictType(wtypes.text, wtypes.text)
"""Health status reason of the cluster from the native COE API"""
discovery_url = wtypes.text
@ -165,7 +169,7 @@ class Cluster(base.APIBase):
master_addresses = wsme.wsattr([wtypes.text], readonly=True)
"""IP addresses of cluster master nodes"""
faults = wsme.wsattr(wtypes.DictType(str, wtypes.text))
faults = wsme.wsattr(wtypes.DictType(wtypes.text, wtypes.text))
"""Fault info collected from the heat resources of this cluster"""
def __init__(self, **kwargs):

View File

@ -14,6 +14,7 @@
from oslo_utils import timeutils
import pecan
import six
import wsme
from wsme import types as wtypes
@ -47,7 +48,7 @@ class ClusterTemplate(base.APIBase):
name = wtypes.StringType(min_length=1, max_length=255)
"""The name of the ClusterTemplate"""
coe = wtypes.Enum(str, *fields.ClusterType.ALL, mandatory=True)
coe = wtypes.Enum(wtypes.text, *fields.ClusterType.ALL, mandatory=True)
"""The Container Orchestration Engine for this clustertemplate"""
image_id = wsme.wsattr(wtypes.StringType(min_length=1, max_length=255),
@ -112,7 +113,10 @@ class ClusterTemplate(base.APIBase):
registry_enabled = wsme.wsattr(types.boolean, default=False)
"""Indicates whether the docker registry is enabled"""
labels = wtypes.DictType(str, str)
labels = wtypes.DictType(wtypes.text, types.MultiType(wtypes.text,
six.integer_types,
bool,
float))
"""One or more key/value pairs"""
tls_disabled = wsme.wsattr(types.boolean, default=False)
@ -121,7 +125,7 @@ class ClusterTemplate(base.APIBase):
public = wsme.wsattr(types.boolean, default=False)
"""Indicates whether the ClusterTemplate is public or not."""
server_type = wsme.wsattr(wtypes.Enum(str, *fields.ServerType.ALL),
server_type = wsme.wsattr(wtypes.Enum(wtypes.text, *fields.ServerType.ALL),
default='vm')
"""Server type for this ClusterTemplate """

View File

@ -73,13 +73,13 @@ class Federation(base.APIBase):
member_ids = wsme.wsattr([wtypes.text])
# Status of the federation.
status = wtypes.Enum(str, *fields.FederationStatus.ALL)
status = wtypes.Enum(wtypes.text, *fields.FederationStatus.ALL)
# Status reason of the federation.
status_reason = wtypes.text
# Set of federation metadata (COE-specific in some cases).
properties = wtypes.DictType(str, str)
properties = wtypes.DictType(wtypes.text, wtypes.text)
# A list containing a self link and associated federations links
links = wsme.wsattr([link.Link], readonly=True)

View File

@ -29,10 +29,10 @@ class MagnumService(base.APIBase):
host = wtypes.StringType(min_length=1, max_length=255)
"""Name of the host """
binary = wtypes.Enum(str, *fields.MagnumServiceBinary.ALL)
binary = wtypes.Enum(wtypes.text, *fields.MagnumServiceBinary.ALL)
"""Name of the binary"""
state = wtypes.Enum(str, *fields.MagnumServiceState.ALL)
state = wtypes.Enum(wtypes.text, *fields.MagnumServiceState.ALL)
"""State of the binary"""
id = wsme.wsattr(wtypes.IntegerType(minimum=1))

View File

@ -46,7 +46,8 @@ class Quota(base.APIBase):
default=None)
"""The project id"""
resource = wsme.wsattr(wtypes.Enum(str, *fields.QuotaResourceName.ALL),
resource = wsme.wsattr(wtypes.Enum(wtypes.text,
*fields.QuotaResourceName.ALL),
default='Cluster')
"""The resource name"""

View File

@ -141,7 +141,7 @@ class JsonPatchType(wtypes.Base):
path = wtypes.wsattr(wtypes.StringType(pattern='^(/[\w-]+)+$'),
mandatory=True)
op = wtypes.wsattr(wtypes.Enum(str, 'add', 'replace', 'remove'),
op = wtypes.wsattr(wtypes.Enum(wtypes.text, 'add', 'replace', 'remove'),
mandatory=True)
value = MultiType(wtypes.text, int)