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

Added changes to support WWPNs in host. #176

Merged
merged 8 commits into from
Mar 13, 2024
Merged
Changes from 1 commit
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
20 changes: 8 additions & 12 deletions internal/resources/resource_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func resourceMetalHostRead(d *schema.ResourceData, meta interface{}) (err error)
return fmt.Errorf("error reading volume attachment information %v", err)
}

hostvas, protocol := getVAsForHost(host.ID, varesources)
hostvas := getVAsForHost(host.ID, varesources)

volumeInfos := make([]map[string]interface{}, 0, len(hostvas))
for _, i := range hostvas {
Expand All @@ -597,13 +597,11 @@ func resourceMetalHostRead(d *schema.ResourceData, meta interface{}) (err error)
return err
}

if protocol == "iscsi" {
_ = d.Set(hCHAPUser, host.ISCSIConfig.CHAPUser)
_ = d.Set(hCHAPSecret, host.ISCSIConfig.CHAPSecret)
_ = d.Set(hInitiatorName, host.ISCSIConfig.InitiatorName)
}
d.Set(hCHAPUser, host.ISCSIConfig.CHAPUser)
d.Set(hCHAPSecret, host.ISCSIConfig.CHAPSecret)
d.Set(hInitiatorName, host.ISCSIConfig.InitiatorName)
Copy link

@shi98382 shi98382 Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like iscsi information will always be filled in host here regardless protocol. Is it correct that the protocol field was introduced to differentiate the cases, otherwise it will defeat the purpose. Just FYI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shi98382, please check this comment from Mike - https://github.com/HewlettPackard/hpegl-metal-terraform-resources/pull/176/files/b7e0b747020293dd264e681bea394e6506632e6d#r1520373211

I have reverted back the protocol check after this discussion.


if protocol == "fc" {
if len(host.WWPNs) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this was previously discussed, I'm wondering why this is needed (conditional set). without this check, hWWPNs is set to whatever host.WWPNs is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just accepted your suggestion on the PR as is. I was also thinking why this is needed. If you are ok I will remove this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed your comment.

_ = d.Set(hWWPNS, host.WWPNs)
chitranm marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -664,7 +662,7 @@ func setConnectionsValues(d *schema.ResourceData, hostConnections []rest.HostCon
return nil
}

func getVAsForHost(hostID string, vas []rest.VolumeAttachment) (hvas []rest.VolumeInfo, protocol string) {
func getVAsForHost(hostID string, vas []rest.VolumeAttachment) []rest.VolumeInfo {
hostvas := make([]rest.VolumeInfo, 0, len(vas))

for _, i := range vas {
Expand All @@ -676,11 +674,9 @@ func getVAsForHost(hostID string, vas []rest.VolumeAttachment) (hvas []rest.Volu
vi.TargetIQN = i.VolumeTargetIQN
hostvas = append(hostvas, vi)
}

protocol = string(i.AttachProtocol)
}

return hostvas, protocol
return hostvas
}

//nolint:funlen // Ignoring function length check on existing function
Expand Down Expand Up @@ -708,7 +704,7 @@ func resourceMetalHostUpdate(d *schema.ResourceData, meta interface{}) (err erro
return fmt.Errorf("error reading volume attachment information %v", err)
}

hostvas, _ := getVAsForHost(host.ID, varesources)
hostvas := getVAsForHost(host.ID, varesources)

// desired volume IDs
desired := make([]string, 0, len(hostvas))
Expand Down
Loading