Class: Fog::AWS::Support::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/aws/support.rb,
lib/fog/aws/requests/support/describe_trusted_advisor_checks.rb,
lib/fog/aws/requests/support/describe_trusted_advisor_check_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



77
78
79
# File 'lib/fog/aws/support.rb', line 77

def initialize(options={})
  @region = 'us-east-1'
end

Instance Attribute Details

#regionObject

Returns the value of attribute region.



75
76
77
# File 'lib/fog/aws/support.rb', line 75

def region
  @region
end

Class Method Details

.dataObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/aws/support.rb', line 22

def self.data
  @data ||= Hash.new do |hash, region|
    hash[region] = Hash.new do |region_hash, key|
      tac_id = Fog::Mock.random_hex(5)
      region_hash[key] = {
        :trusted_advisor_checks => {
          tac_id => {
            "category"=>"cost_optimizing",
            "description"=>"Checks the Amazon Elastic Compute Cloud (Amazon EC2) instances that were running at any time during the last 14 days and alerts you if the daily CPU utilization was 10% or less and network I/O was 5 MB or less on 4 or more days. Running instances generate hourly usage charges. Although some scenarios can result in low utilization by design, you can often lower your costs by managing the number and size of your instances.\n<br><br>\nEstimated monthly savings are calculated by using the current usage rate for On-Demand Instances and the estimated number of days the instance might be underutilized. Actual savings will vary if you are using Reserved Instances or Spot Instances, or if the instance is not running for a full day. To get daily utilization data, download the report for this check. \n<br>\n<br>\n<b>Alert Criteria</b><br>\nYellow: An instance had 10% or less daily average CPU utilization and 5 MB or less network I/O on at least 4 of the previous 14 days.<br>\n<br>\n<b>Recommended Action</b><br>\nConsider stopping or terminating instances that have low utilization, or scale the number of instances by using Auto Scaling. For more information, see <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html\" target=\"_blank\">Stop and Start Your Instance</a>, <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html\" target=\"_blank\">Terminate Your Instance</a>, and <a href=\"http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/WhatIsAutoScaling.html\" target=\"_blank\">What is Auto Scaling?</a><br>\n<br>\n<b>Additional Resources</b><br>\n<a href=\"http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-monitoring.html\" target=\"_blank\">Monitoring Amazon EC2</a><br>\n<a href=\"http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html\" target=\"_blank\">Instance Metadata and User Data</a><br>\n<a href=\"http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/Welcome.html\" target=\"_blank\">Amazon CloudWatch Developer Guide</a><br>\n<a href=\"http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/WhatIsAutoScaling.html\" target=\"_blank\">Auto Scaling Developer Guide</a>",
            "id"=>tac_id,
            "metadata"=>["Region/AZ", "Instance ID", "Instance Name", "Instance Type", "Estimated Monthly Savings", "Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7", "Day 8", "Day 9", "Day 10", "Day 11", "Day 12", "Day 13", "Day 14", "14-Day Average CPU Utilization", "14-Day Average Network I/O", "Number of Days Low Utilization"],
            "name"=>"Low Utilization Amazon EC2 Instances"
          }
        },
        :trusted_advisor_check_results => {
          tac_id => {
            'checkId'          => tac_id,
            'status'           => "warning",
            'timestamp'        => "2016-09-18T13:19:35Z",
            'resourcesSummary' => {
              "resourcesFlagged"    => 40,
              "resourcesIgnored"    => 0,
              "resourcesProcessed"  => 47,
              "resourcesSuppressed" => 0
            },
            'categorySpecificSummary' => {
              "costOptimizing" => {
                "estimatedMonthlySavings"        => 4156.920000000003,
                "estimatedPercentMonthlySavings" => 0.9918398900532555
              }
            },
            'flaggedResources' => [{
              "region"       => "us-west-2",
              "resourceId"   => Fog::Mock.random_hex(22),
              "status"       => "warning",
              "isSuppressed" => false,
              "metadata"     => ["us-west-2a", "i-#{Fog::Mock.random_hex(5)}", "instance_tags", "m3.large", "$95.76", "2.3%  0.23MB", "2.3%  0.20MB", "2.3%  0.21MB", "2.4%  0.28MB", "2.3%  0.20MB", "2.3%  0.20MB", "2.3%  0.20MB", "2.3%  0.20MB", "2.3%  0.20MB", "2.3%  0.20MB", "2.6%  0.54MB", "2.4%  0.31MB", "2.3%  0.21MB", "2.3%  0.20MB", "2.3%", "0.24MB", "14 days"]
            }]
          }
        }
      }
    end
  end
end

.resetObject



67
68
69
# File 'lib/fog/aws/support.rb', line 67

def self.reset
  @data = nil
end

Instance Method Details

#dataObject



81
82
83
# File 'lib/fog/aws/support.rb', line 81

def data
  self.class.data[@region][@aws_access_key_id]
end

#describe_trusted_advisor_check_result(options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/fog/aws/requests/support/describe_trusted_advisor_check_result.rb', line 23

def describe_trusted_advisor_check_result(options={})
  response = Excon::Response.new
  response.body = {'result' => self.data[:trusted_advisor_check_results][options[:id]]}
  response
end

#describe_trusted_advisor_checks(options = {}) ⇒ Object



21
22
23
24
25
# File 'lib/fog/aws/requests/support/describe_trusted_advisor_checks.rb', line 21

def describe_trusted_advisor_checks(options={})
  response = Excon::Response.new
  response.body = {'checks' => self.data[:trusted_advisor_checks].values}
  response
end

#resetObject



71
72
73
# File 'lib/fog/aws/support.rb', line 71

def reset
  self.class.reset
end