-
Notifications
You must be signed in to change notification settings - Fork 1.8k
T2-VOQ-Chassis: VS support #18512
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
Merged
rlhui
merged 8 commits into
sonic-net:master
from
deepak-singhal0408:deepsinghal/voq_chassis_vs_support
Apr 19, 2024
Merged
T2-VOQ-Chassis: VS support #18512
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
16221da
T2-VOQ-VS: vswitch related changes
deepak-singhal0408 6b51aef
Fix Makefile
deepak-singhal0408 723e4c8
Fix Indentation
deepak-singhal0408 d0d6c86
Handled Macaddress Get for single asic linecards. Addressed review co…
deepak-singhal0408 3c85d30
Parse the switch_type from minigraph file instead of checking from ex…
deepak-singhal0408 18555c3
Modify MacAddress Generation logic for VS: Generate based on hostname…
deepak-singhal0408 3334bb1
remove unused import
deepak-singhal0408 a74e296
Modified first octet of VS_MAC from 0x02 to 0x22
deepak-singhal0408 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,11 @@ | ||
| # VS Platform modules | ||
|
|
||
| VS_PLATFORM_MODULE_VERSION = 1.0 | ||
|
|
||
| export VS_PLATFORM_MODULE_VERSION | ||
|
|
||
| VS_PLATFORM_MODULE = sonic-platform-vs_$(VS_PLATFORM_MODULE_VERSION)_amd64.deb | ||
| $(VS_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-vs | ||
| $(VS_PLATFORM_MODULE)_DEPENDS = | ||
| $(VS_PLATFORM_MODULE)_PLATFORM = x86_64-kvm_x86_64-r0 | ||
| SONIC_DPKG_DEBS += $(VS_PLATFORM_MODULE) |
This file contains hidden or 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 hidden or 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,10 @@ | ||
| sonic-platform-vs (1.0) UNRELEASED; urgency=low | ||
|
|
||
| * Initial release of the sonic-platform-vs package. | ||
| * This package provides platform-specific modules for SONiC on virtualized VS platforms. | ||
| * Included modules: | ||
| - Chassis module | ||
| * This package is part of the initial release of SONiC for VS platforms. | ||
|
|
||
| -- Deepak Singhal <deepsinghal@microsoft.com> Fri, 26 Feb 2024 12:00:00 +0000 | ||
|
|
This file contains hidden or 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 @@ | ||
| 10 |
This file contains hidden or 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,10 @@ | ||
| Source: sonic-platform-vs | ||
| Section: main | ||
| Priority: extra | ||
| Maintainer: Deepak Singhal <deepsinghal@microsoft.com> | ||
| Build-Depends: debhelper (>= 9), bzip2 | ||
| Standards-Version: 3.9.3 | ||
|
|
||
| Package: sonic-platform-vs | ||
| Architecture: amd64 | ||
| Description: Sonic VS platform Module |
This file contains hidden or 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,58 @@ | ||
| #!/usr/bin/make -f | ||
| # -*- makefile -*- | ||
| # Sample debian/rules that uses debhelper. | ||
| # As a special exception, when this file is copied by dh-make into a | ||
| # dh-make output file, you may use that output file without restriction. | ||
|
|
||
| include /usr/share/dpkg/pkg-info.mk | ||
|
|
||
| # Uncomment this to turn on verbose mode. | ||
| export DH_VERBOSE=1 | ||
|
|
||
| PYTHON ?= python3 | ||
| PACKAGE_PRE_NAME := sonic-platform-vs | ||
| SRC_DIR:= $(shell pwd) | ||
|
|
||
| %: | ||
| dh $@ --with python3 --buildsystem=pybuild | ||
|
|
||
| clean: | ||
| dh_testdir | ||
| dh_testroot | ||
| dh_clean | ||
|
|
||
| build: | ||
| # Nothing to do | ||
|
|
||
|
|
||
| binary: binary-arch binary-indep | ||
| # Nothing to do | ||
|
|
||
| binary-arch: | ||
| # Nothing to do | ||
|
|
||
| binary-indep: | ||
| # temporary commented out | ||
| # dh_testdir | ||
| dh_installdirs | ||
|
|
||
| # Custom package commands | ||
| $(PYTHON) setup.py install --root=$(SRC_DIR)/debian/$(PACKAGE_PRE_NAME) --install-layout=deb; | ||
|
|
||
| # Resuming debhelper scripts | ||
| dh_testroot | ||
| dh_install | ||
| dh_installchangelogs | ||
| dh_installdocs | ||
| dh_systemd_enable | ||
| dh_installinit | ||
| dh_systemd_start | ||
| dh_link | ||
| dh_fixperms | ||
| dh_compress | ||
| dh_strip | ||
| dh_installdeb | ||
| dh_gencontrol | ||
| dh_md5sums | ||
| dh_builddeb | ||
| .PHONY: build binary binary-arch binary-indep clean |
This file contains hidden or 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,15 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import os | ||
| import sys | ||
| from setuptools import setup | ||
| os.listdir | ||
|
|
||
| setup( | ||
| name='sonic_platform', | ||
| version='1.0', | ||
| description='Module to initialize VS platforms', | ||
|
|
||
| packages=['sonic_platform'], | ||
| package_dir={'sonic_platform': 'sonic_platform'} | ||
| ) |
2 changes: 2 additions & 0 deletions
2
platform/vs/sonic-platform-modules-vs/sonic_platform/__init__.py
This file contains hidden or 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,2 @@ | ||
| __all__ = ["platform"] | ||
| from sonic_platform import * |
61 changes: 61 additions & 0 deletions
61
platform/vs/sonic-platform-modules-vs/sonic_platform/chassis.py
This file contains hidden or 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,61 @@ | ||
| # Description: Module contains the definitions of SONiC platform APIs | ||
| # which provide the chassis specific details | ||
| # | ||
| # Copyright (c) 2019, Nokia | ||
| # All rights reserved. | ||
| # | ||
|
|
||
| try: | ||
| from sonic_platform_base.chassis_base import ChassisBase | ||
| from sonic_platform_base.module_base import ModuleBase | ||
| import os | ||
| import json | ||
| import threading | ||
|
|
||
| except ImportError as e: | ||
| raise ImportError(str(e) + "- required module not found") | ||
|
|
||
|
|
||
| class Chassis(ChassisBase): | ||
| """ | ||
| VS Platform-specific Chassis class | ||
| """ | ||
| def __init__(self): | ||
| ChassisBase.__init__(self) | ||
| self.metadata_file = '/etc/sonic/vs_chassis_metadata.json' | ||
| self.metadata = self._read_metadata() | ||
|
|
||
| def _read_metadata(self): | ||
| metadata = {} | ||
| if os.path.exists(self.metadata_file): | ||
| with open(self.metadata_file, 'r') as f: | ||
| metadata = json.load(f) | ||
| else: | ||
| raise FileNotFoundError("Metadata file {} not found".format(self.metadata_file)) | ||
| return metadata | ||
|
|
||
| def get_supervisor_slot(self): | ||
| if 'sup_slot_num' not in self.metadata: | ||
| raise KeyError("sup_slot_num not found in Metadata file {}".format(self.metadata_file)) | ||
| return self.metadata['sup_slot_num'] | ||
|
|
||
| def get_linecard_slot(self): | ||
| if 'lc_slot_num' not in self.metadata: | ||
| raise KeyError("lc_slot_num not found in Metadata file {}".format(self.metadata_file)) | ||
| return self.metadata['lc_slot_num'] | ||
|
|
||
| def get_my_slot(self): | ||
| if 'is_supervisor' not in self.metadata or 'is_linecard' not in self.metadata: | ||
| raise KeyError("is_supervisor or is_linecard not found in metadata file {}".format(self.metadata_file)) | ||
|
|
||
| if self.metadata['is_supervisor']: | ||
| return self.get_supervisor_slot() | ||
| elif self.metadata['is_linecard']: | ||
| return self.get_linecard_slot() | ||
| else: | ||
| raise ValueError("Invalid configuration: Neither supervisor nor line card") | ||
|
|
||
| def get_chassis_mac(self): | ||
| slotid = self.get_my_slot() | ||
| mac = "52:54:56:58:{:02x}:00".format(slotid) | ||
| return mac |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.