-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from 1 commit
be170ee
98c885f
b7e0b74
c2ea79b
98c8a32
226c2db
9294bb1
49e5c61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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) | ||
|
||
if protocol == "fc" { | ||
if len(host.WWPNs) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
} | ||
|
||
|
@@ -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 { | ||
|
@@ -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 | ||
|
@@ -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)) | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.