Skip to content

Commit

Permalink
Merge pull request #267 from e-sonic/merge-1128/broadcom_sonic_4.x_sh…
Browse files Browse the repository at this point in the history
…are-to-dell_sonic_4.x_share

sync from broadcom_sonic_4.x_share to dell_sonic_4.x_share - 1128
  • Loading branch information
bhavini-gada authored and GitHub Enterprise committed Nov 29, 2022
2 parents 34779be + 4ecf715 commit b4cc178
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 52 deletions.
4 changes: 2 additions & 2 deletions CLI/actioner/show_config_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ def show_if_unlos(render_tables):
for port in render_tables["sonic-port:sonic-port/PORT/PORT_LIST"]:
if port.get("ifname") != ifname_key:
continue
mode = port.get("unreliable_los")
mode = port.get("unreliable_los", "N/A")
if mode not in ['off', 'OFF', 'on', 'ON']:
continue
mode = 'auto'
cmd_str = "unreliable-los {}".format(mode)

return "CB_SUCCESS", cmd_str
Expand Down
46 changes: 5 additions & 41 deletions CLI/actioner/sonic_cli_cable_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,19 @@
from collections import OrderedDict
from rpipe_utils import pipestr
from scripts.render_cli import show_cli_output
from sonic_cli_if_range import eth_intf_range_expand

aa = cc.ApiClient()

def getRangedPortNameList(name):
if name is None:
return []

if ("-" not in name) and ("," not in name):
return [name]
elif name.startswith("Ethernet"):
prefix = "Ethernet"
elif name.startswith("Eth") and ('/' in name):
prefix = "Eth"
else:
return [name]

list = []
try:
for port in name[len(prefix):].split(","):
pp = ""
ids = port.split("-")
if len(ids) == 2:
# The build-in checker of KLISH CLI will ensure all the ids
# are using the same format
if '/' in ids[0]:
pp = ids[0][0:ids[0].rindex("/") + 1]
s1 = int(ids[0][len(pp):], 10)
s2 = int(ids[1][len(pp):], 10)
if s2 > s1:
for id in range(s1, s2 + 1, 1):
list.append("{}{}{}".format(prefix, pp, id))
else:
for id in range(s2, s1 + 1, 1):
list.append("{}{}{}".format(prefix, pp, id))
else:
for id in ids:
list.append("{}{}{}".format(prefix, pp, id))
except:
pass

return list if len(list) > 0 else [name]


def getPortList(if_name=None):
list = []
path = cc.Path("/restconf/data/sonic-port:sonic-port/PORT/PORT_LIST")
resp = aa.get(path, None, False)
if (resp.ok() and (resp.content is not None) and ("sonic-port:PORT_LIST" in resp.content)):
filter = getRangedPortNameList(if_name)
if if_name is None:
filter = []
else:
filter = eth_intf_range_expand(if_name)
for port in resp.content["sonic-port:PORT_LIST"]:
name = port.get("ifname")
if (name is None) or (not name.startswith("Eth")):
Expand Down
23 changes: 21 additions & 2 deletions CLI/actioner/sonic_cli_file_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,19 +356,38 @@ def handle_copy(func, args, input_dict):

return run_copy(func, n_args, input_dict)

def show_cfg_reload_status(cmd, args):
tmpl = args[0]
api = cc.ApiClient()
path = cc.Path("/restconf/data/openconfig-file-mgmt-private:config-reload/state")
api_response = api.get(path)
if api_response.ok():
response = api_response.content
if 'openconfig-file-mgmt-private:state' in response:
show_cli_output(tmpl, response['openconfig-file-mgmt-private:state'])
else:
show_cli_output(tmpl, response)
else:
print(api_response.error_message())
return (-1)
return (0)


def run(cmd, args):
status = 0
if cmd == "show_cfg_reload_status":
status = show_cfg_reload_status(cmd, args)
return status

input_dict, count = process_args(args)
if (count == 0):
return -1

if cmd == "dir":
status = handle_dir(args, input_dict)
elif cmd == "copy":
status = handle_copy(cmd, args, input_dict)
elif cmd == "del":
status = handle_del(cmd, args, input_dict)

return status

if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions CLI/actioner/sonic_intf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ def get_intf_name_alias_map():


def get_intf_ui_name(intf_name, naming_mode, aliasmap = None):
if naming_mode != "standard" and naming_mode != "standard-ext":
return intf_name
if "." in intf_name:
#This is subinterface
split = intf_name.split(".")
if "Po" in intf_name:
split[0] = get_intf_ui_name(split[0].replace("Po", "PortChannel"), naming_mode, aliasmap=aliasmap)
elif naming_mode == "standard":
split[0] = get_intf_ui_name(split[0].replace("Po", "PortChannel").replace("Eth", "Ethernet"), naming_mode, aliasmap=aliasmap)
elif naming_mode != "standard-ext" and "Ethernet" not in intf_name:
split[0] = get_intf_ui_name(split[0].replace("Eth", "Ethernet"), naming_mode, aliasmap=aliasmap)
return ".".join(split)
if naming_mode != "standard" and naming_mode != "standard-ext":
return intf_name
if aliasmap == None:
aliasmap = get_intf_name_alias_map()
if intf_name in aliasmap:
Expand Down
10 changes: 9 additions & 1 deletion CLI/clitree/cli-xml/file_mgmt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ permissions and limitations under the License. -->
</DOCGEN>

</COMMAND>


<COMMAND
name="show config-reload"
help="Display Config Reload status"
>
<ACTION
builtin="clish_pyobj">sonic_cli_file_mgmt show_cfg_reload_status show_config_reload_status.j2
</ACTION>
</COMMAND>
</VIEW>
</CLISH_MODULE>
19 changes: 19 additions & 0 deletions CLI/renderer/templates/show_config_reload_status.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{'------------------------------------------------------'}}
{{'Config Reload Status'}}
{{'------------------------------------------------------'}}
{% if json_output %}
{{'State'.ljust(25)}}: {{json_output['state']}}
{{'State detail'.ljust(25)}}: {{json_output['state-detail']}}
{% if 'start-time' in json_output %}
{% set cfg_reload_start_time = datetimeformat(json_output['start-time']) %}
{% else %}
{% set cfg_reload_start_time = "N/A" %}
{% endif %}
{{'Start time'.ljust(25) }}: {{ cfg_reload_start_time }}
{% if 'end-time' in json_output %}
{% set cfg_reload_end_time = datetimeformat(json_output['end-time']) %}
{% else %}
{% set cfg_reload_end_time = "N/A" %}
{% endif %}
{{'End time'.ljust(25) }}: {{ cfg_reload_end_time }}
{% endif %}
4 changes: 2 additions & 2 deletions CLI/renderer/templates/show_ip_ospf_neighbor_detail.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ VRF Name: {{list_elem['vrfName']}}
{% for interfaceinfo in interface_list %}
{% if 'openconfig-ospfv2-ext:neighbours' in interfaceinfo and 'neighbour' in interfaceinfo['openconfig-ospfv2-ext:neighbours'] %}
{% set neighbor_list = interfaceinfo['openconfig-ospfv2-ext:neighbours']['neighbour'] %}
{% for neighborinfo in neighbor_list %}
{% for neighborinfo in neighbor_list -%}
{% if 'state' in neighborinfo %}
{% if vars.interface_name == "" or vars.interface_name == neighborinfo['state']['interface-name'] %}
{% if vars.update({'number':neighborinfo['state']['dead-time'] | float}) %}{% endif %}
Expand Down Expand Up @@ -95,7 +95,7 @@ VRF Name: {{list_elem['vrfName']}}
{% endif %}
{% endif %}
{{' '}}
{% endfor -%}
{%- endfor -%}
{% endif -%}
{% endfor -%}
{% endif -%}
Expand Down

0 comments on commit b4cc178

Please sign in to comment.