Skip to content

Commit

Permalink
Co-authored-by: Mike <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbrache committed Oct 21, 2024
1 parent da7dcfb commit 73321a4
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 37 deletions.
4 changes: 2 additions & 2 deletions internal/controller/http/v1/devicemanagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ func TestDeviceManagement(t *testing.T) {
method: http.MethodGet,
mock: func(m *mocks.MockDeviceManagementFeature) {
m.EXPECT().GetHardwareInfo(context.Background(), "valid-guid").
Return(map[string]interface{}{"hardware": "info"}, nil)
Return(dto.HardwareInfoResults{}, dtov2.HardwareInfoResults{}, nil)
},
expectedCode: http.StatusOK,
response: map[string]interface{}{"hardware": "info"},
response: dto.HardwareInfoResults{},
},
{
name: "getDiskInfo - successful retrieval",
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/http/v2/devicemanagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func TestDeviceManagement(t *testing.T) {
url: "/api/v2/amt/hardwareInfo/valid-guid",
method: http.MethodGet,
mock: func(m *mocks.MockDeviceManagementFeature) {
m.EXPECT().GetVersion(context.Background(), "valid-guid").
Return(dtov2.HardwareInfoResults{}, nil)
m.EXPECT().GetHardwareInfo(context.Background(), "valid-guid").
Return(dto.HardwareInfoResults{}, dtov2.HardwareInfoResults{}, nil)
},
expectedCode: http.StatusOK,
response: dtov2.HardwareInfoResults{},
Expand Down
2 changes: 1 addition & 1 deletion internal/entity/dto/v1/hardwareinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type (
CIMComputerSystemPackage CIMComputerSystemPackage
CIMSystemPackage CIMSystemPackage
CIMChassis CIMChassis
CIMChip CIMChips
CIMChip CIMChips `json:"CIMChip" binding:"required"`
CIMCard CIMCard
CIMBIOSElement CIMBIOSElement
CIMProcessor CIMProcessor
Expand Down
53 changes: 26 additions & 27 deletions internal/usecase/devices/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (uc *UseCase) getHardwareInfoEntityToDTO(d *wsmanAPI.HWResults) *dto.Hardwa
},
},
CIMChip: dto.CIMChips{
Responses: cimChipArray(d),
Responses: CimChipArray(d),
},
CIMCard: dto.CIMCard{
Response: dto.CIMCardResponseGet{
Expand Down Expand Up @@ -315,10 +315,10 @@ func (uc *UseCase) getHardwareInfoEntityToDTO(d *wsmanAPI.HWResults) *dto.Hardwa
},
},
CIMProcessor: dto.CIMProcessor{
Responses: cimProcessorArray(d),
Responses: CimProcessorArray(d),
},
CIMPhysicalMemory: dto.CIMPhysicalMemory{
Responses: cimPhysicalMemoryArray(d),
Responses: CimPhysicalMemoryArray(d),
},
// CIM_MediaAccessDevices: dto.CIMMediaAccessDevice{
// Pull: mediaAccessDeviceToDTO(d.MediaAccessPullResult.Body.PullResponse.MediaAccessDevices),
Expand Down Expand Up @@ -360,7 +360,7 @@ func (uc *UseCase) getHardwareInfoEntityToDTOv2(d *wsmanAPI.HWResults) *dtov2.Ha
Tag: d.ChipResult.Body.PackageResponse.Tag,
Version: d.ChipResult.Body.PackageResponse.Version,
},
Pull: chipItemsToDTOv2(d.ChipResult.Body.PullResponse.ChipItems),
Pull: ChipItemsToDTOv2(d.ChipResult.Body.PullResponse.ChipItems),
},
Card: dtov2.CIMCard{
Get: dtov2.CardItems{
Expand All @@ -375,7 +375,7 @@ func (uc *UseCase) getHardwareInfoEntityToDTOv2(d *wsmanAPI.HWResults) *dtov2.Ha
Tag: d.CardResult.Body.PackageResponse.Tag,
Version: d.CardResult.Body.PackageResponse.Version,
},
Pull: cardItemsToDTOv2(d.CardResult.Body.PullResponse.CardItems),
Pull: CardItemsToDTOv2(d.CardResult.Body.PullResponse.CardItems),
},
BIOSElement: dtov2.CIMBIOSElement{
TargetOperatingSystem: dtov2.TargetOperatingSystem(d.BiosResult.Body.GetResponse.TargetOperatingSystem),
Expand Down Expand Up @@ -410,7 +410,7 @@ func (uc *UseCase) getHardwareInfoEntityToDTOv2(d *wsmanAPI.HWResults) *dtov2.Ha
CPUStatus: dtov2.CPUStatus(d.ProcessorResult.Body.PackageResponse.CPUStatus),
ExternalBusClockSpeed: d.ProcessorResult.Body.PackageResponse.ExternalBusClockSpeed,
},
Pull: processorItemsToDTOv2(d.ProcessorResult.Body.PullResponse.PackageItems),
Pull: ProcessorItemsToDTOv2(d.ProcessorResult.Body.PullResponse.PackageItems),
},
PhysicalMemory: dtov2.CIMPhysicalMemory{
Get: dtov2.PhysicalMemory{
Expand All @@ -430,10 +430,10 @@ func (uc *UseCase) getHardwareInfoEntityToDTOv2(d *wsmanAPI.HWResults) *dtov2.Ha
IsSpeedInMhz: d.PhysicalMemoryResult.Body.MemoryResponse.IsSpeedInMhz,
MaxMemorySpeed: d.PhysicalMemoryResult.Body.MemoryResponse.MaxMemorySpeed,
},
Pull: physicalMemoryToDTOv2(d.PhysicalMemoryResult.Body.PullResponse.MemoryItems),
Pull: PhysicalMemoryToDTOv2(d.PhysicalMemoryResult.Body.PullResponse.MemoryItems),
},
MediaAccessDevices: dtov2.CIMMediaAccessDevice{
Pull: mediaAccessDeviceToDTOv2(d.MediaAccessPullResult.Body.PullResponse.MediaAccessDevices),
Pull: MediaAccessDeviceToDTOv2(d.MediaAccessPullResult.Body.PullResponse.MediaAccessDevices),
},
PhysicalPackage: dtov2.CIMPhysicalPackage{
PullMemoryItems: ppPullResponseMemoryToDTOv2(d.PPPullResult.Body.PullResponse),
Expand All @@ -444,7 +444,7 @@ func (uc *UseCase) getHardwareInfoEntityToDTOv2(d *wsmanAPI.HWResults) *dtov2.Ha
return d1
}

func chipItemsToDTOv2(d []chip.PackageResponse) []dtov2.ChipItems {
func ChipItemsToDTOv2(d []chip.PackageResponse) []dtov2.ChipItems {
// iterate over the data and convert each entity to dto
d2 := make([]dtov2.ChipItems, len(d))

Expand All @@ -463,7 +463,7 @@ func chipItemsToDTOv2(d []chip.PackageResponse) []dtov2.ChipItems {
return d2
}

func cardItemsToDTOv2(d []card.PackageResponse) []dtov2.CardItems {
func CardItemsToDTOv2(d []card.PackageResponse) []dtov2.CardItems {
// iterate over the data and convert each entity to dto
d2 := make([]dtov2.CardItems, len(d))

Expand All @@ -485,7 +485,7 @@ func cardItemsToDTOv2(d []card.PackageResponse) []dtov2.CardItems {
return d2
}

func processorItemsToDTOv2(d []processor.PackageResponse) []dtov2.ProcessorItems {
func ProcessorItemsToDTOv2(d []processor.PackageResponse) []dtov2.ProcessorItems {
// iterate over the data and convert each entity to dto
d2 := make([]dtov2.ProcessorItems, len(d))

Expand Down Expand Up @@ -515,7 +515,7 @@ func processorItemsToDTOv2(d []processor.PackageResponse) []dtov2.ProcessorItems
return d2
}

func physicalMemoryToDTOv2(d []physical.PhysicalMemory) []dtov2.PhysicalMemory {
func PhysicalMemoryToDTOv2(d []physical.PhysicalMemory) []dtov2.PhysicalMemory {
// iterate over the data and convert each entity to dto
d2 := make([]dtov2.PhysicalMemory, len(d))

Expand All @@ -542,24 +542,23 @@ func physicalMemoryToDTOv2(d []physical.PhysicalMemory) []dtov2.PhysicalMemory {
return d2
}

func mediaAccessDeviceToDTOv2(d []mediaaccess.MediaAccessDevice) []dtov2.MediaAccessDevice {
func MediaAccessDeviceToDTOv2(d []mediaaccess.MediaAccessDevice) []dtov2.MediaAccessDevice {
// iterate over the data and convert each entity to dto
d2 := make([]dtov2.MediaAccessDevice, len(d))

for i := range d {
d2[i] = dtov2.MediaAccessDevice{
// Capabilities: d[1].Capabilities,
CreationClassName: d[1].CreationClassName,
DeviceID: d[1].DeviceID,
ElementName: d[1].ElementName,
EnabledDefault: dtov2.EnabledDefault(d[1].EnabledDefault),
EnabledState: dtov2.EnabledState(d[1].EnabledState),
MaxMediaSize: d[1].MaxMediaSize,
CreationClassName: d[i].CreationClassName,
DeviceID: d[i].DeviceID,
ElementName: d[i].ElementName,
EnabledDefault: dtov2.EnabledDefault(d[i].EnabledDefault),
EnabledState: dtov2.EnabledState(d[i].EnabledState),
MaxMediaSize: d[i].MaxMediaSize,
OperationalStatus: *(*[]int)(unsafe.Pointer(&d[i].OperationalStatus)),
RequestedState: dtov2.RequestedState(d[1].RequestedState),
Security: dtov2.Security(d[1].Security),
SystemCreationClassName: d[1].SystemCreationClassName,
SystemName: d[1].SystemName,
RequestedState: dtov2.RequestedState(d[i].RequestedState),
Security: dtov2.Security(d[i].Security),
SystemCreationClassName: d[i].SystemCreationClassName,
SystemName: d[i].SystemName,
}
}

Expand Down Expand Up @@ -614,7 +613,7 @@ func ppPullResponseCardToDTOv2(d physical.PullResponse) []dtov2.CardItems {
return d2
}

func cimChipArray(d *wsmanAPI.HWResults) []dto.CIMChipGet {
func CimChipArray(d *wsmanAPI.HWResults) []dto.CIMChipGet {
var y []dto.CIMChipGet

z := dto.CIMChipGet{
Expand All @@ -631,7 +630,7 @@ func cimChipArray(d *wsmanAPI.HWResults) []dto.CIMChipGet {
return y
}

func cimPhysicalMemoryArray(d *wsmanAPI.HWResults) []dto.CIMPhysicalMemoryResponse {
func CimPhysicalMemoryArray(d *wsmanAPI.HWResults) []dto.CIMPhysicalMemoryResponse {
var y []dto.CIMPhysicalMemoryResponse

for i := range d.PhysicalMemoryResult.Body.PullResponse.MemoryItems {
Expand All @@ -658,7 +657,7 @@ func cimPhysicalMemoryArray(d *wsmanAPI.HWResults) []dto.CIMPhysicalMemoryRespon
return y
}

func cimProcessorArray(d *wsmanAPI.HWResults) []dto.CIMProcessorResponse {
func CimProcessorArray(d *wsmanAPI.HWResults) []dto.CIMProcessorResponse {
var y []dto.CIMProcessorResponse

z := dto.CIMProcessorResponse{
Expand Down
Loading

0 comments on commit 73321a4

Please sign in to comment.