Class: Opswatch::AwsPoller
- Inherits:
-
Object
- Object
- Opswatch::AwsPoller
- Defined in:
- lib/aws_poller.rb
Instance Method Summary collapse
-
#initialize(params) ⇒ AwsPoller
constructor
A new instance of AwsPoller.
- #poll ⇒ Object
Constructor Details
#initialize(params) ⇒ AwsPoller
Returns a new instance of AwsPoller.
5 6 7 8 9 |
# File 'lib/aws_poller.rb', line 5 def initialize(params) credentials = Aws::Credentials.new(params['iam_user'], params['iam_secret']) @client = Aws::OpsWorks::Client.new(region: params['region'], credentials: credentials) @stack_id = params['stack_id'] end |
Instance Method Details
#poll ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aws_poller.rb', line 11 def poll ret = {} begin stack_resp = @client.describe_stack_summary(stack_id: @stack_id) deploy_resp = @client.describe_deployments(stack_id: @stack_id).deployments.first ret[:online] = stack_resp.stack_summary.instances_count.online ret[:running_setup] = stack_resp.stack_summary.instances_count.running_setup ret[:setup_failed] = stack_resp.stack_summary.instances_count.setup_failed ret[:start_failed] = stack_resp.stack_summary.instances_count.start_failed ret[:deploy_state] = deploy_resp.status ret rescue StandardError ret[:exception] = true ret end end |