Have spot requests launch instances.
This commit is contained in:
parent
24035877f6
commit
5c3d9b4ae1
5 changed files with 111 additions and 74 deletions
|
|
@ -2517,6 +2517,8 @@ class SpotInstanceRequest(BotoSpotRequest, TaggedEC2Resource):
|
|||
default_group = self.ec2_backend.get_security_group_from_name("default")
|
||||
ls.groups.append(default_group)
|
||||
|
||||
self.instance = self.launch_instance()
|
||||
|
||||
def get_filter_value(self, filter_name):
|
||||
if filter_name == 'state':
|
||||
return self.state
|
||||
|
|
@ -2529,6 +2531,18 @@ class SpotInstanceRequest(BotoSpotRequest, TaggedEC2Resource):
|
|||
|
||||
return filter_value
|
||||
|
||||
def launch_instance(self):
|
||||
reservation = self.ec2_backend.add_instances(
|
||||
image_id=self.launch_specification.image_id, count=1, user_data=self.user_data,
|
||||
instance_type=self.launch_specification.instance_type,
|
||||
subnet_id=self.launch_specification.subnet_id,
|
||||
key_name=self.launch_specification.key_name,
|
||||
security_group_names=[],
|
||||
security_group_ids=self.launch_specification.groups,
|
||||
)
|
||||
instance = reservation.instances[0]
|
||||
return instance
|
||||
|
||||
|
||||
@six.add_metaclass(Model)
|
||||
class SpotRequestBackend(object):
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ DESCRIBE_SPOT_FLEET_INSTANCES_TEMPLATE = """<DescribeSpotFleetInstancesResponse
|
|||
<activeInstanceSet>
|
||||
{% for spot_request in spot_requests %}
|
||||
<item>
|
||||
<instanceId>{{ spot_request.instance_id }}</instanceId>
|
||||
<instanceId>{{ spot_request.instance.id }}</instanceId>
|
||||
<spotInstanceRequestId>{{ spot_request.id }}</spotInstanceRequestId>
|
||||
<instanceType>{{ spot_request.instance_type }}</instanceType>
|
||||
<instanceType>{{ spot_request.instance.instance_type }}</instanceType>
|
||||
</item>
|
||||
{% endfor %}
|
||||
</activeInstanceSet>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue