Skip to content
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

refactor(common): split inventory from common #386

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/inventory-skip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: 'OPI Inventory API CI'

on:
push:
branches: [ main ]
paths-ignore:
- 'common/v1/**'
- 'common/Makefile'
- 'inventory/v1/**'
- 'inventory/Makefile'
- '.github/workflows/inventory.yml'
pull_request:
branches: [ main ]
paths-ignore:
- 'common/v1/**'
- 'common/Makefile'
- 'inventory/v1/**'
- 'inventory/Makefile'
- '.github/workflows/inventory.yml'

concurrency:
# if workflow for PR or push is already running stop it, and start new one
group: inventory-api-skip-${{ github.ref }}
cancel-in-progress: true

jobs:
build-inventory-protobuf:
runs-on: ubuntu-latest
steps:
- run: 'echo "No inventory API test run required"'
54 changes: 54 additions & 0 deletions .github/workflows/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: 'OPI Inventory API CI'

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'common/v1/**'
- 'common/Makefile'
- 'inventory/v1/**'
- 'inventory/Makefile'
- '.github/workflows/inventory.yml'
pull_request:
branches: [ main ]
paths:
- 'common/v1/**'
- 'common/Makefile'
- 'inventory/v1/**'
- 'inventory/Makefile'
- '.github/workflows/inventory.yml'

concurrency:
# if workflow for PR or push is already running stop it, and start new one
group: inventory-api-${{ github.ref }}
cancel-in-progress: true

jobs:
build-inventory-protobuf:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@7703e82fbced3d0c9eec08dff4429c023a5fd9a9

- name: Build protobufs
run: make
working-directory: inventory

- name: Check uncomitted auto generated protobufs
run: git diff --exit-code
working-directory: inventory

- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
path: inventory/v1/gen/go/*.pb.go
retention-days: 1
6 changes: 3 additions & 3 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: v1
plugins:
- plugin: go
out: proto
out: proto/go
opt: paths=source_relative
- plugin: go-grpc
out: proto
out: proto/go
opt: paths=source_relative
- name: grpc-gateway
out: ./proto
out: ./proto/go
opt:
- paths=source_relative

Expand Down
1 change: 1 addition & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: v1
directories:
- common
- inventory
- security
# - storage
# - network/opinetcommon
Expand Down
225 changes: 0 additions & 225 deletions common/v1/autogen.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,238 +3,13 @@

## Table of Contents

- [inventory.proto](#inventory-proto)
- [BIOSInfo](#opi_api-inventory-v1-BIOSInfo)
- [BaseboardInfo](#opi_api-inventory-v1-BaseboardInfo)
- [CPUInfo](#opi_api-inventory-v1-CPUInfo)
- [ChassisInfo](#opi_api-inventory-v1-ChassisInfo)
- [GetInventoryRequest](#opi_api-inventory-v1-GetInventoryRequest)
- [Inventory](#opi_api-inventory-v1-Inventory)
- [MemoryInfo](#opi_api-inventory-v1-MemoryInfo)
- [PCIeDeviceInfo](#opi_api-inventory-v1-PCIeDeviceInfo)
- [SystemInfo](#opi_api-inventory-v1-SystemInfo)

- [InventorySvc](#opi_api-inventory-v1-InventorySvc)

- [uuid.proto](#uuid-proto)
- [Uuid](#opi_api-common-v1-Uuid)

- [Scalar Value Types](#scalar-value-types)



<a name="inventory-proto"></a>
<p align="right"><a href="#top">Top</a></p>

## inventory.proto



<a name="opi_api-inventory-v1-BIOSInfo"></a>

### BIOSInfo
BIOS Information (Type 0)


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| vendor | [string](#string) | | String number of the BIOS Vendor’s Name. |
| version | [string](#string) | | String number of the BIOS Version. This value is a free-form string that may contain Core and OEM version information. |
| date | [string](#string) | | String number of the BIOS release date. The date string, if supplied, is in either mm/dd/yy or mm/dd/yyyy format. If the year portion of the string is two digits, the year is assumed to be 19yy. NOTE: In version 2.3 and later of SMBIOS the mm/dd/yyyy format is only used. |






<a name="opi_api-inventory-v1-BaseboardInfo"></a>

### BaseboardInfo
Baseboard (or Module) Information (Type 2)
The information in this structure defines attributes of a system baseboard (for
example, a motherboard, planar, server blade, or other standard system module)


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| asset_tag | [string](#string) | | Number of a null-terminated string |
| serial_number | [string](#string) | | Number of null-terminated string |
| vendor | [string](#string) | | Number of null-terminated string |
| version | [string](#string) | | Number of null-terminated string |
| product | [string](#string) | | Number of null-terminated string |






<a name="opi_api-inventory-v1-CPUInfo"></a>

### CPUInfo
Processor Information (Type 4)
The information in this structure (see Table 21) defines the attributes of a single processor; a separate
structure instance is provided for each system processor socket/slot. For example, a system with an
IntelDX2™ processor would have a single structure instance while a system with an IntelSX2™ processor
would have a structure to describe the main CPU and a second structure to describe the 80487 co1054 processor.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| total_cores | [int32](#int32) | | Number of cores per processor socket See 7.5.6. If the value is unknown, the field is set to 0. For core counts of 256 or greater, the Core Count field is set to FFh and the Core Count 2 field is set to the number of cores. |
| total_threads | [int32](#int32) | | Number of threads per processor socket See 7.5.8. If the value is unknown, the field is set to 0. For thread counts of 256 or greater, the Thread Count field is set to FFh and the Thread Count 2 field is set to the number of threads. |






<a name="opi_api-inventory-v1-ChassisInfo"></a>

### ChassisInfo
System Enclosure or Chassis (Type 3)
The information in this structure (see Table 16) defines attributes of the system’s mechanical
enclosure(s). For example, if a system included a separate enclosure for its peripheral devices, two
structures would be returned: one for the main system enclosure and the second for the peripheral device
enclosure. The additions to this structure in version 2.1 of this specification support the population of the
CIM_Chassis class.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| asset_tag | [string](#string) | | Number of null-terminated string |
| serial_number | [string](#string) | | Number of null-terminated string |
| type | [string](#string) | | Bit 7 Chassis lock is present if 1. Otherwise, either a lock is not present, or it is unknown if the enclosure has a lock. Bits 6:0 Enumeration value; see below. |
| type_description | [string](#string) | | Table 17 shows the byte values for the System Enclosure or Chassis Types field Number of null-terminated string |
| vendor | [string](#string) | | Number of null-terminated string |
| version | [string](#string) | | Number of null-terminated string |






<a name="opi_api-inventory-v1-GetInventoryRequest"></a>

### GetInventoryRequest
Request for Retrieving Inventory data from a device


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the inventory to retrieve - blank for the full inventory |






<a name="opi_api-inventory-v1-Inventory"></a>

### Inventory
Response for device inventory data


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| bios | [BIOSInfo](#opi_api-inventory-v1-BIOSInfo) | | BIOS Inventory |
| system | [SystemInfo](#opi_api-inventory-v1-SystemInfo) | | System Inventory |
| baseboard | [BaseboardInfo](#opi_api-inventory-v1-BaseboardInfo) | | Baseboard Inventory |
| chassis | [ChassisInfo](#opi_api-inventory-v1-ChassisInfo) | | Chassis Inventory |
| processor | [CPUInfo](#opi_api-inventory-v1-CPUInfo) | | CPU Inventory |
| memory | [MemoryInfo](#opi_api-inventory-v1-MemoryInfo) | | Memory Inventory |
| pci | [PCIeDeviceInfo](#opi_api-inventory-v1-PCIeDeviceInfo) | repeated | PCI Devices Inventory |






<a name="opi_api-inventory-v1-MemoryInfo"></a>

### MemoryInfo
Physical Memory Array (Type 16)
This structure describes a collection of memory devices that operate together to form a memory address
space.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| total_physical_bytes | [int64](#int64) | | Maximum memory capacity, in kilobytes, for this array If the capacity is not represented in this field, then this field contains 8000 0000h and the Extended Maximum Capacity field should be used. Values 2 TB (8000 0000h) or greater must be represented in the Extended Maximum Capacity field. |
| total_usable_bytes | [int64](#int64) | | TBD |






<a name="opi_api-inventory-v1-PCIeDeviceInfo"></a>

### PCIeDeviceInfo
PCI device information
TBD: Type 9 or Type 41 ?
This structure describes a collection of PCI devices.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| driver | [string](#string) | | Driver assiociated with the device |
| address | [string](#string) | | BDF address in a string format, for example &#34;0000:00:17.7&#34; |
| vendor | [string](#string) | | string vendor info |
| product | [string](#string) | | string product info |
| revision | [string](#string) | | string revision info |
| subsystem | [string](#string) | | string subsystem info |
| class | [string](#string) | | string class info |
| subclass | [string](#string) | | string subclass info |






<a name="opi_api-inventory-v1-SystemInfo"></a>

### SystemInfo
System Information (Type 1)
The information in this structure defines attributes of the overall system and is intended to be associated
with the Component ID group of the system’s MIF. An SMBIOS implementation is associated with a single
system instance and contains one and only one System Information (Type 1) structure. Table 10 shows
the contents of this structure.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| family | [string](#string) | | Number of null-terminated string This text string identifies the family to which a particular computer belongs. A family refers to a set of computers that are similar but not identical from a hardware or software point of view. Typically, a family is composed of different computer models, which have different configurations and pricing points. Computers in the same family often have similar branding and cosmetic features. |
| name | [string](#string) | | Number of null-terminated string |
| vendor | [string](#string) | | Number of null-terminated string |
| serial_number | [string](#string) | | Number of null-terminated string |
| uuid | [string](#string) | | A UUID is an identifier that is designed to be unique across both time and space. It requires no central registration process. The UUID is 128 bits long. Its format is described in RFC4122, but the actual field contents are opaque and not significant to the SMBIOS specification, which is only concerned with the byte order. Table 11 shows the field names; these field names, particularly for multiplexed fields, follow historical practice. |
| sku | [string](#string) | | Number of null-terminated string This text string identifies a particular computer configuration for sale. It is sometimes also called a product ID or purchase order number. This number is frequently found in existing fields, but there is no standard format. Typically for a given system board from a given OEM, there are tens of unique processor, memory, hard drive, and optical drive configurations. |
| version | [string](#string) | | Number of null-terminated string |












<a name="opi_api-inventory-v1-InventorySvc"></a>

### InventorySvc
Service functions for the device inventory data

| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| GetInventory | [GetInventoryRequest](#opi_api-inventory-v1-GetInventoryRequest) | [Inventory](#opi_api-inventory-v1-Inventory) | retrieves the inventory data for the device |





<a name="uuid-proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
24 changes: 24 additions & 0 deletions inventory/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2022 Intel Corporation
# Copyright (c) 2022 Dell Inc, or its subsidiaries.

all:
rm -rf ./google
rm -rf ./v1/{autogen.md,gen}
mkdir -p ./v1/gen/{go,cpp,python,java}

docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs namely/protoc-all:1.51_2 --lint -d v1 -l go -o ./v1/gen/go/ --go-source-relative --with-gateway
glimchb marked this conversation as resolved.
Show resolved Hide resolved
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs namely/protoc-all:1.51_2 --lint -d v1 -l cpp -o ./v1/gen/cpp/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs namely/protoc-all:1.51_2 --lint -d v1 -l python -o ./v1/gen/python/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs namely/protoc-all:1.51_2 --lint -d v1 -l java -o ./v1/gen/java/ --go-source-relative

# protoc doesn't include the googleapis, so we have to get them here
curl -kL https://github.com/googleapis/googleapis/archive/master.tar.gz | tar --strip=1 -zxvf - googleapis-master/google/api

mv google "${PWD}"/v1/

docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -v "${PWD}"/v1:/protos pseudomuto/protoc-gen-doc:1.5.1 --doc_opt=markdown,autogen.md
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -w /out --entrypoint=sh ghcr.io/docker-multiarch/google-api-linter:1.58.1 -c "api-linter /out/*.proto --output-format summary"
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -w /out --entrypoint=sh ghcr.io/docker-multiarch/google-api-linter:1.58.1 -c "api-linter /out/*.proto --output-format github --set-exit-status"
rm -rf "${PWD}"/v1/google

13 changes: 13 additions & 0 deletions inventory/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: 048ae6ff94ca4476b3225904b1078fad
digest: shake256:e5250bf2d999516c02206d757502b902e406f35c099d0e869dc3e4f923f6870fe0805a9974c27df0695462937eae90cd4d9db90bb9a03489412560baa74a87b6
8 changes: 8 additions & 0 deletions inventory/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
name: buf.build/opiproject/inventory
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
lint:
except:
- PACKAGE_DIRECTORY_MATCH
Empty file added inventory/v1/__init__.py
Empty file.
Loading
Loading