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

upgrading Gofish to v0.19.0 #239

Merged
merged 1 commit into from
Sep 24, 2024
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
1 change: 0 additions & 1 deletion docs/data-sources/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ Read-Only:
- `cache_summary` (Attributes) cache summary (see [below for nested schema](#nestedatt--storage--storage_controllers--cache_summary))
- `firmware_version` (String) firmware version
- `manufacturer` (String) manufacturer
- `member_id` (String) member id of storage controller
- `model` (String) model
- `name` (String) name of the storage controller
- `speed_gbps` (Number) speed gbps
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
require (
github.com/hashicorp/terraform-plugin-framework v1.4.1
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/stmcginnis/gofish v0.15.1-0.20240129095132-7eb050882d70
github.com/stmcginnis/gofish v0.19.0
)

require github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/stmcginnis/gofish v0.15.1-0.20240129095132-7eb050882d70 h1:9Fg+kVdfcZUFnn0rYXNkUlk02R6Yn42arjMsHNx/j7o=
github.com/stmcginnis/gofish v0.15.1-0.20240129095132-7eb050882d70/go.mod h1:BLDSFTp8pDlf/xDbLZa+F7f7eW0E/CHCboggsu8CznI=
github.com/stmcginnis/gofish v0.19.0 h1:fmxdRZ5WHfs+4ExArMYoeRfoh+SAxLELKtmoVplBkU4=
github.com/stmcginnis/gofish v0.19.0/go.mod h1:lq2jHj2t8Krg0Gx02ABk8MbK7Dz9jvWpO/TGnVksn00=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
Expand Down
40 changes: 38 additions & 2 deletions gofish/dell/updateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import (
type UpdateServiceExtended struct {
*redfish.UpdateService
// Actions will hold all UpdateService Dell OEM actions
Actions UpdateServiceActions
Actions UpdateServiceActions
SimpleUpdateActions SimpleUpdateActions

FirmwareInventory *redfish.SoftwareInventory
}

// UpdateServiceActions contains Dell OEM actions
Expand All @@ -38,6 +41,17 @@ type UpdateServiceActions struct {
DellUpdateServiceInstallUpon []string
}

// SimpleUpdate contains SimpleUpdate
type SimpleUpdate struct {
AllowableValues []string `json:"[email protected]"`
Target string
}

// SimpleUpdateActions contains SimpleUpdate
type SimpleUpdateActions struct {
SimpleUpdate SimpleUpdate `json:"#UpdateService.SimpleUpdate"`
}

// UnmarshalJSON unmarshals Dell update service object from raw JSON
func (u *UpdateServiceActions) UnmarshalJSON(data []byte) error {
type DellUpdateService struct {
Expand All @@ -62,7 +76,11 @@ func (u *UpdateServiceActions) UnmarshalJSON(data []byte) error {
// UpdateService returns a Dell.UpdateServiceExtended pointer given a redfish.UpdateService pointer from gofish library
// This is the wrapper that extracts and parses Dell UpdateService OEM actions
func UpdateService(updateService *redfish.UpdateService) (*UpdateServiceExtended, error) {
dellUpdate := UpdateServiceExtended{UpdateService: updateService}
dellUpdate := UpdateServiceExtended{
UpdateService: updateService,
SimpleUpdateActions: SimpleUpdateActions{},
FirmwareInventory: &redfish.SoftwareInventory{},
}
var oemUpdateService UpdateServiceActions

err := json.Unmarshal(dellUpdate.OemActions, &oemUpdateService)
Expand All @@ -71,5 +89,23 @@ func UpdateService(updateService *redfish.UpdateService) (*UpdateServiceExtended
}
dellUpdate.Actions = oemUpdateService

rawDataBytes, err := GetRawDataBytes(updateService)
if err != nil {
return &dellUpdate, err
}
if updateActionRawData, found := GetNodeFromRawDataBytes(rawDataBytes, "Actions"); found == nil {
var simpleUpdateData SimpleUpdateActions
if err = json.Unmarshal(updateActionRawData, &simpleUpdateData); err == nil {
dellUpdate.SimpleUpdateActions = simpleUpdateData
}
}

if inventoryRawData, found := GetNodeFromRawDataBytes(rawDataBytes, "FirmwareInventory"); found == nil {
var inventoryData *redfish.SoftwareInventory
if err = json.Unmarshal(inventoryRawData, &inventoryData); err == nil {
dellUpdate.FirmwareInventory = inventoryData
}
}

return &dellUpdate, nil
}
2 changes: 1 addition & 1 deletion gofish/dell/updateService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestDellUpdateService(t *testing.T) {
t.Run("Test redfish values", func(t *testing.T) {
dellUpdateService := getDellUpdateService(t)

assertField(t, dellUpdateService.UpdateServiceTarget, "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate")
assertField(t, dellUpdateService.SimpleUpdateActions.SimpleUpdate.Target, "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate")
assertField(t, dellUpdateService.HTTPPushURI, "/redfish/v1/UpdateService/FirmwareInventory")
assertArray(t, dellUpdateService.TransferProtocol, []string{"HTTP"})
})
Expand Down
1 change: 0 additions & 1 deletion redfish/models/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ type StorageControllers struct {
CacheSummary CacheSummary `tfsdk:"cache_summary"`
FirmwareVersion types.String `tfsdk:"firmware_version"`
Manufacturer types.String `tfsdk:"manufacturer"`
MemberID types.String `tfsdk:"member_id"`
Model types.String `tfsdk:"model"`
Name types.String `tfsdk:"name"`
SpeedGbps types.Int64 `tfsdk:"speed_gbps"`
Expand Down
8 changes: 4 additions & 4 deletions redfish/provider/data_source_redfish_nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,8 @@ func newFibreChannel(input redfish.FibreChannel) *models.FibreChannel {
FibreChannelId: types.StringValue(input.FibreChannelID),
AllowFIPVLANDiscovery: types.BoolValue(input.AllowFIPVLANDiscovery),
BootTargets: newBootTargets(input.BootTargets),
FCoEActiveVLANId: types.Int64Value(int64(input.FCoEActiveVLANId)),
FCoELocalVLANId: types.Int64Value(int64(input.FCoELocalVLANId)),
FCoEActiveVLANId: types.Int64Value(int64(input.FCoEActiveVLANID)),
FCoELocalVLANId: types.Int64Value(int64(input.FCoELocalVLANID)),
PermanentWWNN: types.StringValue(input.PermanentWWNN),
PermanentWWPN: types.StringValue(input.PermanentWWPN),
WWNN: types.StringValue(input.WWNN),
Expand Down Expand Up @@ -868,15 +868,15 @@ func newISCSIBoot(input redfish.ISCSIBoot) *models.ISCSIBoot {
PrimaryTargetName: types.StringValue(input.PrimaryTargetName),
PrimaryTargetTCPPort: types.Int64Value(int64(input.PrimaryTargetTCPPort)),
PrimaryVLANEnable: types.BoolValue(input.PrimaryVLANEnable),
PrimaryVLANId: types.Int64Value(int64(input.PrimaryVLANId)),
PrimaryVLANId: types.Int64Value(int64(input.PrimaryVLANID)),
RouterAdvertisementEnabled: types.BoolValue(input.RouterAdvertisementEnabled),
SecondaryDNS: types.StringValue(input.SecondaryDNS),
SecondaryLUN: types.Int64Value(int64(input.SecondaryLUN)),
SecondaryTargetIPAddress: types.StringValue(input.SecondaryTargetIPAddress),
SecondaryTargetName: types.StringValue(input.SecondaryTargetName),
SecondaryTargetTCPPort: types.Int64Value(int64(input.SecondaryTargetTCPPort)),
SecondaryVLANEnable: types.BoolValue(input.SecondaryVLANEnable),
SecondaryVLANId: types.Int64Value(int64(input.SecondaryVLANId)),
SecondaryVLANId: types.Int64Value(int64(input.SecondaryVLANID)),
TargetInfoViaDHCP: types.BoolValue(input.TargetInfoViaDHCP),
}
}
Expand Down
6 changes: 0 additions & 6 deletions redfish/provider/data_source_redfish_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func newStorageControllers(input redfish.StorageController) models.StorageContro
CacheSummary: newCacheSummary(input.CacheSummary),
FirmwareVersion: types.StringValue(input.FirmwareVersion),
Manufacturer: types.StringValue(input.Manufacturer),
MemberID: types.StringValue(input.MemberID),
Model: types.StringValue(input.Model),
Name: types.StringValue(input.Name),
SpeedGbps: types.Int64Value(int64(input.SpeedGbps)),
Expand Down Expand Up @@ -715,11 +714,6 @@ func StorageControllersSchema() map[string]schema.Attribute {
Description: "manufacturer",
Computed: true,
},
"member_id": schema.StringAttribute{
MarkdownDescription: "member id of storage controller",
Description: "member id of storage controller",
Computed: true,
},
"model": schema.StringAttribute{
MarkdownDescription: "model",
Description: "model",
Expand Down
8 changes: 4 additions & 4 deletions redfish/provider/resource_redfish_nic_schema_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ func getISCSIBootObjectValue(ctx context.Context, dellDeviceFunction *dell.Netwo
fieldNamePrimaryTargetName: types.StringValue(dellDeviceFunction.ISCSIBoot.PrimaryTargetName),
fieldNamePrimaryTargetTCPPort: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.PrimaryTargetTCPPort)),
fieldNamePrimaryVLANEnable: types.BoolValue(dellDeviceFunction.ISCSIBoot.PrimaryVLANEnable),
fieldNamePrimaryVLANID: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.PrimaryVLANId)),
fieldNamePrimaryVLANID: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.PrimaryVLANID)),
fieldNameRouterAdvertisementEnabled: types.BoolValue(dellDeviceFunction.ISCSIBoot.RouterAdvertisementEnabled),
fieldNameSecondaryDNS: types.StringValue(dellDeviceFunction.ISCSIBoot.SecondaryDNS),
fieldNameSecondaryLun: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.SecondaryLUN)),
fieldNameSecondaryTargetIPAddress: types.StringValue(dellDeviceFunction.ISCSIBoot.SecondaryTargetIPAddress),
fieldNameSecondaryTargetName: types.StringValue(dellDeviceFunction.ISCSIBoot.SecondaryTargetName),
fieldNameSecondaryTargetTCPPort: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.SecondaryTargetTCPPort)),
fieldNameSecondaryVLANEnable: types.BoolValue(dellDeviceFunction.ISCSIBoot.SecondaryVLANEnable),
fieldNameSecondaryVLANID: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.SecondaryVLANId)),
fieldNameSecondaryVLANID: types.Int64Value(int64(dellDeviceFunction.ISCSIBoot.SecondaryVLANID)),
fieldNameTargetInfoViaDHCP: types.BoolValue(dellDeviceFunction.ISCSIBoot.TargetInfoViaDHCP),
}
for key, value := range oldDevFuncSettings.ISCSIBoot.Attributes() {
Expand Down Expand Up @@ -298,8 +298,8 @@ func getFibreChannelObjectValue(ctx context.Context, dellDeviceFunction *dell.Ne

fibreChannelItemMap := map[string]attr.Value{
fieldNameAllowFipVlanDiscovery: types.BoolValue(dellDeviceFunction.FibreChannel.AllowFIPVLANDiscovery),
"fcoe_active_vlan_id": types.Int64Value(int64(dellDeviceFunction.FibreChannel.FCoEActiveVLANId)),
fieldNameFcoeLocalVlanID: types.Int64Value(int64(dellDeviceFunction.FibreChannel.FCoELocalVLANId)),
"fcoe_active_vlan_id": types.Int64Value(int64(dellDeviceFunction.FibreChannel.FCoEActiveVLANID)),
fieldNameFcoeLocalVlanID: types.Int64Value(int64(dellDeviceFunction.FibreChannel.FCoELocalVLANID)),
"permanent_wwnn": types.StringValue(dellDeviceFunction.FibreChannel.PermanentWWNN),
"permanent_wwpn": types.StringValue(dellDeviceFunction.FibreChannel.PermanentWWPN),
fieldNameWWNN: types.StringValue(dellDeviceFunction.FibreChannel.WWNN),
Expand Down
18 changes: 15 additions & 3 deletions redfish/provider/resource_redfish_simple_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"path/filepath"
"strings"
"terraform-provider-redfish/common"
"terraform-provider-redfish/gofish/dell"
"terraform-provider-redfish/redfish/models"
"time"

Expand Down Expand Up @@ -416,7 +417,13 @@ func (u *simpleUpdater) updateRedfishSimpleUpdate(d models.SimpleUpdateRes) (dia
func (u *simpleUpdater) uploadLocalFirmware(d models.SimpleUpdateRes) (*redfish.SoftwareInventory, error) {
// Get ETag from FW inventory
service, updateService := u.service, u.updateService
response, err := service.GetClient().Get(updateService.FirmwareInventory)

dellUpdateService, err := dell.UpdateService(updateService)
if err != nil {
return nil, fmt.Errorf("error while retrieving FirmwareInventory URI: %w", err)
}

response, err := service.GetClient().Get(dellUpdateService.FirmwareInventory.ODataID)
if err != nil {
return nil, fmt.Errorf("error while retrieving Etag from FirmwareInventory: %w", err)
}
Expand Down Expand Up @@ -461,7 +468,7 @@ func (u *simpleUpdater) uploadLocalFirmware(d models.SimpleUpdateRes) (*redfish.
ImageURI: packageLocation,
}
// Do the POST call against Simple.Update service
response, err = service.GetClient().Post(updateService.UpdateServiceTarget, triggerUpdatePayload)
response, err = service.GetClient().Post(dellUpdateService.SimpleUpdateActions.SimpleUpdate.Target, triggerUpdatePayload)
if err != nil {
// Delete uploaded package - TBD
return nil, fmt.Errorf("there was an issue when scheduling the update job - %w", err)
Expand Down Expand Up @@ -538,9 +545,14 @@ func (u *simpleUpdater) pullUpdate(d models.SimpleUpdateRes) (models.SimpleUpdat
updateService := u.updateService
service := u.service

dellUpdateService, err := dell.UpdateService(updateService)
if err != nil {
return d, fmt.Errorf("error while retrieving dellUpdate service: %w", err)
}

protocol := d.Protocol.ValueString()
imagePath := d.Image.ValueString()
httpURI := updateService.UpdateServiceTarget
httpURI := dellUpdateService.SimpleUpdateActions.SimpleUpdate.Target

payload := make(map[string]interface{})
payload["ImageURI"] = imagePath
Expand Down
Loading