Skip to content

Commit

Permalink
EC2: describe_hosts() now returns the AllocationTime-attribute (getmo…
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Nov 9, 2023
1 parent 90e8bb1 commit 0b84eec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions moto/ec2/models/hosts.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -21,6 +22,7 @@ def __init__(
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"
Expand Down
1 change: 1 addition & 0 deletions moto/ec2/responses/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def release_hosts(self) -> str:
<hostSet>
{% for host in hosts %}
<item>
<allocationTime>{{ host.allocation_time }}</allocationTime>
<autoPlacement>{{ host.auto_placement }}</autoPlacement>
<availabilityZone>{{ host.zone }}</availabilityZone>
<availableCapacity></availableCapacity>
Expand Down
1 change: 1 addition & 0 deletions tests/test_ec2/test_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down

0 comments on commit 0b84eec

Please sign in to comment.