Skip to content

Port System EEPROM handling from pfm_app.go to xfmr_platform.go - #236

Open
bibhuprasad-hcl wants to merge 2 commits into
sonic-net:masterfrom
bibhuprasad-hcl:pr_compmodel_eeprom
Open

bibhuprasad-hcl wants to merge 2 commits into
sonic-net:masterfrom
bibhuprasad-hcl:pr_compmodel_eeprom

Conversation

@bibhuprasad-hcl

@bibhuprasad-hcl bibhuprasad-hcl commented Aug 6, 2026

Copy link
Copy Markdown

Why I did it

To migrate System EEPROM handling to SONiC's standardized Subtree Transformer (xfmr) architecture, replacing its implementation in pfm_app.go.

How I did it

Ported System EEPROM from the legacy pfm_app.go application module into the subtree transformer translib/transformer/xfmr_platform.go. Added CompTypeSysEeprom to compTblMap along with EepromDb, getEepromDbObj(), and fillSysEepromInfo() to support full component queries as well as granular state leaf paths.

PR Merge Order:

  1. Components Root Support (Base PR):
    sonic-mgmt-common/pull/224
  2. System EEPROM Support:
    sonic-mgmt-common/pull/236

PR link for Component test:

sonic-net/sonic-gnmi#751

Unit Test Result:

=== RUN TestEeprom_ValidSysEepromName
=== RUN TestEeprom_ValidSysEepromName/System_Eeprom_exact_match
=== RUN TestEeprom_ValidSysEepromName/eeprom_lowercase
=== RUN TestEeprom_ValidSysEepromName/chassis_prefix_match
=== RUN TestEeprom_ValidSysEepromName/invalid_component_name
=== RUN TestEeprom_ValidSysEepromName/empty_string
--- PASS: TestEeprom_ValidSysEepromName (0.00s)
--- PASS: TestEeprom_ValidSysEepromName/System_Eeprom_exact_match (0.00s)
--- PASS: TestEeprom_ValidSysEepromName/eeprom_lowercase (0.00s)
--- PASS: TestEeprom_ValidSysEepromName/chassis_prefix_match (0.00s)
--- PASS: TestEeprom_ValidSysEepromName/invalid_component_name (0.00s)
--- PASS: TestEeprom_ValidSysEepromName/empty_string (0.00s)
=== RUN TestEeprom_GetCompTypeByName
=== RUN TestEeprom_GetCompTypeByName/IC_Component_with_0_index
=== RUN TestEeprom_GetCompTypeByName/IC_Component_with_1_index
=== RUN TestEeprom_GetCompTypeByName/System_Eeprom_Component
=== RUN TestEeprom_GetCompTypeByName/Chassis_Component
=== RUN TestEeprom_GetCompTypeByName/Eeprom_Component
=== RUN TestEeprom_GetCompTypeByName/Invalid_Component
--- PASS: TestEeprom_GetCompTypeByName (0.00s)
--- PASS: TestEeprom_GetCompTypeByName/IC_Component_with_0_index (0.00s)
--- PASS: TestEeprom_GetCompTypeByName/IC_Component_with_1_index (0.00s)
--- PASS: TestEeprom_GetCompTypeByName/System_Eeprom_Component (0.00s)
--- PASS: TestEeprom_GetCompTypeByName/Chassis_Component (0.00s)
--- PASS: TestEeprom_GetCompTypeByName/Eeprom_Component (0.00s)
--- PASS: TestEeprom_GetCompTypeByName/Invalid_Component (0.00s)
=== RUN TestEeprom_KeyInDbTable_And_GetCompType
=== RUN TestEeprom_KeyInDbTable_And_GetCompType/keyInDbTable_Exists
=== RUN TestEeprom_KeyInDbTable_And_GetCompType/keyInDbTable_NonExistent
=== RUN TestEeprom_KeyInDbTable_And_GetCompType/keyInDbTable_NilDB
=== RUN TestEeprom_KeyInDbTable_And_GetCompType/getCompType_SysEeprom_FromDB
=== RUN TestEeprom_KeyInDbTable_And_GetCompType/getCompType_Wildcard
--- PASS: TestEeprom_KeyInDbTable_And_GetCompType (0.00s)
--- PASS: TestEeprom_KeyInDbTable_And_GetCompType/keyInDbTable_Exists (0.00s)
--- PASS: TestEeprom_KeyInDbTable_And_GetCompType/keyInDbTable_NonExistent (0.00s)
--- PASS: TestEeprom_KeyInDbTable_And_GetCompType/keyInDbTable_NilDB (0.00s)
--- PASS: TestEeprom_KeyInDbTable_And_GetCompType/getCompType_SysEeprom_FromDB (0.00s)
--- PASS: TestEeprom_KeyInDbTable_And_GetCompType/getCompType_Wildcard (0.00s)
=== RUN TestEeprom_GetEepromDbObj
=== RUN TestEeprom_GetEepromDbObj/Nil_DB
=== RUN TestEeprom_GetEepromDbObj/Populated_DB
--- PASS: TestEeprom_GetEepromDbObj (0.00s)
--- PASS: TestEeprom_GetEepromDbObj/Nil_DB (0.00s)
--- PASS: TestEeprom_GetEepromDbObj/Populated_DB (0.00s)
=== RUN TestEeprom_FillSysEepromInfo
=== RUN TestEeprom_FillSysEepromInfo/Fill_Full_Tree_(COMP_path)
=== RUN TestEeprom_FillSysEepromInfo/Fill_Specific_Leaf_Path_(Part-No)
=== RUN TestEeprom_FillSysEepromInfo/Fill_Specific_Leaf_Paths_(All_Cases)
--- PASS: TestEeprom_FillSysEepromInfo (0.01s)
--- PASS: TestEeprom_FillSysEepromInfo/Fill_Full_Tree_(COMP_path) (0.00s)
--- PASS: TestEeprom_FillSysEepromInfo/Fill_Specific_Leaf_Path_(Part-No) (0.00s)
--- PASS: TestEeprom_FillSysEepromInfo/Fill_Specific_Leaf_Paths_(All_Cases) (0.01s)
=== RUN TestEeprom_Subscribe_pfm_components_xfmr
=== RUN TestEeprom_Subscribe_pfm_components_xfmr/System_Eeprom_Subscription_Virtual_Table_check
--- PASS: TestEeprom_Subscribe_pfm_components_xfmr (0.00s)
--- PASS: TestEeprom_Subscribe_pfm_components_xfmr/System_Eeprom_Subscription_Virtual_Table_check (0.00s)
=== RUN TestEeprom_DbToYang_pfm_components_xfmr
--- PASS: TestEeprom_DbToYang_pfm_components_xfmr (0.00s)
=== RUN TestEeprom_Xfmr_KeyExtractionFallback
--- PASS: TestEeprom_Xfmr_KeyExtractionFallback (0.00s)
=== RUN TestEeprom_GetSysComponents_AutoCreation
--- PASS: TestEeprom_GetSysComponents_AutoCreation (0.00s)
=== RUN TestEeprom_DbToYang_ListAll
--- PASS: TestEeprom_DbToYang_ListAll (0.00s)
PASS

Gnmi_get logs:

root@sonic:/# gnmi_get -target_addr :8080 -xpath "/components/component[name=System Eeprom]" -notls
== getRequest:notlsget -target_addr :8080 -xpath "/components/component[name=Syst
prefix: <

path: <
elem: <
name: "components"

elem: <
name: "component"
key: <
key: "name"
value: "System Eeprom"
>

encoding: JSON_IETF

== getResponse:
notification: <
timestamp: 1786517489313608653
prefix: <

update: <
path: <
elem: <
name: "openconfig-platform:components"
>
elem: <
name: "component"
key: <
key: "name"
value: "System Eeprom"
>
>
>
val: <
json_ietf_val: "{"openconfig-platform:component":[{"config":{"name":"System Eeprom"},"name":"System Eeprom","state":{"empty":false,"location":"Slot 1","name":"System Eeprom","oper-status":"openconfig-platform-types:ACTIVE","removable":false}}]}"
>

Successfully retrieved all 5 component types (EEPROM, Software Module, IC, and Transceiver).
root@sonic:/# gnmi_get -target_addr :8080 -xpath "/components/component" -notls
== getRequest:
prefix: <

path: <
elem: <
name: "components"

elem: <
name: "component"

encoding: JSON_IETF

== getResponse:
notification: <
timestamp: 1786963982734606255
prefix: <

update: <
path: <
elem: <
name: "openconfig-platform:components"
>
elem: <
name: "component"
>
>
val: <
json_ietf_val: "{"openconfig-platform:component":[{"config":{"name":"Ethernet0"},"name":"Ethernet0","state":{"empty":false,"name":"Ethernet0","oper-status":"openconfig-platform-types:ACTIVE","removable":true,"temperature":{"instant":"42.5"},"type":"openconfig-platform-types:TRANSCEIVER"}},{"config":{"name":"System Eeprom"},"name":"System Eeprom","state":{"empty":false,"location":"Slot 1","name":"System Eeprom","oper-status":"openconfig-platform-types:ACTIVE","removable":false}},{"name":"boot_loader","state":{"name":"boot_loader","parent":"chassis","software-version":"1.17.0-debian-1.17.0-1","type":"openconfig-platform-types:BOOT_LOADER"}},{"integrated-circuit":{"config":{"openconfig-p4rt:node-id":"101"},"state":{"openconfig-p4rt:node-id":"101"}},"name":"integrated_circuit1","state":{"name":"integrated_circuit1","parent":"chassis","type":"openconfig-platform-types:INTEGRATED_CIRCUIT"}},{"name":"network_stack0","software-module":{"state":{"openconfig-platform-software:module-type":"openconfig-platform-software:USERSPACE_PACKAGE_BUNDLE"}},"state":{"name":"network_stack0","oper-status":"openconfig-platform-types:ACTIVE","parent":"chassis","software-version":"HEAD.0-dirty-20260817.091218","type":"openconfig-platform-types:SOFTWARE_MODULE"}},{"name":"os0","state":{"name":"os0","oper-status":"openconfig-platform-types:ACTIVE","parent":"chassis","software-version":"6.12.41+deb13-sonic-amd64","type":"openconfig-platform-types:OPERATING_SYSTEM"}}]}"
>

Gnmi_cli log for wildcard support

root@sonic:~# /usr/sbin/gnmi_cli --address 127.0.0.1:8080 -query_type o -streaming_type ON_CHANGE -q /openconfig-platform:components/component[name=] -v 0 -target YANG --logtostderr -insecure
[et YANG --logtostderr -insecure-platform:components/component[name=
] -v 0 -targ
{
"openconfig-platform:components": {
"component": {
"Ethernet0": {
"config": {
"name": "Ethernet0"
},
"name": "Ethernet0",
"state": {
"empty": false,
"name": "Ethernet0",
"oper-status": "ACTIVE",
"removable": true,
"temperature": {
"instant": 42.5
},
"type": "TRANSCEIVER"
}
},
"boot_loader": {
"name": "boot_loader",
"state": {
"name": "boot_loader",
"parent": "chassis",
"software-version": "1.17.0-debian-1.17.0-1",
"type": "BOOT_LOADER"
}
},
"integrated_circuit1": {
"integrated-circuit": {
"config": {
"node-id": 101
},
"state": {
"node-id": 101
}
},
"name": "integrated_circuit1",
"state": {
"name": "integrated_circuit1",
"parent": "chassis",
"type": "INTEGRATED_CIRCUIT"
}
},
"network_stack0": {
"name": "network_stack0",
"software-module": {
"state": {
"module-type": "USERSPACE_PACKAGE_BUNDLE"
}
},
"state": {
"name": "network_stack0",
"oper-status": "ACTIVE",
"parent": "chassis",
"software-version": "HEAD.0-dirty-20260817.091218",
"type": "SOFTWARE_MODULE"
}
},
"os0": {
"name": "os0",
"state": {
"name": "os0",
"oper-status": "ACTIVE",
"parent": "chassis",
"software-version": "6.12.41+deb13-sonic-amd64",
"type": "OPERATING_SYSTEM"
}
}
}
}
}
]

@mssonicbld

Copy link
Copy Markdown

/azp run

@bibhuprasad-hcl
bibhuprasad-hcl marked this pull request as draft August 6, 2026 16:26
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@niranjanivivek

Copy link
Copy Markdown
Contributor

@ndas7 @rlucus Please review

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@bibhuprasad-hcl
bibhuprasad-hcl marked this pull request as ready for review August 25, 2026 06:52
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Comment thread translib/pfm_app.go
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@niranjanivivek

Copy link
Copy Markdown
Contributor

@kwangsuk Please review and approve

niranjanivivek and others added 2 commits September 18, 2026 16:14
Signed-off-by: Niranjani Vivek <niranjaniv@google.com>
Signed-off-by: Bibhuprasad Singh <bibhuprasad@google.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

5 participants