Skip to content

Create a Python library to house common general SONiC-related APIs #4999

@jleveque

Description

@jleveque

There is currently a lot of duplicated code in many SONiC repos, and other shared code is located in various packages. We need to centralize this common functionality in a Python library which resides in sonic-buildimage that we can import from sonic-daemon-base, sonic-utilities, sonic-platform-common, sonic-platform-daemons, etc., and eliminate duplicate code in the process. Examples of this functionality include:

  • get_platform()
  • get_hwsku
  • get_path_to_platform_and_hwsku()
  • get_path_to_port_config_file()
  • Logging
  • ...

Plan of action:

  • Create sonic-py-common package in sonic-buildimage repo
  • Migrate all Python applications in sonic-buildimage from sonic-daemon-base and sonic_device_util to sonic-py-common
  • Migrate all Python applications in submodules from sonic-daemon-base and sonic_device_util to sonic-py-common
  • Migrate sonic-mgmt
    • master PR merged 8/8/20
      • 201911 PR not needed, no 201911 branch
  • Remove sonic-daemon-base from sonic-buildimage entirely
  • Remove sonic_device_util.py from sonic-buildimage entirely
  • Migrate common code from sonic-utilities into sonic-py-common
  • Migrate all Python daemons to inherit from sonic_py_common.daemon_base (lldpmgrd, bgpcfgd, etc.)
    • lldpmgrd: master PR merged 9/15/20
    • caclmgrd: master PR merged 9/15/20
    • procdockerstatsd: master PR merged 9/14/20
    • bgpcfgd
    • hostcfgd
    • ctrmgrd
  • Remove all bespoke logging code from Python applications and import from sonic_py_common instead
    • dockers/docker-sflow/port_index_mapper.py
    • files/image_config/process-reboot-cause/process-reboot-cause: master PR
    • files/scripts/core_cleanup.py
    • src/sonic-yang-mgmt/sonic_yang.py
  • Remove portconfig.py from sonic-config-engine and move functionality into sonic-py-common
  • Add regression tests for sonic-py-common to sonic-mgmt repo

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions