

def get_optimal_spot_price(self, conn, instance_type, zone):
    '\n    Returns the spot price for an EC2 instance of the specified instance type.\n    The returned value is computed by averaging all the spot price history\n    values returned by the back-end EC2 APIs and incrementing the average by\n    extra 10%.\n\n    Args:\n      conn: A boto.EC2Connection that can be used to communicate with AWS.\n      instance_type: A str representing the instance type whose prices we\n        should speculate for.\n      zone: A str representing the availability zone that the instance will\n        be placed in.\n    Returns:\n      The estimated spot price for the specified instance type, in the\n        specified availability zone.\n    '
    end_time = datetime.datetime.now()
    start_time = (end_time - datetime.timedelta(days=7))
    history = conn.get_spot_price_history(start_time=start_time.isoformat(), end_time=end_time.isoformat(), product_description='Linux/UNIX', instance_type=instance_type, availability_zone=zone)
    var_sum = 0.0
    for entry in history:
        var_sum += entry.price
    average = (var_sum / len(history))
    bid_price = (average * 1.1)
    AppScaleLogger.log('The average spot instance price for a {0} machine is {1}, and 10% more is {2}'.format(instance_type, average, bid_price))
    return bid_price

dataset/ETHPy150Open AppScale/appscale-tools/lib/agents/ec2_agent.py EC2Agent.get_optimal_spot_price/original