From 8fa89344243d572dcefe242248711e4a02ab0bec Mon Sep 17 00:00:00 2001
From: licanwei
Date: Sun, 5 May 2019 17:28:29 +0800
Subject: [PATCH] update wsme types
wsproperty and wsattr are in module wsme.types
Change-Id: I6a33c81b7207e14b3bda512381ef809e4a7de4ce
---
watcher/api/controllers/v1/action.py | 8 ++--
watcher/api/controllers/v1/action_plan.py | 17 +++++----
watcher/api/controllers/v1/audit.py | 40 ++++++++++----------
watcher/api/controllers/v1/audit_template.py | 14 +++----
watcher/api/controllers/v1/goal.py | 3 +-
watcher/api/controllers/v1/scoring_engine.py | 3 +-
watcher/api/controllers/v1/service.py | 11 +++---
watcher/api/controllers/v1/strategy.py | 11 +++---
8 files changed, 52 insertions(+), 55 deletions(-)
diff --git a/watcher/api/controllers/v1/action.py b/watcher/api/controllers/v1/action.py
index 0aae7bf44..73e9a17f7 100644
--- a/watcher/api/controllers/v1/action.py
+++ b/watcher/api/controllers/v1/action.py
@@ -117,9 +117,9 @@ class Action(base.APIBase):
uuid = wtypes.wsattr(types.uuid, readonly=True)
"""Unique UUID for this action"""
- action_plan_uuid = wsme.wsproperty(types.uuid, _get_action_plan_uuid,
- _set_action_plan_uuid,
- mandatory=True)
+ action_plan_uuid = wtypes.wsproperty(types.uuid, _get_action_plan_uuid,
+ _set_action_plan_uuid,
+ mandatory=True)
"""The action plan this action belongs to """
state = wtypes.text
@@ -137,7 +137,7 @@ class Action(base.APIBase):
parents = wtypes.wsattr(types.jsontype, readonly=True)
"""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"""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/action_plan.py b/watcher/api/controllers/v1/action_plan.py
index 1dd1c0a98..3c18729e6 100644
--- a/watcher/api/controllers/v1/action_plan.py
+++ b/watcher/api/controllers/v1/action_plan.py
@@ -95,7 +95,7 @@ class ActionPlanPatchType(types.JsonPatchType):
@staticmethod
def _validate_state(patch):
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
# todo: use state machines to handle state transitions
state_value = patch.value
@@ -214,19 +214,20 @@ class ActionPlan(base.APIBase):
uuid = wtypes.wsattr(types.uuid, readonly=True)
"""Unique UUID for this action plan"""
- audit_uuid = wsme.wsproperty(types.uuid, _get_audit_uuid, _set_audit_uuid,
- mandatory=True)
+ audit_uuid = wtypes.wsproperty(types.uuid, _get_audit_uuid,
+ _set_audit_uuid,
+ mandatory=True)
"""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)
"""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)
"""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,
mandatory=True)
"""The list of efficacy indicators associated to this action plan"""
@@ -237,10 +238,10 @@ class ActionPlan(base.APIBase):
state = wtypes.text
"""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"""
- hostname = wsme.wsattr(wtypes.text, mandatory=False)
+ hostname = wtypes.wsattr(wtypes.text, mandatory=False)
"""Hostname the actionplan is running on"""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/audit.py b/watcher/api/controllers/v1/audit.py
index 3d6cf18ff..f31536e9a 100644
--- a/watcher/api/controllers/v1/audit.py
+++ b/watcher/api/controllers/v1/audit.py
@@ -71,8 +71,8 @@ def hide_fields_in_newer_versions(obj):
matches or exceeds the versions when these fields were introduced.
"""
if not api_utils.allow_start_end_audit_time():
- obj.start_time = wsme.Unset
- obj.end_time = wsme.Unset
+ obj.start_time = wtypes.Unset
+ obj.end_time = wtypes.Unset
class AuditPostType(wtypes.Base):
@@ -87,12 +87,12 @@ class AuditPostType(wtypes.Base):
audit_type = wtypes.wsattr(wtypes.text, mandatory=True)
- state = wsme.wsattr(wtypes.text, readonly=True,
- default=objects.audit.State.PENDING)
+ state = wtypes.wsattr(wtypes.text, readonly=True,
+ default=objects.audit.State.PENDING)
parameters = wtypes.wsattr({wtypes.text: types.jsontype}, mandatory=False,
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)
@@ -100,9 +100,9 @@ class AuditPostType(wtypes.Base):
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):
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():
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()
# If audit_template_uuid was provided, we will provide any
@@ -316,47 +316,47 @@ class Audit(base.APIBase):
state = wtypes.text
"""This audit state"""
- goal_uuid = wsme.wsproperty(
+ goal_uuid = wtypes.wsproperty(
wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True)
"""Goal UUID the audit refers to"""
- goal_name = wsme.wsproperty(
+ goal_name = wtypes.wsproperty(
wtypes.text, _get_goal_name, _set_goal_name, mandatory=False)
"""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)
"""Strategy UUID the audit refers to"""
- strategy_name = wsme.wsproperty(
+ strategy_name = wtypes.wsproperty(
wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False)
"""The name of the strategy this audit refers to"""
parameters = {wtypes.text: types.jsontype}
"""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"""
- interval = wsme.wsattr(wtypes.text, mandatory=False)
+ interval = wtypes.wsattr(wtypes.text, mandatory=False)
"""Launch audit periodically (in seconds)"""
- scope = wsme.wsattr(types.jsontype, mandatory=False)
+ scope = wtypes.wsattr(types.jsontype, mandatory=False)
"""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"""
- next_run_time = wsme.wsattr(datetime.datetime, mandatory=False)
+ next_run_time = wtypes.wsattr(datetime.datetime, mandatory=False)
"""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"""
- start_time = wsme.wsattr(datetime.datetime, mandatory=False)
+ start_time = wtypes.wsattr(datetime.datetime, mandatory=False)
"""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"""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/audit_template.py b/watcher/api/controllers/v1/audit_template.py
index 757654c95..b493270a8 100644
--- a/watcher/api/controllers/v1/audit_template.py
+++ b/watcher/api/controllers/v1/audit_template.py
@@ -342,29 +342,29 @@ class AuditTemplate(base.APIBase):
description = wtypes.wsattr(wtypes.text, mandatory=False)
"""Short description of this audit template"""
- goal_uuid = wsme.wsproperty(
+ goal_uuid = wtypes.wsproperty(
wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True)
"""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)
"""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)
"""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)
"""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 = wsme.wsattr([link.Link], readonly=True)
+ links = wtypes.wsattr([link.Link], readonly=True)
"""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"""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/goal.py b/watcher/api/controllers/v1/goal.py
index 831031272..3e87091db 100644
--- a/watcher/api/controllers/v1/goal.py
+++ b/watcher/api/controllers/v1/goal.py
@@ -34,7 +34,6 @@ Here are some examples of :ref:`Goals `:
import pecan
from pecan import rest
-import wsme
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
@@ -77,7 +76,7 @@ class Goal(base.APIBase):
efficacy_specification = wtypes.wsattr(types.jsontype, readonly=True)
"""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"""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/scoring_engine.py b/watcher/api/controllers/v1/scoring_engine.py
index ee7323e02..8f439dcd2 100644
--- a/watcher/api/controllers/v1/scoring_engine.py
+++ b/watcher/api/controllers/v1/scoring_engine.py
@@ -29,7 +29,6 @@ be needed by the user of a given scoring engine.
import pecan
from pecan import rest
-import wsme
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
@@ -73,7 +72,7 @@ class ScoringEngine(base.APIBase):
metainfo = wtypes.text
"""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"""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/service.py b/watcher/api/controllers/v1/service.py
index eb047aee2..24709e1f2 100644
--- a/watcher/api/controllers/v1/service.py
+++ b/watcher/api/controllers/v1/service.py
@@ -26,7 +26,6 @@ from oslo_log import log
from oslo_utils import timeutils
import pecan
from pecan import rest
-import wsme
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
@@ -93,7 +92,7 @@ class Service(base.APIBase):
else:
self._status = objects.service.ServiceStatus.ACTIVE
- id = wsme.wsattr(int, readonly=True)
+ id = wtypes.wsattr(int, readonly=True)
"""ID for this service."""
name = wtypes.text
@@ -102,13 +101,13 @@ class Service(base.APIBase):
host = wtypes.text
"""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."""
- status = wsme.wsproperty(wtypes.text, _get_status, _set_status,
- mandatory=True)
+ status = wtypes.wsproperty(wtypes.text, _get_status, _set_status,
+ mandatory=True)
- links = wsme.wsattr([link.Link], readonly=True)
+ links = wtypes.wsattr([link.Link], readonly=True)
"""A list containing a self link."""
def __init__(self, **kwargs):
diff --git a/watcher/api/controllers/v1/strategy.py b/watcher/api/controllers/v1/strategy.py
index cc89a09a5..d7c928097 100644
--- a/watcher/api/controllers/v1/strategy.py
+++ b/watcher/api/controllers/v1/strategy.py
@@ -29,7 +29,6 @@ to find an optimal :ref:`Solution `.
import pecan
from pecan import rest
-import wsme
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
@@ -109,15 +108,15 @@ class Strategy(base.APIBase):
display_name = wtypes.text
"""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"""
- goal_uuid = wsme.wsproperty(wtypes.text, _get_goal_uuid, _set_goal_uuid,
- mandatory=True)
+ goal_uuid = wtypes.wsproperty(wtypes.text, _get_goal_uuid, _set_goal_uuid,
+ mandatory=True)
"""The UUID of the goal this audit refers to"""
- goal_name = wsme.wsproperty(wtypes.text, _get_goal_name, _set_goal_name,
- mandatory=False)
+ goal_name = wtypes.wsproperty(wtypes.text, _get_goal_name, _set_goal_name,
+ mandatory=False)
"""The name of the goal this audit refers to"""
parameters_spec = {wtypes.text: types.jsontype}