EC2: describe_hosts() now returns the AllocationTime-attribute (#7012)
This commit is contained in:
parent
90e8bb1313
commit
0b84eec6ab
@ -1,5 +1,6 @@
|
||||
from .core import TaggedEC2Resource
|
||||
from ..utils import generic_filter, random_dedicated_host_id
|
||||
from moto.core.utils import unix_time
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
||||
@ -21,6 +22,7 @@ class Host(TaggedEC2Resource):
|
||||
self.instance_family: Optional[str] = instance_family
|
||||
self.auto_placement = auto_placement or "on"
|
||||
self.ec2_backend = backend
|
||||
self.allocation_time = unix_time()
|
||||
|
||||
def release(self) -> None:
|
||||
self.state = "released"
|
||||
|
@ -66,6 +66,7 @@ EC2_DESCRIBE_HOSTS = """<DescribeHostsResult xmlns="http://ec2.amazonaws.com/doc
|
||||
<hostSet>
|
||||
{% for host in hosts %}
|
||||
<item>
|
||||
<allocationTime>{{ host.allocation_time }}</allocationTime>
|
||||
<autoPlacement>{{ host.auto_placement }}</autoPlacement>
|
||||
<availabilityZone>{{ host.zone }}</availabilityZone>
|
||||
<availableCapacity></availableCapacity>
|
||||
|
@ -26,6 +26,7 @@ def test_describe_hosts_with_instancefamily():
|
||||
|
||||
host = client.describe_hosts(HostIds=host_ids)["Hosts"][0]
|
||||
|
||||
assert "AllocationTime" in host
|
||||
assert host["HostProperties"]["InstanceFamily"] == "c5"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user