From b82507e41b3f603768c1eedd2532ca5123165c2c Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 5 Oct 2014 22:55:36 -0400 Subject: [PATCH] Add instance_id to spot instance requests. Closes #210. --- moto/ec2/responses/spot_instances.py | 2 ++ tests/test_ec2/test_spot_instances.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/moto/ec2/responses/spot_instances.py b/moto/ec2/responses/spot_instances.py index 0cc632909..2ff9595bb 100644 --- a/moto/ec2/responses/spot_instances.py +++ b/moto/ec2/responses/spot_instances.py @@ -96,6 +96,7 @@ REQUEST_SPOT_INSTANCES_TEMPLATE = """YYYY-MM-DDTHH:MM:SS.000Z Your Spot request has been submitted for review, and is pending evaluation. + {{ request.instance_id }} {% if request.availability_zone_group %} {{ request.availability_zone_group }} {% endif %} diff --git a/tests/test_ec2/test_spot_instances.py b/tests/test_ec2/test_spot_instances.py index 26676780b..5db120e71 100644 --- a/tests/test_ec2/test_spot_instances.py +++ b/tests/test_ec2/test_spot_instances.py @@ -180,3 +180,18 @@ def test_get_all_spot_instance_requests_filtering(): requests = conn.get_all_spot_instance_requests(filters={'tag:tag1' : 'value1', 'tag:tag2' : 'value2'}) requests.should.have.length_of(1) + + +@mock_ec2 +def test_request_spot_instances_setting_instance_id(): + conn = boto.connect_ec2() + request = conn.request_spot_instances( + price=0.5, image_id='ami-abcd1234') + + req = get_model('SpotInstanceRequest')[0] + req.state = 'active' + req.instance_id = 'i-12345678' + + request = conn.get_all_spot_instance_requests()[0] + assert request.state == 'active' + assert request.instance_id == 'i-12345678'