onlyoffice_digitalocean_wrapper 0.7.0 → 0.8.0

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: 722a209dd7c530acc9eca5dc95af3482ce07b031f1d60458f0fd4f60d68d97f1
4
- data.tar.gz: 2176a7c8518150703d75437360e757e2be7e6ed770affb877fb02dfc362f2124
3
+ metadata.gz: 0b5f288d8ace3eb4b4233a65a15ad7205c993361a5218939ecae254902e57d39
4
+ data.tar.gz: 987062f1ec25e58d45c5c0fadfdd672ac7f4a9908a4b0563be2e000051dca0d2
5
5
  SHA512:
6
- metadata.gz: efec409153d5b1d2c94d8ef541ed957f708869b5096c42371224d389adab3d7282d0eccb0e56bb40a30dc6e5a43989eae1c2aeb73830346138f9f20511424e31
7
- data.tar.gz: 5680e5bc73b4fd25f402fa18de9b788008710ef00fac98dff796e958e1e3e45c682563eeeb169a5b2871af8898a7247e975c81b5f1bf91fe793cb5448714bf6e
6
+ metadata.gz: 8780c445ee63541b12093435e816a555c05e6d9afeac0244cbb95d88b73b8d5a41b3c4567645ffee12340cfad00ddd1f8a7b2c0c85bfecb7500a292080c0e5e8
7
+ data.tar.gz: a73c0ce3bfde1c16ad9b96b90ec2cf6a5f4b53dc573ff228930d8f680309a0801c008cb26e473eb4cad194730757a5055ec93a3043137070813b8ec3bd671bdf
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeDigitaloceanWrapper
4
+ # Class raised if droplet ssh is not up for defined timeout
5
+ class SshCheckerSshUpTimeout < StandardError
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net-telnet'
4
+
5
+ require_relative 'ssh_checker/ssh_checker_exceptions'
6
+
7
+ module OnlyofficeDigitaloceanWrapper
8
+ # Class for check if ssh can be connected
9
+ class SshChecker
10
+ include LoggerWrapper
11
+ # @return [String] ip of server
12
+ attr_reader :ip
13
+
14
+ # @param ip [String] ip of server to check
15
+ def initialize(ip)
16
+ @ip = ip
17
+ end
18
+
19
+ # Wait until ssh server on server is up and available for connection
20
+ # @param timeout [Integer] how much we should wait for connection
21
+ # @return [void]
22
+ def wait_until_ssh_up(timeout: 60)
23
+ wait_between_tries = 5
24
+ tries = timeout / wait_between_tries
25
+ tries.times do |try|
26
+ if ssh_up?
27
+ logger.info("SSH on `#{@ip}` is up. Waiting finished")
28
+ return true
29
+ end
30
+
31
+ logger.info("SSH on `#{@ip}` is not up. Waited for #{try * wait_between_tries} seconds of #{timeout}")
32
+ sleep wait_between_tries
33
+ end
34
+ raise SshCheckerSshUpTimeout, "SSH on `#{@ip}` is not up for #{timeout} seconds. Could not proceed"
35
+ end
36
+
37
+ # Check is ssh available for connection right now
38
+ # @return [Boolean]
39
+ def ssh_up?
40
+ Net::Telnet.new('Host' => @ip,
41
+ 'Timeout' => 1,
42
+ 'Port' => 22)
43
+ true
44
+ rescue StandardError
45
+ false
46
+ end
47
+ end
48
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OnlyofficeDigitaloceanWrapper
4
4
  # @return [String] version of gem
5
- VERSION = '0.7.0'
5
+ VERSION = '0.8.0'
6
6
  # @return [String] name of gem
7
7
  NAME = 'onlyoffice_digitalocean_wrapper'
8
8
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'onlyoffice_digitalocean_wrapper/digitalocean_wrapper'
4
+ require_relative 'onlyoffice_digitalocean_wrapper/ssh_checker'
4
5
  require_relative 'onlyoffice_digitalocean_wrapper/version'
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.7.0
4
+ version: 0.8.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: 2021-07-29 00:00:00.000000000 Z
13
+ date: 2021-09-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: droplet_kit
@@ -26,6 +26,20 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '3'
29
+ - !ruby/object:Gem::Dependency
30
+ name: net-telnet
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
29
43
  - !ruby/object:Gem::Dependency
30
44
  name: codecov
31
45
  requirement: !ruby/object:Gem::Requirement
@@ -168,6 +182,8 @@ files:
168
182
  - lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/logger_wrapper.rb
169
183
  - lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/power_actions.rb
170
184
  - lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb
185
+ - lib/onlyoffice_digitalocean_wrapper/ssh_checker.rb
186
+ - lib/onlyoffice_digitalocean_wrapper/ssh_checker/ssh_checker_exceptions.rb
171
187
  - lib/onlyoffice_digitalocean_wrapper/version.rb
172
188
  homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_digitalocean_wrapper
173
189
  licenses:
@@ -193,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
209
  - !ruby/object:Gem::Version
194
210
  version: '0'
195
211
  requirements: []
196
- rubygems_version: 3.2.22
212
+ rubygems_version: 3.2.27
197
213
  signing_key:
198
214
  specification_version: 4
199
215
  summary: Wrapper gem for DigitalOcean