easy_manager 0.9.4 → 0.9.6

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: ab9a57597bbf2084e8677c0744935cfc798c99c63cc07b4503568963f11c3d55
4
- data.tar.gz: ba92b5d4810baa0bbb84348e52d8a55dd098c28f03771092d5c9c8df6a479f22
3
+ metadata.gz: 2f4d3fe63e75058880a12dbb337a1ba5ad42fc3c9fdd560f6f88bb9c1bce42e9
4
+ data.tar.gz: 50993b21c01f7ab2e27f9d643dc7c4e22bf06874883e7a53e6f4ea874d379869
5
5
  SHA512:
6
- metadata.gz: dd711601f7aa4bba050f61fc1be56fd48d838892a4f15bfbf15c82c4488bb2b09fbcc5e40a5f26f5b7b00b3baa19fcff47e8992ee0fdc9efc7451ed9bc4bfc87
7
- data.tar.gz: 8cd4d60852f38458df9f0379e8e2a1a5b217de125f7848ce0e4b1e79263bda328b0f588e5cb7a0882357ca4bca5741c5e084b18336870292490d92fd090884da
6
+ metadata.gz: 48c105b80b325399b5fd5782bb554cf428a325be64849b2d92ae43add2b86b550ca9a4fce65b10020f37049d3a1b8023e9b9e15d083c509d7e30df8558afca99
7
+ data.tar.gz: 9b8c8d3d358849e6910fe4769ab50ea4e3293dcf9228dcee4367f9c1afdbea85a2f158974bac6fb3dcad36e703087587b6040e2311a97a690ed876cd5efd78fd
@@ -18,16 +18,11 @@ class EasyManager
18
18
  Utilities.parse_json(response.body)
19
19
  end
20
20
 
21
- def self.delete(scw, ip_id, tries = 0)
22
- resp = Typhoeus.delete(
21
+ def self.delete(scw, ip_id)
22
+ 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
31
26
  end
32
27
  end
33
28
  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)
@@ -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,31 +87,29 @@ class EasyManager
87
87
  )
88
88
  end
89
89
 
90
- def self.action(scw, srv_id, action, tries = 0)
90
+ def self.action(scw, srv_id, action)
91
91
  data = { action: action }
92
- resp = Typhoeus.post(
92
+ 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
102
97
  end
103
98
 
104
- def self.srv_data(scw, srv_type, image, name_pattern)
99
+ def self.srv_data(scw, srv_type, image, name_pattern, tags)
105
100
  srv_infos = Config.srv_infos(srv_type)
106
101
  image_id = Config.image_id(image)
107
102
  new_ip = Ips.reserve(scw)
108
103
  return if image_id.nil? || srv_infos.nil? || new_ip.nil?
109
104
 
110
105
  {
111
- name: name_pattern.gsub('__RANDOM__', Utilities.random_string), commercial_type: srv_type,
112
- public_ip: new_ip['ip']['id'], project: scw.project,
106
+ name: name_pattern.gsub('__RANDOM__', Utilities.random_string),
107
+ commercial_type: srv_type,
108
+ public_ip: new_ip['ip']['id'],
109
+ project: scw.project,
113
110
  image: image_id,
114
- volumes: { '0' => { size: srv_infos[:volume], volume_type: srv_infos[:volume_type] } }
111
+ volumes: { '0' => { size: srv_infos[:volume], volume_type: srv_infos[:volume_type] } },
112
+ tags: tags
115
113
  }
116
114
  end
117
115
  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
4
+ version: 0.9.6
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-11-08 00:00:00.000000000 Z
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt_pbkdf