Skip to content

Commit

Permalink
Merge pull request #220 from e-sonic/merge-1102/broadcom_sonic_4.0.x_…
Browse files Browse the repository at this point in the history
…share-to-dell_sonic_4.0.x_share

sync from broadcom_sonic_4.0.x_share to dell_sonic_4.0.x_share - 1102
  • Loading branch information
jeff-yin authored and GitHub Enterprise committed Nov 3, 2022
2 parents ac36ae0 + 3374719 commit 94c9f3a
Show file tree
Hide file tree
Showing 9 changed files with 1,272 additions and 116 deletions.
3 changes: 3 additions & 0 deletions CLI/actioner/show_config_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from show_config_hardware import *
from show_config_dropcounters import *
from show_config_dhcp_snooping import *
from show_running_config_nd import *

view_dependency = {
"configure-router-bgp": [
Expand Down Expand Up @@ -442,6 +443,8 @@
"reserve_vlan_show": show_config_reserve_vlan,
"dhcp_snooping_static_show": show_dhcp_snooping_static,
"dhcp_snooping_vlan_show": show_dhcp_snooping_vlan,
"nd_running_config": show_nd_running_intf_config,
"nd_radv_enable_config": show_nd_radv_enable_config,

})

Expand Down
194 changes: 194 additions & 0 deletions CLI/actioner/show_running_config_nd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
###########################################################################
#
# Copyright 2020 Broadcom. The term "Broadcom" refers to Broadcom Inc. and/or
# its subsidiaries.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################


def show_nd_running_intf_config(render_tables):
cmd_str = ""
cmd_end = ";"
nd_base_cmd = "ipv6 nd "
intf_name = ""
if "name" in render_tables:
intf_name = render_tables["name"]

if ("sonic-frr-nd:sonic-frr-nd/ND_CFG_MSG/ND_CFG_MSG_LIST"
in render_tables):
nd_cfg_intfs = render_tables[
"sonic-frr-nd:sonic-frr-nd/ND_CFG_MSG/ND_CFG_MSG_LIST"]
for nd_cfg_intf in nd_cfg_intfs:
if intf_name == nd_cfg_intf["name"]:
if "suppress" in nd_cfg_intf and nd_cfg_intf["suppress"] == False:
cmd_str += "no " + nd_base_cmd + "suppress-ra" + cmd_end
if "managed-config" in nd_cfg_intf:
cmd_str += nd_base_cmd + "managed-config-flag" + cmd_end
if "other-config" in nd_cfg_intf:
cmd_str += nd_base_cmd + "other-config-flag" + cmd_end
if "home-agent-config" in nd_cfg_intf:
cmd_str += nd_base_cmd + "home-config-config-flag" + cmd_end
if "ra-fast-retrans" in nd_cfg_intf and nd_cfg_intf["ra-fast-retrans"] == False:
cmd_str += "no " + nd_base_cmd + "ra-fast-retrans" + cmd_end
if "adv-interval-option" in nd_cfg_intf:
cmd_str += nd_base_cmd + "adv-interval-option" + cmd_end
if "home-agent-lifetime" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "home-agent-lifetime {}".format(
nd_cfg_intf["home-agent-lifetime"]) + cmd_end)
if "mtu" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "mtu {}".format(
nd_cfg_intf["mtu"]) + cmd_end)
if "home-agent-preference" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "home-agent-preference {}".format(
nd_cfg_intf["home-agent-preference"]) + cmd_end)
if "ra-hop-limit" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-hop-limit {}".format(
nd_cfg_intf["ra-hop-limit"]) + cmd_end)
if "ra-interval-msec" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-interval msec {}".format(
nd_cfg_intf["ra-interval-msec"]) + cmd_end)
elif "interval" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-interval {}".format(
nd_cfg_intf["interval"]) + cmd_end)
if "lifetime" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-lifetime {}".format(
nd_cfg_intf["lifetime"]) + cmd_end)
if "ra-retrans-interval" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "ra-retrans-interval {}".format(
nd_cfg_intf["ra-retrans-interval"]) + cmd_end)
if "reachable-time" in nd_cfg_intf:
cmd_str += (nd_base_cmd + "reachable-time {}".format(
nd_cfg_intf["reachable-time"]) + cmd_end)
if "router-preference" in nd_cfg_intf and nd_cfg_intf["router-preference"] != "sonic-frr-nd:MEDIUM":
cmd_str += (nd_base_cmd + "router-preference {}".format(
nd_cfg_intf["router-preference"].split(":")[1].lower()) + cmd_end)

status, sub_cmd_str = show_nd_dnssl(render_tables, intf_name,
nd_base_cmd)
if status == "CB_SUCCESS":
cmd_str += sub_cmd_str + cmd_end

status, sub_cmd_str = show_nd_rdnss(render_tables, intf_name,
nd_base_cmd)
if status == "CB_SUCCESS":
cmd_str += sub_cmd_str + cmd_end

status, sub_cmd_str = show_nd_prefix(render_tables, intf_name,
nd_base_cmd)
if status == "CB_SUCCESS":
cmd_str += sub_cmd_str + cmd_end

return "CB_SUCCESS", cmd_str


def show_nd_dnssl(render_tables, intf_name, nd_base_cmd):
cmd_str = ""
cmd_end = ";"
valid_lifetime = ""

if ("sonic-frr-nd:sonic-frr-nd/ND_DNSSL/ND_DNSSL_LIST"
in render_tables):
nd_dnssl_cfgs = render_tables[
"sonic-frr-nd:sonic-frr-nd/ND_DNSSL/ND_DNSSL_LIST"]
for nd_dnssl_cfg in nd_dnssl_cfgs:
if intf_name == nd_dnssl_cfg["name"]:
if nd_dnssl_cfg["valid-lifetime"] == 4294967295:
valid_lifetime = "infinite"
else:
valid_lifetime = str(nd_dnssl_cfg["valid-lifetime"])
cmd_str += (nd_base_cmd + "dnssl " +
str(nd_dnssl_cfg["dnssl-name"]) + " " + valid_lifetime + cmd_end)
return "CB_SUCCESS", cmd_str

def show_nd_rdnss(render_tables, intf_name, nd_base_cmd):
cmd_str = ""
cmd_end = ";"
valid_lifetime = ""

if ("sonic-frr-nd:sonic-frr-nd/ND_RDNSS/ND_RDNSS_LIST"
in render_tables):
nd_rdnss_cfgs = render_tables[
"sonic-frr-nd:sonic-frr-nd/ND_RDNSS/ND_RDNSS_LIST"]
for nd_rdnss_cfg in nd_rdnss_cfgs:
if intf_name == nd_rdnss_cfg["name"]:
if nd_rdnss_cfg["valid-lifetime"] == 4294967295:
valid_lifetime = "infinite"
else:
valid_lifetime = str(nd_rdnss_cfg["valid-lifetime"])
cmd_str += (nd_base_cmd + "rdnss " +
str(nd_rdnss_cfg["address"]) + " " + valid_lifetime + cmd_end)
return "CB_SUCCESS", cmd_str

def show_nd_prefix(render_tables, intf_name, nd_base_cmd):
cmd_str = ""
cmd_end = ";"
valid_lifetime = ""
preferred_lifetime = ""
router_address = ""
no_autoconfig = ""
off_link = ""

if ("sonic-frr-nd:sonic-frr-nd/ND_PREFIX/ND_PREFIX_LIST"
in render_tables):
nd_prefixes = render_tables[
"sonic-frr-nd:sonic-frr-nd/ND_PREFIX/ND_PREFIX_LIST"]
for nd_prefix in nd_prefixes:
if intf_name == nd_prefix["name"]:
valid_lifetime = ""
preferred_lifetime = ""
router_address = ""
no_autoconfig = ""
off_link = ""
cmd_str += (nd_base_cmd + "prefix " +
nd_prefix["prefix"])
if nd_prefix["valid-lifetime"] != 0:
if nd_prefix["valid-lifetime"] == 4294967295:
valid_lifetime = "infinite"
else:
valid_lifetime = str(nd_prefix["valid-lifetime"])
if nd_prefix["preferred-lifetime"] != 0:
if nd_prefix["preferred-lifetime"] == 4294967295:
preferred_lifetime = "infinite"
else:
preferred_lifetime = str(nd_prefix["preferred-lifetime"])
if nd_prefix["no-autoconfig"] == True:
no_autoconfig = "no-autoconfig"
if nd_prefix["router-address"] == True:
router_address = "router-address"
if nd_prefix["off-link"] == True:
off_link = "off-link"
if valid_lifetime != "":
cmd_str += " " + valid_lifetime
if preferred_lifetime != "":
cmd_str += " " + preferred_lifetime
if router_address != "":
cmd_str += " " + router_address
if off_link != "":
cmd_str += " " + off_link
if no_autoconfig != "":
cmd_str += " " + no_autoconfig
cmd_str += cmd_end
return "CB_SUCCESS", cmd_str

def show_nd_radv_enable_config(render_tables):
cmd_str = ""
cmd_end = ";"
if ("sonic-system-infra:sonic-system-infra/RADVDAEMON"
in render_tables and 'RADVDAEMON_LIST' in render_tables["sonic-system-infra:sonic-system-infra/RADVDAEMON"]):
nd_radv_cfgs = render_tables["sonic-system-infra:sonic-system-infra/RADVDAEMON"]['RADVDAEMON_LIST']
if 'radv_daemon' in nd_radv_cfgs[0] and nd_radv_cfgs[0]['radv_daemon'] == 'enable':
cmd_str = "radv enable" + cmd_end
return "CB_SUCCESS", cmd_str
return "CB_SUCCESS", cmd_str
Loading

0 comments on commit 94c9f3a

Please sign in to comment.