Fix urllib/unicode related issues for Python 2/3
replace unicode by six.text_type replace urlparse by six.moves.urllib.parse remove the ignore for F821 from the flake8 config PS: as there is a bug of pylint 1.9, six.moves.urllib.parse should be import as follows: e.g. from doc of module six: from six.moves.urllib.parse import urlparse urlparse(endpoint).path here: from six.moves import urllib urllib.parse.urlparse(endpoint).path pylint bug: https://github.com/PyCQA/pylint/issues/2180 Story: 2003427 Task: 24605 Task: 24608 Change-Id: I098ba8093dbf08dd91acaf403291ebb469195558 Signed-off-by: SidneyAn <ran1.an@intel.com>
This commit is contained in:
parent
cab52fb0fa
commit
730ef6eeaf
@ -315,10 +315,10 @@ class Token(object):
|
||||
if endpoint is None:
|
||||
endpoint = service_info.endpoint_override
|
||||
else:
|
||||
from urlparse import urlparse
|
||||
from six.moves import urllib
|
||||
# this is necessary to keep tenant_id in place
|
||||
endpoint = \
|
||||
service_info.endpoint_override + urlparse(endpoint).path
|
||||
service_info.endpoint_override + urllib.parse.urlparse(endpoint).path
|
||||
|
||||
if strip_version:
|
||||
endpoint = self._url_strip_version(endpoint)
|
||||
|
@ -6,6 +6,7 @@
|
||||
import json
|
||||
import pecan
|
||||
from pecan import rest
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@ -50,15 +51,15 @@ class SwUpdateStrategyStageStepData(wsme_types.Base):
|
||||
Software Update Strategy - Stage Step Data
|
||||
"""
|
||||
step_id = wsme_types.wsattr(int, name='step-id')
|
||||
step_name = wsme_types.wsattr(unicode, name='step-name')
|
||||
step_name = wsme_types.wsattr(six.text_type, name='step-name')
|
||||
timeout = wsme_types.wsattr(int, name='timeout')
|
||||
entity_type = wsme_types.wsattr(unicode, name='entity-type')
|
||||
entity_uuids = wsme_types.wsattr([unicode], name='entity-uuids')
|
||||
entity_names = wsme_types.wsattr([unicode], name='entity-names')
|
||||
result = wsme_types.wsattr(unicode, name='result')
|
||||
reason = wsme_types.wsattr(unicode, name='reason')
|
||||
start_date_time = wsme_types.wsattr(unicode, name='start-date-time')
|
||||
end_date_time = wsme_types.wsattr(unicode, name='end-date-time')
|
||||
entity_type = wsme_types.wsattr(six.text_type, name='entity-type')
|
||||
entity_uuids = wsme_types.wsattr([six.text_type], name='entity-uuids')
|
||||
entity_names = wsme_types.wsattr([six.text_type], name='entity-names')
|
||||
result = wsme_types.wsattr(six.text_type, name='result')
|
||||
reason = wsme_types.wsattr(six.text_type, name='reason')
|
||||
start_date_time = wsme_types.wsattr(six.text_type, name='start-date-time')
|
||||
end_date_time = wsme_types.wsattr(six.text_type, name='end-date-time')
|
||||
|
||||
|
||||
class SwUpdateStrategyStageData(wsme_types.Base):
|
||||
@ -66,23 +67,23 @@ class SwUpdateStrategyStageData(wsme_types.Base):
|
||||
Software Update Strategy - Stage Data
|
||||
"""
|
||||
stage_id = wsme_types.wsattr(int, name='stage-id')
|
||||
stage_name = wsme_types.wsattr(unicode, name='stage-name')
|
||||
stage_name = wsme_types.wsattr(six.text_type, name='stage-name')
|
||||
timeout = wsme_types.wsattr(int, name='timeout')
|
||||
total_steps = wsme_types.wsattr(int, name='total-steps')
|
||||
current_step = wsme_types.wsattr(int, name='current-step')
|
||||
steps = wsme_types.wsattr([SwUpdateStrategyStageStepData], name='steps')
|
||||
inprogress = wsme_types.wsattr(bool, name='inprogress')
|
||||
result = wsme_types.wsattr(unicode, name='result')
|
||||
reason = wsme_types.wsattr(unicode, name='reason')
|
||||
start_date_time = wsme_types.wsattr(unicode, name='start-date-time')
|
||||
end_date_time = wsme_types.wsattr(unicode, name='end-date-time')
|
||||
result = wsme_types.wsattr(six.text_type, name='result')
|
||||
reason = wsme_types.wsattr(six.text_type, name='reason')
|
||||
start_date_time = wsme_types.wsattr(six.text_type, name='start-date-time')
|
||||
end_date_time = wsme_types.wsattr(six.text_type, name='end-date-time')
|
||||
|
||||
|
||||
class SwUpdateStrategyPhaseData(wsme_types.Base):
|
||||
"""
|
||||
Software Update Strategy - Phase Data
|
||||
"""
|
||||
phase_name = wsme_types.wsattr(unicode, name='phase-name')
|
||||
phase_name = wsme_types.wsattr(six.text_type, name='phase-name')
|
||||
timeout = wsme_types.wsattr(int, name='timeout')
|
||||
total_stages = wsme_types.wsattr(int, name='total-stages')
|
||||
current_stage = wsme_types.wsattr(int, name='current-stage')
|
||||
@ -90,17 +91,17 @@ class SwUpdateStrategyPhaseData(wsme_types.Base):
|
||||
stages = wsme_types.wsattr([SwUpdateStrategyStageData], name='stages')
|
||||
inprogress = wsme_types.wsattr(bool, name='inprogress')
|
||||
completion_percentage = wsme_types.wsattr(int, name='completion-percentage')
|
||||
result = wsme_types.wsattr(unicode, name='result')
|
||||
reason = wsme_types.wsattr(unicode, name='reason')
|
||||
start_date_time = wsme_types.wsattr(unicode, name='start-date-time')
|
||||
end_date_time = wsme_types.wsattr(unicode, name='end-date-time')
|
||||
result = wsme_types.wsattr(six.text_type, name='result')
|
||||
reason = wsme_types.wsattr(six.text_type, name='reason')
|
||||
start_date_time = wsme_types.wsattr(six.text_type, name='start-date-time')
|
||||
end_date_time = wsme_types.wsattr(six.text_type, name='end-date-time')
|
||||
|
||||
|
||||
class SwUpdateStrategyData(wsme_types.Base):
|
||||
"""
|
||||
Software Update Strategy - Data
|
||||
"""
|
||||
uuid = wsme_types.wsattr(unicode, name='uuid')
|
||||
uuid = wsme_types.wsattr(six.text_type, name='uuid')
|
||||
name = wsme_types.wsattr(SwUpdateNames, name='name')
|
||||
controller_apply_type = wsme_types.wsattr(SwUpdateApplyTypes,
|
||||
name='controller-apply-type')
|
||||
@ -116,8 +117,8 @@ class SwUpdateStrategyData(wsme_types.Base):
|
||||
name='default-instance-action')
|
||||
alarm_restrictions = wsme_types.wsattr(SwUpdateAlarmRestrictionTypes,
|
||||
name='alarm-restrictions')
|
||||
state = wsme_types.wsattr(unicode, name='state')
|
||||
current_phase = wsme_types.wsattr(unicode, name='current-phase')
|
||||
state = wsme_types.wsattr(six.text_type, name='state')
|
||||
current_phase = wsme_types.wsattr(six.text_type, name='current-phase')
|
||||
current_phase_completion_percentage \
|
||||
= wsme_types.wsattr(int, name='current-phase-completion-percentage')
|
||||
build_phase = wsme_types.wsattr(SwUpdateStrategyPhaseData, name='build-phase')
|
||||
@ -265,7 +266,7 @@ class SwUpdateStrategyActionAPI(rest.RestController):
|
||||
"""
|
||||
Software Update Strategy Action Rest API
|
||||
"""
|
||||
@wsme_pecan.wsexpose(SwUpdateStrategyQueryData, unicode,
|
||||
@wsme_pecan.wsexpose(SwUpdateStrategyQueryData, six.text_type,
|
||||
body=SwUpdateStrategyActionData,
|
||||
status_code=httplib.ACCEPTED)
|
||||
def post(self, request_data):
|
||||
@ -350,7 +351,7 @@ class SwUpdateStrategyAPI(rest.RestController):
|
||||
"""
|
||||
actions = SwUpdateStrategyActionAPI()
|
||||
|
||||
@wsme_pecan.wsexpose(SwUpdateStrategyQueryData, unicode, status_code=httplib.OK)
|
||||
@wsme_pecan.wsexpose(SwUpdateStrategyQueryData, six.text_type, status_code=httplib.OK)
|
||||
def get_one(self, strategy_uuid):
|
||||
if not validate.valid_uuid_str(strategy_uuid):
|
||||
DLOG.error("Invalid strategy uuid received, uuid=%s." % strategy_uuid)
|
||||
@ -418,7 +419,7 @@ class SwUpdateStrategyAPI(rest.RestController):
|
||||
DLOG.error("Unexpected result received, result=%s." % response.result)
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
@wsme_pecan.wsexpose(None, unicode, body=SwUpdateStrategyDeleteData,
|
||||
@wsme_pecan.wsexpose(None, six.text_type, body=SwUpdateStrategyDeleteData,
|
||||
status_code=httplib.OK)
|
||||
def delete(self, request_data):
|
||||
rpc_request = rpc.APIRequestDeleteSwUpdateStrategy()
|
||||
|
@ -4,6 +4,7 @@
|
||||
#
|
||||
import json
|
||||
import pecan
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@ -25,7 +26,7 @@ class ComputeOperateRequestData(wsme_types.Base):
|
||||
Virtualised Resources - Compute Operate Request Data
|
||||
"""
|
||||
compute_operation = wsme_types.wsattr(ComputeOperationType, mandatory=True)
|
||||
compute_operation_data = wsme_types.wsattr(unicode, mandatory=False,
|
||||
compute_operation_data = wsme_types.wsattr(six.text_type, mandatory=False,
|
||||
default=None)
|
||||
|
||||
|
||||
@ -57,7 +58,7 @@ class ComputeOperateAPI(pecan.rest.RestController):
|
||||
% (rpc_request, response.result))
|
||||
return httplib.INTERNAL_SERVER_ERROR
|
||||
|
||||
@wsme_pecan.wsexpose(None, unicode, body=ComputeOperateRequestData,
|
||||
@wsme_pecan.wsexpose(None, six.text_type, body=ComputeOperateRequestData,
|
||||
status_code=httplib.ACCEPTED)
|
||||
def post(self, compute_id, request_data):
|
||||
"""
|
||||
@ -153,7 +154,7 @@ class ComputeMigrateAPI(pecan.rest.RestController):
|
||||
% (rpc_request, response.result))
|
||||
return httplib.INTERNAL_SERVER_ERROR
|
||||
|
||||
@wsme_pecan.wsexpose(None, unicode, body=ComputeMigrateRequestData,
|
||||
@wsme_pecan.wsexpose(None, six.text_type, body=ComputeMigrateRequestData,
|
||||
status_code=httplib.ACCEPTED)
|
||||
def post(self, compute_id, request_data):
|
||||
"""
|
||||
@ -201,17 +202,17 @@ class ComputeCreateVirtualCpuPinningType(wsme_types.Base):
|
||||
Virtualised Resources - Compute Create Virtual CPU Pinning Type
|
||||
"""
|
||||
cpu_pinning_policy = wsme_types.wsattr(CpuPinningPolicy, mandatory=False)
|
||||
cpu_pinning_map = wsme_types.wsattr(unicode, mandatory=False)
|
||||
cpu_pinning_map = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
|
||||
|
||||
class ComputeCreateVirtualCpuType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Create Virtual CPU Type
|
||||
"""
|
||||
cpu_architecture = wsme_types.wsattr(unicode, mandatory=False)
|
||||
cpu_architecture = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
num_virtual_cpu = wsme_types.wsattr(int, mandatory=True)
|
||||
virtual_cpu_clock = wsme_types.wsattr(int, mandatory=False)
|
||||
virtual_cpu_oversubscription_policy = wsme_types.wsattr(unicode,
|
||||
virtual_cpu_oversubscription_policy = wsme_types.wsattr(six.text_type,
|
||||
mandatory=False)
|
||||
virtual_cpu_pinning = wsme_types.wsattr(ComputeCreateVirtualCpuPinningType,
|
||||
mandatory=False)
|
||||
@ -222,7 +223,7 @@ class ComputeCreateVirtualMemoryType(wsme_types.Base):
|
||||
Virtualised Resources - Compute Create Virtual Memory Type
|
||||
"""
|
||||
virtual_mem_size = wsme_types.wsattr(int, mandatory=True)
|
||||
virtual_mem_oversubscription_policy = wsme_types.wsattr(unicode,
|
||||
virtual_mem_oversubscription_policy = wsme_types.wsattr(six.text_type,
|
||||
mandatory=False)
|
||||
numa_enabled = wsme_types.wsattr(bool, mandatory=False)
|
||||
|
||||
@ -239,7 +240,7 @@ class ComputeCreateFlavourType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Create Flavour Type
|
||||
"""
|
||||
flavour_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
flavour_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
virtual_cpu = wsme_types.wsattr(ComputeCreateVirtualCpuType,
|
||||
mandatory=True)
|
||||
virtual_memory = wsme_types.wsattr(ComputeCreateVirtualMemoryType,
|
||||
@ -252,11 +253,11 @@ class ComputeCreateData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Create Data
|
||||
"""
|
||||
compute_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
reservation_id = wsme_types.wsattr(unicode, mandatory=False)
|
||||
compute_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
reservation_id = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
compute_data = wsme_types.wsattr(ComputeCreateFlavourType, mandatory=True)
|
||||
image_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
meta_data = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
image_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
meta_data = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class ComputeQueryVirtualCpuPinningType(wsme_types.Base):
|
||||
@ -264,17 +265,17 @@ class ComputeQueryVirtualCpuPinningType(wsme_types.Base):
|
||||
Virtualised Resources - Compute Query Virtual CPU Pinning Type
|
||||
"""
|
||||
cpu_pinning_policy = CpuPinningPolicy
|
||||
cpu_pinning_map = [unicode]
|
||||
cpu_pinning_map = [six.text_type]
|
||||
|
||||
|
||||
class ComputeQueryVirtualCpuType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Query Virtual CPU Type
|
||||
"""
|
||||
cpu_architecture = unicode
|
||||
cpu_architecture = six.text_type
|
||||
num_virtual_cpu = int
|
||||
virtual_cpu_clock = int
|
||||
virtual_cpu_oversubscription_policy = unicode
|
||||
virtual_cpu_oversubscription_policy = six.text_type
|
||||
virtual_cpu_pinning = ComputeQueryVirtualCpuPinningType
|
||||
|
||||
|
||||
@ -283,7 +284,7 @@ class ComputeQueryVirtualMemoryType(wsme_types.Base):
|
||||
Virtualised Resources - Compute Query Virtual Memory Type
|
||||
"""
|
||||
virtual_mem_size = int
|
||||
virtual_mem_oversubscription_policy = unicode
|
||||
virtual_mem_oversubscription_policy = six.text_type
|
||||
numa_enabled = bool
|
||||
|
||||
|
||||
@ -299,36 +300,36 @@ class ComputeQueryStorageResourceType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Query Storage Resource Type
|
||||
"""
|
||||
resource_id = unicode
|
||||
resource_id = six.text_type
|
||||
storage_attributes = ComputeQueryVirtualStorageType
|
||||
owner_id = unicode
|
||||
host_id = unicode
|
||||
status = unicode
|
||||
meta_data = unicode
|
||||
owner_id = six.text_type
|
||||
host_id = six.text_type
|
||||
status = six.text_type
|
||||
meta_data = six.text_type
|
||||
|
||||
|
||||
class ComputeQueryAttributesResourceType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Query Attributes Resource Type
|
||||
"""
|
||||
flavour_id = unicode
|
||||
acceleration_capabilities = unicode
|
||||
flavour_id = six.text_type
|
||||
acceleration_capabilities = six.text_type
|
||||
virtual_memory = ComputeQueryVirtualMemoryType
|
||||
virtual_cpu = ComputeQueryVirtualCpuType
|
||||
flavour_original_name = unicode
|
||||
flavour_original_name = six.text_type
|
||||
|
||||
|
||||
class ComputeQueryResourceType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Compute Query Resource Type
|
||||
"""
|
||||
compute_id = unicode
|
||||
compute_id = six.text_type
|
||||
compute_attributes = ComputeQueryAttributesResourceType
|
||||
vc_image_id = unicode
|
||||
vc_image_id = six.text_type
|
||||
virtual_disks = [ComputeQueryStorageResourceType]
|
||||
host_id = unicode
|
||||
status = unicode
|
||||
meta_data = unicode
|
||||
host_id = six.text_type
|
||||
status = six.text_type
|
||||
meta_data = six.text_type
|
||||
|
||||
|
||||
class ComputeQueryData(wsme_types.Base):
|
||||
@ -402,7 +403,7 @@ class ComputesAPI(pecan.rest.RestController):
|
||||
% (compute_id, response.result))
|
||||
return httplib.INTERNAL_SERVER_ERROR
|
||||
|
||||
@wsme_pecan.wsexpose(ComputeQueryData, unicode, status_code=httplib.OK)
|
||||
@wsme_pecan.wsexpose(ComputeQueryData, six.text_type, status_code=httplib.OK)
|
||||
def get_one(self, compute_id):
|
||||
if not validate.valid_uuid_str(compute_id):
|
||||
DLOG.error("Invalid uuid received, uuid=%s." % compute_id)
|
||||
@ -555,7 +556,7 @@ class ComputesAPI(pecan.rest.RestController):
|
||||
% (compute_create_data.compute_id, response.result))
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
@wsme_pecan.wsexpose(None, unicode, status_code=httplib.NO_CONTENT)
|
||||
@wsme_pecan.wsexpose(None, six.text_type, status_code=httplib.NO_CONTENT)
|
||||
def delete(self, compute_id):
|
||||
DLOG.verbose("Compute-API delete called for compute %s." % compute_id)
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
import json
|
||||
import pecan
|
||||
from pecan import rest
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@ -51,8 +52,8 @@ class ImageCreateData(wsme_types.Base):
|
||||
"""
|
||||
Image - Create Data
|
||||
"""
|
||||
name = wsme_types.wsattr(unicode, mandatory=True)
|
||||
description = wsme_types.wsattr(unicode, mandatory=False, default="")
|
||||
name = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
description = wsme_types.wsattr(six.text_type, mandatory=False, default="")
|
||||
container_format = wsme_types.wsattr(ContainerFormatType, mandatory=True)
|
||||
disk_format = wsme_types.wsattr(DiskFormatType, mandatory=True)
|
||||
minimum_disk_size = wsme_types.wsattr(int, mandatory=False, default=0)
|
||||
@ -60,8 +61,8 @@ class ImageCreateData(wsme_types.Base):
|
||||
visibility = wsme_types.wsattr(VisibilityType, mandatory=False,
|
||||
default="public")
|
||||
protected = wsme_types.wsattr(bool, mandatory=False, default=False)
|
||||
properties = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
image_data_ref = wsme_types.wsattr(unicode, mandatory=True)
|
||||
properties = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
image_data_ref = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
|
||||
def __str__(self):
|
||||
return ("name=%s, description=%s, container_format=%s, "
|
||||
@ -78,31 +79,31 @@ class ImageUpdateData(wsme_types.Base):
|
||||
"""
|
||||
Image - Update Data
|
||||
"""
|
||||
description = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
description = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
minimum_disk_size = wsme_types.wsattr(int, mandatory=False, default=None)
|
||||
minimum_memory_size = wsme_types.wsattr(int, mandatory=False, default=None)
|
||||
visibility = wsme_types.wsattr(VisibilityType, mandatory=False,
|
||||
default=None)
|
||||
protected = wsme_types.wsattr(bool, mandatory=False, default=None)
|
||||
properties = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
properties = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class ImageQueryData(wsme_types.Base):
|
||||
"""
|
||||
Image - Query Data
|
||||
"""
|
||||
uuid = unicode
|
||||
name = unicode
|
||||
description = unicode
|
||||
uuid = six.text_type
|
||||
name = six.text_type
|
||||
description = six.text_type
|
||||
container_format = ContainerFormatType
|
||||
disk_format = DiskFormatType
|
||||
minimum_disk_size = int
|
||||
minimum_memory_size = int
|
||||
visibility = VisibilityType
|
||||
protected = unicode
|
||||
availability_status = [unicode]
|
||||
action = unicode
|
||||
properties = unicode
|
||||
protected = six.text_type
|
||||
availability_status = [six.text_type]
|
||||
action = six.text_type
|
||||
properties = six.text_type
|
||||
|
||||
def __json__(self):
|
||||
json_data = dict()
|
||||
@ -168,7 +169,7 @@ class ImageAPI(rest.RestController):
|
||||
% (image_uuid, response.result))
|
||||
return httplib.INTERNAL_SERVER_ERROR
|
||||
|
||||
@wsme_pecan.wsexpose(ImageQueryData, unicode, status_code=httplib.OK)
|
||||
@wsme_pecan.wsexpose(ImageQueryData, six.text_type, status_code=httplib.OK)
|
||||
def get_one(self, image_uuid):
|
||||
DLOG.verbose("Image-API get called for image %s." % image_uuid)
|
||||
|
||||
@ -289,7 +290,7 @@ class ImageAPI(rest.RestController):
|
||||
% (image_create_data.name, response.result))
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
@wsme_pecan.wsexpose(ImageQueryData, unicode, body=ImageUpdateData,
|
||||
@wsme_pecan.wsexpose(ImageQueryData, six.text_type, body=ImageUpdateData,
|
||||
status_code=httplib.OK)
|
||||
def put(self, image_uuid, image_update_data):
|
||||
DLOG.verbose("Image-API update called for image %s." % image_uuid)
|
||||
@ -374,7 +375,7 @@ class ImageAPI(rest.RestController):
|
||||
% (image_uuid, response.result))
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
@wsme_pecan.wsexpose(None, unicode, status_code=httplib.NO_CONTENT)
|
||||
@wsme_pecan.wsexpose(None, six.text_type, status_code=httplib.NO_CONTENT)
|
||||
def delete(self, image_uuid):
|
||||
DLOG.verbose("Image-API delete called for image %s." % image_uuid)
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import pecan
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@ -27,80 +28,80 @@ class NetworkCreateInputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Create Input Data
|
||||
"""
|
||||
network_resource_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
reservation_id = wsme_types.wsattr(unicode, mandatory=False)
|
||||
network_resource_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
reservation_id = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
network_resource_type = wsme_types.wsattr(NetworkResourceClass,
|
||||
mandatory=True)
|
||||
type_network_data = wsme_types.wsattr(NetworkType, mandatory=False,
|
||||
default=None)
|
||||
type_subnet_data = wsme_types.wsattr(NetworkSubnetType, mandatory=False,
|
||||
default=None)
|
||||
meta_data = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
meta_data = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworkCreateOutputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Create Output Data
|
||||
"""
|
||||
operation_result = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
operation_result = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
network_data = wsme_types.wsattr(NetworkResourceType, mandatory=False)
|
||||
subnet_data = wsme_types.wsattr(NetworkSubnetResourceType, mandatory=False)
|
||||
message = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
message = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworkUpdateInputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Create Input Data
|
||||
"""
|
||||
network_resource_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
network_resource_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
update_network_data = wsme_types.wsattr(NetworkType, mandatory=False,
|
||||
default=None)
|
||||
update_subnet_data = wsme_types.wsattr(NetworkSubnetType, mandatory=False,
|
||||
default=None)
|
||||
meta_data = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
meta_data = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworkUpdateOutputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Update Output Data
|
||||
"""
|
||||
operation_result = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
network_resource_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
operation_result = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
network_resource_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
network_data = wsme_types.wsattr(NetworkResourceType, mandatory=False)
|
||||
subnet_data = wsme_types.wsattr(NetworkSubnetResourceType, mandatory=False)
|
||||
message = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
message = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworkDeleteInputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Delete Input Data
|
||||
"""
|
||||
network_resource_ids = wsme_types.wsattr([unicode], mandatory=True)
|
||||
network_resource_ids = wsme_types.wsattr([six.text_type], mandatory=True)
|
||||
|
||||
|
||||
class NetworkDeleteOutputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Delete Output Data
|
||||
"""
|
||||
operation_result = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
network_resource_ids = wsme_types.wsattr([unicode], mandatory=False)
|
||||
message = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
operation_result = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
network_resource_ids = wsme_types.wsattr([six.text_type], mandatory=False)
|
||||
message = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworkQueryOutputData(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Query Output Data
|
||||
"""
|
||||
operation_result = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
operation_result = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
query_result = wsme_types.wsattr([NetworkResourceType], mandatory=False)
|
||||
message = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
message = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworksAPI(pecan.rest.RestController):
|
||||
"""
|
||||
Virtualised Resources - Networks API
|
||||
"""
|
||||
@wsme_pecan.wsexpose(NetworkQueryOutputData, unicode,
|
||||
@wsme_pecan.wsexpose(NetworkQueryOutputData, six.text_type,
|
||||
status_code=httplib.OK)
|
||||
def get_one(self, network_resource_id):
|
||||
DLOG.verbose("Network-API get called for network %s."
|
||||
|
@ -2,6 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import six
|
||||
from wsme import types as wsme_types
|
||||
|
||||
NetworkClass = wsme_types.Enum(str, 'flat', 'vlan', 'vxlan')
|
||||
@ -13,14 +14,14 @@ class NetworkSubnetType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Subnet Type
|
||||
"""
|
||||
network_id = wsme_types.wsattr(unicode, mandatory=False)
|
||||
ip_version = wsme_types.wsattr(unicode, mandatory=True)
|
||||
gateway_ip = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
network_id = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
ip_version = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
gateway_ip = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
is_dhcp_enabled = wsme_types.wsattr(bool, mandatory=False, default=True)
|
||||
meta_data = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
meta_data = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
# Extensions
|
||||
wrs_subnet_ip = wsme_types.wsattr(unicode, mandatory=True)
|
||||
wrs_subnet_ip = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
wrs_subnet_prefix = wsme_types.wsattr(int, mandatory=True)
|
||||
|
||||
|
||||
@ -28,17 +29,17 @@ class NetworkSubnetResourceType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Subnet Resource Type
|
||||
"""
|
||||
resource_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
resource_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
subnet_attributes = wsme_types.wsattr(NetworkSubnetType, mandatory=True)
|
||||
status = wsme_types.wsattr(unicode, mandatory=False)
|
||||
status = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
|
||||
|
||||
class NetworkQosType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network QoS Type
|
||||
"""
|
||||
qos_name = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
qos_value = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
qos_name = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
qos_value = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class NetworkType(wsme_types.Base):
|
||||
@ -48,24 +49,24 @@ class NetworkType(wsme_types.Base):
|
||||
bandwidth = wsme_types.wsattr(int, mandatory=False, default=0)
|
||||
type_of_network = wsme_types.wsattr(NetworkClass, mandatory=False,
|
||||
default=None)
|
||||
type_of_segment = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
type_of_segment = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
network_qos = wsme_types.wsattr([NetworkQosType], mandatory=False,
|
||||
default=list())
|
||||
is_shared = wsme_types.wsattr(bool, mandatory=False, default=False)
|
||||
sharing_criteria = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
sharing_criteria = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
layer3_attributes = wsme_types.wsattr([NetworkSubnetType], mandatory=False,
|
||||
default=list())
|
||||
meta_data = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
meta_data = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
# Extensions
|
||||
wrs_physical_network = wsme_types.wsattr(unicode, mandatory=False)
|
||||
wrs_physical_network = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
|
||||
|
||||
class NetworkResourceType(wsme_types.Base):
|
||||
"""
|
||||
Virtualised Resources - Network Resource Type
|
||||
"""
|
||||
resource_id = wsme_types.wsattr(unicode, mandatory=True)
|
||||
reservation_id = wsme_types.wsattr(unicode, mandatory=False)
|
||||
resource_id = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
reservation_id = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
network_attributes = wsme_types.wsattr(NetworkType, mandatory=True)
|
||||
status = wsme_types.wsattr(unicode, mandatory=False)
|
||||
status = wsme_types.wsattr(six.text_type, mandatory=False)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#
|
||||
import json
|
||||
import pecan
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
@ -21,10 +22,10 @@ class VolumeCreateData(wsme_types.Base):
|
||||
"""
|
||||
Volume - Create Data
|
||||
"""
|
||||
name = wsme_types.wsattr(unicode, mandatory=True)
|
||||
description = wsme_types.wsattr(unicode, mandatory=False, default="")
|
||||
name = wsme_types.wsattr(six.text_type, mandatory=True)
|
||||
description = wsme_types.wsattr(six.text_type, mandatory=False, default="")
|
||||
disk_size = wsme_types.wsattr(int, mandatory=True)
|
||||
image_uuid = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
image_uuid = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
def __str__(self):
|
||||
return ("name=%s, description=%s, disk_size=%s, image_uuid=%s"
|
||||
@ -36,21 +37,21 @@ class VolumeUpdateData(wsme_types.Base):
|
||||
"""
|
||||
Volume - Update Data
|
||||
"""
|
||||
description = wsme_types.wsattr(unicode, mandatory=False, default=None)
|
||||
description = wsme_types.wsattr(six.text_type, mandatory=False, default=None)
|
||||
|
||||
|
||||
class VolumeQueryData(wsme_types.Base):
|
||||
"""
|
||||
Volume - Query Data
|
||||
"""
|
||||
uuid = unicode
|
||||
name = unicode
|
||||
description = unicode
|
||||
disk_size = unicode
|
||||
bootable = unicode
|
||||
encrypted = unicode
|
||||
availability_status = [unicode]
|
||||
action = unicode
|
||||
uuid = six.text_type
|
||||
name = six.text_type
|
||||
description = six.text_type
|
||||
disk_size = six.text_type
|
||||
bootable = six.text_type
|
||||
encrypted = six.text_type
|
||||
availability_status = [six.text_type]
|
||||
action = six.text_type
|
||||
|
||||
def __json__(self):
|
||||
json_data = dict()
|
||||
@ -108,7 +109,7 @@ class VolumeAPI(pecan.rest.RestController):
|
||||
% (volume_uuid, response.result))
|
||||
return httplib.INTERNAL_SERVER_ERROR
|
||||
|
||||
@wsme_pecan.wsexpose(VolumeQueryData, unicode, status_code=httplib.OK)
|
||||
@wsme_pecan.wsexpose(VolumeQueryData, six.text_type, status_code=httplib.OK)
|
||||
def get_one(self, volume_uuid):
|
||||
DLOG.verbose("Volume-API get called for volume %s." % volume_uuid)
|
||||
|
||||
@ -211,7 +212,7 @@ class VolumeAPI(pecan.rest.RestController):
|
||||
% (volume_create_data.name, response.result))
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
@wsme_pecan.wsexpose(VolumeQueryData, unicode, body=VolumeUpdateData,
|
||||
@wsme_pecan.wsexpose(VolumeQueryData, six.text_type, body=VolumeUpdateData,
|
||||
status_code=httplib.OK)
|
||||
def put(self, volume_uuid, volume_update_data):
|
||||
DLOG.verbose("Volume-API update called for volume %s." % volume_uuid)
|
||||
@ -261,7 +262,7 @@ class VolumeAPI(pecan.rest.RestController):
|
||||
% (volume_uuid, response.result))
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
@wsme_pecan.wsexpose(None, unicode, status_code=httplib.NO_CONTENT)
|
||||
@wsme_pecan.wsexpose(None, six.text_type, status_code=httplib.NO_CONTENT)
|
||||
def delete(self, volume_uuid):
|
||||
DLOG.verbose("Volume-API delete called for volume %s." % volume_uuid)
|
||||
|
||||
|
@ -336,10 +336,10 @@ class Token(object):
|
||||
if endpoint is None:
|
||||
endpoint = service_info.endpoint_override
|
||||
else:
|
||||
from urlparse import urlparse
|
||||
from six.moves import urllib
|
||||
# this is necessary to keep tenant_id in place
|
||||
endpoint = \
|
||||
service_info.endpoint_override + urlparse(endpoint).path
|
||||
service_info.endpoint_override + urllib.parse.urlparse(endpoint).path
|
||||
|
||||
if strip_version:
|
||||
endpoint = self._url_strip_version(endpoint)
|
||||
|
@ -71,10 +71,9 @@ verbosity=2
|
||||
# H405: multi line docstring summary not separated with an empty line
|
||||
# H501: Do not use self.__dict__ for string formatting
|
||||
# - flake8 codes -
|
||||
# F821 undefined name 'unicode' (python3 specific)
|
||||
# F823 local variable referenced before assignment
|
||||
# F841 local variable 'e' is assigned to but never used
|
||||
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,H104,H404,H405,H501,F821,F823,F841
|
||||
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,H104,H404,H405,H501,F823,F841
|
||||
# H106 Don’t put vim configuration in source files (off by default).
|
||||
# H203 Use assertIs(Not)None to check for None (off by default).
|
||||
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).
|
||||
|
@ -20,6 +20,7 @@
|
||||
# under the License.
|
||||
#
|
||||
#
|
||||
import six
|
||||
|
||||
|
||||
class ProxyException(Exception):
|
||||
@ -51,4 +52,4 @@ class ProxyException(Exception):
|
||||
if self.__class__.__name__.endswith('_Remote'):
|
||||
return self.args[0]
|
||||
else:
|
||||
return unicode(self)
|
||||
return six.text_type(self)
|
||||
|
Loading…
Reference in New Issue
Block a user