onlyoffice_digitalocean_wrapper 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper.rb +6 -5
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/exceptions_retryer.rb +1 -1
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/getters.rb +7 -7
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/logger_wrapper.rb +13 -0
- data/lib/onlyoffice_digitalocean_wrapper/version.rb +1 -1
- metadata +6 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a48169cbc53f211b24f0956d8591465c7569450a04fa7f38a4614d004f7e748
|
4
|
+
data.tar.gz: aeda8616dfbc66abe0674cd79daf564b1aa98941b1eb66cc08aa03c9af831282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05c74d20d448499946ef83c8710aed8f7fcdf2bebd65b6f522c672f602956868920b4377056fc505ce5ac6b0a6fef364f9a0a23547cdab43713cbc24112a4902
|
7
|
+
data.tar.gz: 7da944f64237a89ecf4bc966099c8ab102e783ca5d262075159bb8e5b2fbf37c44e2379ed6307d0c3880bdbbd361eb2b40787527b66139df3b910ab099cfe8e6
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'droplet_kit'
|
4
|
-
require 'onlyoffice_logger_helper'
|
5
4
|
require_relative 'digitalocean_wrapper/digitalocean_exceptions'
|
6
5
|
require_relative 'digitalocean_wrapper/exceptions_retryer'
|
7
6
|
require_relative 'digitalocean_wrapper/getters'
|
7
|
+
require_relative 'digitalocean_wrapper/logger_wrapper'
|
8
8
|
require_relative 'digitalocean_wrapper/power_actions'
|
9
9
|
require_relative 'digitalocean_wrapper/token_methods'
|
10
10
|
|
@@ -13,6 +13,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
13
13
|
# Class for wrapping DigitalOcean API gem
|
14
14
|
class DigitalOceanWrapper
|
15
15
|
include Getters
|
16
|
+
include LoggerWrapper
|
16
17
|
include ExceptionsRetryer
|
17
18
|
include PowerActions
|
18
19
|
include TokenMethods
|
@@ -38,8 +39,8 @@ module OnlyofficeDigitaloceanWrapper
|
|
38
39
|
while get_droplet_status_by_name(droplet_name) != status && counter < timeout
|
39
40
|
counter += 10
|
40
41
|
sleep 10
|
41
|
-
|
42
|
-
|
42
|
+
logger.info("waiting for droplet (#{droplet_name}) to have "\
|
43
|
+
"status: #{status} for #{counter} seconds of #{timeout}")
|
43
44
|
end
|
44
45
|
raise DropletOperationTimeout, "#{droplet_name} was not #{status} for #{timeout}s" if counter >= timeout
|
45
46
|
|
@@ -70,7 +71,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
70
71
|
monitoring: true,
|
71
72
|
size: size)
|
72
73
|
created = @client.droplets.create(droplet)
|
73
|
-
|
74
|
+
logger.info("restore_image_by_name(#{image_name}, #{droplet_name})")
|
74
75
|
if created.is_a?(String)
|
75
76
|
raise "Problem, while creating '#{droplet_name}' from image '#{image_name}'\n" \
|
76
77
|
"Error: #{created}"
|
@@ -84,7 +85,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
84
85
|
def destroy_droplet_by_name(droplet_name = 'nct-at1')
|
85
86
|
droplet_id = get_droplet_id_by_name(droplet_name)
|
86
87
|
client.droplets.delete(id: droplet_id)
|
87
|
-
|
88
|
+
logger.info("destroy_droplet_by_name(#{droplet_name})")
|
88
89
|
wait_until_droplet_have_status(droplet_name, nil)
|
89
90
|
end
|
90
91
|
end
|
@@ -15,7 +15,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
15
15
|
yield
|
16
16
|
rescue exception => e
|
17
17
|
try += 1
|
18
|
-
|
18
|
+
logger.error("Error '#{exception}, #{e}' happened during "\
|
19
19
|
"operation. Retrying #{try} of #{retries}")
|
20
20
|
sleep timeout # Time to cooldown error
|
21
21
|
try <= retries ? retry : raise
|
@@ -8,7 +8,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
8
8
|
image = all_droplets.find { |x| x.name == image_name }
|
9
9
|
raise DigitalOceanImageNotFound, image_name if image.nil?
|
10
10
|
|
11
|
-
|
11
|
+
logger.info("get_image_id_by_name(#{image_name}): #{image.id}")
|
12
12
|
image.id
|
13
13
|
end
|
14
14
|
|
@@ -28,10 +28,10 @@ module OnlyofficeDigitaloceanWrapper
|
|
28
28
|
def get_droplet_id_by_name(droplet_name)
|
29
29
|
droplet = droplet_by_name(droplet_name)
|
30
30
|
if droplet.nil?
|
31
|
-
|
31
|
+
logger.info("get_droplet_id_by_name(#{droplet_name}): not found any droplets")
|
32
32
|
nil
|
33
33
|
else
|
34
|
-
|
34
|
+
logger.info("get_droplet_id_by_name(#{droplet_name}): #{droplet.id}")
|
35
35
|
droplet.id
|
36
36
|
end
|
37
37
|
end
|
@@ -42,12 +42,12 @@ module OnlyofficeDigitaloceanWrapper
|
|
42
42
|
def get_droplet_ip_by_name(droplet_name)
|
43
43
|
droplet = droplet_by_name(droplet_name)
|
44
44
|
if droplet.nil?
|
45
|
-
|
45
|
+
logger.info("There is no created droplet with name: #{droplet_name}")
|
46
46
|
return
|
47
47
|
end
|
48
48
|
retry_exception do
|
49
49
|
ip = public_ip(droplet)
|
50
|
-
|
50
|
+
logger.info("get_droplet_ip_by_name(#{droplet_name}): #{ip}")
|
51
51
|
ip
|
52
52
|
end
|
53
53
|
end
|
@@ -58,13 +58,13 @@ module OnlyofficeDigitaloceanWrapper
|
|
58
58
|
def get_droplet_status_by_name(droplet_name)
|
59
59
|
droplet = droplet_by_name(droplet_name)
|
60
60
|
if droplet.nil?
|
61
|
-
|
61
|
+
logger.info("get_droplet_status_by_name(#{droplet_name}): not found any droplets")
|
62
62
|
nil
|
63
63
|
else
|
64
64
|
retry_exception do
|
65
65
|
status = droplet.status
|
66
66
|
status = :locked if droplet.locked
|
67
|
-
|
67
|
+
logger.info("get_droplet_status_by_name(#{droplet_name}): #{status}")
|
68
68
|
status
|
69
69
|
end
|
70
70
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
module OnlyofficeDigitaloceanWrapper
|
6
|
+
# Logger module for logging stuff
|
7
|
+
module LoggerWrapper
|
8
|
+
# @return [Logger] default logger
|
9
|
+
def logger
|
10
|
+
@logger ||= Logger.new($stdout)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlyoffice_digitalocean_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: droplet_kit
|
@@ -26,20 +26,6 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '3'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: onlyoffice_logger_helper
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - "~>"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '1'
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '1'
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: codecov
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,14 +130,14 @@ dependencies:
|
|
144
130
|
requirements:
|
145
131
|
- - "~>"
|
146
132
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
133
|
+
version: '2'
|
148
134
|
type: :development
|
149
135
|
prerelease: false
|
150
136
|
version_requirements: !ruby/object:Gem::Requirement
|
151
137
|
requirements:
|
152
138
|
- - "~>"
|
153
139
|
- !ruby/object:Gem::Version
|
154
|
-
version: '
|
140
|
+
version: '2'
|
155
141
|
- !ruby/object:Gem::Dependency
|
156
142
|
name: yard
|
157
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,6 +165,7 @@ files:
|
|
179
165
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/digitalocean_exceptions.rb
|
180
166
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/exceptions_retryer.rb
|
181
167
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/getters.rb
|
168
|
+
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/logger_wrapper.rb
|
182
169
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/power_actions.rb
|
183
170
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb
|
184
171
|
- lib/onlyoffice_digitalocean_wrapper/version.rb
|
@@ -206,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
193
|
- !ruby/object:Gem::Version
|
207
194
|
version: '0'
|
208
195
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
196
|
+
rubygems_version: 3.2.9
|
210
197
|
signing_key:
|
211
198
|
specification_version: 4
|
212
199
|
summary: Wrapper gem for DigitalOcean
|