From e25575f29467326ffbe1bae15abe8b94e95ccd85 Mon Sep 17 00:00:00 2001 From: Malay Chitranshi <125026538+chitranm@users.noreply.github.com> Date: Wed, 13 Mar 2024 23:28:12 +0530 Subject: [PATCH] Added changes to support WWPNs in host. (#176) * Added changes to support WWPNs in host. * Update internal/resources/resource_host.go Co-authored-by: Ron Saito --- go.mod | 6 +++--- go.sum | 6 ++++++ internal/resources/resource_host.go | 16 ++++++++++++++++ version | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 0646c4d..dc70da6 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/golangci/golangci-lint v1.55.2 github.com/hashicorp/terraform-plugin-docs v0.18.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/hewlettpackard/hpegl-metal-client v1.5.9 + github.com/hewlettpackard/hpegl-metal-client v1.5.10 github.com/hewlettpackard/hpegl-provider-lib v0.0.14 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v2 v2.4.0 @@ -225,8 +225,8 @@ require ( golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/oauth2 v0.14.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/go.sum b/go.sum index dee77a9..00286aa 100644 --- a/go.sum +++ b/go.sum @@ -401,6 +401,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hewlettpackard/hpegl-metal-client v1.5.9 h1:vAu6XfT0zfAdYU8487j3WPOWkP1Az0yGG7Mc4yDNvqk= github.com/hewlettpackard/hpegl-metal-client v1.5.9/go.mod h1:5E6K3bq3aoBNuolGpbmeD/JuAarnXS96W/MqiHUTmFQ= +github.com/hewlettpackard/hpegl-metal-client v1.5.10 h1:8E7JWzFrQoVH4x1EKTIG5vrKmWdXhennQquRuBne8hI= +github.com/hewlettpackard/hpegl-metal-client v1.5.10/go.mod h1:E72/o32a5WwVAUhXvXEUKZOGiSA84hsTS+xezFqtbgU= github.com/hewlettpackard/hpegl-provider-lib v0.0.14 h1:fwIXQsdEdeYYvaJQr1vwfPgCGYKgZaP7kL0p8xbBQJ4= github.com/hewlettpackard/hpegl-provider-lib v0.0.14/go.mod h1:7StTTobQIl8pZCLcJnZm0/+N4lNE2MO6H/U0LhTfXog= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= @@ -854,6 +856,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -866,6 +870,8 @@ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/resources/resource_host.go b/internal/resources/resource_host.go index 885b6b4..66b98f9 100644 --- a/internal/resources/resource_host.go +++ b/internal/resources/resource_host.go @@ -51,6 +51,7 @@ const ( hLabels = "labels" hSummaryStatus = "summary_status" hHostActionAsync = "host_action_async" + hWWPNS = "wwpns" // allowedImageLength is number of Image related attributes that can be provided in the from of 'image@version'. allowedImageLength = 2 @@ -263,6 +264,14 @@ func hostSchema() map[string]*schema.Schema { Default: true, Description: "set true to do host create, update, and delete asynchronously. The default is true.", }, + hWWPNS: { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "FC HBA world wide port names.", + }, } } @@ -566,6 +575,7 @@ func resourceMetalHostRead(d *schema.ResourceData, meta interface{}) (err error) } hostvas := getVAsForHost(host.ID, varesources) + volumeInfos := make([]map[string]interface{}, 0, len(hostvas)) for _, i := range hostvas { vi := map[string]interface{}{ @@ -590,6 +600,11 @@ func resourceMetalHostRead(d *schema.ResourceData, meta interface{}) (err error) d.Set(hCHAPUser, host.ISCSIConfig.CHAPUser) d.Set(hCHAPSecret, host.ISCSIConfig.CHAPSecret) d.Set(hInitiatorName, host.ISCSIConfig.InitiatorName) + + if err := d.Set(hWWPNS, host.WWPNs); err != nil { + return fmt.Errorf("set WWPNs: %v", err) + } + if err = d.Set(hNetForDefaultRouteID, host.NetworkForDefaultRoute); err != nil { return err } @@ -688,6 +703,7 @@ func resourceMetalHostUpdate(d *schema.ResourceData, meta interface{}) (err erro if err != nil { return fmt.Errorf("error reading volume attachment information %v", err) } + hostvas := getVAsForHost(host.ID, varesources) // desired volume IDs diff --git a/version b/version index 52356d3..81617aa 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.3.50 +1.3.51