Add registeredAt to ecs container instance (#3358)
This commit is contained in:
parent
08da2c92d9
commit
349b9a990d
@ -1,18 +1,18 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import uuid
|
||||
from copy import copy
|
||||
from datetime import datetime
|
||||
from random import random, randint
|
||||
|
||||
import pytz
|
||||
from boto3 import Session
|
||||
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
from moto.core import BaseBackend, BaseModel, CloudFormationModel
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
from moto.core.utils import unix_time
|
||||
from moto.ec2 import ec2_backends
|
||||
from copy import copy
|
||||
|
||||
from .exceptions import (
|
||||
ServiceNotFoundException,
|
||||
TaskDefinitionNotFoundException,
|
||||
@ -481,6 +481,7 @@ class ContainerInstance(BaseObject):
|
||||
if ec2_instance.platform == "windows"
|
||||
else "linux", # options are windows and linux, linux is default
|
||||
}
|
||||
self.registered_at = datetime.now(pytz.utc)
|
||||
|
||||
@property
|
||||
def response_object(self):
|
||||
@ -489,6 +490,10 @@ class ContainerInstance(BaseObject):
|
||||
self._format_attribute(name, value)
|
||||
for name, value in response_object["attributes"].items()
|
||||
]
|
||||
if isinstance(response_object["registeredAt"], datetime):
|
||||
response_object["registeredAt"] = unix_time(
|
||||
response_object["registeredAt"].replace(tzinfo=None)
|
||||
)
|
||||
return response_object
|
||||
|
||||
def _format_attribute(self, name, value):
|
||||
|
@ -950,6 +950,7 @@ def test_describe_container_instances():
|
||||
for instance in response["containerInstances"]:
|
||||
instance.keys().should.contain("runningTasksCount")
|
||||
instance.keys().should.contain("pendingTasksCount")
|
||||
instance["registeredAt"].should.be.a("datetime.datetime")
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
ecs_client.describe_container_instances(
|
||||
|
Loading…
Reference in New Issue
Block a user