net-connector 0.8.0 → 0.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/CONTRIBUTING.md +12 -0
  4. data/README.md +26 -425
  5. data/README.zh-CN.md +64 -0
  6. data/bin/net-backup +1 -0
  7. data/docs/VERIFICATION.md +2 -2
  8. data/docs/architecture.md +9 -4
  9. data/docs/netdisco.md +176 -0
  10. data/docs/netdisco.zh-CN.md +247 -0
  11. data/docs/usage.md +124 -0
  12. data/docs/usage.zh-CN.md +190 -0
  13. data/examples/backup.yml +5 -4
  14. data/examples/inventory_sql.yml +5 -1
  15. data/lib/net/connector/device/base.rb +5 -4
  16. data/lib/net/connector/device/local_backup.rb +3 -0
  17. data/lib/net/connector/device/running_config/strategy.rb +2 -1
  18. data/lib/net/connector/device/running_config.rb +2 -0
  19. data/lib/net/connector/device/tftp/receipt.rb +1 -0
  20. data/lib/net/connector/device/tftp/strategy.rb +28 -9
  21. data/lib/net/connector/device/tftp.rb +9 -8
  22. data/lib/net/connector/device/topology/immediate_strategy.rb +2 -1
  23. data/lib/net/connector/engine/core.rb +1 -0
  24. data/lib/net/connector/engine/dialogue.rb +5 -2
  25. data/lib/net/connector/engine/known_hosts.rb +20 -4
  26. data/lib/net/connector/engine/log.rb +14 -9
  27. data/lib/net/connector/engine/recovery.rb +1 -1
  28. data/lib/net/connector/engine/session.rb +14 -5
  29. data/lib/net/connector/engine/transport.rb +21 -10
  30. data/lib/net/connector/netdisco/backup_run.rb +13 -5
  31. data/lib/net/connector/netdisco/cli/options.rb +17 -8
  32. data/lib/net/connector/netdisco/cli.rb +3 -3
  33. data/lib/net/connector/netdisco/config_file.rb +19 -14
  34. data/lib/net/connector/netdisco/database_client.rb +40 -24
  35. data/lib/net/connector/netdisco/device.rb +3 -0
  36. data/lib/net/connector/netdisco/diagnostic.rb +4 -0
  37. data/lib/net/connector/netdisco/fleet.rb +2 -2
  38. data/lib/net/connector/netdisco/plan.rb +12 -3
  39. data/lib/net/connector/netdisco/progress.rb +9 -0
  40. data/lib/net/connector/netdisco/report/files.rb +1 -0
  41. data/lib/net/connector/netdisco/result_store.rb +1 -0
  42. data/lib/net/connector/netdisco/rules.rb +7 -5
  43. data/lib/net/connector/netdisco/settings.rb +77 -19
  44. data/lib/net/connector/netdisco/tftp_archive.rb +4 -0
  45. data/lib/net/connector/netdisco/worker.rb +1 -1
  46. data/lib/net/connector/storage/private_file.rb +6 -0
  47. data/lib/net/connector/vendor/cisco_ios/running_config.rb +1 -0
  48. data/lib/net/connector/vendor/cisco_ios/tftp_backup.rb +2 -0
  49. data/lib/net/connector/vendor/cisco_ios/topology.rb +2 -0
  50. data/lib/net/connector/vendor/cisco_nxos/tftp_backup.rb +2 -0
  51. data/lib/net/connector/vendor/h3c/tftp_backup.rb +1 -0
  52. data/lib/net/connector/vendor/h3c/topology.rb +2 -0
  53. data/lib/net/connector/vendor/hillstone/running_config.rb +1 -0
  54. data/lib/net/connector/vendor/hillstone/tftp_backup.rb +2 -0
  55. data/lib/net/connector/vendor/hillstone/topology.rb +2 -0
  56. data/lib/net/connector/vendor/huawei/tftp_backup.rb +2 -1
  57. data/lib/net/connector/vendor/palo_alto/running_config.rb +1 -0
  58. data/lib/net/connector/vendor/palo_alto/tftp_backup.rb +2 -0
  59. data/lib/net/connector/vendor/palo_alto/topology.rb +16 -16
  60. data/lib/net/connector/vendor/radware/running_config.rb +1 -0
  61. data/lib/net/connector/vendor/radware/tftp_backup.rb +2 -0
  62. data/lib/net/connector/vendor/radware/topology.rb +1 -0
  63. data/lib/net/connector/version.rb +2 -1
  64. data/lib/net/connector.rb +1 -0
  65. data/lib/net-connector.rb +1 -0
  66. metadata +7 -16
@@ -5,6 +5,7 @@ require_relative "../../device/tftp/file_upload"
5
5
  module Net
6
6
  module Connector
7
7
  module Huawei
8
+ # 上传调用方明确指定的华为保存文件,连接前拒绝缺少源文件的请求。
8
9
  class TftpBackup < Tftp::FileUpload
9
10
  # 缺少源文件也必须在首次设备 I/O 之前拒绝。
10
11
  def validate_options!(target, source_file:, vrf: nil)
@@ -12,7 +13,7 @@ module Net
12
13
  raise ArgumentError, "Huawei TFTP backup requires source_file" if source_file.nil?
13
14
  end
14
15
 
15
- # 要求调用方提供合法的华为启动配置文件路径。
16
+ # 读取调用方明确指定的合法保存文件路径,不根据文件名推断为启动配置。
16
17
  def resolve_source_file(value)
17
18
  raise ArgumentError, "Huawei TFTP backup requires source_file" unless value
18
19
 
@@ -6,6 +6,7 @@ require_relative "../../device/running_config/strategy"
6
6
  module Net
7
7
  module Connector
8
8
  module PaloAlto
9
+ # 通过候选差异与 set 格式校验确认采集证据,拒绝将未提交配置当作运行配置。
9
10
  class RunningConfig < Net::Connector::RunningConfig::Strategy
10
11
  # 配置位于 show 步骤,最后的 exit 只负责离开候选视图。
11
12
  def result_step(result)
@@ -5,6 +5,7 @@ require_relative "../../device/tftp/strategy"
5
5
  module Net
6
6
  module Connector
7
7
  module PaloAlto
8
+ # PAN-OS 上传固定的 running-config.xml,调用方不能改名或指定其他源文件。
8
9
  class TftpBackup < Tftp::Strategy
9
10
  FILENAME = "running-config.xml"
10
11
 
@@ -20,6 +21,7 @@ module Net
20
21
  raise ArgumentError, "PAN-OS TFTP export uses the fixed filename #{FILENAME}"
21
22
  end
22
23
 
24
+ # 声明本厂商实际导出的配置种类与格式,不推断服务器文件已核验。
23
25
  def receipt_metadata(_target, **)
24
26
  { configuration_kind: :running, format: :xml, source_file: FILENAME }
25
27
  end
@@ -5,12 +5,14 @@ require_relative "../../device/topology/strategy"
5
5
  module Net
6
6
  module Connector
7
7
  module PaloAlto
8
+ # 仅开放 LLDP 和描述读取;未验证候选隔离协议前不开放自动提交。
8
9
  class Topology < Topology::Strategy
9
10
  # 候选配置缺少经固件实验确认的所有权/commit 协议,暂只提供读取能力。
10
11
  def self.supports?(capability)
11
12
  %i[neighbors interface_descriptions].include?(capability)
12
13
  end
13
14
 
15
+ # 关闭自动修改时返回固定领域错误,调用方不能把未实现能力当作成功。
14
16
  def change_error_code = :candidate_isolation_unavailable
15
17
 
16
18
  # 读取各本机接口的 LLDP 邻居详情。
@@ -35,22 +37,6 @@ module Net
35
37
  !blocks.empty? && blocks.all? { |block| empty_neighbor_block?(block) }
36
38
  end
37
39
 
38
- private
39
-
40
- # PAN-OS 会列出启用 LLDP、但没有邻居的本机接口;只有明确为空的
41
- # Neighbor information 块可跳过,缺字段的非空块继续交给数量校验拒绝。
42
- def neighbor_blocks(output)
43
- output.split(/^\s*Local information:\s*$/i).select { |block| block.match?(/^\s*Local interface:\s*\S+/i) }
44
- end
45
-
46
- # 邻居字段区只有空行和提示符时,才视为明确的空块。
47
- def empty_neighbor_block?(block)
48
- tail = block.split(/^\s*Neighbor information:\s*$/i, 2)
49
- tail.size == 2 && tail.last.lines.all? { |line| line.strip.empty? || line.match?(/^\S+[>#]\s*$/) }
50
- end
51
-
52
- public
53
-
54
40
  # 模板按行读取;未闭合的引号表示证据不完整,不能把首行当成旧描述。
55
41
  def decode_description(value)
56
42
  value = value.strip
@@ -69,6 +55,20 @@ module Net
69
55
  def script_command(command)
70
56
  command == "commit" ? Command.new(command, timeout: 300) : command
71
57
  end
58
+
59
+ private
60
+
61
+ # PAN-OS 会列出启用 LLDP、但没有邻居的本机接口;只有明确为空的
62
+ # Neighbor information 块可跳过,缺字段的非空块继续交给数量校验拒绝。
63
+ def neighbor_blocks(output)
64
+ output.split(/^\s*Local information:\s*$/i).select { |block| block.match?(/^\s*Local interface:\s*\S+/i) }
65
+ end
66
+
67
+ # 邻居字段区只有空行和提示符时,才视为明确的空块。
68
+ def empty_neighbor_block?(block)
69
+ tail = block.split(/^\s*Neighbor information:\s*$/i, 2)
70
+ tail.size == 2 && tail.last.lines.all? { |line| line.strip.empty? || line.match?(/^\S+[>#]\s*$/) }
71
+ end
72
72
  end
73
73
  end
74
74
  end
@@ -5,6 +5,7 @@ require_relative "../../device/running_config/strategy"
5
5
  module Net
6
6
  module Connector
7
7
  module Radware
8
+ # 复用终端渲染策略,在配置菜单中保持已认证的设备提示身份。
8
9
  class RunningConfig < Net::Connector::RunningConfig::Rendered
9
10
  # /cfg/dump 进入 Configuration 菜单;保留设备前缀,只替换菜单名称。
10
11
  def prompt_text(command)
@@ -5,6 +5,7 @@ require_relative "../../device/tftp/strategy"
5
5
  module Net
6
6
  module Connector
7
7
  module Radware
8
+ # 交互导出 Alteon 原生 tgz 归档;回执不将归档推断为文本运行配置。
8
9
  class TftpBackup < Tftp::Strategy
9
10
  # Radware 原生导出生成压缩配置归档。
10
11
  def self.file_extension = "tgz"
@@ -15,6 +16,7 @@ module Net
15
16
  raise ArgumentError, "Radware TFTP backup does not use vrf" unless vrf.nil?
16
17
  end
17
18
 
19
+ # 声明本厂商实际导出的配置种类与格式,不推断服务器文件已核验。
18
20
  def receipt_metadata(_target, **) = { configuration_kind: :native_archive, format: :tgz }
19
21
 
20
22
  # 构造当前厂商的 TFTP 导出交互脚本。
@@ -5,6 +5,7 @@ require_relative "../../device/topology/strategy"
5
5
  module Net
6
6
  module Connector
7
7
  module Radware
8
+ # 只读取 Alteon 端口名称,不声明邻居发现或描述改写能力。
8
9
  class Topology < Topology::Strategy
9
10
  # Alteon 只支持读取端口描述,不提供邻居发现或自动改写。
10
11
  def self.supports?(capability) = capability == :interface_descriptions
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Net
4
4
  module Connector
5
- VERSION = "0.8.0"
5
+ # gemspec、CLI 与发布工具共用此版本,运行时读取不触发设备依赖加载。
6
+ VERSION = "0.9.0"
6
7
  end
7
8
  end
data/lib/net/connector.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "connector/version"
4
4
  require_relative "connector/device/base"
5
5
 
6
6
  module Net
7
+ # 设备 API 的公开加载入口;只登记厂商名称,实际连接器在首次选择时加载。
7
8
  module Connector
8
9
  VENDORS = {
9
10
  h3c: "H3c",
data/lib/net-connector.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # gem 名称加载入口与 net/connector 共用实现,不额外加载 Netdisco。
3
4
  require_relative "net/connector"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - net-connector contributors
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-10-09 00:00:00.000000000 Z
10
+ date: 2026-10-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: expect-pty
@@ -65,20 +65,6 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '3.1'
68
- - !ruby/object:Gem::Dependency
69
- name: english
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0.7'
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0.7'
82
68
  - !ruby/object:Gem::Dependency
83
69
  name: fileutils
84
70
  requirement: !ruby/object:Gem::Requirement
@@ -341,11 +327,16 @@ files:
341
327
  - CONTRIBUTING.md
342
328
  - LICENSE
343
329
  - README.md
330
+ - README.zh-CN.md
344
331
  - SECURITY.md
345
332
  - bin/net-backup
346
333
  - docs/RELEASING.md
347
334
  - docs/VERIFICATION.md
348
335
  - docs/architecture.md
336
+ - docs/netdisco.md
337
+ - docs/netdisco.zh-CN.md
338
+ - docs/usage.md
339
+ - docs/usage.zh-CN.md
349
340
  - examples/backup.yml
350
341
  - examples/inventory_sql.yml
351
342
  - lib/net-connector.rb