teuton 2.9.3 → 2.9.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b4752e08b15fd862f420e1d48adbd9993d85d195d1b4c4e3a038fd49496c266
4
- data.tar.gz: 35b22222f598310ccb28f208a56a4ae6923585815b41cceea7ed1d3546c6b914
3
+ metadata.gz: 6df4861135eb226e52818814c68af43772f58cd196c5cd8008572a4bbaa26065
4
+ data.tar.gz: fe68c2d388c2e506641addcb32476c8de97c77224d50333a8026e2fc263656a2
5
5
  SHA512:
6
- metadata.gz: 94c0548eea0557f8974d2f11640aa292cb6beaa446ea11f5b8c8927f0fafd846bf03bdb7d9114c82447e149534bc350521ba3998c441996c95aecc1a07341551
7
- data.tar.gz: e6086e5451d2846bde79419d8cc3cf0c6d8dd332c966e2fee3c19f54c66569cc5f3c62e8aeb108a9c6f2e6cfe63e4190d70491b5aeb99d7dbc75cfe3f07991bc
6
+ metadata.gz: 3b853fecce334497ee93d289e90f67ce8ab1d6f3f78d67072d0ed424df431e1e967a3f529c20cec4089e76d05209b7854f1d311115ec5e385185bcbf6d8cacb5
7
+ data.tar.gz: 56d989afeeca6f82b9f03a8a3d1613814db19e47df0d4e301934affa03e8faff033c7d85a6c60d14b04b9764ca56392db66659d5238cb314f204594b07393676
@@ -117,3 +117,12 @@ DSL send:
117
117
  /home/username/example/foo/start.rb
118
118
  or /home/username/example/foo.rb
119
119
  ```
120
+
121
+ ## [2.9.3] 20250402
122
+
123
+ - [FIX] Error with telnet connections.
124
+
125
+ ## [2.9.4] 20250410
126
+
127
+ - [FIX] Improve the markdown output of the readme.
128
+ - [FIX] Telnet exitcode
@@ -2,14 +2,14 @@
2
2
 
3
3
  # Installation
4
4
 
5
- There are 2 types of nodes/hosts, so there are 2 installations:
5
+ There are 2 types of nodes (hosts), so there are 2 installations:
6
6
 
7
7
  | ID | Software | Description |
8
8
  | -- | -------- | ----------- |
9
9
  | **T-node** | [Teuton installation](t-node.md) | T-NODE host monitors one or severals S-NODE hosts |
10
10
  | **S-node** | [SSH server installation](s-node.md) | S-NODE hosts are monitorized by T-NODE host |
11
11
 
12
- Read [modes of use](modes_of_use.md) to know more about differents T-NODE/S-NODE schemes.
12
+ > Read [modes of use](modes_of_use.md) to know more about differents T-NODE/S-NODE schemes.
13
13
 
14
14
  ## Tested OS list
15
15
 
@@ -11,7 +11,7 @@ Install SSH server on every machine with S-NODE role.
11
11
  Run this command as `root` user:
12
12
 
13
13
  ```bash
14
- wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/linux_s-node_install.sh | bash
14
+ wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/s-node_install.sh | bash
15
15
  ```
16
16
 
17
17
  **S-node Windows installation**
@@ -23,7 +23,7 @@ Requirements:
23
23
  Run this command on **PowerShell (PS)** as `Administrator` user:
24
24
 
25
25
  ```powershell
26
- Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/windows_s-node_install.ps1'))
26
+ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/s-node_install.ps1'))
27
27
  ```
28
28
 
29
29
  **S-node Mac OS X installation**
@@ -31,5 +31,5 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.We
31
31
  Run this command as `root` user:
32
32
 
33
33
  ```bash
34
- curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/macosx_s-node_install.sh | bash
34
+ curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/s-node_install.sh | bash
35
35
  ```
@@ -4,24 +4,19 @@
4
4
 
5
5
  # 1. Recommended
6
6
 
7
- **Installation**
8
-
7
+ Installation:
9
8
  1. Install Ruby on your system.
10
9
  2. `gem install teuton`
11
10
 
12
11
  Run `teuton version` to check the installed version.
13
12
 
14
- **Update**
15
-
16
- `gem update teuton`.
17
-
18
- **Uninstall**
19
-
20
- `gem uninstall teuton`.
13
+ > NOTE:
14
+ > * Update: `gem update teuton`.
15
+ > * Uninstall: `gem uninstall teuton`.
21
16
 
22
17
  # 2. Problems
23
18
 
24
- Don't find `teuton` command (OpenSUSE distro, for example), try this:
19
+ Sometimes we don't find `teuton` command (OpenSUSE distro, for example), so try this:
25
20
 
26
21
  Option A:
27
22
  * `ruby -v`, display your current ruby version. Suppose it is "2.5".
@@ -40,7 +35,7 @@ If you don't know how to install Ruby on your system, execute this script to run
40
35
  Run this command as `root` user:
41
36
 
42
37
  ```bash
43
- wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/linux_t-node_install.sh | bash
38
+ wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/t-node_install.sh | bash
44
39
  ```
45
40
 
46
41
  **T-node Windows installation**
@@ -52,7 +47,7 @@ Requirements:
52
47
  Run this command on **PowerShell (PS)** as `Administrator` user:
53
48
 
54
49
  ```powershell
55
- Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/windows_t-node_install.ps1'))
50
+ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/t-node_install.ps1'))
56
51
  ```
57
52
 
58
53
  **T-node Mac OS X installation**
@@ -60,7 +55,7 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.We
60
55
  Run this command as admin user (member of `admin` group):
61
56
 
62
57
  ```bash
63
- curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/macosx_t-node_install.sh | bash
58
+ curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/t-node_install.sh | bash
64
59
  ```
65
60
 
66
61
  # 4. Vagrant/Docker
@@ -8,7 +8,7 @@ A [target](../dsl/target.md) is a feature you want to check. Targets are defined
8
8
 
9
9
  * [target](dsl/target.md): Description of the element to be tested.
10
10
  * [run](../dsl/run.md): Execute a command `id obiwan` on localhost.
11
- * [expect](../&dsl/expect.md): Verify that the result contains expected value.
11
+ * [expect](../dsl/expect.md): Verify that the result contains expected value.
12
12
 
13
13
  ```ruby
14
14
  group "Learn about targets" do
@@ -28,17 +28,17 @@ end
28
28
  When the user exists, we expect this words: `uid=, (obiwan), gid=`.
29
29
 
30
30
  ```
31
- id obiwan
31
+ > id obiwan
32
32
  uid=1000(obiwan) gid=1000(obiwan) grupos=1000(obiwan)
33
33
  ```
34
34
 
35
35
  But when user does not exist, we expect different words: `id:, vader, no exist`.
36
36
 
37
37
  ```
38
- id vader
38
+ > id vader
39
39
  id: «vader»: no such user
40
40
 
41
- echo $?
41
+ > echo $?
42
42
  1
43
43
 
44
44
  ```
@@ -23,6 +23,8 @@ module DSL
23
23
  @action_counter += 1
24
24
  @action[:id] = @action_counter
25
25
  if @result.exitcode < 0
26
+ # When exitcode is less than zero, it is because there has been
27
+ # an error in the remote connection (SSH or Telnet)
26
28
  @action[:check] = false
27
29
  @action[:result] = @action[:output]
28
30
  else
@@ -38,8 +38,12 @@ class ExecuteBase
38
38
  def encode_and_split(encoding, text)
39
39
  # Convert text to UTF-8 deleting unknown chars
40
40
  text ||= "" # Ensure text is not nil
41
- flag = [:default, "UTF-8"].include? encoding
42
- return text.encode("UTF-8", invalid: :replace).split("\n") if flag
41
+
42
+ # TODO: text.gsub!('\r', '')
43
+ if [:default, "UTF-8"].include? encoding
44
+ text.encode!("UTF-8", invalid: :replace, :undef => :replace, :replace => '')
45
+ return text.split("\n")
46
+ end
43
47
 
44
48
  # Convert text from input ENCODING to UTF-8
45
49
  ec = Encoding::Converter.new(encoding.to_s, "UTF-8")
@@ -47,9 +51,9 @@ class ExecuteBase
47
51
  text = ec.convert(text)
48
52
  rescue => e
49
53
  puts "[ERROR] #{e}: Declare text encoding..."
50
- puts " run 'command', on: :host, :encoding => 'ISO-8859-1'"
54
+ puts " run 'command', on: :host, encoding: 'ISO-8859-1'"
51
55
  end
52
56
 
53
- text.split("\n")
57
+ text.split("\n").compact
54
58
  end
55
59
  end
@@ -89,6 +89,5 @@ class ExecuteSSH < ExecuteBase
89
89
  end
90
90
  result.exitcode = exitcode
91
91
  result.content = encode_and_split(action[:encoding], text)
92
- result.content.compact!
93
92
  end
94
93
  end
@@ -1,7 +1,7 @@
1
1
  require "net/telnet"
2
- require "rainbow"
2
+ # require "rainbow"
3
3
  require_relative "../../utils/project"
4
- require_relative "../../utils/verbose"
4
+ # require_relative "../../utils/verbose"
5
5
  require_relative "execute_base"
6
6
 
7
7
  class ExecuteTelnet < ExecuteBase
@@ -9,48 +9,55 @@ class ExecuteTelnet < ExecuteBase
9
9
  action[:conn_type] = :telnet
10
10
  hostname = input_hostname.to_s
11
11
  ip = config.get((hostname + "_ip").to_sym)
12
- username = config.get((hostname + "_username").to_sym).to_s
13
- password = config.get((hostname + "_password").to_sym).to_s
12
+ port = config.get((hostname + "_port").to_sym)
13
+ mode = true
14
+ if port.to_i == 0
15
+ port = "23"
16
+ mode = false
17
+ end
14
18
  text = ""
19
+ exitcode = -1
15
20
  begin
16
21
  if sessions[hostname].nil? || sessions[hostname] == :ok
17
22
  h = Net::Telnet.new(
18
23
  "Host" => ip,
24
+ "Port" => port,
25
+ "Telnetmode" => mode,
19
26
  "Timeout" => 30,
20
- "Prompt" => /login|teuton|[$%#>]|PC1>/
27
+ "Prompt" => /login|teuton|[$%#>]/
21
28
  )
22
29
  # "Prompt" => Regexp.new(username[1, 40]))
23
30
  # "Prompt" => /[$%#>] \z/n)
24
- h.login(username, password)
31
+ unless mode
32
+ username = config.get((hostname + "_username").to_sym).to_s
33
+ password = config.get((hostname + "_password").to_sym).to_s
34
+ h.login(username, password)
35
+ end
25
36
  h.cmd(action[:command]) { |i| text << i }
26
37
  h.close
27
38
  sessions[hostname] = :ok
39
+ exitcode = 0
28
40
  else
29
- text = "TELNET: NO CONNECTION!"
41
+ text = "Telnet: NO CONNECTION!"
30
42
  end
31
43
  rescue Net::OpenTimeout
32
44
  sessions[hostname] = :nosession
33
45
  conn_status[hostname] = :open_timeout
34
- # verbose Rainbow(Application.instance.letter[:error]).red.bright
35
46
  log(" ExceptionType=<Net::OpenTimeout> doing <telnet #{ip}>", :error)
36
47
  log(" └── Revise host IP!", :warn)
37
48
  rescue Net::ReadTimeout
38
49
  sessions[hostname] = :nosession
39
50
  conn_status[hostname] = :read_timeout
40
- # verbose Rainbow(Application.instance.letter[:error]).red.bright
41
51
  log(" ExceptionType=<Net::ReadTimeout> doing <telnet #{ip}>", :error)
42
52
  rescue => e
43
53
  sessions[hostname] = :nosession
44
54
  conn_status[hostname] = :error
45
- # verbose Rainbow(Application.instance.letter[:error]).red.bright
46
55
  log(" ExceptionType=<#{e.class}> doing telnet on <#{username}@#{ip}>" \
47
56
  " exec: #{action[:command]}", :error)
48
57
  log(" └── username=<#{username}>, password=<#{password}>," \
49
58
  " ip=<#{ip}>, HOSTID=<#{hostname}>", :warn)
50
59
  end
51
- output = encode_and_split(action[:encoding], text)
52
- result.exitcode = -1
53
- result.content = output
54
- result.content.compact!
60
+ result.exitcode = exitcode
61
+ result.content = encode_and_split(action[:encoding], text)
55
62
  end
56
63
  end
@@ -71,8 +71,8 @@ class Readme
71
71
  unless @required_hosts.empty?
72
72
  puts Lang.get(:hosts)
73
73
  puts "\n"
74
- puts "| ID | Host | Configuration |"
75
- puts "| --- | --- | --- |"
74
+ puts "| ID | Host | Configuration |"
75
+ puts "| --- | ---- | ------------- |"
76
76
  @required_hosts.each_pair do |k, v|
77
77
  c = []
78
78
  v.each_pair { |k2, v2| c << "#{k2}=#{v2}" }
@@ -123,15 +123,15 @@ class Readme
123
123
  puts Lang.get(:global_params)
124
124
  puts "\n"
125
125
  puts "| Param | Value |"
126
- puts "| --- | --- |"
126
+ puts "| ----- | ----- |"
127
127
  @global_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
128
128
  end
129
129
  if @setted_params.size.positive?
130
130
  puts Lang.get(:created_params)
131
131
  puts "\n"
132
- puts "| Param | Value |"
133
- puts "| --- | --- |"
134
- @setted_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
132
+ puts "| Param |"
133
+ puts "| ----- |"
134
+ @setted_params.each_pair { |k, v| puts "|#{k}|" }
135
135
  end
136
136
  end
137
137
  end
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "2.9.3"
2
+ VERSION = "2.9.4"
3
3
  APPNAME = "teuton"
4
4
  GEMNAME = "teuton"
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
data/lib/teuton.rb CHANGED
@@ -22,7 +22,6 @@ module Teuton
22
22
  end
23
23
 
24
24
  def self.run(projectpath, options = {})
25
- # Application.instance.add_input_params(projectpath, options)
26
25
  Project.add_input_params(projectpath, options)
27
26
  require_dsl_and_script("teuton/case_manager/dsl") # Define DSL
28
27
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.3
4
+ version: 2.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-02 00:00:00.000000000 Z
10
+ date: 2025-04-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rainbow