update wsme types

wsproperty and wsattr are in module wsme.types

Change-Id: I6a33c81b7207e14b3bda512381ef809e4a7de4ce
This commit is contained in:
licanwei
2019-05-05 17:28:29 +08:00
parent 8ac5e620f4
commit 8fa8934424
8 changed files with 52 additions and 55 deletions

View File

@@ -117,9 +117,9 @@ class Action(base.APIBase):
uuid = wtypes.wsattr(types.uuid, readonly=True) uuid = wtypes.wsattr(types.uuid, readonly=True)
"""Unique UUID for this action""" """Unique UUID for this action"""
action_plan_uuid = wsme.wsproperty(types.uuid, _get_action_plan_uuid, action_plan_uuid = wtypes.wsproperty(types.uuid, _get_action_plan_uuid,
_set_action_plan_uuid, _set_action_plan_uuid,
mandatory=True) mandatory=True)
"""The action plan this action belongs to """ """The action plan this action belongs to """
state = wtypes.text state = wtypes.text
@@ -137,7 +137,7 @@ class Action(base.APIBase):
parents = wtypes.wsattr(types.jsontype, readonly=True) parents = wtypes.wsattr(types.jsontype, readonly=True)
"""UUIDs of parent actions""" """UUIDs of parent actions"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated action links""" """A list containing a self link and associated action links"""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -95,7 +95,7 @@ class ActionPlanPatchType(types.JsonPatchType):
@staticmethod @staticmethod
def _validate_state(patch): def _validate_state(patch):
serialized_patch = {'path': patch.path, 'op': patch.op} serialized_patch = {'path': patch.path, 'op': patch.op}
if patch.value is not wsme.Unset: if patch.value is not wtypes.Unset:
serialized_patch['value'] = patch.value serialized_patch['value'] = patch.value
# todo: use state machines to handle state transitions # todo: use state machines to handle state transitions
state_value = patch.value state_value = patch.value
@@ -214,19 +214,20 @@ class ActionPlan(base.APIBase):
uuid = wtypes.wsattr(types.uuid, readonly=True) uuid = wtypes.wsattr(types.uuid, readonly=True)
"""Unique UUID for this action plan""" """Unique UUID for this action plan"""
audit_uuid = wsme.wsproperty(types.uuid, _get_audit_uuid, _set_audit_uuid, audit_uuid = wtypes.wsproperty(types.uuid, _get_audit_uuid,
mandatory=True) _set_audit_uuid,
mandatory=True)
"""The UUID of the audit this port belongs to""" """The UUID of the audit this port belongs to"""
strategy_uuid = wsme.wsproperty( strategy_uuid = wtypes.wsproperty(
wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False) wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False)
"""Strategy UUID the action plan refers to""" """Strategy UUID the action plan refers to"""
strategy_name = wsme.wsproperty( strategy_name = wtypes.wsproperty(
wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False) wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False)
"""The name of the strategy this action plan refers to""" """The name of the strategy this action plan refers to"""
efficacy_indicators = wsme.wsproperty( efficacy_indicators = wtypes.wsproperty(
types.jsontype, _get_efficacy_indicators, _set_efficacy_indicators, types.jsontype, _get_efficacy_indicators, _set_efficacy_indicators,
mandatory=True) mandatory=True)
"""The list of efficacy indicators associated to this action plan""" """The list of efficacy indicators associated to this action plan"""
@@ -237,10 +238,10 @@ class ActionPlan(base.APIBase):
state = wtypes.text state = wtypes.text
"""This action plan state""" """This action plan state"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated action links""" """A list containing a self link and associated action links"""
hostname = wsme.wsattr(wtypes.text, mandatory=False) hostname = wtypes.wsattr(wtypes.text, mandatory=False)
"""Hostname the actionplan is running on""" """Hostname the actionplan is running on"""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -71,8 +71,8 @@ def hide_fields_in_newer_versions(obj):
matches or exceeds the versions when these fields were introduced. matches or exceeds the versions when these fields were introduced.
""" """
if not api_utils.allow_start_end_audit_time(): if not api_utils.allow_start_end_audit_time():
obj.start_time = wsme.Unset obj.start_time = wtypes.Unset
obj.end_time = wsme.Unset obj.end_time = wtypes.Unset
class AuditPostType(wtypes.Base): class AuditPostType(wtypes.Base):
@@ -87,12 +87,12 @@ class AuditPostType(wtypes.Base):
audit_type = wtypes.wsattr(wtypes.text, mandatory=True) audit_type = wtypes.wsattr(wtypes.text, mandatory=True)
state = wsme.wsattr(wtypes.text, readonly=True, state = wtypes.wsattr(wtypes.text, readonly=True,
default=objects.audit.State.PENDING) default=objects.audit.State.PENDING)
parameters = wtypes.wsattr({wtypes.text: types.jsontype}, mandatory=False, parameters = wtypes.wsattr({wtypes.text: types.jsontype}, mandatory=False,
default={}) default={})
interval = wsme.wsattr(types.interval_or_cron, mandatory=False) interval = wtypes.wsattr(types.interval_or_cron, mandatory=False)
scope = wtypes.wsattr(types.jsontype, readonly=True) scope = wtypes.wsattr(types.jsontype, readonly=True)
@@ -100,9 +100,9 @@ class AuditPostType(wtypes.Base):
hostname = wtypes.wsattr(wtypes.text, readonly=True, mandatory=False) hostname = wtypes.wsattr(wtypes.text, readonly=True, mandatory=False)
start_time = wsme.wsattr(datetime.datetime, mandatory=False) start_time = wtypes.wsattr(datetime.datetime, mandatory=False)
end_time = wsme.wsattr(datetime.datetime, mandatory=False) end_time = wtypes.wsattr(datetime.datetime, mandatory=False)
def as_audit(self, context): def as_audit(self, context):
audit_type_values = [val.value for val in objects.audit.AuditType] audit_type_values = [val.value for val in objects.audit.AuditType]
@@ -130,7 +130,7 @@ class AuditPostType(wtypes.Base):
if not api_utils.allow_start_end_audit_time(): if not api_utils.allow_start_end_audit_time():
for field in ('start_time', 'end_time'): for field in ('start_time', 'end_time'):
if getattr(self, field) not in (wsme.Unset, None): if getattr(self, field) not in (wtypes.Unset, None):
raise exception.NotAcceptable() raise exception.NotAcceptable()
# If audit_template_uuid was provided, we will provide any # If audit_template_uuid was provided, we will provide any
@@ -316,47 +316,47 @@ class Audit(base.APIBase):
state = wtypes.text state = wtypes.text
"""This audit state""" """This audit state"""
goal_uuid = wsme.wsproperty( goal_uuid = wtypes.wsproperty(
wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True) wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True)
"""Goal UUID the audit refers to""" """Goal UUID the audit refers to"""
goal_name = wsme.wsproperty( goal_name = wtypes.wsproperty(
wtypes.text, _get_goal_name, _set_goal_name, mandatory=False) wtypes.text, _get_goal_name, _set_goal_name, mandatory=False)
"""The name of the goal this audit refers to""" """The name of the goal this audit refers to"""
strategy_uuid = wsme.wsproperty( strategy_uuid = wtypes.wsproperty(
wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False) wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False)
"""Strategy UUID the audit refers to""" """Strategy UUID the audit refers to"""
strategy_name = wsme.wsproperty( strategy_name = wtypes.wsproperty(
wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False) wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False)
"""The name of the strategy this audit refers to""" """The name of the strategy this audit refers to"""
parameters = {wtypes.text: types.jsontype} parameters = {wtypes.text: types.jsontype}
"""The strategy parameters for this audit""" """The strategy parameters for this audit"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated audit links""" """A list containing a self link and associated audit links"""
interval = wsme.wsattr(wtypes.text, mandatory=False) interval = wtypes.wsattr(wtypes.text, mandatory=False)
"""Launch audit periodically (in seconds)""" """Launch audit periodically (in seconds)"""
scope = wsme.wsattr(types.jsontype, mandatory=False) scope = wtypes.wsattr(types.jsontype, mandatory=False)
"""Audit Scope""" """Audit Scope"""
auto_trigger = wsme.wsattr(bool, mandatory=False, default=False) auto_trigger = wtypes.wsattr(bool, mandatory=False, default=False)
"""Autoexecute action plan once audit is succeeded""" """Autoexecute action plan once audit is succeeded"""
next_run_time = wsme.wsattr(datetime.datetime, mandatory=False) next_run_time = wtypes.wsattr(datetime.datetime, mandatory=False)
"""The next time audit launch""" """The next time audit launch"""
hostname = wsme.wsattr(wtypes.text, mandatory=False) hostname = wtypes.wsattr(wtypes.text, mandatory=False)
"""Hostname the audit is running on""" """Hostname the audit is running on"""
start_time = wsme.wsattr(datetime.datetime, mandatory=False) start_time = wtypes.wsattr(datetime.datetime, mandatory=False)
"""The start time for continuous audit launch""" """The start time for continuous audit launch"""
end_time = wsme.wsattr(datetime.datetime, mandatory=False) end_time = wtypes.wsattr(datetime.datetime, mandatory=False)
"""The end time that stopping continuous audit""" """The end time that stopping continuous audit"""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -342,29 +342,29 @@ class AuditTemplate(base.APIBase):
description = wtypes.wsattr(wtypes.text, mandatory=False) description = wtypes.wsattr(wtypes.text, mandatory=False)
"""Short description of this audit template""" """Short description of this audit template"""
goal_uuid = wsme.wsproperty( goal_uuid = wtypes.wsproperty(
wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True) wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True)
"""Goal UUID the audit template refers to""" """Goal UUID the audit template refers to"""
goal_name = wsme.wsproperty( goal_name = wtypes.wsproperty(
wtypes.text, _get_goal_name, _set_goal_name, mandatory=False) wtypes.text, _get_goal_name, _set_goal_name, mandatory=False)
"""The name of the goal this audit template refers to""" """The name of the goal this audit template refers to"""
strategy_uuid = wsme.wsproperty( strategy_uuid = wtypes.wsproperty(
wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False) wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False)
"""Strategy UUID the audit template refers to""" """Strategy UUID the audit template refers to"""
strategy_name = wsme.wsproperty( strategy_name = wtypes.wsproperty(
wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False) wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False)
"""The name of the strategy this audit template refers to""" """The name of the strategy this audit template refers to"""
audits = wsme.wsattr([link.Link], readonly=True) audits = wtypes.wsattr([link.Link], readonly=True)
"""Links to the collection of audits contained in this audit template""" """Links to the collection of audits contained in this audit template"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated audit template links""" """A list containing a self link and associated audit template links"""
scope = wsme.wsattr(types.jsontype, mandatory=False) scope = wtypes.wsattr(types.jsontype, mandatory=False)
"""Audit Scope""" """Audit Scope"""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -34,7 +34,6 @@ Here are some examples of :ref:`Goals <goal_definition>`:
import pecan import pecan
from pecan import rest from pecan import rest
import wsme
from wsme import types as wtypes from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan import wsmeext.pecan as wsme_pecan
@@ -77,7 +76,7 @@ class Goal(base.APIBase):
efficacy_specification = wtypes.wsattr(types.jsontype, readonly=True) efficacy_specification = wtypes.wsattr(types.jsontype, readonly=True)
"""Efficacy specification for this goal""" """Efficacy specification for this goal"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated audit template links""" """A list containing a self link and associated audit template links"""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -29,7 +29,6 @@ be needed by the user of a given scoring engine.
import pecan import pecan
from pecan import rest from pecan import rest
import wsme
from wsme import types as wtypes from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan import wsmeext.pecan as wsme_pecan
@@ -73,7 +72,7 @@ class ScoringEngine(base.APIBase):
metainfo = wtypes.text metainfo = wtypes.text
"""A metadata associated with the scoring engine""" """A metadata associated with the scoring engine"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated action links""" """A list containing a self link and associated action links"""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -26,7 +26,6 @@ from oslo_log import log
from oslo_utils import timeutils from oslo_utils import timeutils
import pecan import pecan
from pecan import rest from pecan import rest
import wsme
from wsme import types as wtypes from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan import wsmeext.pecan as wsme_pecan
@@ -93,7 +92,7 @@ class Service(base.APIBase):
else: else:
self._status = objects.service.ServiceStatus.ACTIVE self._status = objects.service.ServiceStatus.ACTIVE
id = wsme.wsattr(int, readonly=True) id = wtypes.wsattr(int, readonly=True)
"""ID for this service.""" """ID for this service."""
name = wtypes.text name = wtypes.text
@@ -102,13 +101,13 @@ class Service(base.APIBase):
host = wtypes.text host = wtypes.text
"""Host where service is placed on.""" """Host where service is placed on."""
last_seen_up = wsme.wsattr(datetime.datetime, readonly=True) last_seen_up = wtypes.wsattr(datetime.datetime, readonly=True)
"""Time when Watcher service sent latest heartbeat.""" """Time when Watcher service sent latest heartbeat."""
status = wsme.wsproperty(wtypes.text, _get_status, _set_status, status = wtypes.wsproperty(wtypes.text, _get_status, _set_status,
mandatory=True) mandatory=True)
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link.""" """A list containing a self link."""
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@@ -29,7 +29,6 @@ to find an optimal :ref:`Solution <solution_definition>`.
import pecan import pecan
from pecan import rest from pecan import rest
import wsme
from wsme import types as wtypes from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan import wsmeext.pecan as wsme_pecan
@@ -109,15 +108,15 @@ class Strategy(base.APIBase):
display_name = wtypes.text display_name = wtypes.text
"""Localized name of the strategy""" """Localized name of the strategy"""
links = wsme.wsattr([link.Link], readonly=True) links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated goal links""" """A list containing a self link and associated goal links"""
goal_uuid = wsme.wsproperty(wtypes.text, _get_goal_uuid, _set_goal_uuid, goal_uuid = wtypes.wsproperty(wtypes.text, _get_goal_uuid, _set_goal_uuid,
mandatory=True) mandatory=True)
"""The UUID of the goal this audit refers to""" """The UUID of the goal this audit refers to"""
goal_name = wsme.wsproperty(wtypes.text, _get_goal_name, _set_goal_name, goal_name = wtypes.wsproperty(wtypes.text, _get_goal_name, _set_goal_name,
mandatory=False) mandatory=False)
"""The name of the goal this audit refers to""" """The name of the goal this audit refers to"""
parameters_spec = {wtypes.text: types.jsontype} parameters_spec = {wtypes.text: types.jsontype}