forked from sonic-net/sonic-mgmt-framework
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from e-sonic/merge-1102/broadcom_sonic_4.0.x_…
…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
Showing
9 changed files
with
1,272 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.