From 468a26fa6ea50dc648bf38bb161ffd8d67242f87 Mon Sep 17 00:00:00 2001 From: sai chintalapudi Date: Fri, 24 Aug 2018 10:05:32 -0700 Subject: [PATCH 1/2] fix cisco-72 --- lib/cisco_node_utils/ace.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/cisco_node_utils/ace.rb b/lib/cisco_node_utils/ace.rb index a88f3d34..3233617d 100644 --- a/lib/cisco_node_utils/ace.rb +++ b/lib/cisco_node_utils/ace.rb @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +require 'ipaddr' require_relative 'node_util' module Cisco @@ -139,6 +140,15 @@ def ace_set(attrs) config_set('acl', cmd, @set_args) end + def valid_ipv6?(addr) + begin + ret = IPAddr.new(addr.split[0]).ipv6? + rescue + ret = false + end + ret + end + # PROPERTIES # ---------- def seqno @@ -182,7 +192,7 @@ def src_addr return nil if match.nil? || !match.names.include?('src_addr') addr = match[:src_addr] # Normalize addr. Some platforms zero_pad ipv6 addrs. - addr.gsub!(/^0*/, '').gsub!(/:0*/, ':') + addr.gsub!(/^0*/, '').gsub!(/:0*/, ':') if valid_ipv6?(addr) addr end @@ -205,7 +215,7 @@ def dst_addr return nil if match.nil? || !match.names.include?('dst_addr') addr = match[:dst_addr] # Normalize addr. Some platforms zero_pad ipv6 addrs. - addr.gsub!(/^0*/, '').gsub!(/:0*/, ':') + addr.gsub!(/^0*/, '').gsub!(/:0*/, ':') if valid_ipv6?(addr) addr end From 81c9db2475850ba56da26856d0b21bfe20207395 Mon Sep 17 00:00:00 2001 From: sai chintalapudi Date: Fri, 24 Aug 2018 10:30:24 -0700 Subject: [PATCH 2/2] copyright --- lib/cisco_node_utils/ace.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cisco_node_utils/ace.rb b/lib/cisco_node_utils/ace.rb index 3233617d..a14d87f3 100644 --- a/lib/cisco_node_utils/ace.rb +++ b/lib/cisco_node_utils/ace.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016 Cisco and/or its affiliates. +# Copyright (c) 2015-2018 Cisco and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.