-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from deepak-singhal0408/deepsinghal/t2-voq-su…
…pport-new T2-VOQ: VS Support
- Loading branch information
Showing
20 changed files
with
471 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 * |
56 changes: 56 additions & 0 deletions
56
platform/vs/sonic-platform-modules-vs/sonic_platform/chassis.py
This file contains 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,56 @@ | ||
# 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") |
Oops, something went wrong.