Skip to content

Add gNOI OS Management services #270

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kanchana-HCLTech
Copy link

No description provided.

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft qiluo-msft requested review from hdwhdw and Copilot June 20, 2025 07:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds gNOI OS management services integration, including service registration, protobuf definitions, and an infrastructure module for command execution.

  • Register new gnoi_os_mgmt and infra_host handlers in the D-Bus server script
  • Introduce shared protobuf constants in os_mgmt/gnoi_os_proto_defs.py
  • Implement InfraHost module for executing shell commands and reporting critical state

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.

File Description
tests/mocks/host_service.py Add mock HostModule and Logger for unit tests
scripts/sonic-host-server Register new gNOI OS management and infra host modules
os_mgmt/gnoi_os_proto_defs.py Define shared gNOI OS protobuf field constants
host_modules/infra_host.py Implement InfraHost with command execution and state reporting

timestamp_in_seconds = current_time.timestamp()
tv_sec = int(timestamp_in_seconds)
tv_nsec = int((timestamp_in_seconds - tv_sec)*10**9)
result = "%s timestamp \"%s\" timestamp-seconds %s timestamp-nanoseconds %s" % (
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

REPORT_CRITICAL_STATE_COMMAND has no trailing space, so concatenating it directly with 'timestamp' produces '...essential truetimestamp'. Add a space after the base command or include it in the format string.

Copilot uses AI. Check for mistakes.

REPORT_CRITICAL_STATE_COMMAND, timestamp_string, str(tv_sec), str(tv_nsec))
return result

@staticmethod
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

This method is marked as @staticmethod but still takes 'self'. Either remove the @staticmethod decorator or refactor to use an instance method signature.

Suggested change
@staticmethod

Copilot uses AI. Check for mistakes.

@staticmethod
def raise_critical_state(self):
"""Raise critical state when reboot fails"""
rc, stdout, stderr = self._run_command(self.generate_critical_state_command(self))
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

Calling generate_critical_state_command(self) passes 'self' twice. It should be invoked as self.generate_critical_state_command().

Copilot uses AI. Check for mistakes.

else:
logger.error("%s: !Encountered while processing empty param",
MOD_NAME)
return (1, None)
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

The method signature declares an int and string ('is') return, but returns None for the string. Consider returning an empty string instead of None to match the expected type.

Suggested change
return (1, None)
return (1, "")

Copilot uses AI. Check for mistakes.

@hdwhdw
Copy link
Contributor

hdwhdw commented Jun 23, 2025

Can you see if you can take advantage of https://github.com/sonic-net/sonic-host-services/blob/master/host_modules/image_service.py? We should avoid writing different modules for the same service. Thanks!

Copy link
Contributor

@hdwhdw hdwhdw left a comment

Choose a reason for hiding this comment

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

Please take a look at existing services to see if you can reuse. We should avoid reinventing the wheel. If the implementation here is much more robust feel free to propose substituting the existing service (and also in sonic-gnmi), but we should avoid having two services doing the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you share why this is needed? Ideally the host services should not need to know the exact definition of the gnoi service.


import host_service
import infra_host
import os_mgmt.gnoi_os_proto_defs as ospb
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try to create a separate, stable and well-defined API for sonic-host-service that can be used regardless whether you are from gnoi, i.e. use what you write here to implement gnoi, instead of directly implement gnoi here. This avoid churns when the upstream gnoi definition changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants