blackstack-nodes 1.2.16 → 1.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/blackstack-nodes.rb +29 -9
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7030c06d185e9257db6bcf42deadcbcc1ac609f79140b8ce63f73f5368232144
4
- data.tar.gz: adc175dd676a9b3940454342016ec82b96d771f885f6ca92d26f317d5f722331
3
+ metadata.gz: 52c3717672516ceeba52e4ed373d25d9a61ee5caf5ce53b72ecc71b00f735a3e
4
+ data.tar.gz: 90e5f90805c48500bd1c7b3dcc45b8b299ffeee929dbe9d9b833cb9d0d9d6d8c
5
5
  SHA512:
6
- metadata.gz: 2d3807f8df44577cff9d4b57329ad28e2a6216bce5566a178893ed390c2b6f943b45ddbd561b2fa793506010a586108468eb0e05c53e55ce81f36c74089bb2eb
7
- data.tar.gz: 3cf124a33af4fcffaa3fd2b642fe561774d296cc629cc67d0e9bb865425eb5688fa13bf0e68b89a0272c1c7337b1fb06490b4669c86165bd421bbc88ef68d37a
6
+ metadata.gz: 8e6f7d5517e2c528dd6de300bfae658cb087c9509a3db619e712df2623c3d890ca62af3c24f0cc81764840fbf2cc4ae977b7819767b91fb27de40a10cd43ca93
7
+ data.tar.gz: d30e277d62304e84b5f04b3cf3afdfcd893b2b35f7552e79692cb1137a5789027acbc4836f35e5211061519ed5fc8f9f59e05c52d88b2fba5a73764cb93f9c76
@@ -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, :net_remote_ip, :ssh_username, :ssh_password, :ssh_port, :ssh_private_key_file, :tags
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 :net_remote_ip
28
- errors << "The parameter h does not have a key :net_remote_ip" unless h.has_key?(:net_remote_ip)
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.net_remote_ip = h[:net_remote_ip]
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
- :net_remote_ip => self.net_remote_ip,
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.net_remote_ip.nil? && !self.ssh_username.nil? && !self.ssh_password.nil?
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.net_remote_ip.nil? && !self.ssh_username.nil? && !self.ssh_private_key_file.nil?
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(self.net_remote_ip, self.ssh_username, :password => self.ssh_password, :port => self.ssh_port)
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.net_remote_ip, self.ssh_username, :keys => self.ssh_private_key_file, :port => self.ssh_port)
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.16
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: 2024-09-28 00:00:00.000000000 Z
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: 6.1.0
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: 6.1.0
26
+ version: 7.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: simple_cloud_logging
29
29
  requirement: !ruby/object:Gem::Requirement