Merge "Use ISO8601 format for timestamp fields"

This commit is contained in:
Zuul 2019-04-16 04:22:02 +00:00 committed by Gerrit Code Review
commit 55067a04ed
6 changed files with 34 additions and 14 deletions

View File

@ -3,9 +3,9 @@
"events": [
{
"event": "container__do_container_start",
"finish_time": "2018-03-04 17:03:07+00:00",
"finish_time": "2018-03-04T17:03:07.000000",
"result": "Success",
"start_time": "2018-03-04 17:02:57+00:00",
"start_time": "2018-03-04T17:02:57.000000",
"traceback": null
}
],
@ -13,6 +13,6 @@
"message": null,
"project_id": "853719b303ef4858a195535eb520e58d",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2018-03-04 17:02:54+00:00",
"start_time": "2018-03-04T17:02:54.000000",
"user_id": "22e81669093742b7a74b1d715a9a5813"
}

View File

@ -6,7 +6,7 @@
"message": null,
"project_id": "853719b303ef4858a195535eb520e58d",
"request_id": "req-25517360-b757-47d3-be45-0e8d2a01b36a",
"start_time": "2018-03-04 19:48:49+00:00",
"start_time": "2018-03-04T19:48:49.000000",
"user_id": "22e81669093742b7a74b1d715a9a5813"
},
{
@ -15,7 +15,7 @@
"message": null,
"project_id": "853719b303ef4858a195535eb520e58d",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2018-03-04 17:02:54+00:00",
"start_time": "2018-03-04T17:02:54.000000",
"user_id": "22e81669093742b7a74b1d715a9a5813"
}
]

View File

@ -4,13 +4,13 @@
"binary": "zun-compute",
"availability_zone": "nova",
"state": "up",
"created_at": "2017-02-01 03:25:07+00:00",
"updated_at": "2017-02-01 06:13:07+00:00",
"created_at": "2017-02-01T03:25:07.000000",
"updated_at": "2017-02-01T06:13:07.000000",
"report_count": 166,
"disabled": false,
"host": "instance-1",
"forced_down": false,
"last_seen_up": "2017-02-01 06:13:07+00:00",
"last_seen_up": "2017-02-01T06:13:07.000000",
"disabled_reason": null,
"id": 1
}

View File

@ -11,8 +11,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import itertools
from zun.common import utils
_action_keys = (
'action',
@ -39,7 +42,10 @@ def format_action(action):
if key not in _action_keys:
return
yield (key, value)
if isinstance(value, datetime.datetime):
yield (key, utils.strtime(value))
else:
yield (key, value)
return dict(itertools.chain.from_iterable(
transform(k, v) for k, v in action.as_dict().items()))
@ -50,11 +56,15 @@ def format_event(event, show_traceback=False):
if key not in _action_event_keys:
return
if key == 'traceback' and not show_traceback:
# By default, non-admins are not allowed to see traceback details.
yield (key, None)
if isinstance(value, datetime.datetime):
yield (key, utils.strtime(value))
else:
yield (key, value)
if key == 'traceback' and not show_traceback:
# By default, non-admins are not allowed to see traceback
# details.
yield (key, None)
else:
yield (key, value)
return dict(itertools.chain.from_iterable(
transform(k, v) for k, v in event.as_dict().items()))

View File

@ -11,8 +11,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import itertools
from zun.common import utils
_basic_keys = (
'availability_zone',
@ -34,7 +37,10 @@ def format_service(service):
def transform(key, value):
if key not in _basic_keys:
return
yield (key, value)
if isinstance(value, datetime.datetime):
yield (key, utils.strtime(value))
else:
yield (key, value)
return dict(
itertools.chain.from_iterable(

View File

@ -685,3 +685,7 @@ def decode_file_data(data):
return base64.b64decode(data)
except (TypeError, binascii.Error):
raise exception.Base64Exception()
def strtime(at):
return at.strftime("%Y-%m-%dT%H:%M:%S.%f")