Module: Eclair::Aws
Instance Method Summary collapse
- #dns_records(**options) ⇒ Object
- #dns_records? ⇒ Boolean
- #ec2 ⇒ Object
- #images(**options) ⇒ Object
- #images? ⇒ Boolean
- #instance_map ⇒ Object
- #instances ⇒ Object
- #reload_instances ⇒ Object
- #route53 ⇒ Object
- #security_groups(**options) ⇒ Object
- #security_groups? ⇒ Boolean
Instance Method Details
#dns_records(**options) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/eclair/helpers/aws_helper.rb', line 33 def dns_records ** if .delete :force @route53_thread.join end @dns_records || [] end |
#dns_records? ⇒ Boolean
40 41 42 |
# File 'lib/eclair/helpers/aws_helper.rb', line 40 def dns_records? !@route53_thread.alive? end |
#ec2 ⇒ Object
5 6 7 |
# File 'lib/eclair/helpers/aws_helper.rb', line 5 def ec2 @ec2 ||= ::Aws::EC2::Client.new end |
#images(**options) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/eclair/helpers/aws_helper.rb', line 22 def images ** if .delete :force @images_thread.join end @images || [] end |
#images? ⇒ Boolean
29 30 31 |
# File 'lib/eclair/helpers/aws_helper.rb', line 29 def images? !@images_thread.alive? end |
#instance_map ⇒ Object
18 19 20 |
# File 'lib/eclair/helpers/aws_helper.rb', line 18 def instance_map @instance_map end |
#instances ⇒ Object
13 14 15 16 |
# File 'lib/eclair/helpers/aws_helper.rb', line 13 def instances fetch_all unless @instances @instances end |
#reload_instances ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/eclair/helpers/aws_helper.rb', line 55 def reload_instances return if @reload_thread && @reload_thread.alive? if @reload_thread @instances = @r_instances @instance_map = @r_instances_map @images += @new_images @dns_records = @r_dns_records @security_groups = @r_security_groups Grid.assign @reload_thread = nil end return if @last_reloaded && Time.now - @last_reloaded < 5 @reload_thread = Thread.new do r_instances, r_instances_map = fetch_instances @new_instances = r_instances.map(&:instance_id) - @instances.map(&:instance_id) if new_instances.empty? @new_images = [] else image_ids = @new_instances.map(&:image_id) [ Thread.new do @new_images = fetch_images(image_ids) end, Thread.new do @r_security_groups = fetch_security_groups end ].each(&:join) end @last_reloaded = Time.now end end |
#route53 ⇒ Object
9 10 11 |
# File 'lib/eclair/helpers/aws_helper.rb', line 9 def route53 @route53 ||= ::Aws::Route53::Client.new end |
#security_groups(**options) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/eclair/helpers/aws_helper.rb', line 44 def security_groups ** if .delete :force @security_groups_thread.join end @security_groups || [] end |
#security_groups? ⇒ Boolean
51 52 53 |
# File 'lib/eclair/helpers/aws_helper.rb', line 51 def security_groups? !@security_groups_thread.alive? end |