(self)
return response
Boots the instance on AWS
Boots the instance on AWS
Boots the instance on AWS
def request_instance(self):
        """Boots the instance on AWS"""
        print ">> Requesting instance"
        response = self.client.request_spot_instances(
            SpotPrice=str(self.bid),
            ClientToken=self.random_id,
            InstanceCount=1,
            Type='one-time',
            # ValidUntil=datetime.datetime.utcnow() + datetime.timedelta(seconds=60 * 100),
            LaunchSpecification={
                'ImageId': self.ami_id,
                'KeyName': self.key_name,
                'InstanceType': self.instance_type,
                'Placement': {
                    'AvailabilityZone': self.az_zone,
                },
                'EbsOptimized': False,
                'SecurityGroupIds': [
                    self.security_group_id
                ]
            }
        )
        self.spot_instance_request_id = response.get('SpotInstanceRequests')[0].get('SpotInstanceRequestId')
        return response
def request_instance ( self ) : print ">> Requesting instance" response = self . client . request_spot_instances ( SpotPrice = str ( self . bid ) , ClientToken = self . random_id , InstanceCount = 1 , Type = 'one-time' , # ValidUntil=datetime.datetime.utcnow() + datetime.timedelta(seconds=60 * 100), LaunchSpecification = { 'ImageId' : self . ami_id , 'KeyName' : self . key_name , 'InstanceType' : self . instance_type , 'Placement' : { 'AvailabilityZone' : self . az_zone , } , 'EbsOptimized' : False , 'SecurityGroupIds' : [ self . security_group_id ] } ) self . spot_instance_request_id = response . get ( 'SpotInstanceRequests' ) [ 0 ] . get ( 'SpotInstanceRequestId' ) return response