net-connector 0.4.0 → 0.4.2
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 +4 -4
- data/CHANGELOG.md +110 -68
- data/CONTRIBUTING.md +40 -0
- data/README.md +140 -95
- data/SECURITY.md +11 -0
- data/docs/VERIFICATION.md +129 -5
- data/docs/architecture.md +321 -248
- data/lib/net/connector/device/base.rb +12 -4
- data/lib/net/connector/device/interface_description.rb +3 -0
- data/lib/net/connector/device/profile/builder.rb +236 -0
- data/lib/net/connector/device/profile.rb +2 -227
- data/lib/net/connector/device/running_config/strategy.rb +5 -0
- data/lib/net/connector/device/running_config.rb +7 -0
- data/lib/net/connector/engine/command.rb +14 -2
- data/lib/net/connector/engine/configuration.rb +10 -7
- data/lib/net/connector/engine/dialogue.rb +53 -28
- data/lib/net/connector/engine/errors.rb +41 -54
- data/lib/net/connector/engine/execution.rb +32 -5
- data/lib/net/connector/engine/log.rb +23 -17
- data/lib/net/connector/engine/session.rb +39 -7
- data/lib/net/connector/engine/terminal_renderer.rb +7 -4
- data/lib/net/connector/netdisco/batch.rb +31 -3
- data/lib/net/connector/netdisco/cli.rb +92 -50
- data/lib/net/connector/netdisco/client.rb +206 -73
- data/lib/net/connector/netdisco/config_file.rb +26 -4
- data/lib/net/connector/netdisco/device.rb +4 -8
- data/lib/net/connector/netdisco/diagnostic.rb +91 -0
- data/lib/net/connector/netdisco/fleet.rb +105 -108
- data/lib/net/connector/netdisco/inventory_budget.rb +49 -0
- data/lib/net/connector/netdisco/plan.rb +77 -0
- data/lib/net/connector/netdisco/planner.rb +12 -23
- data/lib/net/connector/netdisco/report.rb +94 -0
- data/lib/net/connector/netdisco/rules.rb +28 -5
- data/lib/net/connector/netdisco/settings.rb +194 -85
- data/lib/net/connector/netdisco/worker.rb +43 -27
- data/lib/net/connector/operations/backup_lock.rb +116 -0
- data/lib/net/connector/operations/local_backup.rb +49 -9
- data/lib/net/connector/operations/parse_output.rb +20 -3
- data/lib/net/connector/operations/private_file.rb +94 -5
- data/lib/net/connector/operations/safe_file.rb +62 -0
- data/lib/net/connector/operations/saved_config/legacy_index.rb +109 -0
- data/lib/net/connector/operations/saved_config.rb +40 -10
- data/lib/net/connector/operations/tftp/file_upload.rb +55 -0
- data/lib/net/connector/operations/tftp/strategy.rb +9 -11
- data/lib/net/connector/operations/tftp_backup.rb +78 -15
- data/lib/net/connector/operations/tftp_receipt.rb +73 -0
- data/lib/net/connector/operations/topology/immediate_strategy.rb +45 -0
- data/lib/net/connector/operations/topology/strategy.rb +34 -0
- data/lib/net/connector/operations/topology.rb +98 -29
- data/lib/net/connector/operations.rb +6 -0
- data/lib/net/connector/vendor/cisco_ios/running_config.rb +1 -0
- data/lib/net/connector/vendor/cisco_ios/tftp_backup.rb +9 -2
- data/lib/net/connector/vendor/cisco_ios/topology.rb +18 -3
- data/lib/net/connector/vendor/cisco_nxos/running_config.rb +1 -0
- data/lib/net/connector/vendor/cisco_nxos/tftp_backup.rb +8 -1
- data/lib/net/connector/vendor/h3c/tftp_backup.rb +7 -18
- data/lib/net/connector/vendor/h3c/topology.rb +17 -3
- data/lib/net/connector/vendor/hillstone/running_config.rb +1 -0
- data/lib/net/connector/vendor/hillstone/tftp_backup.rb +16 -3
- data/lib/net/connector/vendor/hillstone/topology.rb +17 -3
- data/lib/net/connector/vendor/huawei/tftp_backup.rb +8 -18
- data/lib/net/connector/vendor/palo_alto/running_config.rb +4 -0
- data/lib/net/connector/vendor/palo_alto/tftp_backup.rb +19 -8
- data/lib/net/connector/vendor/palo_alto/topology.rb +16 -1
- data/lib/net/connector/vendor/radware/tftp_backup.rb +11 -4
- data/lib/net/connector/vendor/radware/topology.rb +3 -0
- data/lib/net/connector/version.rb +1 -1
- metadata +60 -28
|
@@ -6,19 +6,31 @@ module Net
|
|
|
6
6
|
module Connector
|
|
7
7
|
module PaloAlto
|
|
8
8
|
class Topology < Operations::Topology::Strategy
|
|
9
|
+
# 候选配置缺少经固件实验确认的所有权/commit 协议,暂只提供读取能力。
|
|
9
10
|
def self.supports?(capability)
|
|
10
|
-
%i[neighbors interface_descriptions
|
|
11
|
+
%i[neighbors interface_descriptions].include?(capability)
|
|
11
12
|
end
|
|
12
13
|
|
|
14
|
+
def change_error_code = :candidate_isolation_unavailable
|
|
15
|
+
|
|
16
|
+
# 读取各本机接口的 LLDP 邻居详情。
|
|
13
17
|
def neighbor_command = "show lldp neighbors all"
|
|
18
|
+
|
|
19
|
+
# 从 set 格式配置解析接口备注。
|
|
14
20
|
def description_template = "palo_alto_interface_descriptions.textfsm"
|
|
21
|
+
|
|
22
|
+
# 进入候选配置视图。
|
|
15
23
|
def enter_configuration = "configure"
|
|
24
|
+
|
|
25
|
+
# 提交候选配置后退出配置视图。
|
|
16
26
|
def finish_commands = ["commit", "exit"]
|
|
17
27
|
|
|
28
|
+
# 只计入非空邻居块,跳过没有对端的本机接口。
|
|
18
29
|
def expected_neighbor_count(output, _template)
|
|
19
30
|
neighbor_blocks(output).count { |block| !empty_neighbor_block?(block) }
|
|
20
31
|
end
|
|
21
32
|
|
|
33
|
+
# 输出必须明确说明无邻居,或每个本机接口块都明确为空。
|
|
22
34
|
def empty_neighbor_output?(output)
|
|
23
35
|
return true if output.match?(/No LLDP neighbors/i)
|
|
24
36
|
|
|
@@ -34,6 +46,7 @@ module Net
|
|
|
34
46
|
output.split(/^\s*Local information:\s*$/i).select { |block| block.match?(/^\s*Local interface:\s*\S+/i) }
|
|
35
47
|
end
|
|
36
48
|
|
|
49
|
+
# 邻居字段区只有空行和提示符时,才视为明确的空块。
|
|
37
50
|
def empty_neighbor_block?(block)
|
|
38
51
|
tail = block.split(/^\s*Neighbor information:\s*$/i, 2)
|
|
39
52
|
tail.size == 2 && tail.last.lines.all? { |line| line.strip.empty? || line.match?(/^\S+[>#]\s*$/) }
|
|
@@ -50,10 +63,12 @@ module Net
|
|
|
50
63
|
code: :unrecognized_output, host: @device.host, phase: :parse)
|
|
51
64
|
end
|
|
52
65
|
|
|
66
|
+
# 用 PAN-OS set 语法生成接口备注变更。
|
|
53
67
|
def change_commands(change)
|
|
54
68
|
[%Q(set network interface ethernet #{change.interface} comment "#{change.new_description}")]
|
|
55
69
|
end
|
|
56
70
|
|
|
71
|
+
# commit 可能耗时较长,单独放宽该命令的超时。
|
|
57
72
|
def script_command(command)
|
|
58
73
|
command == "commit" ? Command.new(command, timeout: 300) : command
|
|
59
74
|
end
|
|
@@ -6,13 +6,20 @@ module Net
|
|
|
6
6
|
module Connector
|
|
7
7
|
module Radware
|
|
8
8
|
class TftpBackup < Operations::Tftp::Strategy
|
|
9
|
-
#
|
|
10
|
-
def
|
|
9
|
+
# Radware 原生导出生成压缩配置归档。
|
|
10
|
+
def self.file_extension = "tgz"
|
|
11
|
+
|
|
12
|
+
# 在连接前拒绝当前厂商不支持的参数组合。
|
|
13
|
+
def validate_options!(_target, source_file:, vrf: nil)
|
|
14
|
+
raise ArgumentError, "Radware Alteon does not use source_file" unless source_file.nil?
|
|
15
|
+
raise ArgumentError, "Radware TFTP backup does not use vrf" unless vrf.nil?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def receipt_metadata(_target, **) = { configuration_kind: :native_archive, format: :tgz }
|
|
11
19
|
|
|
12
20
|
# 构造当前厂商的 TFTP 导出交互脚本。
|
|
13
21
|
def script(target, source_file:, vrf: nil)
|
|
14
|
-
|
|
15
|
-
raise ArgumentError, "Radware TFTP backup does not use vrf" if vrf
|
|
22
|
+
validate_options!(target, source_file: source_file, vrf: vrf)
|
|
16
23
|
|
|
17
24
|
Script.new([Command.new("/cfg/ptcfg #{target.host} -tftp", timeout: 180, interactions: [
|
|
18
25
|
interaction(/Enter\s+(?:hostname|IP address)[^\r\n]*:\s*\z/i, "#{target.host}\n"),
|
|
@@ -6,7 +6,10 @@ module Net
|
|
|
6
6
|
module Connector
|
|
7
7
|
module Radware
|
|
8
8
|
class Topology < Operations::Topology::Strategy
|
|
9
|
+
# Alteon 只支持读取端口描述,不提供邻居发现或自动改写。
|
|
9
10
|
def self.supports?(capability) = capability == :interface_descriptions
|
|
11
|
+
|
|
12
|
+
# 从设备配置转储解析端口名称。
|
|
10
13
|
def description_template = "radware_port_names.textfsm"
|
|
11
14
|
end
|
|
12
15
|
end
|
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.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- net-connector contributors
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-09-
|
|
10
|
+
date: 2026-09-27 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: expect-pty
|
|
@@ -15,34 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.5.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: activesupport
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '7.2'
|
|
33
|
-
- - "<"
|
|
34
|
-
- !ruby/object:Gem::Version
|
|
35
|
-
version: '9'
|
|
36
|
-
type: :runtime
|
|
37
|
-
prerelease: false
|
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
-
requirements:
|
|
40
|
-
- - ">="
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
version: '7.2'
|
|
43
|
-
- - "<"
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
version: '9'
|
|
25
|
+
version: 0.5.0
|
|
46
26
|
- !ruby/object:Gem::Dependency
|
|
47
27
|
name: textfsm
|
|
48
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -159,6 +139,26 @@ dependencies:
|
|
|
159
139
|
- - "~>"
|
|
160
140
|
- !ruby/object:Gem::Version
|
|
161
141
|
version: '2.0'
|
|
142
|
+
- !ruby/object:Gem::Dependency
|
|
143
|
+
name: logger
|
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: '1.5'
|
|
149
|
+
- - "<"
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '2.0'
|
|
152
|
+
type: :runtime
|
|
153
|
+
prerelease: false
|
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - ">="
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '1.5'
|
|
159
|
+
- - "<"
|
|
160
|
+
- !ruby/object:Gem::Version
|
|
161
|
+
version: '2.0'
|
|
162
162
|
- !ruby/object:Gem::Dependency
|
|
163
163
|
name: net-http
|
|
164
164
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -333,6 +333,26 @@ dependencies:
|
|
|
333
333
|
- - "<"
|
|
334
334
|
- !ruby/object:Gem::Version
|
|
335
335
|
version: '1.0'
|
|
336
|
+
- !ruby/object:Gem::Dependency
|
|
337
|
+
name: timeout
|
|
338
|
+
requirement: !ruby/object:Gem::Requirement
|
|
339
|
+
requirements:
|
|
340
|
+
- - ">="
|
|
341
|
+
- !ruby/object:Gem::Version
|
|
342
|
+
version: '0.3'
|
|
343
|
+
- - "<"
|
|
344
|
+
- !ruby/object:Gem::Version
|
|
345
|
+
version: '1.0'
|
|
346
|
+
type: :runtime
|
|
347
|
+
prerelease: false
|
|
348
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
349
|
+
requirements:
|
|
350
|
+
- - ">="
|
|
351
|
+
- !ruby/object:Gem::Version
|
|
352
|
+
version: '0.3'
|
|
353
|
+
- - "<"
|
|
354
|
+
- !ruby/object:Gem::Version
|
|
355
|
+
version: '1.0'
|
|
336
356
|
- !ruby/object:Gem::Dependency
|
|
337
357
|
name: uri
|
|
338
358
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -373,16 +393,17 @@ dependencies:
|
|
|
373
393
|
- - "<"
|
|
374
394
|
- !ruby/object:Gem::Version
|
|
375
395
|
version: '1.0'
|
|
376
|
-
description:
|
|
377
|
-
interactive prompts, redacted logging, and Netdisco inventory backups.
|
|
396
|
+
description: 通过 SSH 或 Telnet 登录网络设备,采集配置、执行命令脚本、处理交互提示,并提供脱敏日志与基于 Netdisco 清单的批量备份。
|
|
378
397
|
executables:
|
|
379
398
|
- net-connector-backup
|
|
380
399
|
extensions: []
|
|
381
400
|
extra_rdoc_files: []
|
|
382
401
|
files:
|
|
383
402
|
- CHANGELOG.md
|
|
403
|
+
- CONTRIBUTING.md
|
|
384
404
|
- LICENSE
|
|
385
405
|
- README.md
|
|
406
|
+
- SECURITY.md
|
|
386
407
|
- docs/RELEASING.md
|
|
387
408
|
- docs/VERIFICATION.md
|
|
388
409
|
- docs/architecture.md
|
|
@@ -393,6 +414,7 @@ files:
|
|
|
393
414
|
- lib/net/connector/device/interface_description.rb
|
|
394
415
|
- lib/net/connector/device/interface_name.rb
|
|
395
416
|
- lib/net/connector/device/profile.rb
|
|
417
|
+
- lib/net/connector/device/profile/builder.rb
|
|
396
418
|
- lib/net/connector/device/running_config.rb
|
|
397
419
|
- lib/net/connector/device/running_config/strategy.rb
|
|
398
420
|
- lib/net/connector/engine.rb
|
|
@@ -418,13 +440,18 @@ files:
|
|
|
418
440
|
- lib/net/connector/netdisco/client.rb
|
|
419
441
|
- lib/net/connector/netdisco/config_file.rb
|
|
420
442
|
- lib/net/connector/netdisco/device.rb
|
|
443
|
+
- lib/net/connector/netdisco/diagnostic.rb
|
|
421
444
|
- lib/net/connector/netdisco/fleet.rb
|
|
445
|
+
- lib/net/connector/netdisco/inventory_budget.rb
|
|
446
|
+
- lib/net/connector/netdisco/plan.rb
|
|
422
447
|
- lib/net/connector/netdisco/planner.rb
|
|
448
|
+
- lib/net/connector/netdisco/report.rb
|
|
423
449
|
- lib/net/connector/netdisco/result_store.rb
|
|
424
450
|
- lib/net/connector/netdisco/rules.rb
|
|
425
451
|
- lib/net/connector/netdisco/settings.rb
|
|
426
452
|
- lib/net/connector/netdisco/worker.rb
|
|
427
453
|
- lib/net/connector/operations.rb
|
|
454
|
+
- lib/net/connector/operations/backup_lock.rb
|
|
428
455
|
- lib/net/connector/operations/local_backup.rb
|
|
429
456
|
- lib/net/connector/operations/parse_output.rb
|
|
430
457
|
- lib/net/connector/operations/private_file.rb
|
|
@@ -433,9 +460,12 @@ files:
|
|
|
433
460
|
- lib/net/connector/operations/running_config/hillstone.rb
|
|
434
461
|
- lib/net/connector/operations/running_config/palo_alto.rb
|
|
435
462
|
- lib/net/connector/operations/running_config/strategy.rb
|
|
463
|
+
- lib/net/connector/operations/safe_file.rb
|
|
436
464
|
- lib/net/connector/operations/saved_config.rb
|
|
465
|
+
- lib/net/connector/operations/saved_config/legacy_index.rb
|
|
437
466
|
- lib/net/connector/operations/tftp/cisco_ios.rb
|
|
438
467
|
- lib/net/connector/operations/tftp/cisco_nxos.rb
|
|
468
|
+
- lib/net/connector/operations/tftp/file_upload.rb
|
|
439
469
|
- lib/net/connector/operations/tftp/h3c.rb
|
|
440
470
|
- lib/net/connector/operations/tftp/hillstone.rb
|
|
441
471
|
- lib/net/connector/operations/tftp/huawei.rb
|
|
@@ -443,10 +473,12 @@ files:
|
|
|
443
473
|
- lib/net/connector/operations/tftp/radware.rb
|
|
444
474
|
- lib/net/connector/operations/tftp/strategy.rb
|
|
445
475
|
- lib/net/connector/operations/tftp_backup.rb
|
|
476
|
+
- lib/net/connector/operations/tftp_receipt.rb
|
|
446
477
|
- lib/net/connector/operations/topology.rb
|
|
447
478
|
- lib/net/connector/operations/topology/cisco.rb
|
|
448
479
|
- lib/net/connector/operations/topology/h3c.rb
|
|
449
480
|
- lib/net/connector/operations/topology/hillstone.rb
|
|
481
|
+
- lib/net/connector/operations/topology/immediate_strategy.rb
|
|
450
482
|
- lib/net/connector/operations/topology/palo_alto.rb
|
|
451
483
|
- lib/net/connector/operations/topology/radware.rb
|
|
452
484
|
- lib/net/connector/operations/topology/strategy.rb
|
|
@@ -511,7 +543,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
511
543
|
- !ruby/object:Gem::Version
|
|
512
544
|
version: '0'
|
|
513
545
|
requirements: []
|
|
514
|
-
rubygems_version: 4.0.
|
|
546
|
+
rubygems_version: 4.0.16
|
|
515
547
|
specification_version: 4
|
|
516
|
-
summary:
|
|
548
|
+
summary: 网络设备命令行会话与 Netdisco 清单批量备份
|
|
517
549
|
test_files: []
|