Example #1
0
        /// <summary>
        /// Query the market for product spot pricing.
        /// </summary>
        protected override void AmazonExecute()
        {
            var request = new DescribeSpotPriceHistoryRequest
            {
                InstanceType = new List <string> {
                    this.InstanceType.Get(this.ActivityContext)
                },
                ProductDescription = new List <string> {
                    this.ProductDescription.Get(this.ActivityContext)
                },
                StartTime = DateTime.Now.ToAmazonDateTime(),
            };

            try
            {
                var response = EC2Client.DescribeSpotPriceHistory(request);

                // Get the first price in the price history array
                decimal price = decimal.Parse(response.DescribeSpotPriceHistoryResult.SpotPriceHistory[0].SpotPrice);
                this.CurrentSpotPrice.Set(this.ActivityContext, price);
            }
            catch (EndpointNotFoundException ex)
            {
                LogBuildMessage(ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Query EC2 for the spot pricing history for a specified instance type.
        /// </summary>
        protected override void AmazonExecute()
        {
            var request = new DescribeSpotPriceHistoryRequest
            {
                InstanceType = new List <string> {
                    this.InstanceType.Get(this.ActivityContext)
                },
                StartTime = this.StartTime.Get(this.ActivityContext).ToAmazonDateTime(),
                EndTime   = this.EndTime.Get(this.ActivityContext).ToAmazonDateTime()
            };

            try
            {
                var response = EC2Client.DescribeSpotPriceHistory(request);
                this.PriceHistory.Set(this.ActivityContext, response.DescribeSpotPriceHistoryResult.SpotPriceHistory);
            }
            catch (EndpointNotFoundException ex)
            {
                this.LogBuildMessage(ex.Message);
            }
        }