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