enviroblyd 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1557473923398525894640e93df45810a6333ede11a9b51974071bf80b48509
4
- data.tar.gz: 77a34dabf2f079257158827a8a2f80448c9b19c0d879b194f29dab720ec9de66
3
+ metadata.gz: c88f9afa8cae744a95f4b3813a6ba92b273fb259b6b58815baadc60a889bc698
4
+ data.tar.gz: e1e3938c06ffa662ad066cca2b49d3f69500a04178e264721c78faf954523135
5
5
  SHA512:
6
- metadata.gz: ff373c35e37d10c84fa9d70bde75c12845d99eb89e24f3fb597c9abfad81a20b3646a8be542d4d36b0303893984aa331f3fdfcd19a08abf82509bf21ef53d514
7
- data.tar.gz: 8f6819a56c04a72a18e1b41e9aee4ad5ab9f21adbcd032b8df9ee1440464f871edae1734ef9a13d96dcabb13132caa5fe0dc04cd04c445b86c985f5a7e63bea9
6
+ metadata.gz: ff3a731d3ba7d43faeb6da6573060db09dd0087ceaba056bdbe9d2d6e71223b00ed6452199d895d8d3fcae4a4cd9504708ea82296628d58c6cff11a3a822dbe3
7
+ data.tar.gz: 79a94b0c5a26173b5d10d39da7a513073be4cf280ad6d47c510d211fc8939cfe7ad2eea45e126dc529174ac34ea96b60b5781f3cd4049bd7593927b69b18ef8a
@@ -13,9 +13,13 @@ class Enviroblyd::Cli::Main < Enviroblyd::Base
13
13
  API_HOST = ENV.fetch("ENVIROBLYD_API_HOST", "envirobly.com")
14
14
  desc "boot", "Get IMDSv2 metadata"
15
15
  def boot
16
- token = http("http://#{IMDS_HOST}/latest/api/token").body.chomp("")
16
+ token = http("http://#{IMDS_HOST}/latest/api/token",
17
+ type: Net::HTTP::Put, headers: { "X-aws-ec2-metadata-token-ttl-seconds" => TOKEN_TTL_SECONDS.to_s }).
18
+ body.chomp("")
17
19
  puts "token: #{token} ."
18
- instance_id = http("http://#{IMDS_HOST}/latest/meta-data/instance-id").body.chomp("")
20
+ instance_id = http("http://#{IMDS_HOST}/latest/meta-data/instance-id",
21
+ headers: { "X-aws-ec2-metadata-token" => token }).
22
+ body.chomp("")
19
23
  puts "instance_id: #{instance_id} ."
20
24
 
21
25
  response = http("https://#{API_HOST}/api/v1/boots/#{instance_id}", retry_interval: 3, retries: 5, backoff: :exponential)
@@ -35,8 +39,14 @@ class Enviroblyd::Cli::Main < Enviroblyd::Base
35
39
 
36
40
  yield request if block_given?
37
41
 
38
- response = http.request(request)
39
- if success_codes.include?(response.code.to_i)
42
+ response =
43
+ begin
44
+ http.request(request)
45
+ rescue Net::OpenTimeout, Net::ReadTimeout, Errno::EHOSTUNREACH, Errno::EHOSTDOWN
46
+ nil
47
+ end
48
+
49
+ if response && success_codes.include?(response.code.to_i)
40
50
  response
41
51
  elsif retries <= tries
42
52
  $stderr.puts "Retried #{tries} times. Aborting."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enviroblyd
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enviroblyd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starsi