Remove state field from API
Following the patch [1], this patchset executes the removal of the state field from the API. [1] https://review.opendev.org/c/openstack/cloudkitty/+/774634 Change-Id: I0dfef93c603524b732e6b2694d9c8877826b5ddc
This commit is contained in:
@@ -57,8 +57,6 @@ class ScopeState(base.BaseResource):
|
|||||||
voluptuous.Required('collector'): vutils.get_string_type(),
|
voluptuous.Required('collector'): vutils.get_string_type(),
|
||||||
voluptuous.Optional(
|
voluptuous.Optional(
|
||||||
'last_processed_timestamp'): vutils.get_string_type(),
|
'last_processed_timestamp'): vutils.get_string_type(),
|
||||||
# This "state" property should be removed in the next release.
|
|
||||||
voluptuous.Optional('state'): vutils.get_string_type(),
|
|
||||||
voluptuous.Required('active'): bool,
|
voluptuous.Required('active'): bool,
|
||||||
voluptuous.Optional('scope_activation_toggle_date'):
|
voluptuous.Optional('scope_activation_toggle_date'):
|
||||||
vutils.get_string_type(),
|
vutils.get_string_type(),
|
||||||
@@ -84,7 +82,6 @@ class ScopeState(base.BaseResource):
|
|||||||
'scope_key': r.scope_key,
|
'scope_key': r.scope_key,
|
||||||
'fetcher': r.fetcher,
|
'fetcher': r.fetcher,
|
||||||
'collector': r.collector,
|
'collector': r.collector,
|
||||||
'state': r.last_processed_timestamp.isoformat(),
|
|
||||||
'last_processed_timestamp':
|
'last_processed_timestamp':
|
||||||
r.last_processed_timestamp.isoformat(),
|
r.last_processed_timestamp.isoformat(),
|
||||||
'active': r.active,
|
'active': r.active,
|
||||||
@@ -107,9 +104,6 @@ class ScopeState(base.BaseResource):
|
|||||||
api_utils.MultiQueryParam(str),
|
api_utils.MultiQueryParam(str),
|
||||||
voluptuous.Optional('last_processed_timestamp'):
|
voluptuous.Optional('last_processed_timestamp'):
|
||||||
voluptuous.Coerce(tzutils.dt_from_iso),
|
voluptuous.Coerce(tzutils.dt_from_iso),
|
||||||
# This "state" property should be removed in the next release.
|
|
||||||
voluptuous.Optional('state'):
|
|
||||||
voluptuous.Coerce(tzutils.dt_from_iso),
|
|
||||||
})
|
})
|
||||||
def put(self,
|
def put(self,
|
||||||
all_scopes=False,
|
all_scopes=False,
|
||||||
@@ -117,8 +111,7 @@ class ScopeState(base.BaseResource):
|
|||||||
scope_key=None,
|
scope_key=None,
|
||||||
fetcher=None,
|
fetcher=None,
|
||||||
collector=None,
|
collector=None,
|
||||||
last_processed_timestamp=None,
|
last_processed_timestamp=None):
|
||||||
state=None):
|
|
||||||
|
|
||||||
policy.authorize(
|
policy.authorize(
|
||||||
flask.request.context,
|
flask.request.context,
|
||||||
@@ -130,14 +123,9 @@ class ScopeState(base.BaseResource):
|
|||||||
raise http_exceptions.BadRequest(
|
raise http_exceptions.BadRequest(
|
||||||
"Either all_scopes or a scope_id should be specified.")
|
"Either all_scopes or a scope_id should be specified.")
|
||||||
|
|
||||||
if not state and not last_processed_timestamp:
|
if not last_processed_timestamp:
|
||||||
raise http_exceptions.BadRequest(
|
raise http_exceptions.BadRequest(
|
||||||
"Variables 'state' and 'last_processed_timestamp' cannot be "
|
"Variable 'last_processed_timestamp' cannot be empty/None.")
|
||||||
"empty/None. We expect at least one of them.")
|
|
||||||
if state:
|
|
||||||
LOG.warning("The use of 'state' variable is deprecated, and will "
|
|
||||||
"be removed in the next upcomming release. You should "
|
|
||||||
"consider using 'last_processed_timestamp' variable.")
|
|
||||||
|
|
||||||
results = self._storage_state.get_all(
|
results = self._storage_state.get_all(
|
||||||
identifier=scope_id,
|
identifier=scope_id,
|
||||||
@@ -157,8 +145,6 @@ class ScopeState(base.BaseResource):
|
|||||||
'collector': r.collector,
|
'collector': r.collector,
|
||||||
} for r in results]
|
} for r in results]
|
||||||
|
|
||||||
if not last_processed_timestamp:
|
|
||||||
last_processed_timestamp = state
|
|
||||||
self._client.cast({}, 'reset_state', res_data={
|
self._client.cast({}, 'reset_state', res_data={
|
||||||
'scopes': serialized_results,
|
'scopes': serialized_results,
|
||||||
'last_processed_timestamp': last_processed_timestamp.isoformat()
|
'last_processed_timestamp': last_processed_timestamp.isoformat()
|
||||||
@@ -183,8 +169,6 @@ class ScopeState(base.BaseResource):
|
|||||||
voluptuous.Required('scope_key'): vutils.get_string_type(),
|
voluptuous.Required('scope_key'): vutils.get_string_type(),
|
||||||
voluptuous.Required('fetcher'): vutils.get_string_type(),
|
voluptuous.Required('fetcher'): vutils.get_string_type(),
|
||||||
voluptuous.Required('collector'): vutils.get_string_type(),
|
voluptuous.Required('collector'): vutils.get_string_type(),
|
||||||
# This "state" property should be removed in the next release.
|
|
||||||
voluptuous.Required('state'): vutils.get_string_type(),
|
|
||||||
voluptuous.Optional('last_processed_timestamp'):
|
voluptuous.Optional('last_processed_timestamp'):
|
||||||
voluptuous.Coerce(tzutils.dt_from_iso),
|
voluptuous.Coerce(tzutils.dt_from_iso),
|
||||||
voluptuous.Required('active'): bool,
|
voluptuous.Required('active'): bool,
|
||||||
@@ -228,7 +212,6 @@ class ScopeState(base.BaseResource):
|
|||||||
'scope_key': update_storage_scope.scope_key,
|
'scope_key': update_storage_scope.scope_key,
|
||||||
'fetcher': update_storage_scope.fetcher,
|
'fetcher': update_storage_scope.fetcher,
|
||||||
'collector': update_storage_scope.collector,
|
'collector': update_storage_scope.collector,
|
||||||
'state': update_storage_scope.state.isoformat(),
|
|
||||||
'last_processed_timestamp':
|
'last_processed_timestamp':
|
||||||
update_storage_scope.last_processed_timestamp.isoformat(),
|
update_storage_scope.last_processed_timestamp.isoformat(),
|
||||||
'active': update_storage_scope.active,
|
'active': update_storage_scope.active,
|
||||||
@@ -253,8 +236,6 @@ class ScopeState(base.BaseResource):
|
|||||||
voluptuous.Required('scope_key'): vutils.get_string_type(),
|
voluptuous.Required('scope_key'): vutils.get_string_type(),
|
||||||
voluptuous.Required('fetcher'): vutils.get_string_type(),
|
voluptuous.Required('fetcher'): vutils.get_string_type(),
|
||||||
voluptuous.Required('collector'): vutils.get_string_type(),
|
voluptuous.Required('collector'): vutils.get_string_type(),
|
||||||
# This "state" property should be removed in the next release.
|
|
||||||
voluptuous.Required('state'): vutils.get_string_type(),
|
|
||||||
voluptuous.Optional('last_processed_timestamp'):
|
voluptuous.Optional('last_processed_timestamp'):
|
||||||
voluptuous.Coerce(tzutils.dt_from_iso),
|
voluptuous.Coerce(tzutils.dt_from_iso),
|
||||||
voluptuous.Required('active'): bool,
|
voluptuous.Required('active'): bool,
|
||||||
@@ -291,7 +272,7 @@ class ScopeState(base.BaseResource):
|
|||||||
|
|
||||||
update_storage_scope = storage_scopes[0]
|
update_storage_scope = storage_scopes[0]
|
||||||
last_processed_timestamp = None
|
last_processed_timestamp = None
|
||||||
if update_storage_scope.last_processed_timestamp.isoformat():
|
if update_storage_scope.last_processed_timestamp:
|
||||||
last_processed_timestamp =\
|
last_processed_timestamp =\
|
||||||
update_storage_scope.last_processed_timestamp.isoformat()
|
update_storage_scope.last_processed_timestamp.isoformat()
|
||||||
|
|
||||||
@@ -300,7 +281,6 @@ class ScopeState(base.BaseResource):
|
|||||||
'scope_key': update_storage_scope.scope_key,
|
'scope_key': update_storage_scope.scope_key,
|
||||||
'fetcher': update_storage_scope.fetcher,
|
'fetcher': update_storage_scope.fetcher,
|
||||||
'collector': update_storage_scope.collector,
|
'collector': update_storage_scope.collector,
|
||||||
'state': last_processed_timestamp,
|
|
||||||
'last_processed_timestamp': last_processed_timestamp,
|
'last_processed_timestamp': last_processed_timestamp,
|
||||||
'active': update_storage_scope.active,
|
'active': update_storage_scope.active,
|
||||||
'scope_activation_toggle_date':
|
'scope_activation_toggle_date':
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ tests:
|
|||||||
request_headers:
|
request_headers:
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
data:
|
data:
|
||||||
state: 20190716T085501Z
|
last_processed_timestamp: 20190716T085501Z
|
||||||
all_scopes: true
|
all_scopes: true
|
||||||
|
|
||||||
- name: Reset one scope state
|
- name: Reset one scope state
|
||||||
@@ -129,7 +129,7 @@ tests:
|
|||||||
request_headers:
|
request_headers:
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
data:
|
data:
|
||||||
state: 20190716T085501Z
|
last_processed_timestamp: 20190716T085501Z
|
||||||
scope_id: aaaa
|
scope_id: aaaa
|
||||||
|
|
||||||
- name: Reset several scope states
|
- name: Reset several scope states
|
||||||
@@ -139,7 +139,7 @@ tests:
|
|||||||
request_headers:
|
request_headers:
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
data:
|
data:
|
||||||
state: 20190716T085501Z
|
last_processed_timestamp: 20190716T085501Z
|
||||||
scope_id: aaaa
|
scope_id: aaaa
|
||||||
scope_id: bbbb
|
scope_id: bbbb
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ tests:
|
|||||||
content-type: application/json
|
content-type: application/json
|
||||||
data:
|
data:
|
||||||
scope_key: key1
|
scope_key: key1
|
||||||
state: 20190716T085501Z
|
last_processed_timestamp: 20190716T085501Z
|
||||||
response_strings:
|
response_strings:
|
||||||
- "Either all_scopes or a scope_id should be specified."
|
- "Either all_scopes or a scope_id should be specified."
|
||||||
|
|
||||||
@@ -167,5 +167,5 @@ tests:
|
|||||||
request_headers:
|
request_headers:
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
data:
|
data:
|
||||||
state: 20190716T085501Z
|
last_processed_timestamp: 20190716T085501Z
|
||||||
scope_id: foobar
|
scope_id: foobar
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
The ``state`` field is removed from the scope API.
|
||||||
|
Use ``last_processed_timestamp`` instead.
|
||||||
Reference in New Issue
Block a user