onlyoffice_digitalocean_wrapper 0.4.1 → 0.5.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 +17 -0
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/getters.rb +10 -1
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/power_actions.rb +9 -0
- data/lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb +8 -5
- data/lib/onlyoffice_digitalocean_wrapper/version.rb +3 -1
- metadata +120 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab5d384e54522d5e32c96089492303e10cd3243ed0f167d7fdbf4fd0a20b4786
|
4
|
+
data.tar.gz: 7df0fc6a8ff136cf2de91791e8301b3ab9acc2e8b05a0adfe9750b6979610a1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 406592b3cc7107311271454d6af88b98a5eda6cfd3edc18e50b2a6a6168ec72cf946d92398189588f6e9c1d734f8416fa6368f43dc02f16cf7d520f77d38b5dd
|
7
|
+
data.tar.gz: d3854132511ae1441671a5924655bd49898d415e19ad0d295257c043a861328e93201bae94d2737bef7d659b9ff15af7393fa8ef07065d423505e8ff4cbb37f2
|
@@ -8,6 +8,7 @@ require_relative 'digitalocean_wrapper/getters'
|
|
8
8
|
require_relative 'digitalocean_wrapper/power_actions'
|
9
9
|
require_relative 'digitalocean_wrapper/token_methods'
|
10
10
|
|
11
|
+
# Namespace for this gem
|
11
12
|
module OnlyofficeDigitaloceanWrapper
|
12
13
|
# Class for wrapping DigitalOcean API gem
|
13
14
|
class DigitalOceanWrapper
|
@@ -16,6 +17,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
16
17
|
include PowerActions
|
17
18
|
include TokenMethods
|
18
19
|
|
20
|
+
# @return [Array<String>] list of allowed droplet sizes
|
19
21
|
DROPLET_SIZES = %w[512mb 1gb 2gb 4gb 8gb 16gb 32gb 48gb 64gb].freeze
|
20
22
|
attr_accessor :client
|
21
23
|
|
@@ -25,6 +27,11 @@ module OnlyofficeDigitaloceanWrapper
|
|
25
27
|
raise ArgumentError, 'DigitalOceanWrapper: Your Access Token is Incorrect' unless correct_access_token?
|
26
28
|
end
|
27
29
|
|
30
|
+
# Wait until droplet has status
|
31
|
+
# @param droplet_name [String] name of droplet
|
32
|
+
# @param status [String] status to wait
|
33
|
+
# @param params [Hash] additiona params
|
34
|
+
# @return [Symbol] droplet status after wait over
|
28
35
|
def wait_until_droplet_have_status(droplet_name, status = 'active', params = {})
|
29
36
|
timeout = params.fetch(:timeout, 300)
|
30
37
|
counter = 0
|
@@ -39,6 +46,13 @@ module OnlyofficeDigitaloceanWrapper
|
|
39
46
|
get_droplet_status_by_name(droplet_name)
|
40
47
|
end
|
41
48
|
|
49
|
+
# Restore droplet from image by name
|
50
|
+
# @param image_name [String] name of image
|
51
|
+
# @param droplet_name [String] name for droplet
|
52
|
+
# @param region [String] region to restore
|
53
|
+
# @param size [String] size of droplet
|
54
|
+
# @param tags [String, Array<String>] name of tags to apply
|
55
|
+
# @return [Object] object with droplet data
|
42
56
|
def restore_image_by_name(image_name = 'nct-at-stable',
|
43
57
|
droplet_name = image_name,
|
44
58
|
region = 'nyc3',
|
@@ -64,6 +78,9 @@ module OnlyofficeDigitaloceanWrapper
|
|
64
78
|
created
|
65
79
|
end
|
66
80
|
|
81
|
+
# Destroy droplet by name
|
82
|
+
# @param droplet_name [String] name of droplet
|
83
|
+
# @return [Symbol] Droplet status after destruction
|
67
84
|
def destroy_droplet_by_name(droplet_name = 'nct-at1')
|
68
85
|
droplet_id = get_droplet_id_by_name(droplet_name)
|
69
86
|
client.droplets.delete(id: droplet_id)
|
@@ -22,6 +22,9 @@ module OnlyofficeDigitaloceanWrapper
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
# Return droplet id by it's name
|
26
|
+
# @param droplet_name [String] name of droplet
|
27
|
+
# @return [Integer] id of droplet
|
25
28
|
def get_droplet_id_by_name(droplet_name)
|
26
29
|
droplet = droplet_by_name(droplet_name)
|
27
30
|
if droplet.nil?
|
@@ -33,6 +36,9 @@ module OnlyofficeDigitaloceanWrapper
|
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
39
|
+
# Return droplet ip by it's name
|
40
|
+
# @param droplet_name [String] name of droplet
|
41
|
+
# @return [String] ip of droplet
|
36
42
|
def get_droplet_ip_by_name(droplet_name)
|
37
43
|
droplet = droplet_by_name(droplet_name)
|
38
44
|
if droplet.nil?
|
@@ -46,6 +52,9 @@ module OnlyofficeDigitaloceanWrapper
|
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
55
|
+
# Return droplet status by it's name
|
56
|
+
# @param droplet_name [String] name of droplet
|
57
|
+
# @return [Symbol] droplet status
|
49
58
|
def get_droplet_status_by_name(droplet_name)
|
50
59
|
droplet = droplet_by_name(droplet_name)
|
51
60
|
if droplet.nil?
|
@@ -66,7 +75,7 @@ module OnlyofficeDigitaloceanWrapper
|
|
66
75
|
# @return [String] public ip
|
67
76
|
def public_ip(droplet)
|
68
77
|
networks = droplet.networks.to_a.first
|
69
|
-
public_network = networks.find { |net| net.type == 'public'}
|
78
|
+
public_network = networks.find { |net| net.type == 'public' }
|
70
79
|
public_network.ip_address
|
71
80
|
end
|
72
81
|
end
|
@@ -3,18 +3,27 @@
|
|
3
3
|
module OnlyofficeDigitaloceanWrapper
|
4
4
|
# Actions with power (turn on/off, reboot)
|
5
5
|
module PowerActions
|
6
|
+
# Turn off droplet
|
7
|
+
# @param droplet_name [String] droplet to turn off
|
8
|
+
# @return [Symbol] droplet result status
|
6
9
|
def power_off_droplet(droplet_name)
|
7
10
|
droplet_id = get_droplet_id_by_name(droplet_name)
|
8
11
|
client.droplet_actions.power_off(droplet_id: droplet_id)
|
9
12
|
wait_until_droplet_have_status(droplet_name, 'off')
|
10
13
|
end
|
11
14
|
|
15
|
+
# Turn on droplet
|
16
|
+
# @param droplet_name [String] droplet to turn on
|
17
|
+
# @return [Symbol] droplet result status
|
12
18
|
def power_on_droplet(droplet_name)
|
13
19
|
droplet_id = get_droplet_id_by_name(droplet_name)
|
14
20
|
client.droplet_actions.power_on(droplet_id: droplet_id)
|
15
21
|
wait_until_droplet_have_status(droplet_name)
|
16
22
|
end
|
17
23
|
|
24
|
+
# Reboot droplet
|
25
|
+
# @param droplet_name [String] droplet to reboot
|
26
|
+
# @return [Symbol] droplet result status
|
18
27
|
def reboot_droplet(droplet_name)
|
19
28
|
droplet_id = get_droplet_id_by_name(droplet_name)
|
20
29
|
client.droplet_actions.reboot(droplet_id: droplet_id)
|
@@ -15,14 +15,17 @@ module OnlyofficeDigitaloceanWrapper
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Read access token from file system
|
18
|
+
# @param token_file_path [String] path to token
|
19
|
+
# @param force_file_read [True, False] should read from file be forced
|
18
20
|
# @return [String] token
|
19
|
-
def read_token
|
20
|
-
|
21
|
+
def read_token(token_file_path: "#{Dir.home}/.do/access_token",
|
22
|
+
force_file_read: false)
|
23
|
+
return ENV['DO_ACCESS_TOKEN'] if ENV['DO_ACCESS_TOKEN'] && !force_file_read
|
21
24
|
|
22
|
-
File.read(
|
25
|
+
File.read(token_file_path).delete("\n")
|
23
26
|
rescue Errno::ENOENT
|
24
|
-
raise Errno::ENOENT, "No access token found in #{
|
25
|
-
"Please create
|
27
|
+
raise Errno::ENOENT, "No access token found in #{token_file_path}. " \
|
28
|
+
"Please create file #{token_file_path} with token"
|
26
29
|
end
|
27
30
|
end
|
28
31
|
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.5.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: 2020-10-
|
13
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: droplet_kit
|
@@ -40,6 +40,34 @@ dependencies:
|
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: codecov
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: overcommit
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
43
71
|
- !ruby/object:Gem::Dependency
|
44
72
|
name: rake
|
45
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,6 +82,90 @@ dependencies:
|
|
54
82
|
- - "~>"
|
55
83
|
- !ruby/object:Gem::Version
|
56
84
|
version: '13.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rspec
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '3'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '3'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rubocop
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 0.49.0
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 0.49.0
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rubocop-performance
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '1'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: rubocop-rake
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: rubocop-rspec
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '1'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '1'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: yard
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 0.9.20
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 0.9.20
|
57
169
|
description: Wrapper gem for DigitalOcean. Use in testing projects
|
58
170
|
email:
|
59
171
|
- shockwavenn@gmail.com
|
@@ -70,15 +182,15 @@ files:
|
|
70
182
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/power_actions.rb
|
71
183
|
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb
|
72
184
|
- lib/onlyoffice_digitalocean_wrapper/version.rb
|
73
|
-
homepage: https://github.com/
|
185
|
+
homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_digitalocean_wrapper
|
74
186
|
licenses:
|
75
187
|
- AGPL-3.0
|
76
188
|
metadata:
|
77
|
-
bug_tracker_uri: https://github.com/
|
78
|
-
changelog_uri: https://github.com/
|
189
|
+
bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_digitalocean_wrapper/issues
|
190
|
+
changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_digitalocean_wrapper/blob/master/CHANGELOG.md
|
79
191
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_digitalocean_wrapper
|
80
|
-
homepage_uri: https://github.com/
|
81
|
-
source_code_uri: https://github.com/
|
192
|
+
homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_digitalocean_wrapper
|
193
|
+
source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_digitalocean_wrapper
|
82
194
|
post_install_message:
|
83
195
|
rdoc_options: []
|
84
196
|
require_paths:
|
@@ -87,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
199
|
requirements:
|
88
200
|
- - ">="
|
89
201
|
- !ruby/object:Gem::Version
|
90
|
-
version: '2.
|
202
|
+
version: '2.5'
|
91
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
204
|
requirements:
|
93
205
|
- - ">="
|