blackstack-nodes 1.2.16 → 1.2.17
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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45a726611b5bad35e0d76252b517c2ddc39628bb140e7f497292b0a65992ad54
|
4
|
+
data.tar.gz: f1d1662260d1d18251069b5ca5ef67253d837086f299fc688c3d90e1c68483eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df3fd698e785fdad3139a7fbfcdf5a45569e13a98bbd07ca3a296b051a6fe195fb6909d548c8425761e0b6632aa56f176aa1bffe740349a6a8b9a9ae85a552e0
|
7
|
+
data.tar.gz: b48d4d6cef656baa41cbeb79c39c357d25df02cbb8e9c00118107682e4033b89f8cf0efd720248bac8d4af4258a5ed3c55aec5827ea1d547c251f4465c9cc31a
|
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.17
|
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: 2024-
|
11
|
+
date: 2024-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|