easy_manager 0.9.2 → 0.9.4

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: 11feb80943534098ca933a620ea7face972816314e4292336b34ea432ff0f5b4
4
- data.tar.gz: de1c828f3d43fc9581c9e99045a11741bb77567c1f341b89ac268cfda7544888
3
+ metadata.gz: ab9a57597bbf2084e8677c0744935cfc798c99c63cc07b4503568963f11c3d55
4
+ data.tar.gz: ba92b5d4810baa0bbb84348e52d8a55dd098c28f03771092d5c9c8df6a479f22
5
5
  SHA512:
6
- metadata.gz: 00cd84e57894fee52e4ea070f27db99f3ca3c9f1c8c9df46adf50e5e4c1ccd0f8384b87686d3968cb76d739483559b2528c937cdd542c8e5e1cd6d5c7d7cf909
7
- data.tar.gz: b06fc5f300eccce23a5a3fbbddf25dfc0bfc23b3c76307cd04d6ea4d07afd8c842097d2fb79e3920e4b123aae7b4ad1ba15dcd189f215b6742d5a1b8ac66c934
6
+ metadata.gz: dd711601f7aa4bba050f61fc1be56fd48d838892a4f15bfbf15c82c4488bb2b09fbcc5e40a5f26f5b7b00b3baa19fcff47e8992ee0fdc9efc7451ed9bc4bfc87
7
+ data.tar.gz: 8cd4d60852f38458df9f0379e8e2a1a5b217de125f7848ce0e4b1e79263bda328b0f588e5cb7a0882357ca4bca5741c5e084b18336870292490d92fd090884da
@@ -18,11 +18,16 @@ class EasyManager
18
18
  Utilities.parse_json(response.body)
19
19
  end
20
20
 
21
- def self.delete(scw, ip_id)
22
- Typhoeus.delete(
21
+ def self.delete(scw, ip_id, tries = 0)
22
+ resp = Typhoeus.delete(
23
23
  File.join(scw.api_url, "/instance/v1/zones/#{scw.zone}/ips/#{ip_id}"),
24
24
  headers: scw.headers
25
25
  )
26
+ return resp if resp&.code == 204
27
+
28
+ sleep(rand(10..60))
29
+ tries += 1
30
+ delete(scw, ip_id, tries) unless tries >= 3
26
31
  end
27
32
  end
28
33
  end
@@ -35,9 +35,16 @@ class EasyManager
35
35
  end
36
36
 
37
37
  def delete_by_id(id)
38
+ response = nil
38
39
  servers = list
39
40
 
40
- servers.each { |server| delete(server) if server['id'] == id }
41
+ servers.each do |server|
42
+ next unless server['id'] == id
43
+
44
+ response = delete(server)
45
+ end
46
+
47
+ response
41
48
  end
42
49
 
43
50
  def status(srv)
@@ -48,7 +55,7 @@ class EasyManager
48
55
  Servers.ready?(self, srv, ssh, srv_ready_cmds)
49
56
  end
50
57
 
51
- def wait_until_ready!(srv, ssh, timeout = 300)
58
+ def wait_until_ready!(srv, ssh, timeout = 600)
52
59
  ready = false
53
60
  start = Time.now
54
61
  loop do
@@ -67,7 +74,7 @@ class EasyManager
67
74
  check_cloud_init_cmd = "test -f '/var/log/cloud-init.log' && echo true"
68
75
  cloud_init_ready_cmd = 'tail -1 /var/log/cloud-init-output.log'
69
76
 
70
- [check_cloud_init_cmd, cloud_init_ready_cmd, 'hostname']
77
+ [check_cloud_init_cmd, cloud_init_ready_cmd]
71
78
  end
72
79
  end
73
80
  end
@@ -29,11 +29,11 @@ class EasyManager
29
29
  return unless srv_up?(scw, srv)
30
30
 
31
31
  cmd_values = SSH.cmd_exec(ssh, srv, cmds)
32
- if cmd_values[cmds[0]].empty?
33
- cmd_values['hostname'] == srv['hostname']
34
- else
35
- cmd_values[cmds[1]].include?('The system is finally up')
36
- end
32
+ return unless cmd_values
33
+ return if cmd_values[cmds[0]].empty?
34
+
35
+ cmd_values[cmds[1]].include?('The system is finally up') ||
36
+ cmd_values[cmds[1]].match?(/Cloud-init v.*finished\sat.*Up.*seconds/)
37
37
  end
38
38
 
39
39
  def self.status(scw, srv_id)
@@ -87,13 +87,18 @@ class EasyManager
87
87
  )
88
88
  end
89
89
 
90
- def self.action(scw, srv_id, action)
90
+ def self.action(scw, srv_id, action, tries = 0)
91
91
  data = { action: action }
92
- Typhoeus.post(
92
+ resp = Typhoeus.post(
93
93
  File.join(scw.api_url, "/instance/v1/zones/#{scw.zone}/servers/#{srv_id}/action"),
94
94
  headers: scw.headers,
95
95
  body: data.to_json
96
96
  )
97
+ return resp if resp&.code == 202
98
+
99
+ sleep(rand(10..60))
100
+ tries += 1
101
+ action(scw, srv_id, action, tries) unless tries >= 3
97
102
  end
98
103
 
99
104
  def self.srv_data(scw, srv_type, image, name_pattern)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua MARTINELLE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-31 00:00:00.000000000 Z
11
+ date: 2022-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt_pbkdf