Switch to providing created_at field for servers

All of the current models return the creation date in created_at
with the exception of servers which are currently returned with
a created field instead.

This patch addresses this and gives the ability to get access to
both.

Change-Id: Ifbd59834080eea62dead19d18a9a11a851a4ce2e
This commit is contained in:
Mohammed Naser 2018-01-19 19:32:00 -08:00 committed by Monty Taylor
parent 4ab1dac7a5
commit 41a7c9f55a
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
4 changed files with 13 additions and 0 deletions

View File

@ -208,6 +208,7 @@ A Server from Nova
accessIPv6=str(), accessIPv6=str(),
addresses=dict(), # string, list(Address) addresses=dict(), # string, list(Address)
created=str(), created=str(),
created_at=str(),
key_name=str(), key_name=str(),
metadata=dict(), # string, string metadata=dict(), # string, string
private_v4=str(), private_v4=str(),

View File

@ -503,6 +503,11 @@ class Normalizer(object):
# Protect against security_groups being None # Protect against security_groups being None
ret['security_groups'] = server.pop('security_groups', None) or [] ret['security_groups'] = server.pop('security_groups', None) or []
# NOTE(mnaser): The Nova API returns the creation date in `created`
# however the Shade contract returns `created_at` for
# all resources.
ret['created_at'] = server.get('created')
for field in _SERVER_FIELDS: for field in _SERVER_FIELDS:
ret[field] = server.pop(field, None) ret[field] = server.pop(field, None)
if not ret['networks']: if not ret['networks']:

View File

@ -575,6 +575,7 @@ class TestUtils(base.TestCase):
u'version': 4}]}, u'version': 4}]},
'adminPass': None, 'adminPass': None,
'created': u'2015-08-01T19:52:16Z', 'created': u'2015-08-01T19:52:16Z',
'created_at': u'2015-08-01T19:52:16Z',
'disk_config': u'MANUAL', 'disk_config': u'MANUAL',
'flavor': {u'id': u'bbcb7eb5-5c8d-498f-9d7e-307c575d3566'}, 'flavor': {u'id': u'bbcb7eb5-5c8d-498f-9d7e-307c575d3566'},
'has_config_drive': True, 'has_config_drive': True,
@ -644,6 +645,7 @@ class TestUtils(base.TestCase):
'cloud': '_test_cloud_', 'cloud': '_test_cloud_',
'config_drive': u'True', 'config_drive': u'True',
'created': u'2015-08-01T19:52:16Z', 'created': u'2015-08-01T19:52:16Z',
'created_at': u'2015-08-01T19:52:16Z',
'disk_config': u'MANUAL', 'disk_config': u'MANUAL',
'flavor': {u'id': u'bbcb7eb5-5c8d-498f-9d7e-307c575d3566'}, 'flavor': {u'id': u'bbcb7eb5-5c8d-498f-9d7e-307c575d3566'},
'has_config_drive': True, 'has_config_drive': True,

View File

@ -0,0 +1,5 @@
---
features:
- The `created` field which was returned by the Nova API is now returned as
`created_at` as well when not using strict mode for consistency with other
models.