teuton 2.8.0 → 2.9.0

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/docs/changelog/changelog.1.md +119 -0
  4. data/docs/changelog/changelog.2.md +105 -0
  5. data/docs/diagram.md +10 -10
  6. data/docs/dsl/expect.md +76 -25
  7. data/docs/dsl/result.md +24 -30
  8. data/docs/learn/02-target.md +32 -27
  9. data/docs/learn/25-expect-result.md +39 -0
  10. data/docs/learn/26-expect_sequence.md +79 -0
  11. data/docs/learn/27-run_script.md +91 -0
  12. data/docs/learn/28-upload.md +55 -0
  13. data/docs/learn/README.md +4 -15
  14. data/docs/videos.md +14 -8
  15. data/lib/teuton/case/case.rb +3 -2
  16. data/lib/teuton/case/config.rb +0 -5
  17. data/lib/teuton/case/dsl/all.rb +5 -1
  18. data/lib/teuton/case/dsl/expect.rb +13 -42
  19. data/lib/teuton/case/dsl/expect_exitcode.rb +31 -0
  20. data/lib/teuton/case/dsl/expect_sequence.rb +173 -0
  21. data/lib/teuton/case/dsl/getset.rb +0 -1
  22. data/lib/teuton/case/dsl/host.rb +5 -0
  23. data/lib/teuton/case/dsl/macro.rb +7 -3
  24. data/lib/teuton/case/dsl/run_script.rb +35 -0
  25. data/lib/teuton/case/dsl/upload.rb +42 -0
  26. data/lib/teuton/case/dsl/weight.rb +12 -0
  27. data/lib/teuton/case/host.rb +68 -0
  28. data/lib/teuton/case/play.rb +2 -6
  29. data/lib/teuton/{utils → case}/result/ext_array.rb +0 -1
  30. data/lib/teuton/{utils → case}/result/ext_compare.rb +0 -1
  31. data/lib/teuton/{utils → case}/result/ext_filter.rb +0 -2
  32. data/lib/teuton/{utils → case}/result/result.rb +13 -21
  33. data/lib/teuton/check/checker.rb +82 -0
  34. data/lib/teuton/check/dsl/all.rb +37 -0
  35. data/lib/teuton/check/{builtin.rb → dsl/builtin.rb} +1 -3
  36. data/lib/teuton/check/dsl/expect.rb +90 -0
  37. data/lib/teuton/check/dsl/expect_sequence.rb +29 -0
  38. data/lib/teuton/check/dsl/getset.rb +23 -0
  39. data/lib/teuton/check/dsl/run.rb +35 -0
  40. data/lib/teuton/check/main.rb +29 -0
  41. data/lib/teuton/check/show.rb +75 -100
  42. data/lib/teuton/deprecated/application_test.rb +32 -0
  43. data/lib/teuton/readme/dsl/all.rb +32 -0
  44. data/lib/teuton/readme/dsl/expect.rb +29 -0
  45. data/lib/teuton/readme/dsl/getset.rb +33 -0
  46. data/lib/teuton/readme/dsl/run.rb +51 -0
  47. data/lib/teuton/readme/lang.rb +8 -10
  48. data/lib/teuton/readme/main.rb +27 -0
  49. data/lib/teuton/readme/readme.rb +31 -58
  50. data/lib/teuton/readme/result.rb +7 -0
  51. data/lib/teuton/utils/configfile_reader.rb +8 -4
  52. data/lib/teuton/utils/logger.rb +32 -0
  53. data/lib/teuton/utils/verbose.rb +1 -1
  54. data/lib/teuton/version.rb +1 -1
  55. data/lib/teuton.rb +6 -5
  56. metadata +45 -39
  57. data/docs/CHANGELOG.md +0 -10
  58. data/docs/changelog/v2.0.md +0 -18
  59. data/docs/changelog/v2.1.md +0 -54
  60. data/docs/changelog/v2.2.md +0 -42
  61. data/docs/changelog/v2.3.md +0 -10
  62. data/docs/changelog/v2.4.md +0 -41
  63. data/docs/changelog/v2.5.md +0 -6
  64. data/docs/changelog/v2.6.md +0 -4
  65. data/docs/changelog/v2.7.md +0 -23
  66. data/docs/changelog/v2.8.md +0 -11
  67. data/docs/changelog/version2.1.md +0 -4
  68. data/docs/learn/videos.md +0 -13
  69. data/lib/teuton/case/execute/copy_ssh.rb +0 -70
  70. data/lib/teuton/check/dsl.rb +0 -112
  71. data/lib/teuton/check/laboratory.rb +0 -59
  72. data/lib/teuton/readme/dsl.rb +0 -126
  73. /data/lib/teuton/case/dsl/{goto.rb → run.rb} +0 -0
  74. /data/lib/teuton/{utils → deprecated}/application.rb +0 -0
  75. /data/lib/teuton/{case/deprecated → deprecated}/runner.rb +0 -0
  76. /data/lib/teuton/{case/deprecated → deprecated}/utils.rb +0 -0
@@ -2,7 +2,7 @@ require_relative "project"
2
2
 
3
3
  module Verbose
4
4
  def verboseln(text)
5
- verbose(text + "\n")
5
+ verbose(text.to_s + "\n")
6
6
  end
7
7
 
8
8
  def verbose(text)
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "2.8.0"
2
+ VERSION = "2.9.0"
3
3
  APPNAME = "teuton"
4
4
  GEMNAME = "teuton"
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
data/lib/teuton.rb CHANGED
@@ -8,15 +8,16 @@ module Teuton
8
8
 
9
9
  def self.check(projectpath, options = {})
10
10
  Project.add_input_params(projectpath, options)
11
- require_dsl_and_script("teuton/check/laboratory") # Define DSL
12
- lab = Laboratory.new(
11
+ require_dsl_and_script("teuton/check/main")
12
+ require_relative "teuton/check/checker"
13
+ checker = Checker.new(
13
14
  Project.value[:script_path],
14
15
  Project.value[:config_path]
15
16
  )
16
17
  if options["onlyconfig"]
17
- lab.show_onlyconfig
18
+ checker.show_onlyconfig
18
19
  else
19
- lab.show
20
+ checker.show
20
21
  end
21
22
  end
22
23
 
@@ -28,7 +29,7 @@ module Teuton
28
29
 
29
30
  def self.readme(projectpath, options = {})
30
31
  Project.add_input_params(projectpath, options)
31
- require_dsl_and_script("teuton/readme/readme") # Define DSL
32
+ require_dsl_and_script("teuton/readme/main") # Define DSL
32
33
  readme = Readme.new(
33
34
  Project.value[:script_path],
34
35
  Project.value[:config_path]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-15 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -124,18 +124,9 @@ extensions: []
124
124
  extra_rdoc_files:
125
125
  - README.md
126
126
  - LICENSE
127
- - docs/CHANGELOG.md
127
+ - docs/changelog/changelog.1.md
128
+ - docs/changelog/changelog.2.md
128
129
  - docs/changelog/todo.md
129
- - docs/changelog/v2.0.md
130
- - docs/changelog/v2.1.md
131
- - docs/changelog/v2.2.md
132
- - docs/changelog/v2.3.md
133
- - docs/changelog/v2.4.md
134
- - docs/changelog/v2.5.md
135
- - docs/changelog/v2.6.md
136
- - docs/changelog/v2.7.md
137
- - docs/changelog/v2.8.md
138
- - docs/changelog/version2.1.md
139
130
  - docs/commands/README.md
140
131
  - docs/commands/example_check.md
141
132
  - docs/commands/example_run.md
@@ -188,25 +179,19 @@ extra_rdoc_files:
188
179
  - docs/learn/22-result.md
189
180
  - docs/learn/23-test-code.md
190
181
  - docs/learn/24-test-sql.md
182
+ - docs/learn/25-expect-result.md
183
+ - docs/learn/26-expect_sequence.md
184
+ - docs/learn/27-run_script.md
185
+ - docs/learn/28-upload.md
191
186
  - docs/learn/README.md
192
- - docs/learn/videos.md
193
187
  - docs/videos.md
194
188
  files:
195
189
  - LICENSE
196
190
  - README.md
197
191
  - bin/teuton
198
- - docs/CHANGELOG.md
192
+ - docs/changelog/changelog.1.md
193
+ - docs/changelog/changelog.2.md
199
194
  - docs/changelog/todo.md
200
- - docs/changelog/v2.0.md
201
- - docs/changelog/v2.1.md
202
- - docs/changelog/v2.2.md
203
- - docs/changelog/v2.3.md
204
- - docs/changelog/v2.4.md
205
- - docs/changelog/v2.5.md
206
- - docs/changelog/v2.6.md
207
- - docs/changelog/v2.7.md
208
- - docs/changelog/v2.8.md
209
- - docs/changelog/version2.1.md
210
195
  - docs/commands/README.md
211
196
  - docs/commands/example_check.md
212
197
  - docs/commands/example_run.md
@@ -259,8 +244,11 @@ files:
259
244
  - docs/learn/22-result.md
260
245
  - docs/learn/23-test-code.md
261
246
  - docs/learn/24-test-sql.md
247
+ - docs/learn/25-expect-result.md
248
+ - docs/learn/26-expect_sequence.md
249
+ - docs/learn/27-run_script.md
250
+ - docs/learn/28-upload.md
262
251
  - docs/learn/README.md
263
- - docs/learn/videos.md
264
252
  - docs/videos.md
265
253
  - lib/teuton.rb
266
254
  - lib/teuton/case/builtin/main.rb
@@ -272,24 +260,32 @@ files:
272
260
  - lib/teuton/case/case.rb
273
261
  - lib/teuton/case/close.rb
274
262
  - lib/teuton/case/config.rb
275
- - lib/teuton/case/deprecated/runner.rb
276
- - lib/teuton/case/deprecated/utils.rb
277
263
  - lib/teuton/case/dsl/all.rb
278
264
  - lib/teuton/case/dsl/expect.rb
265
+ - lib/teuton/case/dsl/expect_exitcode.rb
266
+ - lib/teuton/case/dsl/expect_sequence.rb
279
267
  - lib/teuton/case/dsl/getset.rb
280
- - lib/teuton/case/dsl/goto.rb
268
+ - lib/teuton/case/dsl/host.rb
281
269
  - lib/teuton/case/dsl/log.rb
282
270
  - lib/teuton/case/dsl/macro.rb
271
+ - lib/teuton/case/dsl/run.rb
272
+ - lib/teuton/case/dsl/run_script.rb
283
273
  - lib/teuton/case/dsl/send.rb
284
274
  - lib/teuton/case/dsl/target.rb
285
275
  - lib/teuton/case/dsl/unique.rb
286
- - lib/teuton/case/execute/copy_ssh.rb
276
+ - lib/teuton/case/dsl/upload.rb
277
+ - lib/teuton/case/dsl/weight.rb
287
278
  - lib/teuton/case/execute/execute_base.rb
288
279
  - lib/teuton/case/execute/execute_local.rb
289
280
  - lib/teuton/case/execute/execute_manager.rb
290
281
  - lib/teuton/case/execute/execute_ssh.rb
291
282
  - lib/teuton/case/execute/execute_telnet.rb
283
+ - lib/teuton/case/host.rb
292
284
  - lib/teuton/case/play.rb
285
+ - lib/teuton/case/result/ext_array.rb
286
+ - lib/teuton/case/result/ext_compare.rb
287
+ - lib/teuton/case/result/ext_filter.rb
288
+ - lib/teuton/case/result/result.rb
293
289
  - lib/teuton/case_manager/case_manager.rb
294
290
  - lib/teuton/case_manager/check_cases.rb
295
291
  - lib/teuton/case_manager/dsl.rb
@@ -299,19 +295,33 @@ files:
299
295
  - lib/teuton/case_manager/send_manager.rb
300
296
  - lib/teuton/case_manager/show_report.rb
301
297
  - lib/teuton/case_manager/utils.rb
302
- - lib/teuton/check/builtin.rb
303
- - lib/teuton/check/dsl.rb
304
- - lib/teuton/check/laboratory.rb
298
+ - lib/teuton/check/checker.rb
299
+ - lib/teuton/check/dsl/all.rb
300
+ - lib/teuton/check/dsl/builtin.rb
301
+ - lib/teuton/check/dsl/expect.rb
302
+ - lib/teuton/check/dsl/expect_sequence.rb
303
+ - lib/teuton/check/dsl/getset.rb
304
+ - lib/teuton/check/dsl/run.rb
305
+ - lib/teuton/check/main.rb
305
306
  - lib/teuton/check/show.rb
306
307
  - lib/teuton/cli.rb
308
+ - lib/teuton/deprecated/application.rb
309
+ - lib/teuton/deprecated/application_test.rb
310
+ - lib/teuton/deprecated/runner.rb
311
+ - lib/teuton/deprecated/utils.rb
307
312
  - lib/teuton/files/README.md
308
313
  - lib/teuton/files/config.yaml
309
314
  - lib/teuton/files/start.rb
310
315
  - lib/teuton/files/template/case.html
311
316
  - lib/teuton/files/template/resume.html
312
- - lib/teuton/readme/dsl.rb
317
+ - lib/teuton/readme/dsl/all.rb
318
+ - lib/teuton/readme/dsl/expect.rb
319
+ - lib/teuton/readme/dsl/getset.rb
320
+ - lib/teuton/readme/dsl/run.rb
313
321
  - lib/teuton/readme/lang.rb
322
+ - lib/teuton/readme/main.rb
314
323
  - lib/teuton/readme/readme.rb
324
+ - lib/teuton/readme/result.rb
315
325
  - lib/teuton/report/formatter/base_formatter.rb
316
326
  - lib/teuton/report/formatter/default/array.rb
317
327
  - lib/teuton/report/formatter/default/colored_text.rb
@@ -330,14 +340,10 @@ files:
330
340
  - lib/teuton/report/formatter/resume/yaml.rb
331
341
  - lib/teuton/report/report.rb
332
342
  - lib/teuton/skeleton.rb
333
- - lib/teuton/utils/application.rb
334
343
  - lib/teuton/utils/configfile_reader.rb
344
+ - lib/teuton/utils/logger.rb
335
345
  - lib/teuton/utils/name_file_finder.rb
336
346
  - lib/teuton/utils/project.rb
337
- - lib/teuton/utils/result/ext_array.rb
338
- - lib/teuton/utils/result/ext_compare.rb
339
- - lib/teuton/utils/result/ext_filter.rb
340
- - lib/teuton/utils/result/result.rb
341
347
  - lib/teuton/utils/settings.rb
342
348
  - lib/teuton/utils/verbose.rb
343
349
  - lib/teuton/version.rb
data/docs/CHANGELOG.md DELETED
@@ -1,10 +0,0 @@
1
- [<< back](../README.md)
2
-
3
- # Changelog
4
-
5
- * [version 2.5](changelog/v2.5.md)
6
- * [version 2.4](changelog/v2.4.md)
7
- * [version 2.3](changelog/v2.3.md)
8
- * [version 2.2](changelog/v2.2.md)
9
- * [version 2.1](changelog/v2.1.md)
10
- * [version 2.0](changelog/v2.0.md)
@@ -1,18 +0,0 @@
1
- [<< back](../CHANGELOG.md)
2
-
3
- # CHANGELOG
4
-
5
- ## 2019
6
-
7
- |Date |Version |Changes |
8
- |--------- |------- |------- |
9
- | August 2019 | 2.0.4 | TEUTON project grew up and was divided into the folowing repositories: teuton, challenges, panel, resources and vagrant. Documentation has been moved into respository teuton wiki. Only maintain English docs. |
10
- |January 2019 |1.10.0 | SysadminGame change his name by TEUTON. "project" command replaced by "teuton". Challenges (Teuton scripts) moved to "teuton-challenges" github repository. Execute "rake get_challenges" to get sample teuton challenges |
11
-
12
- ## 2017
13
-
14
- |Date |Version |Changes |
15
- |--------- |------- |------- |
16
- |July 2017 |1.0.0 | New stable version |
17
- |June 2017 |0.22.1 | * Now it's posible to use config files with YAML and JSON format |
18
- | | | * Preparing migration of CLI command to use Thor gem |
@@ -1,54 +0,0 @@
1
- [<< back](../CHANGELOG.md)
2
-
3
- # CHANGELOG teuton v 2.1
4
-
5
- # 1. Export grades on csv file using Moodle format
6
-
7
- * Automaticaly exports `moodle.csv` file with all cases grades, using adecuate format so it could be imported directly into Moodle platform.
8
- * We need to configure some params like this:
9
-
10
- ```
11
- ---
12
- :global:
13
- :cases:
14
- - :tt_members: ...
15
- :tt_moodle_id: User Moodle Identity
16
- ```
17
-
18
- # 2. readme keyword
19
-
20
- We currently use the "teuton readme pry-folder" command to export README file from the challenge.
21
-
22
- * This example shows how to use readme keyword to add group description or target description:
23
-
24
- ```
25
- group "GROUPNAME" do
26
- readme "Description for this group"
27
-
28
- target "target1"
29
- readme "Description for this target"
30
- goto :host, :exec => 'id root'
31
- expec_one 'root'
32
- ```
33
-
34
- # 3. Installation process
35
-
36
- * Use Bundler to install gems instead of rake.
37
- * It will be usefull use sysadming-game as gem? And install it with `gem install teuton`.
38
- * Vagrant: test how to use vagrant machines as case hosts.
39
-
40
- # 4. Info sobre novedades de la versión 2.1
41
-
42
- 1. Teuton readme y dsl readme
43
- 2. Macros de define macro
44
- 3. Export yaml y html
45
- 4. Teuton --no-color
46
- 5. teuton run --case
47
- 6. teuton run --cname
48
- 7. teuton run --cpath
49
- 8. actualizar formatos de salida
50
- 9. instalación mediante gemas
51
- 10. teuton panel
52
- 11. teuton client y server
53
- 12. nuevos nombres de comandos...
54
- 13. cambio de goto a run
@@ -1,42 +0,0 @@
1
- [<< back](../CHANGELOG.md)
2
-
3
- # Teuton (version 2.2)
4
-
5
- ## New features
6
-
7
- * Let's see new features examples:
8
- * 10 result and moodle_id
9
- * 11 get_vars
10
- * 12 alias
11
- * 13 include (tt_include config param)
12
- * 14 macros
13
-
14
- **Configuration file**
15
-
16
- * Por defecto los valores de clave de los ficheros de configuración serán Strings en lugar de símbolos, aunque lo símbolos seguirán funcionando.
17
-
18
- **get_vars: To think - We are not sure about this***
19
-
20
- * "get" keyword simplification: Simplify getting and setting params process. For example: `_username_`, may be alias for `get(:username)`. Then
21
-
22
- ```
23
- target "Create user #{_username_}"
24
- run "id #{_username_}"
25
- expect_one _username_
26
- ```
27
- Same as
28
-
29
- ```
30
- target "Create user "+get(:username)
31
- run "id " + get(:username)
32
- expect_one get(:username)
33
- ```
34
-
35
- * Promocinar el proyecto:
36
- * Documentar y hacer videos.
37
- * Charlas y talleres
38
-
39
- ## Fixed
40
-
41
- * Solucionar fallo en --cname
42
- * Revisar doc options como cpanel
@@ -1,10 +0,0 @@
1
-
2
- ## [2.3.11]
3
-
4
- - Issue #18
5
-
6
- ## [2.3.9]
7
-
8
- Bug fixed:
9
- - Remove warnings from linter
10
- - Remove warning about thor gem version. Upgrade gem to 1.2
@@ -1,41 +0,0 @@
1
- ## [2.4.5]
2
-
3
- -- FIX: "expect_nothing" was always TRUE when SSH/Telnet connections fails!
4
- Now when SSH/Telnet connections fails result contains "SSH: NO CONNECTION!"
5
- So "expect_nothing" will fail.
6
-
7
- ## [2.4.4]
8
-
9
- -- Modify: teuton check output colors and exit codes.
10
- exit code 0 = check OK
11
- exit code 1 = check error
12
- -- Fix teuton check docs.
13
-
14
- ## [2.4.3]
15
-
16
- - Fix: "expect_none" without params works as "expect result.count.eq 0"
17
- - Add: "expect_nothing" that works as "expect result.count.eq 0".
18
-
19
- ## [2.4.2]
20
-
21
- - Fix bug with result.grep_v(Array)
22
-
23
- ## [2.4.0]
24
-
25
- New features:
26
- - Hide feedback from reports: `export feedback: false`
27
- - Add new DSL keyword: expect_last, expect_fisrt
28
- - Remove os gem.
29
- - Change test output colors to green as use others test tools.
30
- - Change show DSL params. Accepts one param "verbose: NUMBER" to adjust verbosity output level on screen.
31
-
32
- New doc and example:
33
- - 14-alias
34
- - 16-exit_codes
35
-
36
- Bug fixed:
37
- - All "expect*" keywords must require 2 arguments. The second is optional.
38
-
39
- Revise
40
- - Remove colors to log text
41
- - teuton readme: macros, getvars, expect_last, expect_first
@@ -1,6 +0,0 @@
1
-
2
- ## [2.5.0]
3
-
4
- - ADD: "tt_moodle_max_score" global configuration param. Teuton grades (0-100) are divided by this value when exporting data into "moodle.csv" output file.
5
- - UPDATE: Revise documentation. Doc learn 10,11, 12,13 y 14. 10 result and moodle_id, 12 alias, 13 include, 14 macro, Doc tt_include
6
- - UPDATE: Internal changes. Remove Colorize gem and replace with Rainbow.
@@ -1,4 +0,0 @@
1
-
2
- ## [2.6.0]
3
-
4
- - [ADD] When running local or SSH commands, stdout and stderr are captured and readed by "expect" sentence.
@@ -1,23 +0,0 @@
1
-
2
- ## [2.7.3] 20230607
3
-
4
- - [FIX] Hall of fame now use Project class instead of Application.
5
-
6
- ## [2.7.2] 20230607
7
-
8
- - [FIX] Fixed an issue that appeared when exporting reports without feedback after failing to connect to remote computer.
9
-
10
- ## [2.7.1]
11
-
12
- - [FIX] Fixed an issue that appeared when executing test and fail connection to remote computer.
13
-
14
- ## [2.7.0]
15
-
16
- New features:
17
- - [ADD] "teuton config PROJECTPATH" will suggest suitable configuration for the project.
18
- - [ADD] Every one line command output is registered into reports.
19
- - [ADD] "expect_exit 1", check last command exit code is equal to 1.
20
-
21
- Internal changes:
22
- * Application class splited into Settings and Project classes
23
- * Create SendManager similar to ExportManager
@@ -1,11 +0,0 @@
1
-
2
- ## [2.8.0] 20230630
3
-
4
- expect:
5
- - [ADD] "expect_ok" as "expect_exit 0 ".
6
- - [ADD] "expect_fail" as "expect_exit NUMBER" where NUMBER > 0.
7
- - [FIX] expect evaluation fail when there is no remote connection.
8
-
9
- send:
10
- - [UPDATE] Rename "remote_dir" send param to "dir".
11
- - [UPDATE] send output messages
@@ -1,4 +0,0 @@
1
-
2
- # TEUTON (version 2.1)
3
-
4
- Goto to [version 2.1](https://github.com/teuton-software/teuton/tree/devel).
data/docs/learn/videos.md DELETED
@@ -1,13 +0,0 @@
1
-
2
- By now there are no English videos. We are sorry!
3
- But if you want to see Spanish videos, here you are:
4
-
5
- Teuton (v2.0):
6
- * [CHAPI19 - Charla Teuton](https://youtu.be/KFWQDfNAFxI?t=12221)
7
-
8
- Sysadmingame (Teuton v1.0)
9
- * [Sysadmingame (1 de 3): Instalación del programa](https://youtu.be/dnyMq9_KDco)
10
- * [Sysadmingame (2 de 3): Crear un caso simple](https://youtu.be/0e2g5Izvc6c)
11
- * [Sysadmingame (3 de 3): Crear un caso complejo](https://youtu.be/ebEK6OXH8kQ)
12
- * [CHAPI16 - Charla sysadmingame](https://youtu.be/cNJaB5xzHHQ)
13
-
@@ -1,70 +0,0 @@
1
- require "net/ssh"
2
- require "net/sftp"
3
- require "rainbow"
4
- require_relative "../../utils/project"
5
- require_relative "../../utils/verbose"
6
- require_relative "execute_base"
7
-
8
- class CopySSH < ExecuteBase
9
- def call(host, localfilename)
10
- # Check params
11
- unless config.get("#{host}_route".to_sym) == "NODATA"
12
- log("'copy script' requires direct host access!", :error)
13
- return false
14
- end
15
-
16
- host = host.to_s
17
-
18
- begin
19
- if sessions[host].nil?
20
- # Open new SSH session
21
- ip = config.get("#{host}_ip".to_sym).to_s
22
- username = config.get("#{host}_username".to_sym).to_s
23
- password = config.get("#{host}_password".to_sym).to_s
24
- port = config.get("#{host}_port".to_sym).to_i
25
- port = 22 if port.zero?
26
-
27
- sessions[host] = Net::SSH.start(
28
- ip,
29
- username,
30
- port: port,
31
- password: password,
32
- keepalive: true,
33
- timeout: 30,
34
- non_interactive: true
35
- )
36
- end
37
- if sessions[host].instance_of? Net::SSH::Connection::Session
38
- copy_to(host, localfilename)
39
- else
40
- "SSH: NO CONNECTION!"
41
- end
42
- rescue => e
43
- sessions[host] = :nosession
44
- conn_status[host] = :error
45
- log("[#{e.class}] SSH on <#{username}@#{ip}>", :error)
46
- end
47
- end
48
-
49
- def copy_to(host, localfilename)
50
- ip = get((host + "_ip").to_sym)
51
- username = get((host + "_username").to_sym).to_s
52
- password = get((host + "_password").to_sym).to_s
53
- port = get((host + "_port").to_sym).to_i
54
- port = 22 if port.zero?
55
-
56
- localfilepath = File.join(Dir.pwd, localfilename)
57
- remotefilepath = File.join(".", File.basename(localfilename))
58
-
59
- # Upload a file or directory to the remote host
60
- begin
61
- Net::SFTP.start(ip, username, password: password, port: port) do |sftp|
62
- sftp.upload!(localfilepath, remotefilepath)
63
- end
64
- rescue
65
- log("copy file: #{localfilename} => #{remotefilepath}", :error)
66
- return false
67
- end
68
- true
69
- end
70
- end
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Laboratory
4
- # Include Teuton DSL keywords into Laboratory class
5
- def readme(_text)
6
- # Usefull for "teuton readme" command action.
7
- end
8
-
9
- def target(desc, args = {})
10
- @stats[:targets] += 1
11
- @targetid += 1
12
- weight = args[:weight] || 1.0
13
- verboseln format("(%03<targetid>d) target %<desc>s", targetid: @targetid, desc: desc)
14
- verboseln " weight #{weight}"
15
- end
16
- alias goal target
17
-
18
- def expect(cond)
19
- verboseln " alter #{result.alterations}" unless result.alterations.empty?
20
- verboseln " expect #{cond} (#{cond.class})"
21
- verboseln ""
22
- end
23
-
24
- def expect_first(cond)
25
- verboseln " alter #{result.alterations}" unless result.alterations.empty?
26
- verboseln " expect_first #{cond} (#{cond.class})"
27
- verboseln ""
28
- end
29
-
30
- def expect_last(cond)
31
- verboseln " alter #{result.alterations}" unless result.alterations.empty?
32
- verboseln " expect_last #{cond} (#{cond.class})"
33
- verboseln ""
34
- end
35
-
36
- def expect_none(cond)
37
- verboseln " alter #{result.alterations}" unless result.alterations.empty?
38
- verboseln " expect_none #{cond} (#{cond.class})"
39
- verboseln ""
40
- end
41
-
42
- def expect_one(cond)
43
- verboseln " alter #{result.alterations}" unless result.alterations.empty?
44
- verboseln " expect_one #{cond} (#{cond.class})"
45
- verboseln ""
46
- end
47
-
48
- def get(varname)
49
- @stats[:gets] += 1
50
-
51
- if @gets[varname]
52
- @gets[varname] += 1
53
- else
54
- @gets[varname] = 1
55
- end
56
-
57
- "get(#{varname})"
58
- end
59
-
60
- def run(command, args = {})
61
- args[:exec] = command
62
- host = :localhost
63
- host = args[:on] if args[:on]
64
- goto(host, args)
65
- end
66
-
67
- def goto(host = :localhost, args = {})
68
- result.reset
69
- args[:on] = host unless args[:on]
70
-
71
- if @hosts[host]
72
- @hosts[host] += 1
73
- else
74
- @hosts[host] = 1
75
- end
76
- verboseln " run '#{args[:exec]}' on #{args[:on]}"
77
- end
78
-
79
- # Check macros and _get_vars
80
- def method_missing(method, *args, &block)
81
- a = method.to_s
82
- if args.nil? && block.nil?
83
- instance_eval("get(:#{a[0, a.size - 1]})", __FILE__, __LINE__) if a[a.size - 1] == "?"
84
- end
85
- end
86
-
87
- def gett(option)
88
- get(option)
89
- end
90
-
91
- def unique(key, _value)
92
- @stats[:uniques] += 1
93
-
94
- verboseln " ! Unique value for <#{key}>"
95
- verboseln ""
96
- end
97
-
98
- def log(text = "", type = :info)
99
- @stats[:logs] += 1
100
- verboseln " log [#{type}]: " + text.to_s
101
- end
102
-
103
- def set(key, value)
104
- @stats[:sets] += 1
105
-
106
- key = ":" + key.to_s if key.instance_of? Symbol
107
- value = ":" + value.to_s if value.instance_of? Symbol
108
-
109
- @sets[key] = value
110
- "set(#{key},#{value})"
111
- end
112
- end