blackstack-nodes 1.2.16 → 1.2.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack-nodes.rb +29 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52c3717672516ceeba52e4ed373d25d9a61ee5caf5ce53b72ecc71b00f735a3e
|
4
|
+
data.tar.gz: 90e5f90805c48500bd1c7b3dcc45b8b299ffeee929dbe9d9b833cb9d0d9d6d8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e6f7d5517e2c528dd6de300bfae658cb087c9509a3db619e712df2623c3d890ca62af3c24f0cc81764840fbf2cc4ae977b7819767b91fb27de40a10cd43ca93
|
7
|
+
data.tar.gz: d30e277d62304e84b5f04b3cf3afdfcd893b2b35f7552e79692cb1137a5789027acbc4836f35e5211061519ed5fc8f9f59e05c52d88b2fba5a73764cb93f9c76
|
data/lib/blackstack-nodes.rb
CHANGED
@@ -8,7 +8,7 @@ module BlackStack
|
|
8
8
|
# this module has attributes an methods used by both classes Node and Node.
|
9
9
|
module NodeModule
|
10
10
|
# :name is this is just a descriptive name for the node. It is not the host name, nor the domain, nor any ip.
|
11
|
-
attr_accessor :name, :
|
11
|
+
attr_accessor :name, :ip, :ssh_username, :ssh_password, :ssh_port, :ssh_private_key_file, :tags
|
12
12
|
# non-database attributes, used for ssh connection and logging
|
13
13
|
attr_accessor :ssh, :logger
|
14
14
|
|
@@ -24,8 +24,8 @@ module BlackStack
|
|
24
24
|
# validate: the parameter h[:name] is a string
|
25
25
|
errors << "The parameter h[:name] is not a string" unless h[:name].is_a?(String)
|
26
26
|
|
27
|
-
# validate: the paramerer h has a key :
|
28
|
-
errors << "The parameter h does not have a key :
|
27
|
+
# validate: the paramerer h has a key :ip
|
28
|
+
errors << "The parameter h does not have a key :ip" unless h.has_key?(:ip)
|
29
29
|
|
30
30
|
# validate: the paramerer h has a key :ssh_username
|
31
31
|
errors << "The parameter h does not have a key :ssh_username" unless h.has_key?(:ssh_username)
|
@@ -64,7 +64,7 @@ module BlackStack
|
|
64
64
|
raise "The node descriptor is not valid: #{errors.uniq.join(".\n")}" if errors.length > 0
|
65
65
|
# map attributes
|
66
66
|
self.name = h[:name]
|
67
|
-
self.
|
67
|
+
self.ip = h[:ip]
|
68
68
|
self.ssh_username = h[:ssh_username]
|
69
69
|
self.ssh_password = h[:ssh_password]
|
70
70
|
self.ssh_port = h[:ssh_port]
|
@@ -82,7 +82,7 @@ module BlackStack
|
|
82
82
|
def to_hash
|
83
83
|
{
|
84
84
|
:name => self.name,
|
85
|
-
:
|
85
|
+
:ip => self.ip,
|
86
86
|
:ssh_username => self.ssh_username,
|
87
87
|
:ssh_password => self.ssh_password,
|
88
88
|
:ssh_port => self.ssh_port,
|
@@ -93,20 +93,40 @@ module BlackStack
|
|
93
93
|
|
94
94
|
# return true if the node is all set to connect using ssh user and password.
|
95
95
|
def using_password?
|
96
|
-
!self.
|
96
|
+
!self.ip.nil? && !self.ssh_username.nil? && !self.ssh_password.nil?
|
97
97
|
end
|
98
98
|
|
99
99
|
# return true if the node is all set to connect using a private key file.
|
100
100
|
def using_private_key_file?
|
101
|
-
!self.
|
101
|
+
!self.ip.nil? && !self.ssh_username.nil? && !self.ssh_private_key_file.nil?
|
102
102
|
end
|
103
103
|
|
104
|
+
# Returns true if the SSH connection is not established or inactive
|
105
|
+
def disconnected?
|
106
|
+
self.ssh.nil? || self.ssh.closed?
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns true if the SSH connection is established
|
110
|
+
def connected?
|
111
|
+
!disconnected?
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
104
115
|
def connect
|
105
116
|
# connect
|
106
117
|
if self.using_password?
|
107
|
-
self.ssh = Net::SSH.start(
|
118
|
+
self.ssh = Net::SSH.start(
|
119
|
+
self.ip,
|
120
|
+
self.ssh_username,
|
121
|
+
:password => self.ssh_password,
|
122
|
+
:port => self.ssh_port,
|
123
|
+
:verify_host_key => :never, # Disable host key verification
|
124
|
+
:non_interactive => true, # Ensure non-interactive mode
|
125
|
+
:timeout => 10, # Set a connection timeout (in seconds)
|
126
|
+
#:verbose => :debug # Enable verbose logging
|
127
|
+
)
|
108
128
|
elsif self.using_private_key_file?
|
109
|
-
self.ssh = Net::SSH.start(self.
|
129
|
+
self.ssh = Net::SSH.start(self.ip, self.ssh_username, :keys => self.ssh_private_key_file, :port => self.ssh_port)
|
110
130
|
else
|
111
131
|
raise "No ssh credentials available"
|
112
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-nodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 7.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simple_cloud_logging
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|