Class: Ec2spec::Client
- Inherits:
-
Object
- Object
- Ec2spec::Client
- Defined in:
- lib/ec2spec/client.rb
Constant Summary collapse
- META_DATA_URL_BASE =
'http://169.254.169.254/latest/meta-data/'- META_DATA_INSTANCE_TYPE_PATH =
'/instance-type'- META_DATA_INSTANCE_ID_PATH =
'/instance-id'- DEFAULT_REGION =
'ap-northeast-1'- OUTPUT_FORMATTERS =
{ plain_text: PlainTextFormatter, json: JsonFormatter, hash: HashFormatter, }
Instance Method Summary collapse
-
#initialize(hosts, days, format, region = DEFAULT_REGION) ⇒ Client
constructor
A new instance of Client.
- #run ⇒ Object
Constructor Details
#initialize(hosts, days, format, region = DEFAULT_REGION) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 |
# File 'lib/ec2spec/client.rb', line 20 def initialize(hosts, days, format, region = DEFAULT_REGION) @hosts = hosts @days = days @format = format @region = region extend_formatter OfferFile.instance.prepare(@region) end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ec2spec/client.rb', line 30 def run hosts = @hosts.map { |host| target(host) } threads = hosts.map do |host| Thread.start(host.backend) do |backend| exec_host_result(host, backend) end end results = threads.each(&:join).map(&:value) output(results, @hosts) end |