easy_manager 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/easymanager/scaleway/ips.rb +7 -2
- data/lib/easymanager/scaleway/main.rb +3 -2
- data/lib/easymanager/scaleway/servers.rb +16 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c69241067a306ea8a4121569bb19963b9531cc8ba7a44ba01be9c742220a8f1
|
4
|
+
data.tar.gz: d14b0fc7bb8d684acfa7c836765ad86bcc562b69507262a2161a6312e40afbea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55e47bd71a06f13344ead528da9276e682739af5eb2269f72a368072113c87a394609dc47bbb0f73fd93c96fca01ae6fdd7d42a696cdd03652315174abaa3166
|
7
|
+
data.tar.gz: 811d7c1e4033c69ac3738796ed984a630cb9f31f28eee2b30c1364438a9ebed309bf8b8901c4a4c13afdc5ce6a8eec313ef562aa5c39701118db80d2226bc21f
|
@@ -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
|
@@ -25,9 +25,10 @@ class EasyManager
|
|
25
25
|
srv_type = options[:srv_type] || 'DEV1-S'
|
26
26
|
image = options[:image] || 'ubuntu-jammy'
|
27
27
|
name_pattern = options[:name_pattern] || 'scw-easymanager-__RANDOM__'
|
28
|
+
tags = options[:tags] || []
|
28
29
|
cloud_init = options[:cloud_init] || false
|
29
30
|
|
30
|
-
Servers.create(self, srv_type, image, name_pattern, cloud_init)
|
31
|
+
Servers.create(self, srv_type, image, name_pattern, tags, cloud_init)
|
31
32
|
end
|
32
33
|
|
33
34
|
def delete(srv)
|
@@ -55,7 +56,7 @@ class EasyManager
|
|
55
56
|
Servers.ready?(self, srv, ssh, srv_ready_cmds)
|
56
57
|
end
|
57
58
|
|
58
|
-
def wait_until_ready!(srv, ssh, timeout =
|
59
|
+
def wait_until_ready!(srv, ssh, timeout = 600)
|
59
60
|
ready = false
|
60
61
|
start = Time.now
|
61
62
|
loop do
|
@@ -49,8 +49,8 @@ class EasyManager
|
|
49
49
|
json_body['server']['state']
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.create(scw, srv_type, image, name_pattern, cloud_init)
|
53
|
-
data = srv_data(scw, srv_type, image, name_pattern)
|
52
|
+
def self.create(scw, srv_type, image, name_pattern, tags, cloud_init)
|
53
|
+
data = srv_data(scw, srv_type, image, name_pattern, tags)
|
54
54
|
return if data.nil?
|
55
55
|
|
56
56
|
response = Typhoeus.post(File.join(scw.api_url, "/instance/v1/zones/#{scw.zone}/servers/"),
|
@@ -87,26 +87,34 @@ 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
|
-
def self.srv_data(scw, srv_type, image, name_pattern)
|
104
|
+
def self.srv_data(scw, srv_type, image, name_pattern, tags)
|
100
105
|
srv_infos = Config.srv_infos(srv_type)
|
101
106
|
image_id = Config.image_id(image)
|
102
107
|
new_ip = Ips.reserve(scw)
|
103
108
|
return if image_id.nil? || srv_infos.nil? || new_ip.nil?
|
104
109
|
|
105
110
|
{
|
106
|
-
name: name_pattern.gsub('__RANDOM__', Utilities.random_string),
|
107
|
-
|
111
|
+
name: name_pattern.gsub('__RANDOM__', Utilities.random_string),
|
112
|
+
commercial_type: srv_type,
|
113
|
+
public_ip: new_ip['ip']['id'],
|
114
|
+
project: scw.project,
|
108
115
|
image: image_id,
|
109
|
-
volumes: { '0' => { size: srv_infos[:volume], volume_type: srv_infos[:volume_type] } }
|
116
|
+
volumes: { '0' => { size: srv_infos[:volume], volume_type: srv_infos[:volume_type] } },
|
117
|
+
tags: tags
|
110
118
|
}
|
111
119
|
end
|
112
120
|
end
|
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.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua MARTINELLE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt_pbkdf
|