Skip to content

Commit

Permalink
Merge pull request #223 from e-sonic/rocev2_mgmt_framework_changes
Browse files Browse the repository at this point in the history
RoCEv2 Mgmt framework changes
  • Loading branch information
bhavini-gada authored and GitHub Enterprise committed Nov 4, 2022
2 parents 2eea156 + 410db6c commit 30e6449
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 38 deletions.
28 changes: 23 additions & 5 deletions CLI/actioner/show_config_qos_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
#
###########################################################################

profile_reserved_names = [ "egress_lossless_profile", "ingress_lossless_profile", "egress_lossy_profile", "ingress_lossy_profile", "pg_lossless_" ]

def is_buffer_profile_default(name):
for profile in profile_reserved_names:
if profile is name or profile in name:
return True
return False

def get_buffer_name_from_db_format(name, prefix):
prefix = "[" + prefix + "|"
Expand All @@ -35,10 +42,11 @@ def show_qos_buffer_profile(render_tables):
for prfl_inst in render_tables[
"sonic-buffer-profile:sonic-buffer-profile/BUFFER_PROFILE/BUFFER_PROFILE_LIST"]:

if more_prfl:
cmd_str = cmd_str + ";"

if "name" in prfl_inst:
if is_buffer_profile_default(prfl_inst["name"]) == True:
continue
if more_prfl:
cmd_str = cmd_str + ";"
cmd_str = cmd_str + cmd_prfx + str(prfl_inst["name"])
else:
return "CB_SUCCESS", ""
Expand Down Expand Up @@ -96,9 +104,13 @@ def show_qos_buffer_priority_group(render_tables):
for pg_inst in render_tables[
"sonic-buffer-pg:sonic-buffer-pg/BUFFER_PG/BUFFER_PG_LIST"]:
if "ifname" in pg_inst and ifname_key == pg_inst["ifname"]:

if "profile" in pg_inst:
prfl_name = get_buffer_name_from_db_format(
pg_inst["profile"], "BUFFER_PROFILE")
if is_buffer_profile_default(prfl_name) == True:
continue
if more_pg:
cmd_str = cmd_str + ";"
cmd_str = cmd_str + ";"

if "pg_num" in pg_inst:
cmd_str = cmd_str + cmd_prfx + str(pg_inst["pg_num"])
Expand Down Expand Up @@ -132,6 +144,12 @@ def show_qos_buffer_queue(render_tables):
"sonic-buffer-queue:sonic-buffer-queue/BUFFER_QUEUE/BUFFER_QUEUE_LIST"]:
if "ifname" in qq_inst and ifname_key == qq_inst["ifname"]:

if "profile" in qq_inst:
prfl_name = get_buffer_name_from_db_format(
qq_inst["profile"], "BUFFER_PROFILE")
if is_buffer_profile_default(prfl_name) == True:
continue

if more_qq:
cmd_str = cmd_str + ";"

Expand Down
30 changes: 30 additions & 0 deletions CLI/actioner/sonic_cli_breakout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@

urllib3.disable_warnings()

def prompt(msg):
prompt_msg = msg + "[Proceed y/N]: "
x = input(prompt_msg)
while x.lower() != "y" and x.lower() != "n":
print("Invalid input, expected [y/N]")
x = input(prompt_msg)
if x.lower() == "n":
return False
else:
return True

def get_switch_lossless_mode_status():
api = cc.ApiClient()
path = cc.Path("/restconf/data/sonic-switch:sonic-switch/SWITCH/SWITCH_LIST")
response = api.get(path)
if response.ok() and response.content is not None:
parent_data_list = list((response.content["sonic-switch:SWITCH_LIST"][0]))
if ("buffer_mode_lossless" in parent_data_list):
if response.content["sonic-switch:SWITCH_LIST"][0]["buffer_mode_lossless"] == True:
return True
if ("roce_enable" in parent_data_list):
if response.content["sonic-switch:SWITCH_LIST"][0]["roce_enable"] == True:
return True
return False

def invoke(func, args):
body = None
aa = cc.ApiClient()
Expand Down Expand Up @@ -74,6 +99,11 @@ def invoke(func, args):
elif (func ==
"patch_openconfig_platform_port_components_component_port_breakout_mode_config"
):
if get_switch_lossless_mode_status():
msg = "Switch in lossless mode, Ports created can be used only after reboot."
initMessage = prompt(msg)
if not(initMessage):
return
interface = args[0]
speed_map = {
"4x10G": "SPEED_10GB",
Expand Down
34 changes: 32 additions & 2 deletions CLI/actioner/sonic_cli_qos_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@ def invoke_api(func, args=[]):

return None

elif func == "qos_roce_enable":
initMessage = prompt(msg)
if initMessage:
body = {"openconfig-qos-private:input": {"operation": "ENABLE"}}
path = cc.Path(
"/restconf/operations/openconfig-qos-private:qos-roce-config")
qos_buffer_rpc_reboot(api,path,body)

return None

elif func == "qos_roce_enable_force_defaults":
initMessage = prompt(msg)
if initMessage:
body = {"openconfig-qos-private:input": {"force": True}}
path = cc.Path(
"/restconf/operations/openconfig-qos-private:qos-roce-config")
qos_buffer_rpc_reboot(api,path,body)

return None

elif func == "qos_roce_disable":
initMessage = prompt(msg)
if initMessage:
body = {"openconfig-qos-private:input": {"operation": "DISABLE"}}
path = cc.Path(
"/restconf/operations/openconfig-qos-private:qos-roce-config")
qos_buffer_rpc_reboot(api,path,body)

return None

elif func == "create_qos_buffer_pool":
path = cc.Path(
"/restconf/data/openconfig-qos:qos/openconfig-qos-buffer:buffer/buffer-pools"
Expand Down Expand Up @@ -232,11 +262,11 @@ def invoke_api(func, args=[]):

elif func == "set_default_lossless_buffer_profile":
path = cc.Path(
"/restconf/data/openconfig-qos:qos/interfaces/interface={name}/openconfig-qos-deviation:buffer/config/default-lossless-buffer-profile",
"/restconf/data/openconfig-qos:qos/interfaces/interface={name}/openconfig-qos-buffer:buffer/config/default-lossless-buffer-profile",
name=args[0],
)
body = {
"openconfig-qos-deviation:default-lossless-buffer-profile":
"openconfig-qos-buffer:default-lossless-buffer-profile":
True if args[1] == "True" else False
}

Expand Down
Loading

0 comments on commit 30e6449

Please sign in to comment.