Skip to content

Commit

Permalink
Support to display the SONiC OS Version in the command show version (#…
Browse files Browse the repository at this point in the history
…2787)

What I did
Support to display the SONiC OS Version in the command show version.
It will be used to display the version info in the SONiC command "show version". The version is used to do the FIPS certification. We do not do the FIPS certification on a specific release, but on the SONiC OS Version.

SONiC Software Version: SONiC.master-13812.218661-7d94c0c28
SONiC OS Version: 11
Distribution: Debian 11.6
Kernel: 5.10.0-18-2-amd64
How I did it
The device info is in sonic-net/sonic-buildimage, see PR: sonic-net/sonic-buildimage#14601
The submodule change can be merged to sonic-buildimage, after the PR 14601 merged.

How to verify it
  • Loading branch information
xumia authored and yxieca committed Apr 19, 2023
1 parent a5199f7 commit 3a880a2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ def version(verbose):
sys_date = datetime.now()

click.echo("\nSONiC Software Version: SONiC.{}".format(version_info['build_version']))
click.echo("\nSONiC OS Version: {}".format(version_info['sonic_os_version']))
click.echo("Distribution: Debian {}".format(version_info['debian_version']))
click.echo("Kernel: {}".format(version_info['kernel_version']))
click.echo("Build commit: {}".format(version_info['commit_id']))
Expand Down
31 changes: 31 additions & 0 deletions tests/show_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,34 @@ def test_show_logging_tmpfs_syslog_1(run_command, cli_arguments, expected):
runner = CliRunner()
result = runner.invoke(show.cli.commands["logging"], cli_arguments)
run_command.assert_called_with(EXPECTED_BASE_COMMAND + expected, display_cmd=False)

def side_effect_subprocess_popen(*args, **kwargs):
mock = MagicMock()
if args[0] == "uptime":
mock.stdout.read.return_value = "05:58:07 up 25 days"
elif args[0].startswith("sudo docker images"):
mock.stdout.read.return_value = "REPOSITORY TAG"
return mock

@patch('sonic_py_common.device_info.get_sonic_version_info', MagicMock(return_value={
"build_version": "release-1.1-7d94c0c28",
"sonic_os_version": "11",
"debian_version": "11.6",
"kernel_version": "5.10",
"commit_id": "7d94c0c28",
"build_date": "Wed Feb 15 06:17:08 UTC 2023",
"built_by": "AzDevOps"}))
@patch('sonic_py_common.device_info.get_platform_info', MagicMock(return_value={
"platform": "x86_64-kvm_x86_64-r0",
"hwsku": "Force10-S6000",
"asic_type": "vs",
"asic_count": 1}))
@patch('sonic_py_common.device_info.get_chassis_info', MagicMock(return_value={
"serial": "N/A",
"model": "N/A",
"revision": "N/A"}))
@patch('subprocess.Popen', MagicMock(side_effect=side_effect_subprocess_popen))
def test_show_version():
runner = CliRunner()
result = runner.invoke(show.cli.commands["version"])
assert "SONiC OS Version: 11" in result.output

0 comments on commit 3a880a2

Please sign in to comment.