network-utility 1.1.26 → 1.1.28

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: dddb5ef87fcf77347bd4fe83824094aac1176a46f262665fd9e28e8aa97627c8
4
- data.tar.gz: 8864d580b9816f9cbbd67bcd02e02164ae0e19ebcb92159a76b79c673a3c2b85
3
+ metadata.gz: 1ed31f6d3fd8bd8901b0f0b70f11e5a6ae2a29006dc77bd345e448fff7bb9b48
4
+ data.tar.gz: 4cfd31e694af5307bc9358924dd2548a8315f646a5e16030eb21a248c03c02eb
5
5
  SHA512:
6
- metadata.gz: 7b481dba22b7ca7218fcb210d71200983dae8513fa3b01c043b1477df01ac19f76f38ba894e712ab219c8a89dc5d418d1ef1ac900c234494677f6c0f7d5dda50
7
- data.tar.gz: 8cef0b797c129f6d0d0db83fc657438e5a30ec516d870586f9773234a0c4c0ad778cd8dde95c2fed0b2956e577fd54324e7022b30039dea578f488f7436d47fb
6
+ metadata.gz: c2dd6922f7d9de15cf2d9ee5c7506993e2f7272e5a63ead6534a7f8324211e2d9ed7662401199ae4c35f4124905ca65286ff82985b0f5bf35085742af261a7d9
7
+ data.tar.gz: 1db2d8ed2c0b9ea7a16b04895cff626bcbaad314fc3e72627b25ce49fe1e486fa8370bf60a61c0bd9a5f1ec081bb973674eaa1c3e6c907fc67fc49184f254376
data/document/config.md CHANGED
@@ -999,6 +999,7 @@ module M6000_18S
999
999
  raw = newraw.join("\n")
1000
1000
  hostname = guards[0] || self.preprocess(raw).split("\n").find{|line|line.include?("hostname ")}.to_s.split("hostname ")[1]
1001
1001
  prepart = self.preprocess(raw).split(/#{hostname}#( )*show running-config( )*\n/)[1]
1002
+ prepart = self.preprocess(raw).split("show running-config\n")[1].split("<<<<")[0] unless prepart # ssh >>>>
1002
1003
  return cfg unless prepart
1003
1004
  content = prepart.split(/#{hostname}#( )*\n/)[0]
1004
1005
 
@@ -85,7 +85,7 @@ module M6000_18S
85
85
  # ospfv2
86
86
  # ospfv3
87
87
  # qos # 未实现
88
- #
88
+ #
89
89
  # 2. 被动模块:(暂不关联)
90
90
  # samgr
91
91
  # monitor
@@ -110,7 +110,7 @@ module M6000_18S
110
110
  end
111
111
  接口表
112
112
  end
113
-
113
+
114
114
  def 接口物理信息 正文
115
115
  tag = 正文["PORT-PHYSICAL-INFO"] ? "PORT-PHYSICAL-INFO" : "port-physical-config"
116
116
  接口物理表 = {}
@@ -121,11 +121,11 @@ module M6000_18S
121
121
  elsif tag == "port-physical-config"
122
122
  (正文[tag]||"").split("\n$")\
123
123
  .collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
124
- .compact.each{|接口|接口物理表[/interface (.)*/.match(接口)[0].to_s.strip] = 接口}
124
+ .compact.each{|接口|接口物理表[/interface (.)*/.match(接口)[0].to_s.strip] = 接口}
125
125
  end
126
126
  接口物理表
127
127
  end
128
-
128
+
129
129
  def 接口基本信息 正文
130
130
  tag = 正文["INTERFACE"] ? "INTERFACE" : "if-intf"
131
131
  接口基本表 = {}
@@ -142,7 +142,7 @@ module M6000_18S
142
142
  end
143
143
  接口基本表
144
144
  end
145
-
145
+
146
146
  def 接口vlan信息 正文
147
147
  tag = 正文["VLAN"] ? "VLAN" : "vlan"
148
148
  接口vlan表 = {}
@@ -172,7 +172,7 @@ module M6000_18S
172
172
  end
173
173
  接口acl表
174
174
  end
175
-
175
+
176
176
  def 接口urpf信息 正文
177
177
  tag = 正文["URPF"] ? "URPF" : "urpf"
178
178
  接口urpf表 = {}
@@ -185,9 +185,9 @@ module M6000_18S
185
185
  .collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
186
186
  .compact.each{|接口|接口urpf表[/interface (.)*/.match(接口)[0].to_s.strip]=接口}
187
187
  end
188
- 接口urpf表
188
+ 接口urpf表
189
189
  end
190
-
190
+
191
191
  def 接口mpls信息 正文
192
192
  tag = 正文["MPLS"] ? "MPLS" : "ldp"
193
193
  接口mpls表 = {}
@@ -202,7 +202,7 @@ module M6000_18S
202
202
  end
203
203
  接口mpls表
204
204
  end
205
-
205
+
206
206
  def 接口lacp信息 正文 # trunk
207
207
  tag = 正文["LACP"] ? "LACP" : "lacp"
208
208
  接口lacp表 = {}
@@ -219,7 +219,7 @@ module M6000_18S
219
219
  end
220
220
  接口lacp表
221
221
  end
222
-
222
+
223
223
  def 接口am信息 正文
224
224
  tag = 正文["AM"] ? "AM" : "am"
225
225
  接口am表 = {}
@@ -234,7 +234,7 @@ module M6000_18S
234
234
  end
235
235
  接口am表
236
236
  end
237
-
237
+
238
238
  def 接口uim信息 正文
239
239
  tag = 正文["UIM"] ? "UIM" : "uim"
240
240
  接口uim表 = {}
@@ -263,7 +263,7 @@ module M6000_18S
263
263
  end
264
264
  接口uim表
265
265
  end
266
-
266
+
267
267
  def 接口isis信息 正文
268
268
  tag = 正文["ISIS"] ? "ISIS" : "isis"
269
269
  接口isis表 = {}
@@ -278,7 +278,7 @@ module M6000_18S
278
278
  end
279
279
  接口isis表
280
280
  end
281
-
281
+
282
282
  def 接口multicast信息 正文
283
283
  tag = 正文["MULTICAST"] ? "MULTICAST" : "multicast"
284
284
  接口multicast表 = {}
@@ -387,7 +387,7 @@ module M6000_18S
387
387
  end
388
388
  end
389
389
  end
390
-
390
+
391
391
  tag = 正文["ospfv3"] ? "ospfv3" : "ospfv3"
392
392
  接口ospfv3表 = {}
393
393
  if tag == "ospfv3"
@@ -419,9 +419,9 @@ module M6000_18S
419
419
  .collect{|l|"<#{tag}>\n"+l.strip+"\n!\n</#{tag}>" if l!="\n!"}\
420
420
  .compact.each{|接口|接口urpf表[/interface (.)*/.match(接口)[0].to_s.strip]=接口}
421
421
  end
422
- 接口urpf表
422
+ 接口urpf表
423
423
  end
424
-
424
+
425
425
  def 接口am信息 正文
426
426
  tag = 正文["AM"] ? "AM" : "am"
427
427
  接口am表 = {}
@@ -436,7 +436,7 @@ module M6000_18S
436
436
  end
437
437
  接口am表
438
438
  end
439
-
439
+
440
440
  def 接口uim信息 正文
441
441
  tag = 正文["UIM"] ? "UIM" : "uim"
442
442
  接口uim表 = {}
@@ -489,8 +489,8 @@ module M6000_18S
489
489
  cars[current]['cbs'] = words.index('cbs') ? words[words.index('cbs')+1]+'bytes' : ''
490
490
  cars[current]['pbs'] = words.index('pbs') ? words[words.index('pbs')+1]+'bytes' : ''
491
491
  cars[current]['action'] = [
492
- words.index('conform-action') ? words[words.index('conform-action')+1] : '',
493
- words.index('exceed-action') ? words[words.index('exceed-action')+1] : '',
492
+ words.index('conform-action') ? words[words.index('conform-action')+1] : '',
493
+ words.index('exceed-action') ? words[words.index('exceed-action')+1] : '',
494
494
  words.index('violate-action') ? words[words.index('violate-action')+1] : ''
495
495
  ]
496
496
  end
@@ -516,7 +516,7 @@ module M6000_18S
516
516
  end
517
517
  svc_policy
518
518
  end
519
-
519
+
520
520
  # func: 端口统计功能
521
521
  def 接口统计 正文
522
522
  tag = 正文["interface-performance"] ? 'interface-performance' : 'interface-performance'
@@ -533,7 +533,7 @@ module M6000_18S
533
533
  intf_perf.delete(nil)
534
534
  intf_perf
535
535
  end
536
-
536
+
537
537
  # func: 端口URPF功能
538
538
  def 接口URPF 正文
539
539
  接口urpf表 = self.接口urpf信息 正文
@@ -548,7 +548,7 @@ module M6000_18S
548
548
  end
549
549
  urpf
550
550
  end
551
-
551
+
552
552
  # func: 端口接入类型
553
553
  def 接口接入类型 正文
554
554
  接口uim表 = self.接口uim信息 正文
@@ -566,11 +566,11 @@ module M6000_18S
566
566
  特殊接口集合 << [key]+configs if key.include?('loopback') || key.include?('null') || \
567
567
  key.include?('extimer') || key.include?('vbui') || key.include?('spi') || \
568
568
  key.include?('gcvi') || key.include?('guvi') || key.include?('mgmt_eth') || \
569
- key.include?('qx_eth') || key.include?('qx') || key.include?('gre_tunnel')
569
+ key.include?('qx_eth') || key.include?('qx') || key.include?('gre_tunnel') || key.include?('vxlan_tunnel')
570
570
  end
571
571
  特殊接口集合
572
572
  end
573
-
573
+
574
574
  def 物理接口配置 接口集合,特殊接口集合=nil
575
575
  物理接口集合 = []
576
576
  例外 = (特殊接口集合 ? 特殊接口集合 : (self.特殊接口配置 接口集合)).collect{|c|c[0]}
@@ -579,7 +579,7 @@ module M6000_18S
579
579
  end
580
580
  物理接口集合
581
581
  end
582
-
582
+
583
583
  def 子接口配置 接口集合,特殊接口集合=nil
584
584
  子接口集合 = []
585
585
  例外 = (特殊接口集合 ? 特殊接口集合 : (self.特殊接口配置 接口集合)).collect{|c|c[0]}
@@ -588,7 +588,7 @@ module M6000_18S
588
588
  end
589
589
  子接口集合
590
590
  end
591
-
591
+
592
592
  def 接口分捡 接口集合
593
593
  特殊接口集合 = self.特殊接口配置 接口集合
594
594
  物理接口集合 = self.物理接口配置 接口集合,特殊接口集合
@@ -604,19 +604,19 @@ module M6000_18S
604
604
  # func: 根据一个端口的描述信息,给出其格式化的类型、连接符、端口编号
605
605
  def 端口识别 描述
606
606
  描述 = 描述[0] if 描述.instance_of?(Array) # M6000取接口配置中名称部分 [name,<tag>...</tag>,...]
607
- type = /xgei|gei|smartgroup|loopback|eth_dslgroup|extimer|vbui|vlan|virtual_template|vei|null|guvi|gcvi|gre_tunnel|mgmt_eth|ulei|irb|spi|flexe_client|flexe_group|ptp|gps|qx_eth|qx|bvi|pw|subvlan/.match(描述)
607
+ type = /xgei|gei|ulei|smartgroup|loopback|eth_dslgroup|extimer|vbui|vlan|virtual_template|vei|null|guvi|gcvi|gre_tunnel|mgmt_eth|ulei|irb|spi|vxlan_tunnel|flexe_client|flexe_group|ptp|gps|qx_eth|qx|bvi|pw|subvlan/.match(描述)
608
608
  类型 = type ? type.to_s : '未知类型'
609
609
  port = /(\d+|\/|\.)*(\d+)/.match(描述.split(类型).join)
610
610
  端口 = port ? port.to_s : '未知端口'
611
611
  端口 = '' if 类型=='mgmt_eth'
612
- 连接符 = if ['smartgroup','loopback','vlan','vbui','null','mgmt_eth','irb','vei','eth_dslgroup','flexe_client','flexe_group','qx','bvi','pw','subvlan','gre_tunnel','virtual_template'].include?(类型)
612
+ 连接符 = if ['smartgroup','loopback','vlan','vbui','null','mgmt_eth','irb','vei','eth_dslgroup','vxlan_tunnel','flexe_client','flexe_group','qx','bvi','pw','subvlan','gre_tunnel','virtual_template'].include?(类型)
613
613
  ''
614
- elsif ['xgei','gei','extimer','ulei','guvi','gcvi','spi','ptp','gps','qx_eth'].include?(类型)
614
+ elsif ['xgei','gei','ulei','extimer','guvi','gcvi','spi','ptp','gps','qx_eth'].include?(类型)
615
615
  '-'
616
616
  end
617
617
  return 类型,连接符,端口
618
618
  end
619
-
619
+
620
620
  # func: 根据一个端口的描述信息,给出其mac地址,若无mac则返回nil
621
621
  def 端口MAC 描述
622
622
  描述.each_line do|line|
@@ -627,7 +627,7 @@ module M6000_18S
627
627
  end
628
628
  return nil
629
629
  end
630
-
630
+
631
631
  # func: 根据一个端口的描述信息,给出其管理状态是打开/关闭的判断
632
632
  def 端口管理状态 描述
633
633
  描述 = 描述[1..-1].join("\n") if 描述.instance_of?(Array) # M6000取接口配置中名称部分 [name,<tag>...</tag>,...]
@@ -660,7 +660,7 @@ module M6000_18S
660
660
  end
661
661
  地址集
662
662
  end
663
-
663
+
664
664
  # func: 根据一个端口的配置给出其开关状态(配置层面的"端口管理状态")
665
665
  def 接口开关 接口配置
666
666
  描述 = '' # for phy_if is shutdown, for sub_if,smartgroup are open
@@ -677,7 +677,7 @@ module M6000_18S
677
677
  end
678
678
  描述
679
679
  end
680
-
680
+
681
681
  # func: 根据一个端口的配置给出其关联的vpn实例
682
682
  def 接口vpn实例 接口配置
683
683
  实例 = ''
@@ -690,11 +690,11 @@ module M6000_18S
690
690
  #####################################################################################################
691
691
  # 聚合接口判定相关
692
692
  #####################################################################################################
693
-
693
+
694
694
  # func: 根据一个接口的描述信息,给出其所属聚合接口的信息,若非聚合端口返回空
695
695
  def 聚合接口判定 配置
696
696
  配置.join.split("\n").each do|描述|
697
- if 描述.include?("smartgroup") && 描述.include?("mode") &&
697
+ if 描述.include?("smartgroup") && 描述.include?("mode") &&
698
698
  !描述.include?("description") && !self.端口识别(配置).join.include?("smartgroup")
699
699
  return {self.端口识别(配置).join=>"smartgroup"+描述.strip.split(" ")[1]}
700
700
  end
@@ -768,7 +768,7 @@ module M6000_18S
768
768
  end
769
769
  return vlan # {vlan:[ int|range ] qinq:[ [int,int|range] ] dot1q:[ int ]}
770
770
  end
771
-
771
+
772
772
  def vlan统计 name,物理接口集合,子接口集合
773
773
  bas子接口数据库,聚合接口表 = {},[]
774
774
  聚合接口集合 = 物理接口集合.select{|物理接口|self.端口识别(物理接口)[0]=='smartgroup'}
@@ -779,7 +779,7 @@ module M6000_18S
779
779
  物理接口 = 物理接口集合.find{|物理接口|物理接口[0].split(" ")[1]==(物理接口名称)}
780
780
  next unless self.端口管理状态(物理接口) # 物理接口关闭的不统计
781
781
  next unless self.端口管理状态(接口配置) # 子接口关闭的不统计
782
-
782
+
783
783
  vlan配置 = {}
784
784
  self.vlan分捡(接口配置).each do|type,data|
785
785
  if type=='vlan' || type=='dot1q'
@@ -788,13 +788,13 @@ module M6000_18S
788
788
  data.each{|pvlan,cvlan|vlan配置[pvlan] ||= []; vlan配置[pvlan] << cvlan}
789
789
  end
790
790
  end
791
-
791
+
792
792
  子接口名称 = self.端口识别(接口配置)
793
793
  if 子接口名称[0].include?("gei")
794
794
  # 子接口索引 = ["eth--"+子接口名称[-1].split(".")[0].split('/')[-3..-1].join(',')] # AIBOS风格
795
795
  子接口索引 = [子接口名称.join.split(".")[0]] # 原生风格
796
796
  end
797
- if 子接口名称[0].include?("smartgroup") &&
797
+ if 子接口名称[0].include?("smartgroup") &&
798
798
  聚合接口组 = 聚合接口表.find{|聚合接口组|聚合接口组.include?(子接口名称.join.split('.')[0])}
799
799
  聚合接口的等效名称 = 聚合接口组.clone;
800
800
  # 聚合接口的等效名称.delete(子接口名称.join.split('.')[0]) # 除了smartgroup自身,为所有等效接口创建 # 是否保留smartgroup是个争议
@@ -823,7 +823,7 @@ module M6000_18S
823
823
  #####################################################################################################
824
824
  # 接口相关统计信息的处理
825
825
  #####################################################################################################
826
-
826
+
827
827
  # gei-x/x/x.00000xxx => gei-x/x/x.xxx
828
828
  # 一些统计场合子接口会补前置0,这里可以将其去掉
829
829
  def 端口去0 描述