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

Add SPC5 to generic config updater file #9

Closed
wants to merge 15 commits into from
Closed
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ A convenient alternative is to let the SONiC build system configure a build envi

2. Build the sonic-utilities Python wheel package inside the Bullseye slave container, and tell the build system to keep the container alive when finished
```
make NOSTRETCH=1 NOBUSTER=1 KEEP_SLAVE_ON=yes target/python-wheels/bullseye/sonic_utilities-1.2-py3-none-any.whl
make -f Makefile.work BLDENV=bookworm KEEP_SLAVE_ON=yes target/python-wheels/bookworm/sonic_utilities-1.2-py3-none-any.whl
```

3. When the build finishes, your prompt will change to indicate you are inside the slave container. Change into the `src/sonic-utilities/` directory
Expand All @@ -66,13 +66,20 @@ A convenient alternative is to let the SONiC build system configure a build envi
```
python3 setup.py bdist_wheel
```
Note: This command by default will not update the wheel package in target/. To specify the destination location of wheel package, use "-d" option.

#### To run unit tests

```
python3 setup.py test
```

#### To install the package on a SONiC machine
```
sudo pip uninstall sonic-utilities
sudo pip install YOUR_WHEEL_PACKAGE
```
Note: Don't use "--force-reinstall".

### sonic-utilities-data

Expand Down
15 changes: 13 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3498,7 +3498,10 @@ def add_snmp_agent_address(ctx, agentip, port, vrf):
"""Add the SNMP agent listening IP:Port%Vrf configuration"""

#Construct SNMP_AGENT_ADDRESS_CONFIG table key in the format ip|<port>|<vrf>
if not clicommon.is_ipaddress(agentip):
# Link local IP address should be provided along with zone id
# <link_local_ip>%<zone_id> for ex fe80::1%eth0
agent_ip_addr = agentip.split('%')[0]
if not clicommon.is_ipaddress(agent_ip_addr):
click.echo("Invalid IP address")
return False
config_db = ctx.obj['db']
Expand All @@ -3508,7 +3511,7 @@ def add_snmp_agent_address(ctx, agentip, port, vrf):
click.echo("ManagementVRF is Enabled. Provide vrf.")
return False
found = 0
ip = ipaddress.ip_address(agentip)
ip = ipaddress.ip_address(agent_ip_addr)
for intf in netifaces.interfaces():
ipaddresses = netifaces.ifaddresses(intf)
if ip_family[ip.version] in ipaddresses:
Expand Down Expand Up @@ -4853,6 +4856,14 @@ def add_interface_ip(ctx, interface_name, ip_addr, gw, secondary):
interface_name = interface_alias_to_name(config_db, interface_name)
if interface_name is None:
ctx.fail("'interface_name' is None!")
# Add a validation to check this interface is not a member in vlan before
# changing it to a router port mode
vlan_member_table = config_db.get_table('VLAN_MEMBER')

if (interface_is_in_vlan(vlan_member_table, interface_name)):
click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name))
return


portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"spc1": [ "ACS-MSN2700", "ACS-MSN2740", "ACS-MSN2100", "ACS-MSN2410", "ACS-MSN2010", "Mellanox-SN2700", "Mellanox-SN2700-C28D8", "Mellanox-SN2700-D40C8S8", "Mellanox-SN2700-D44C10", "Mellanox-SN2700-D48C8",
"ACS-MSN2700-A1", "Mellanox-SN2700-A1", "Mellanox-SN2700-A1-C28D8", "Mellanox-SN2700-A1-D40C8S8", "Mellanox-SN2700-A1-D44C10", "Mellanox-SN2700-A1-D48C8" ],
"spc2": [ "ACS-MSN3800", "Mellanox-SN3800-D112C8", "ACS-MSN3420", "ACS-MSN3700C", "ACS-MSN3700", "Mellanox-SN3800-C64", "Mellanox-SN3800-D100C12S2", "Mellanox-SN3800-D24C52", "Mellanox-SN3800-D28C49S1", "Mellanox-SN3800-D28C50" ],
"spc3": [ "ACS-MSN4700", "ACS-MSN4600", "ACS-MSN4600C", "ACS-MSN4410", "ACS-SN4280", "Mellanox-SN4600C-D112C8", "Mellanox-SN4600C-C64", "Mellanox-SN4700-O8C48", "Mellanox-SN4600C-D100C12S2", "Mellanox-SN4600C-D48C40",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACS-SN4280 is removed. by mistake?
the rest LGTM

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase issue - fixed

"spc3": [ "ACS-MSN4700", "ACS-MSN4600", "ACS-MSN4600C", "ACS-MSN4410", "ACS-SN4280", "Mellanox-SN4600C-D112C8", "Mellanox-SN4600C-C64", "Mellanox-SN4700-O8C48", "Mellanox-SN4600C-D100C12S2", "Mellanox-SN4600C-D48C40","Mellanox-SN4700-O32","Mellanox-SN4700-V64",
"Mellanox-SN4700-A96C8V8", "Mellanox-SN4700-C128", "Mellanox-SN4700-O28", "Mellanox-SN4700-O8V48", "Mellanox-SN4700-V48C32", "Mellanox-SN4280-O28"],
"spc4": [ "ACS-SN5600", "Mellanox-SN5600-O128", "Mellanox-SN5600-V256", "ACS-SN5400" ]
"spc4": [ "ACS-SN5600", "Mellanox-SN5600-O128", "Mellanox-SN5600-V256", "ACS-SN5400" ],
"spc5": ["ACS-SN5640"]
},
"broadcom_asics": {
"th": [ "Force10-S6100", "Arista-7060CX-32S-C32", "Arista-7060CX-32S-C32-T1", "Arista-7060CX-32S-D48C8", "Celestica-DX010-C32", "Seastone-DX010" ],
Expand Down
3 changes: 3 additions & 0 deletions generic_config_updater/generic_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def extract_scope(path):
scope = HOST_NAMESPACE
remainder = "/" + "/".join(parts[1:])
else:
if multi_asic.is_multi_asic():
raise GenericConfigUpdaterError(f"Multi ASIC must have namespace prefix in path: '{path}'.")

scope = ""
remainder = path
return scope, remainder
Expand Down
14 changes: 12 additions & 2 deletions rcli/linecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import termios
import tty

from .utils import get_linecard_ip
from .utils import get_linecard_ip, get_linecard_hostname_from_module_name, get_linecard_module_name_from_hostname
from paramiko.py3compat import u
from paramiko import Channel

Expand All @@ -31,7 +31,17 @@ def __init__(self, linecard_name, username, password):
if not self.ip:
sys.exit(1)

self.linecard_name = linecard_name
# if the user passes linecard hostname, then try to get the module name for that linecard
module_name = get_linecard_module_name_from_hostname(linecard_name)
if module_name is None:
# if the module name cannot be found from host, assume the user has passed module name
self.module_name = linecard_name
self.hostname = get_linecard_hostname_from_module_name(linecard_name)
else:
# the user has passed linecard hostname
self.hostname = linecard_name
self.module_name = module_name

self.username = username
self.password = password

Expand Down
12 changes: 7 additions & 5 deletions rcli/rexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ def cli(linecard_names, command, username):

if list(linecard_names) == ["all"]:
# Get all linecard names using autocompletion helper
linecard_names = rcli_utils.get_all_linecards(None, None, "")
module_names = sorted(rcli_utils.get_all_linecards(None, None, ""))
else:
module_names = linecard_names

linecards = []
# Iterate through each linecard, check if the login was successful
for linecard_name in linecard_names:
linecard = Linecard(linecard_name, username, password)
for module_name in module_names:
linecard = Linecard(module_name, username, password)
if not linecard.connection:
click.echo(f"Failed to connect to {linecard_name} with username {username}")
click.echo(f"Failed to connect to {module_name} with username {username}")
sys.exit(1)
linecards.append(linecard)

for linecard in linecards:
if linecard.connection:
click.echo(f"======== {linecard.linecard_name} output: ========")
click.echo(f"======== {linecard.module_name}|{linecard.hostname} output: ========")
click.echo(linecard.execute_cmd(command))


Expand Down
4 changes: 2 additions & 2 deletions rcli/rshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def cli(linecard_name, username):
try:
linecard = Linecard(linecard_name, username, password)
if linecard.connection:
click.echo(f"Connecting to {linecard.linecard_name}")
click.echo(f"Connecting to {linecard.module_name}")
# If connection was created, connection exists.
# Otherwise, user will see an error message.
linecard.start_shell()
click.echo("Connection Closed")
except paramiko.ssh_exception.AuthenticationException:
click.echo(
f"Login failed on '{linecard.linecard_name}' with username '{linecard.username}'")
f"Login failed on '{linecard.module_name}' with username '{linecard.username}'")


if __name__=="__main__":
Expand Down
15 changes: 15 additions & 0 deletions rcli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def get_linecard_module_name_from_hostname(linecard_name: str):

return None


def get_linecard_hostname_from_module_name(linecard_name: str):

chassis_state_db = connect_to_chassis_state_db()
keys = chassis_state_db.keys(chassis_state_db.CHASSIS_STATE_DB, '{}|{}'.format(CHASSIS_MODULE_HOSTNAME_TABLE, '*'))
for key in keys:
module_name = key.split('|')[1]
if module_name.replace('-', '').lower() == linecard_name.replace('-', '').lower():
hostname = chassis_state_db.get(chassis_state_db.CHASSIS_STATE_DB, key, CHASSIS_MODULE_HOSTNAME)
return hostname

return None


def get_linecard_ip(linecard_name: str):
"""
Given a linecard name, lookup its IP address in the midplane table
Expand All @@ -69,6 +83,7 @@ def get_linecard_ip(linecard_name: str):
return None
return module_ip


def get_module_ip_and_access_from_state_db(module_name):
state_db = connect_state_db()
data_dict = state_db.get_all(
Expand Down
14 changes: 11 additions & 3 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, namespace, socket=None):
none-zero values.
build: sequentially increase within a minor version domain.
"""
self.CURRENT_VERSION = 'version_202405_01'
self.CURRENT_VERSION = 'version_202411_01'

self.TABLE_NAME = 'VERSIONS'
self.TABLE_KEY = 'DATABASE'
Expand Down Expand Up @@ -1228,10 +1228,18 @@ def version_202311_03(self):

def version_202405_01(self):
"""
Version 202405_01, this version should be the final version for
master branch until 202405 branch is created.
Version 202405_01.
"""
log.log_info('Handling version_202405_01')
self.set_version('version_202411_01')
return 'version_202411_01'

def version_202411_01(self):
"""
Version 202411_01, this version should be the final version for
master branch until 202411 branch is created.
"""
log.log_info('Handling version_202411_01')
return None

def get_version(self):
Expand Down
Loading
Loading