Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate buffer and qos config for dynamic breakout port #3669

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion config/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def _verifyAsicDB(self, db, ports, portMap, timeout):
return True

def breakOutPort(self, delPorts=list(), portJson=dict(), force=False, \
loadDefConfig=True):
loadDefConfig=True, addPorts=list()):
'''
This is the main function for port breakout. Exposed to caller.

Expand Down Expand Up @@ -446,6 +446,11 @@ def breakOutPort(self, delPorts=list(), portJson=dict(), force=False, \
if ret == False:
return None, ret

# generate queue config for addPorts
for newPort in addPorts:
queue_cfg = self._generate_queue_cfg(self.configDeps, newPort)
self._mergeConfigs(addConfigtoLoad, queue_cfg, True)

# Save Port OIDs Mapping Before Deleting Port
dataBase = SonicV2Connector(host="127.0.0.1")
if_name_map, if_oid_map = port_util.get_interface_oid_map(dataBase)
Expand Down Expand Up @@ -483,6 +488,8 @@ def _deletePorts(self, ports=list(), force=False):
and success/fail.
'''
configToLoad = None; deps = None
self.configDeps = {}
self._searchKeysInConfig(self.configdbJsonIn, self.configDeps, [ports[0]])
try:
self.sysLog(msg="delPorts ports:{} force:{}".format(ports, force))

Expand Down Expand Up @@ -592,6 +599,23 @@ def _addPorts(self, portJson=dict(), loadDefConfig=True):

return configToLoad, True

def _generate_queue_cfg(self, cfgIn, new_port):
cfgOut = {}
for cfg_key in ['BUFFER_QUEUE', 'PORT_QOS_MAP', 'QUEUE']:
if cfg_key in cfgIn:
cfgOut[cfg_key] = {}
for k in cfgIn[cfg_key]:
new_k = re.sub(r"Ethernet[\w]+", new_port, k)
cfgOut[cfg_key][new_k] = cfgIn[cfg_key][k]
if 'CABLE_LENGTH' in cfgIn:
if 'AZURE' in cfgIn['CABLE_LENGTH']:
cfgOut['CABLE_LENGTH'] = {}
cfgOut['CABLE_LENGTH']['AZURE'] = {}
for k in cfgIn['CABLE_LENGTH']['AZURE']:
new_k = re.sub(r"Ethernet[\w]+", new_port, k)
cfgOut['CABLE_LENGTH']['AZURE'][new_k] = cfgIn['CABLE_LENGTH']['AZURE'][k]
return cfgOut

def _shutdownIntf(self, ports):
"""
Based on the list of Ports, create a dict to shutdown port, update Config DB.
Expand Down
6 changes: 3 additions & 3 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ def breakout_warnUser_extraTables(cm, final_delPorts, confirm=True):
return

def breakout_Ports(cm, delPorts=list(), portJson=dict(), force=False, \
loadDefConfig=False, verbose=False):
loadDefConfig=False, verbose=False, addPorts=list()):

deps, ret = cm.breakOutPort(delPorts=delPorts, portJson=portJson, \
force=force, loadDefConfig=loadDefConfig)
force=force, loadDefConfig=loadDefConfig, addPorts=addPorts)
# check if DPB failed
if ret == False:
if not force and deps:
Expand Down Expand Up @@ -4881,7 +4881,7 @@ def breakout(ctx, interface_name, mode, verbose, force_remove_dependencies, load

# breakout_Ports will abort operation on failure, So no need to check return
breakout_Ports(cm, delPorts=final_delPorts, portJson=portJson, force=force_remove_dependencies,
loadDefConfig=load_predefined_config, verbose=verbose)
loadDefConfig=load_predefined_config, verbose=verbose, addPorts=add_ports)

# Set Current Breakout mode in config DB
brkout_cfg_keys = config_db.get_keys('BREAKOUT_CFG')
Expand Down
Loading