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 +4 -4
- data/lib/enviroblyd/cli/main.rb +14 -4
- data/lib/enviroblyd/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c88f9afa8cae744a95f4b3813a6ba92b273fb259b6b58815baadc60a889bc698
|
4
|
+
data.tar.gz: e1e3938c06ffa662ad066cca2b49d3f69500a04178e264721c78faf954523135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff3a731d3ba7d43faeb6da6573060db09dd0087ceaba056bdbe9d2d6e71223b00ed6452199d895d8d3fcae4a4cd9504708ea82296628d58c6cff11a3a822dbe3
|
7
|
+
data.tar.gz: 79a94b0c5a26173b5d10d39da7a513073be4cf280ad6d47c510d211fc8939cfe7ad2eea45e126dc529174ac34ea96b60b5781f3cd4049bd7593927b69b18ef8a
|
data/lib/enviroblyd/cli/main.rb
CHANGED
@@ -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"
|
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"
|
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 =
|
39
|
-
|
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."
|
data/lib/enviroblyd/version.rb
CHANGED