diff --git a/senlin/common/utils.py b/senlin/common/utils.py index f84d08e4..acac2cf4 100644 --- a/senlin/common/utils.py +++ b/senlin/common/utils.py @@ -168,14 +168,6 @@ def random_name(length=8): return lead + tail -def format_time(value): - """Cut microsecond and format to isoformat string.""" - if value: - value = value.replace(microsecond=0) - value = value.isoformat() - return value - - def isotime(at): """Stringify time in ISO 8601 format. diff --git a/senlin/engine/cluster.py b/senlin/engine/cluster.py index 80255243..dd19b84a 100644 --- a/senlin/engine/cluster.py +++ b/senlin/engine/cluster.py @@ -208,9 +208,9 @@ class Cluster(object): 'user': self.user, 'project': self.project, 'domain': self.domain, - 'init_at': utils.format_time(self.init_at), - 'created_at': utils.format_time(self.created_at), - 'updated_at': utils.format_time(self.updated_at), + 'init_at': utils.isotime(self.init_at), + 'created_at': utils.isotime(self.created_at), + 'updated_at': utils.isotime(self.updated_at), 'min_size': self.min_size, 'max_size': self.max_size, 'desired_capacity': self.desired_capacity, diff --git a/senlin/engine/node.py b/senlin/engine/node.py index f8db002e..76696afc 100644 --- a/senlin/engine/node.py +++ b/senlin/engine/node.py @@ -197,9 +197,9 @@ class Node(object): 'domain': self.domain, 'index': self.index, 'role': self.role, - 'init_at': utils.format_time(self.init_at), - 'created_at': utils.format_time(self.created_at), - 'updated_at': utils.format_time(self.updated_at), + 'init_at': utils.isotime(self.init_at), + 'created_at': utils.isotime(self.created_at), + 'updated_at': utils.isotime(self.updated_at), 'status': self.status, 'status_reason': self.status_reason, 'data': self.data, diff --git a/senlin/engine/receiver.py b/senlin/engine/receiver.py index 0068d3b1..ab8557dc 100644 --- a/senlin/engine/receiver.py +++ b/senlin/engine/receiver.py @@ -175,8 +175,8 @@ class Receiver(object): 'user': self.user, 'project': self.project, 'domain': self.domain, - 'created_at': utils.format_time(self.created_at), - 'updated_at': utils.format_time(self.updated_at), + 'created_at': utils.isotime(self.created_at), + 'updated_at': utils.isotime(self.updated_at), 'cluster_id': self.cluster_id, 'actor': self.actor, 'action': self.action, diff --git a/senlin/profiles/base.py b/senlin/profiles/base.py index 05c05d55..642caae2 100644 --- a/senlin/profiles/base.py +++ b/senlin/profiles/base.py @@ -338,8 +338,8 @@ class Profile(object): 'domain': self.domain, 'spec': self.spec, 'metadata': self.metadata, - 'created_at': utils.format_time(self.created_at), - 'updated_at': utils.format_time(self.updated_at), + 'created_at': utils.isotime(self.created_at), + 'updated_at': utils.isotime(self.updated_at), } return pb_dict diff --git a/senlin/tests/unit/engine/test_node.py b/senlin/tests/unit/engine/test_node.py index a415adae..814a1b37 100644 --- a/senlin/tests/unit/engine/test_node.py +++ b/senlin/tests/unit/engine/test_node.py @@ -182,9 +182,9 @@ class TestNode(base.SenlinTestCase): 'domain': node.domain, 'index': node.index, 'role': node.role, - 'init_at': common_utils.format_time(node.init_at), - 'created_at': common_utils.format_time(node.created_at), - 'updated_at': common_utils.format_time(node.updated_at), + 'init_at': common_utils.isotime(node.init_at), + 'created_at': common_utils.isotime(node.created_at), + 'updated_at': common_utils.isotime(node.updated_at), 'status': node.status, 'status_reason': node.status_reason, 'data': node.data, @@ -212,9 +212,9 @@ class TestNode(base.SenlinTestCase): 'domain': node.domain, 'index': node.index, 'role': node.role, - 'init_at': common_utils.format_time(node.init_at), - 'created_at': common_utils.format_time(node.created_at), - 'updated_at': common_utils.format_time(node.updated_at), + 'init_at': common_utils.isotime(node.init_at), + 'created_at': common_utils.isotime(node.created_at), + 'updated_at': common_utils.isotime(node.updated_at), 'status': node.status, 'status_reason': node.status_reason, 'data': node.data, diff --git a/senlin/tests/unit/engine/test_receiver.py b/senlin/tests/unit/engine/test_receiver.py index ff0e6931..c160bbbd 100644 --- a/senlin/tests/unit/engine/test_receiver.py +++ b/senlin/tests/unit/engine/test_receiver.py @@ -236,8 +236,8 @@ class TestReceiver(base.SenlinTestCase): 'action': receiver.action, 'actor': receiver.actor, 'params': receiver.params, - 'created_at': common_utils.format_time(receiver.created_at), - 'updated_at': receiver.updated_at, + 'created_at': common_utils.isotime(receiver.created_at), + 'updated_at': common_utils.isotime(receiver.updated_at), 'channel': None, } diff --git a/senlin/tests/unit/profiles/test_profile_base.py b/senlin/tests/unit/profiles/test_profile_base.py index 1a979ee9..66f3273b 100644 --- a/senlin/tests/unit/profiles/test_profile_base.py +++ b/senlin/tests/unit/profiles/test_profile_base.py @@ -672,7 +672,7 @@ class TestProfileBase(base.SenlinTestCase): 'domain': profile.domain, 'spec': profile.spec, 'metadata': profile.metadata, - 'created_at': common_utils.format_time(profile.created_at), + 'created_at': common_utils.isotime(profile.created_at), 'updated_at': None, }