From 9f15f181c321829b5b08242a6251a89e037f96f5 Mon Sep 17 00:00:00 2001 From: yuvirani Date: Wed, 19 May 2021 13:29:50 +0530 Subject: [PATCH 1/7] Support getAll for ethernet resource --- oneview/data_source_ethernet_network.go | 253 ++++++++++++++---------- 1 file changed, 154 insertions(+), 99 deletions(-) diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index e0d90daa..758d206c 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -12,7 +12,14 @@ package oneview import ( + "github.com/HewlettPackard/oneview-golang/ov" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/HewlettPackard/oneview-golang/utils" + "encoding/json" + "io/ioutil" + "fmt" + "strconv" + "time" ) func dataSourceEthernetNetwork() *schema.Resource { @@ -20,116 +27,164 @@ func dataSourceEthernetNetwork() *schema.Resource { Read: dataSourceEthernetNetworkRead, Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - "vlan_id": { - Type: schema.TypeInt, - Computed: true, - }, - "purpose": { - Type: schema.TypeString, - Computed: true, - }, - "private_network": { - Type: schema.TypeBool, - Computed: true, - }, - "smart_link": { - Type: schema.TypeBool, - Computed: true, - }, - "ethernet_network_type": { - Type: schema.TypeString, - Computed: true, - }, - "type": { - Type: schema.TypeString, - Computed: true, - }, - "connection_template_uri": { - Type: schema.TypeString, - Computed: true, - }, - "created": { - Type: schema.TypeString, - Computed: true, - }, - "modified": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "uri": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, + "count_": { + Type: schema.TypeInt, + Computed: true, + }, + "total": { + Type: schema.TypeInt, + Computed: true, + }, + "list_uri": { + Type: schema.TypeString, + Computed: true, + }, + "members": { + Type: schema.TypeList, Computed: true, - }, - "category": { - Type: schema.TypeString, - Computed: true, - }, - "state": { - Type: schema.TypeString, - Computed: true, - }, - "fabric_uri": { - Type: schema.TypeString, - Computed: true, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - }, - "scopesuri": { - Type: schema.TypeString, - Computed: true, - }, - "initial_scope_uris": { - Computed: true, - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, + + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + }, + "vlan_id": { + Type: schema.TypeInt, + Computed: true, + }, + "purpose": { + Type: schema.TypeString, + Computed: true, + }, + "private_network": { + Type: schema.TypeBool, + Computed: true, + }, + "smart_link": { + Type: schema.TypeBool, + Computed: true, + }, + "ethernet_network_type": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "connection_template_uri": { + Type: schema.TypeString, + Computed: true, + }, + "created": { + Type: schema.TypeString, + Computed: true, + }, + "modified": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "uri": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "category": { + Type: schema.TypeString, + Computed: true, + }, + "state": { + Type: schema.TypeString, + Computed: true, + }, + "fabric_uri": { + Type: schema.TypeString, + Computed: true, + }, + "etag": { + Type: schema.TypeString, + Computed: true, + }, + "scopesuri": { + Type: schema.TypeString, + Computed: true, + }, + "initial_scope_uris": { + Computed: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Set: schema.HashString, + }, + }, }, - Set: schema.HashString, }, + }, + } } func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - name := d.Get("name").(string) - eNet, err := config.ovClient.GetEthernetNetworkByName(name) - if err != nil || eNet.URI.IsNil() { + eNetList, err := config.ovClient.GetEthernetNetworks("", "", "", "") + + if err != nil { d.SetId("") return nil + } else { + d.Set("count_", eNetList.Count) + d.Set("total", eNetList.Total) + d.Set("list_uri", eNetList.URI) + + elist := [] ov.EthernetNetwork{} + for i := range eNetList.Members { + ethernet := ov.EthernetNetwork{} + ethernet.Name = eNetList.Members[i].Name + ethernet.VlanId = eNetList.Members[i].VlanId + ethernet.Purpose = eNetList.Members[i].Purpose + ethernet.SmartLink = eNetList.Members[i].SmartLink + ethernet.PrivateNetwork = eNetList.Members[i].PrivateNetwork + ethernet.EthernetNetworkType = eNetList.Members[i].EthernetNetworkType + ethernet.Type = eNetList.Members[i].Type + ethernet.Created = eNetList.Members[i].Created + ethernet.Modified = eNetList.Members[i].Modified + ethernet.URI = utils.Nstring(eNetList.Members[i].URI.String()) + ethernet.ConnectionTemplateUri = utils.Nstring(eNetList.Members[i].ConnectionTemplateUri.String()) + ethernet.State = eNetList.Members[i].State + ethernet.Status = eNetList.Members[i].Status + ethernet.Category = eNetList.Members[i].Category + ethernet.FabricUri = utils.Nstring(eNetList.Members[i].FabricUri.String()) + ethernet.ETAG = eNetList.Members[i].ETAG + ethernet.ScopesUri = utils.Nstring(eNetList.Members[i].ScopesUri.String()) + + initialScopeUris := make([]utils.Nstring, len(eNetList.Members[i].InitialScopeUris)) + for _, scope := range eNetList.Members[i].InitialScopeUris { + initialScopeUri := utils.Nstring(scope.String()) + initialScopeUris = append(initialScopeUris, initialScopeUri) + } + + ethernet.InitialScopeUris = initialScopeUris + elist = append(elist, ethernet) + + } + file, _ := json.MarshalIndent(elist, "", " ") + file_name := fmt.Sprintf("test_check_%d.json", 5) + _ = ioutil.WriteFile(file_name, file, 0644) + + d.Set("members", elist) + d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) + } - d.Set("name", eNet.Name) - d.Set("vlan_id", eNet.VlanId) - d.Set("purpose", eNet.Purpose) - d.Set("smart_link", eNet.SmartLink) - d.Set("private_network", eNet.PrivateNetwork) - d.Set("ethernet_network_type", eNet.EthernetNetworkType) - d.Set("type", eNet.Type) - d.Set("created", eNet.Created) - d.Set("modified", eNet.Modified) - d.Set("uri", eNet.URI.String()) - d.Set("connection_template_uri", eNet.ConnectionTemplateUri.String()) - d.Set("status", eNet.Status) - d.Set("category", eNet.Category) - d.Set("state", eNet.State) - d.Set("fabric_uri", eNet.FabricUri.String()) - d.Set("etag", eNet.ETAG) - d.Set("scopesuri", eNet.ScopesUri.String()) - d.Set("initial_scope_uris", eNet.InitialScopeUris) - d.SetId(name) return nil + } From dbdfb7f57548fe57169a362258831a5b1ec95fe8 Mon Sep 17 00:00:00 2001 From: yuvirani Date: Wed, 19 May 2021 15:29:58 +0530 Subject: [PATCH 2/7] Fix Members --- oneview/data_source_ethernet_network.go | 78 ++++++++----------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index 758d206c..82df3be6 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -12,12 +12,7 @@ package oneview import ( - "github.com/HewlettPackard/oneview-golang/ov" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/HewlettPackard/oneview-golang/utils" - "encoding/json" - "io/ioutil" - "fmt" "strconv" "time" ) @@ -41,7 +36,7 @@ func dataSourceEthernetNetwork() *schema.Resource { }, "members": { Type: schema.TypeList, - Computed: true, + Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -85,10 +80,6 @@ func dataSourceEthernetNetwork() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "description": { - Type: schema.TypeString, - Computed: true, - }, "uri": { Type: schema.TypeString, Computed: true, @@ -115,15 +106,7 @@ func dataSourceEthernetNetwork() *schema.Resource { }, "scopesuri": { Type: schema.TypeString, - Computed: true, - }, - "initial_scope_uris": { - Computed: true, - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Set: schema.HashString, + Optional: true, }, }, }, @@ -146,44 +129,31 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err d.Set("total", eNetList.Total) d.Set("list_uri", eNetList.URI) - elist := [] ov.EthernetNetwork{} - for i := range eNetList.Members { - ethernet := ov.EthernetNetwork{} - ethernet.Name = eNetList.Members[i].Name - ethernet.VlanId = eNetList.Members[i].VlanId - ethernet.Purpose = eNetList.Members[i].Purpose - ethernet.SmartLink = eNetList.Members[i].SmartLink - ethernet.PrivateNetwork = eNetList.Members[i].PrivateNetwork - ethernet.EthernetNetworkType = eNetList.Members[i].EthernetNetworkType - ethernet.Type = eNetList.Members[i].Type - ethernet.Created = eNetList.Members[i].Created - ethernet.Modified = eNetList.Members[i].Modified - ethernet.URI = utils.Nstring(eNetList.Members[i].URI.String()) - ethernet.ConnectionTemplateUri = utils.Nstring(eNetList.Members[i].ConnectionTemplateUri.String()) - ethernet.State = eNetList.Members[i].State - ethernet.Status = eNetList.Members[i].Status - ethernet.Category = eNetList.Members[i].Category - ethernet.FabricUri = utils.Nstring(eNetList.Members[i].FabricUri.String()) - ethernet.ETAG = eNetList.Members[i].ETAG - ethernet.ScopesUri = utils.Nstring(eNetList.Members[i].ScopesUri.String()) - - initialScopeUris := make([]utils.Nstring, len(eNetList.Members[i].InitialScopeUris)) - for _, scope := range eNetList.Members[i].InitialScopeUris { - initialScopeUri := utils.Nstring(scope.String()) - initialScopeUris = append(initialScopeUris, initialScopeUri) - } - - ethernet.InitialScopeUris = initialScopeUris - elist = append(elist, ethernet) - + members := make([]map[string]interface{}, 0, len(eNetList.Members)) + for _, eNet := range eNetList.Members { + members = append(members, map[string]interface{}{ + "name": eNet.Name, + "purpose": eNet.Purpose, + "vlan_id": eNet.VlanId, + "smart_link": eNet.SmartLink, + "private_network": eNet.PrivateNetwork, + "ethernet_network_type": eNet.EthernetNetworkType, + "type": eNet.Type, + "created": eNet.Created, + "modified": eNet.Modified, + "uri": eNet.URI, + "connection_template_uri": eNet.ConnectionTemplateUri, + "state": eNet.State, + "status": eNet.Status, + "category": eNet.Category, + "fabric_uri": eNet.FabricUri, + "etag": eNet.ETAG, + "scopesuri": eNet.ScopesUri, + }) } - file, _ := json.MarshalIndent(elist, "", " ") - file_name := fmt.Sprintf("test_check_%d.json", 5) - _ = ioutil.WriteFile(file_name, file, 0644) - d.Set("members", elist) + d.Set("members", members) d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) - } return nil From c18f4534d3e0a82c6d8c7dc9e50bcd30c58f6f5c Mon Sep 17 00:00:00 2001 From: yuvirani Date: Thu, 20 May 2021 11:47:24 +0530 Subject: [PATCH 3/7] Add GetById --- examples/ethernet_networks/data_source.tf | 15 ++- oneview/data_source_ethernet_network.go | 109 +++++++++++++++------- 2 files changed, 91 insertions(+), 33 deletions(-) diff --git a/examples/ethernet_networks/data_source.tf b/examples/ethernet_networks/data_source.tf index 3fc57ca9..fa37d56a 100644 --- a/examples/ethernet_networks/data_source.tf +++ b/examples/ethernet_networks/data_source.tf @@ -9,7 +9,20 @@ provider "oneview" { # Testing data source data "oneview_ethernet_network" "ethernetnetworks" { - name = "TestEthNetwork_terraform_Rename" +get_type = "GetAll" +} + +output "oneview_ethernet_network_value" { + value = data.oneview_ethernet_network.ethernetnetworks +} + +data "oneview_ethernet_network" "ethernetnetworkbyname" { +get_type = "GetById" +name = "Test" +} + +output "oneview_ethernet_network_by_name_value" { + value = data.oneview_ethernet_network.ethernetnetworkbyname } resource "oneview_ethernet_network" "ethernetnetwork_1" { diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index 82df3be6..c2da7a54 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -34,9 +34,17 @@ func dataSourceEthernetNetwork() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "name": { + Type: schema.TypeString, + Optional: true, + }, + "get_type": { + Type: schema.TypeString, + Required: true, + }, "members": { Type: schema.TypeList, - Optional: true, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -119,41 +127,78 @@ func dataSourceEthernetNetwork() *schema.Resource { func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - eNetList, err := config.ovClient.GetEthernetNetworks("", "", "", "") + getType := d.Get("get_type").(string) + name := d.Get("name").(string) - if err != nil { - d.SetId("") + if getType == "GetById" { + eNet , err := config.ovClient.GetEthernetNetworkByName(name) + if err != nil { + d.SetId("") + return nil + } + members := make([]map[string]interface{}, 0, 1) + members = append(members, map[string]interface{}{ + "name": eNet.Name, + "purpose": eNet.Purpose, + "vlan_id": eNet.VlanId, + "smart_link": eNet.SmartLink, + "private_network": eNet.PrivateNetwork, + "ethernet_network_type": eNet.EthernetNetworkType, + "type": eNet.Type, + "created": eNet.Created, + "modified": eNet.Modified, + "uri": eNet.URI, + "connection_template_uri": eNet.ConnectionTemplateUri, + "state": eNet.State, + "status": eNet.Status, + "category": eNet.Category, + "fabric_uri": eNet.FabricUri, + "etag": eNet.ETAG, + "scopesuri": eNet.ScopesUri, + }) + d.Set("members", members) + d.SetId(name) return nil - } else { - d.Set("count_", eNetList.Count) - d.Set("total", eNetList.Total) - d.Set("list_uri", eNetList.URI) + } - members := make([]map[string]interface{}, 0, len(eNetList.Members)) - for _, eNet := range eNetList.Members { - members = append(members, map[string]interface{}{ - "name": eNet.Name, - "purpose": eNet.Purpose, - "vlan_id": eNet.VlanId, - "smart_link": eNet.SmartLink, - "private_network": eNet.PrivateNetwork, - "ethernet_network_type": eNet.EthernetNetworkType, - "type": eNet.Type, - "created": eNet.Created, - "modified": eNet.Modified, - "uri": eNet.URI, - "connection_template_uri": eNet.ConnectionTemplateUri, - "state": eNet.State, - "status": eNet.Status, - "category": eNet.Category, - "fabric_uri": eNet.FabricUri, - "etag": eNet.ETAG, - "scopesuri": eNet.ScopesUri, - }) - } - d.Set("members", members) - d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) + if getType == "GetAll" { + eNetList, err := config.ovClient.GetEthernetNetworks("", "", "", "") + + if err != nil { + d.SetId("") + return nil + } else { + d.Set("count_", eNetList.Count) + d.Set("total", eNetList.Total) + d.Set("list_uri", eNetList.URI) + + members := make([]map[string]interface{}, 0, len(eNetList.Members)) + for _, eNet := range eNetList.Members { + members = append(members, map[string]interface{}{ + "name": eNet.Name, + "purpose": eNet.Purpose, + "vlan_id": eNet.VlanId, + "smart_link": eNet.SmartLink, + "private_network": eNet.PrivateNetwork, + "ethernet_network_type": eNet.EthernetNetworkType, + "type": eNet.Type, + "created": eNet.Created, + "modified": eNet.Modified, + "uri": eNet.URI, + "connection_template_uri": eNet.ConnectionTemplateUri, + "state": eNet.State, + "status": eNet.Status, + "category": eNet.Category, + "fabric_uri": eNet.FabricUri, + "etag": eNet.ETAG, + "scopesuri": eNet.ScopesUri, + }) + } + + d.Set("members", members) + d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) + } } return nil From 345f1e1cc90694a87e0a85d6c829f04ee6b8d99d Mon Sep 17 00:00:00 2001 From: yuvirani Date: Thu, 20 May 2021 16:40:50 +0530 Subject: [PATCH 4/7] Remove get_type --- oneview/data_source_ethernet_network.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index c2da7a54..45e3dd40 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -38,10 +38,6 @@ func dataSourceEthernetNetwork() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "get_type": { - Type: schema.TypeString, - Required: true, - }, "members": { Type: schema.TypeList, Computed: true, @@ -127,10 +123,9 @@ func dataSourceEthernetNetwork() *schema.Resource { func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - getType := d.Get("get_type").(string) name := d.Get("name").(string) - if getType == "GetById" { + if len(name) > 0 { eNet , err := config.ovClient.GetEthernetNetworkByName(name) if err != nil { d.SetId("") @@ -159,10 +154,7 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err d.Set("members", members) d.SetId(name) return nil - } - - - if getType == "GetAll" { + } else { eNetList, err := config.ovClient.GetEthernetNetworks("", "", "", "") if err != nil { From 5d008530b9fee12744b90f38c4fa55fcf7deb233 Mon Sep 17 00:00:00 2001 From: yuvirani Date: Fri, 4 Jun 2021 15:08:56 +0530 Subject: [PATCH 5/7] Import schema from file --- oneview/data_source_ethernet_network.go | 193 ++++++------------------ oneview/ethernet_schema.go | 99 ++++++++++++ oneview/resource_ethernet_network.go | 90 +---------- 3 files changed, 144 insertions(+), 238 deletions(-) create mode 100644 oneview/ethernet_schema.go diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index 45e3dd40..f4ab6dd5 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -12,112 +12,15 @@ package oneview import ( + "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "strconv" - "time" + "io/ioutil" ) func dataSourceEthernetNetwork() *schema.Resource { return &schema.Resource{ - Read: dataSourceEthernetNetworkRead, - - Schema: map[string]*schema.Schema{ - "count_": { - Type: schema.TypeInt, - Computed: true, - }, - "total": { - Type: schema.TypeInt, - Computed: true, - }, - "list_uri": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Optional: true, - }, - "members": { - Type: schema.TypeList, - Computed: true, - - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - }, - "vlan_id": { - Type: schema.TypeInt, - Computed: true, - }, - "purpose": { - Type: schema.TypeString, - Computed: true, - }, - "private_network": { - Type: schema.TypeBool, - Computed: true, - }, - "smart_link": { - Type: schema.TypeBool, - Computed: true, - }, - "ethernet_network_type": { - Type: schema.TypeString, - Computed: true, - }, - "type": { - Type: schema.TypeString, - Computed: true, - }, - "connection_template_uri": { - Type: schema.TypeString, - Computed: true, - }, - "created": { - Type: schema.TypeString, - Computed: true, - }, - "modified": { - Type: schema.TypeString, - Computed: true, - }, - "uri": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - "category": { - Type: schema.TypeString, - Computed: true, - }, - "state": { - Type: schema.TypeString, - Computed: true, - }, - "fabric_uri": { - Type: schema.TypeString, - Computed: true, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - }, - "scopesuri": { - Type: schema.TypeString, - Optional: true, - }, - }, - }, - }, - - }, - + Read: dataSourceEthernetNetworkRead, + Schema: ethernetSchema().Schema, } } @@ -126,32 +29,28 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err name := d.Get("name").(string) if len(name) > 0 { - eNet , err := config.ovClient.GetEthernetNetworkByName(name) + eNet, err := config.ovClient.GetEthernetNetworkByName(name) if err != nil { - d.SetId("") - return nil + d.SetId("") + return nil } - members := make([]map[string]interface{}, 0, 1) - members = append(members, map[string]interface{}{ - "name": eNet.Name, - "purpose": eNet.Purpose, - "vlan_id": eNet.VlanId, - "smart_link": eNet.SmartLink, - "private_network": eNet.PrivateNetwork, - "ethernet_network_type": eNet.EthernetNetworkType, - "type": eNet.Type, - "created": eNet.Created, - "modified": eNet.Modified, - "uri": eNet.URI, - "connection_template_uri": eNet.ConnectionTemplateUri, - "state": eNet.State, - "status": eNet.Status, - "category": eNet.Category, - "fabric_uri": eNet.FabricUri, - "etag": eNet.ETAG, - "scopesuri": eNet.ScopesUri, - }) - d.Set("members", members) + d.Set("name", eNet.Name) + d.Set("purpose", eNet.Purpose) + d.Set("vlan_id", eNet.VlanId) + d.Set("smart_link", eNet.SmartLink) + d.Set("private_network", eNet.PrivateNetwork) + d.Set("ethernet_network_type", eNet.EthernetNetworkType) + d.Set("type", eNet.Type) + d.Set("created", eNet.Created) + d.Set("modified", eNet.Modified) + d.Set("uri", eNet.URI) + d.Set("connection_template_uri", eNet.ConnectionTemplateUri) + d.Set("state", eNet.State) + d.Set("status", eNet.Status) + d.Set("category", eNet.Category) + d.Set("fabric_uri", eNet.FabricUri) + d.Set("etag", eNet.ETAG) + d.Set("scopesuri", eNet.ScopesUri) d.SetId(name) return nil } else { @@ -161,37 +60,33 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err d.SetId("") return nil } else { - d.Set("count_", eNetList.Count) - d.Set("total", eNetList.Total) - d.Set("list_uri", eNetList.URI) - members := make([]map[string]interface{}, 0, len(eNetList.Members)) for _, eNet := range eNetList.Members { members = append(members, map[string]interface{}{ - "name": eNet.Name, - "purpose": eNet.Purpose, - "vlan_id": eNet.VlanId, - "smart_link": eNet.SmartLink, - "private_network": eNet.PrivateNetwork, - "ethernet_network_type": eNet.EthernetNetworkType, - "type": eNet.Type, - "created": eNet.Created, - "modified": eNet.Modified, - "uri": eNet.URI, + "name": eNet.Name, + "purpose": eNet.Purpose, + "vlan_id": eNet.VlanId, + "smart_link": eNet.SmartLink, + "private_network": eNet.PrivateNetwork, + "ethernet_network_type": eNet.EthernetNetworkType, + "type": eNet.Type, + "created": eNet.Created, + "modified": eNet.Modified, + "uri": eNet.URI, "connection_template_uri": eNet.ConnectionTemplateUri, - "state": eNet.State, - "status": eNet.Status, - "category": eNet.Category, - "fabric_uri": eNet.FabricUri, - "etag": eNet.ETAG, - "scopesuri": eNet.ScopesUri, + "state": eNet.State, + "status": eNet.Status, + "category": eNet.Category, + "fabric_uri": eNet.FabricUri, + "etag": eNet.ETAG, + "scopesuri": eNet.ScopesUri, }) } + file, _ := json.MarshalIndent(members, "", " ") + _ = ioutil.WriteFile("test.json", file, 0644) - d.Set("members", members) - d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) + d.SetId(string(file)) } + return nil } - return nil - } diff --git a/oneview/ethernet_schema.go b/oneview/ethernet_schema.go new file mode 100644 index 00000000..e69524ca --- /dev/null +++ b/oneview/ethernet_schema.go @@ -0,0 +1,99 @@ +package oneview + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +func ethernetSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "vlan_id": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, + "purpose": { + Type: schema.TypeString, + Optional: true, + Default: "General", + }, + "private_network": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "smart_link": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "ethernet_network_type": { + Type: schema.TypeString, + Optional: true, + Default: "Tagged", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Default: "ethernet-networkV3", + }, + "connection_template_uri": { + Type: schema.TypeString, + Computed: true, + }, + "created": { + Type: schema.TypeString, + Computed: true, + }, + "modified": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "uri": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "category": { + Type: schema.TypeString, + Computed: true, + }, + "state": { + Type: schema.TypeString, + Computed: true, + }, + "fabric_uri": { + Type: schema.TypeString, + Computed: true, + }, + "etag": { + Type: schema.TypeString, + Computed: true, + }, + "scopesuri": { + Optional: true, + Type: schema.TypeString, + Computed: true, + }, + "initial_scope_uris": { + Optional: true, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Set: schema.HashString, + }, + }, + } +} diff --git a/oneview/resource_ethernet_network.go b/oneview/resource_ethernet_network.go index ba5805be..848f1c01 100644 --- a/oneview/resource_ethernet_network.go +++ b/oneview/resource_ethernet_network.go @@ -27,95 +27,7 @@ func resourceEthernetNetwork() *schema.Resource { State: schema.ImportStatePassthrough, }, - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - "vlan_id": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - }, - "purpose": { - Type: schema.TypeString, - Optional: true, - Default: "General", - }, - "private_network": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - "smart_link": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - "ethernet_network_type": { - Type: schema.TypeString, - Optional: true, - Default: "Tagged", - }, - "type": { - Type: schema.TypeString, - Optional: true, - Default: "ethernet-networkV3", - }, - "connection_template_uri": { - Type: schema.TypeString, - Computed: true, - }, - "created": { - Type: schema.TypeString, - Computed: true, - }, - "modified": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - }, - "uri": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - "category": { - Type: schema.TypeString, - Computed: true, - }, - "state": { - Type: schema.TypeString, - Computed: true, - }, - "fabric_uri": { - Type: schema.TypeString, - Computed: true, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - }, - "scopesuri": { - Optional: true, - Type: schema.TypeString, - Computed: true, - }, - "initial_scope_uris": { - Optional: true, - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Set: schema.HashString, - }, - }, + Schema: ethernetSchema().Schema, } } From 22c280712b27ac35edb7fe1ca86703581cf4cafa Mon Sep 17 00:00:00 2001 From: yuvirani Date: Tue, 8 Jun 2021 09:56:15 +0530 Subject: [PATCH 6/7] Schema with members attribute --- examples/ethernet_networks/data_source.tf | 9 +- go.mod | 2 +- oneview/data_source_ethernet_network.go | 109 ++++++++++++---------- 3 files changed, 67 insertions(+), 53 deletions(-) diff --git a/examples/ethernet_networks/data_source.tf b/examples/ethernet_networks/data_source.tf index fa37d56a..38958606 100644 --- a/examples/ethernet_networks/data_source.tf +++ b/examples/ethernet_networks/data_source.tf @@ -8,21 +8,22 @@ provider "oneview" { } # Testing data source +# Gets all ethernet networks if name not given data "oneview_ethernet_network" "ethernetnetworks" { -get_type = "GetAll" } output "oneview_ethernet_network_value" { value = data.oneview_ethernet_network.ethernetnetworks } +# Gets a network with name Test data "oneview_ethernet_network" "ethernetnetworkbyname" { -get_type = "GetById" -name = "Test" + name = "Test" } + output "oneview_ethernet_network_by_name_value" { - value = data.oneview_ethernet_network.ethernetnetworkbyname + value = data.oneview_ethernet_network.ethernetnetworkbyname.members[0] } resource "oneview_ethernet_network" "ethernetnetwork_1" { diff --git a/go.mod b/go.mod index 0c83c956..d6df53dc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/HewlettPackard/terraform-provider-oneview go 1.15 require ( - github.com/HewlettPackard/oneview-golang v6.0.0+incompatible + github.com/HewlettPackard/oneview-golang v6.1.1-0.20210525113815-98df2c8566ee+incompatible github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/docker/machine v0.16.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index f4ab6dd5..2164d232 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -12,15 +12,26 @@ package oneview import ( - "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "io/ioutil" ) func dataSourceEthernetNetwork() *schema.Resource { return &schema.Resource{ - Read: dataSourceEthernetNetworkRead, - Schema: ethernetSchema().Schema, + Read: dataSourceEthernetNetworkRead, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "members": { + Type: schema.TypeList, + Computed: true, + + Elem: &schema.Resource{ + Schema: ethernetSchema().Schema, + }, + }, + }, } } @@ -34,59 +45,61 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err d.SetId("") return nil } - d.Set("name", eNet.Name) - d.Set("purpose", eNet.Purpose) - d.Set("vlan_id", eNet.VlanId) - d.Set("smart_link", eNet.SmartLink) - d.Set("private_network", eNet.PrivateNetwork) - d.Set("ethernet_network_type", eNet.EthernetNetworkType) - d.Set("type", eNet.Type) - d.Set("created", eNet.Created) - d.Set("modified", eNet.Modified) - d.Set("uri", eNet.URI) - d.Set("connection_template_uri", eNet.ConnectionTemplateUri) - d.Set("state", eNet.State) - d.Set("status", eNet.Status) - d.Set("category", eNet.Category) - d.Set("fabric_uri", eNet.FabricUri) - d.Set("etag", eNet.ETAG) - d.Set("scopesuri", eNet.ScopesUri) + members := make([]map[string]interface{}, 0, 1) + members = append(members, map[string]interface{}{ + "name": eNet.Name, + "purpose": eNet.Purpose, + "vlan_id": eNet.VlanId, + "smart_link": eNet.SmartLink, + "private_network": eNet.PrivateNetwork, + "ethernet_network_type": eNet.EthernetNetworkType, + "type": eNet.Type, + "created": eNet.Created, + "modified": eNet.Modified, + "uri": eNet.URI.String(), + "connection_template_uri": eNet.ConnectionTemplateUri, + "state": eNet.State, + "status": eNet.Status, + "category": eNet.Category, + "fabric_uri": eNet.FabricUri, + "etag": eNet.ETAG, + "scopesuri": eNet.ScopesUri, + }) + d.Set("members", members) d.SetId(name) return nil + } else { eNetList, err := config.ovClient.GetEthernetNetworks("", "", "", "") if err != nil { d.SetId("") return nil - } else { - members := make([]map[string]interface{}, 0, len(eNetList.Members)) - for _, eNet := range eNetList.Members { - members = append(members, map[string]interface{}{ - "name": eNet.Name, - "purpose": eNet.Purpose, - "vlan_id": eNet.VlanId, - "smart_link": eNet.SmartLink, - "private_network": eNet.PrivateNetwork, - "ethernet_network_type": eNet.EthernetNetworkType, - "type": eNet.Type, - "created": eNet.Created, - "modified": eNet.Modified, - "uri": eNet.URI, - "connection_template_uri": eNet.ConnectionTemplateUri, - "state": eNet.State, - "status": eNet.Status, - "category": eNet.Category, - "fabric_uri": eNet.FabricUri, - "etag": eNet.ETAG, - "scopesuri": eNet.ScopesUri, - }) - } - file, _ := json.MarshalIndent(members, "", " ") - _ = ioutil.WriteFile("test.json", file, 0644) - - d.SetId(string(file)) } + members := make([]map[string]interface{}, 0, len(eNetList.Members)) + for _, eNet := range eNetList.Members { + members = append(members, map[string]interface{}{ + "name": eNet.Name, + "purpose": eNet.Purpose, + "vlan_id": eNet.VlanId, + "smart_link": eNet.SmartLink, + "private_network": eNet.PrivateNetwork, + "ethernet_network_type": eNet.EthernetNetworkType, + "type": eNet.Type, + "created": eNet.Created, + "modified": eNet.Modified, + "uri": eNet.URI.String(), + "connection_template_uri": eNet.ConnectionTemplateUri, + "state": eNet.State, + "status": eNet.Status, + "category": eNet.Category, + "fabric_uri": eNet.FabricUri, + "etag": eNet.ETAG, + "scopesuri": eNet.ScopesUri, + }) + } + d.Set("members", members) + d.SetId(string(eNetList.Members[0].URI)) return nil } } From 18c1148c53b7aa89bed031427138cb4bd32ae23e Mon Sep 17 00:00:00 2001 From: yuvirani Date: Tue, 8 Jun 2021 15:28:08 +0530 Subject: [PATCH 7/7] Create folder for schema --- go.sum | 2 + .../{ => common_schema}/ethernet_schema.go | 4 +- oneview/data_source_ethernet_network.go | 5 +- oneview/resource_ethernet_network.go | 3 +- .../resource_logical_interconnect_group.go | 997 +++++++++++------- 5 files changed, 640 insertions(+), 371 deletions(-) rename oneview/{ => common_schema}/ethernet_schema.go (96%) diff --git a/go.sum b/go.sum index b203a472..b46f8e24 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/HewlettPackard/oneview-golang v6.0.0+incompatible h1:QKxGpu+Mg09mJwd/X1mb6495h9AT8RAzeivk6SKe8kI= github.com/HewlettPackard/oneview-golang v6.0.0+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE= +github.com/HewlettPackard/oneview-golang v6.1.1-0.20210525113815-98df2c8566ee+incompatible h1:oX+M5aRCpnpDKuBCVEz2oak9vHA4ilKo1ZCg7Fodv5s= +github.com/HewlettPackard/oneview-golang v6.1.1-0.20210525113815-98df2c8566ee+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/oneview/ethernet_schema.go b/oneview/common_schema/ethernet_schema.go similarity index 96% rename from oneview/ethernet_schema.go rename to oneview/common_schema/ethernet_schema.go index e69524ca..3099b358 100644 --- a/oneview/ethernet_schema.go +++ b/oneview/common_schema/ethernet_schema.go @@ -1,10 +1,10 @@ -package oneview +package common_schema import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) -func ethernetSchema() *schema.Resource { +func EthernetSchema() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { diff --git a/oneview/data_source_ethernet_network.go b/oneview/data_source_ethernet_network.go index 2164d232..5e98a3a8 100644 --- a/oneview/data_source_ethernet_network.go +++ b/oneview/data_source_ethernet_network.go @@ -13,6 +13,7 @@ package oneview import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/HewlettPackard/terraform-provider-oneview/oneview/common_schema" ) func dataSourceEthernetNetwork() *schema.Resource { @@ -28,7 +29,7 @@ func dataSourceEthernetNetwork() *schema.Resource { Computed: true, Elem: &schema.Resource{ - Schema: ethernetSchema().Schema, + Schema: common_schema.EthernetSchema().Schema, }, }, }, @@ -66,6 +67,7 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err "scopesuri": eNet.ScopesUri, }) d.Set("members", members) + d.Set("name", eNet.Name) d.SetId(name) return nil @@ -99,6 +101,7 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err }) } d.Set("members", members) + d.Set("name", "EthernetList") d.SetId(string(eNetList.Members[0].URI)) return nil } diff --git a/oneview/resource_ethernet_network.go b/oneview/resource_ethernet_network.go index 848f1c01..c5986009 100644 --- a/oneview/resource_ethernet_network.go +++ b/oneview/resource_ethernet_network.go @@ -15,6 +15,7 @@ import ( "github.com/HewlettPackard/oneview-golang/ov" "github.com/HewlettPackard/oneview-golang/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/HewlettPackard/terraform-provider-oneview/oneview/common_schema" ) func resourceEthernetNetwork() *schema.Resource { @@ -27,7 +28,7 @@ func resourceEthernetNetwork() *schema.Resource { State: schema.ImportStatePassthrough, }, - Schema: ethernetSchema().Schema, + Schema: common_schema.EthernetSchema().Schema, } } diff --git a/oneview/resource_logical_interconnect_group.go b/oneview/resource_logical_interconnect_group.go index ba7270eb..2374fbf3 100644 --- a/oneview/resource_logical_interconnect_group.go +++ b/oneview/resource_logical_interconnect_group.go @@ -13,12 +13,11 @@ package oneview import ( "fmt" - "reflect" - "strconv" - "github.com/HewlettPackard/oneview-golang/ov" "github.com/HewlettPackard/oneview-golang/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "reflect" + "strconv" ) func resourceLogicalInterconnectGroup() *schema.Resource { @@ -482,7 +481,7 @@ func resourceLogicalInterconnectGroup() *schema.Resource { }, }, "igmp_settings": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, Computed: true, Elem: &schema.Resource{ @@ -490,11 +489,12 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "type": { Type: schema.TypeString, Optional: true, - Default: "IgmpSettings", + Computed: true, }, "category": { Type: schema.TypeString, Optional: true, + Computed: true, }, "consistency_checking": { Type: schema.TypeString, @@ -504,6 +504,7 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "created": { Type: schema.TypeString, Optional: true, + Computed: true, }, "dependent_resource_uri": { Type: schema.TypeString, @@ -516,6 +517,7 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "etag": { Type: schema.TypeString, Optional: true, + Computed: true, }, "igmp_snooping": { Type: schema.TypeBool, @@ -532,6 +534,7 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "id": { Type: schema.TypeString, Optional: true, + Computed: true, }, "igmp_idle_timeout_interval": { Type: schema.TypeInt, @@ -544,10 +547,12 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "modified": { Type: schema.TypeString, Optional: true, + Computed: true, }, "name": { Type: schema.TypeString, Optional: true, + Computed: true, }, "state": { Type: schema.TypeString, @@ -560,12 +565,13 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "uri": { Type: schema.TypeString, Optional: true, + Computed: true, }, }, }, }, "port_flap_settings": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, Computed: true, Elem: &schema.Resource{ @@ -573,34 +579,42 @@ func resourceLogicalInterconnectGroup() *schema.Resource { "type": { Type: schema.TypeString, Optional: true, + Computed: true, }, "uri": { Type: schema.TypeString, Optional: true, + Computed: true, }, "category": { Type: schema.TypeString, Optional: true, + Computed: true, }, "etag": { Type: schema.TypeString, Optional: true, + Computed: true, }, "created": { Type: schema.TypeString, Optional: true, + Computed: true, }, "modified": { Type: schema.TypeString, Optional: true, + Computed: true, }, "id": { Type: schema.TypeString, Optional: true, + Computed: true, }, "name": { Type: schema.TypeString, Optional: true, + Computed: true, }, "detection_interval": { Type: schema.TypeInt, @@ -648,73 +662,221 @@ func resourceLogicalInterconnectGroup() *schema.Resource { Optional: true, Default: "qos-aggregated-configuration", }, - "active_qos_config_type": { + "category": { + Type: schema.TypeString, + Optional: true, + }, + "consistency_checking": { + Type: schema.TypeString, + Optional: true, + }, + "created": { + Type: schema.TypeString, + Optional: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "etag": { Type: schema.TypeString, Optional: true, - Default: "QosConfiguration", }, - "config_type": { + "modified": { Type: schema.TypeString, Optional: true, - Default: "Passthrough", }, - "uplink_classification_type": { + "name": { Type: schema.TypeString, Optional: true, }, - "downlink_classification_type": { + "state": { Type: schema.TypeString, Optional: true, }, - "qos_traffic_class": { + "status": { + Type: schema.TypeString, + Optional: true, + }, + "uri": { + Type: schema.TypeString, + Optional: true, + }, + "active_qos_config": { Type: schema.TypeList, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "category": { + Type: schema.TypeString, + Optional: true, + }, + "config_type": { + Type: schema.TypeString, + Optional: true, + }, + "created": { + Type: schema.TypeString, + Optional: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "downlink_classification_type": { + Type: schema.TypeString, + Optional: true, + }, + "etag": { + Type: schema.TypeString, + Optional: true, + }, + "modified": { + Type: schema.TypeString, + Optional: true, + }, "name": { Type: schema.TypeString, - Required: true, + Optional: true, }, - "enabled": { - Type: schema.TypeBool, + "state": { + Type: schema.TypeString, Optional: true, - Default: true, }, - "egress_dot1p_value": { - Type: schema.TypeInt, - Required: true, + "status": { + Type: schema.TypeString, + Optional: true, }, - "real_time": { - Type: schema.TypeBool, + "type": { + Type: schema.TypeString, Optional: true, - Default: false, }, - "bandwidth_share": { + "uplink_classification_type": { Type: schema.TypeString, - Required: true, + Optional: true, }, - "max_bandwidth": { - Type: schema.TypeInt, - Required: true, + "uri": { + Type: schema.TypeString, + Optional: true, }, - "qos_classification_map": { + "qos_traffic_classifiers": { Type: schema.TypeList, - Required: true, + Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dot1p_class_map": { - Type: schema.TypeSet, + "qos_classification_mapping": { + Type: schema.TypeList, Optional: true, - Elem: &schema.Schema{Type: schema.TypeInt}, - Set: func(a interface{}) int { - return a.(int) + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dot1p_class_mapping": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + "dscp_class_mapping": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, }, }, - "dscp_class_map": { - Type: schema.TypeSet, + "qos_traffic_class": { + Type: schema.TypeList, Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bandwidth_share": { + Type: schema.TypeString, + Optional: true, + }, + "class_name": { + Type: schema.TypeString, + Optional: true, + }, + "egress_dot1p_value": { + Type: schema.TypeInt, + Optional: true, + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "max_bandwidth": { + Type: schema.TypeInt, + Optional: true, + }, + "real_time": { + Type: schema.TypeBool, + Optional: true, + }, + "roce": { + Type: schema.TypeBool, + Optional: true, + }, + "dcbx_configuration": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "application_protocol": { + Type: schema.TypeString, + Optional: true, + }, + "default_max_bandwidth": { + Type: schema.TypeString, + Optional: true, + }, + "default_min_bandwidth": { + Type: schema.TypeString, + Optional: true, + }, + "priority_code_point": { + Type: schema.TypeString, + Optional: true, + }, + "priority_flow_control": { + Type: schema.TypeString, + Optional: true, + }, + "dcbx_ets_port": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bay_number": { + Type: schema.TypeString, + Optional: true, + }, + "enclosure_index": { + Type: schema.TypeInt, + Optional: true, + }, + "icm_name": { + Type: schema.TypeString, + Optional: true, + }, + "max_bandwidth": { + Type: schema.TypeString, + Optional: true, + }, + "min_bandwidth": { + Type: schema.TypeString, + Optional: true, + }, + "port_name": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, }, }, }, @@ -967,8 +1129,7 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa sflowCollector := ov.SflowCollector{} if val, ok := d.GetOk(sflowCollectorPrefix + ".collector_enabled"); ok { - enabled := val.(bool) - sflowCollector.CollectorEnabled = &enabled + sflowCollector.CollectorEnabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(sflowCollectorPrefix + ".collector_id"); ok { @@ -1053,8 +1214,7 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa sflowConfiguration.Description = utils.NewNstring(val.(string)) } if val, ok := d.GetOk(sflowConfigurationPrefix + ".enabled"); ok { - enabled := val.(bool) - sflowConfiguration.Enabled = &enabled + sflowConfiguration.Enabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(sflowConfigurationPrefix + ".name"); ok { sflowConfiguration.Name = val.(string) @@ -1090,8 +1250,7 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa telemetryConfiguration.SampleInterval = val.(int) } if val, ok := d.GetOk(telemetryConfigPrefix + ".enabled"); ok { - enabled := val.(bool) - telemetryConfiguration.EnableTelemetry = &enabled + telemetryConfiguration.EnableTelemetry = GetBoolPointer(val.(bool)) } if telemetryConfiguration != (ov.TelemetryConfiguration{}) { telemetryConfiguration.Type = d.Get(telemetryConfigPrefix + ".type").(string) @@ -1101,12 +1260,10 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa snmpConfigPrefix := fmt.Sprintf("snmp_configuration.0") snmpConfiguration := ov.SnmpConfiguration{} if val, ok := d.GetOk(snmpConfigPrefix + ".enabled"); ok { - enabled := val.(bool) - snmpConfiguration.Enabled = &enabled + snmpConfiguration.Enabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(snmpConfigPrefix + ".v3_enabled"); ok { - v3Enabled := val.(bool) - snmpConfiguration.V3Enabled = &v3Enabled + snmpConfiguration.V3Enabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(snmpConfigPrefix + ".read_community"); ok { snmpConfiguration.ReadCommunity = val.(string) @@ -1184,13 +1341,11 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa interconnectSettings.EnablePauseFloodProtection = &pauseFloodProtectionEnabled if val1, ok := d.GetOk(interconnectSettingsPrefix + ".rich_tlv"); ok { - enabled := val1.(bool) - interconnectSettings.EnableRichTLV = &enabled + interconnectSettings.EnableRichTLV = GetBoolPointer(val1.(bool)) } if val1, ok := d.GetOk(interconnectSettingsPrefix + ".interconnect_utilization_alert"); ok { - enabled := val1.(bool) - interconnectSettings.EnableInterconnectUtilizationAlert = &enabled + interconnectSettings.EnableInterconnectUtilizationAlert = GetBoolPointer(val1.(bool)) } if val1, ok := d.GetOk(interconnectSettingsPrefix + ".mac_refresh_interval"); ok { @@ -1201,88 +1356,32 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa lig.EthernetSettings = &interconnectSettings } - igmpSettingsPrefix := fmt.Sprintf("igmp_settings.0") - if val, ok := d.GetOk(igmpSettingsPrefix + ".type"); ok { - igmpSettings := ov.IgmpSettings{} - - consistencyChecking := d.Get(igmpSettingsPrefix + ".consistency_checking") - igmpSettings.ConsistencyChecking = consistencyChecking.(string) - - igmpSnooping := d.Get(igmpSettingsPrefix + ".igmp_snooping").(bool) - igmpSettings.EnableIgmpSnooping = &igmpSnooping - - preventFlooding := d.Get(igmpSettingsPrefix + ".prevent_flooding").(bool) - igmpSettings.EnablePreventFlooding = &preventFlooding - - proxyReporting := d.Get(igmpSettingsPrefix + ".proxy_reporting").(bool) - igmpSettings.EnableProxyReporting = &proxyReporting - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".created"); ok { - enabled := val1.(string) - igmpSettings.Created = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".description"); ok { - enabled := val1.(string) - igmpSettings.Description = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".id"); ok { - enabled := val1.(string) - igmpSettings.ID = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".etag"); ok { - enabled := utils.NewNstring(val1.(string)) - igmpSettings.ETAG = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".igmp_idle_timeout_interval"); ok { - enabled := val1.(int) - igmpSettings.IgmpIdleTimeoutInterval = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".igmp_snooping_vlan_ids"); ok { - enabled := val1.(string) - igmpSettings.IgmpSnoopingVlanIds = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".modified"); ok { - enabled := val1.(string) - igmpSettings.Modified = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".name"); ok { - enabled := val1.(string) - igmpSettings.Name = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".state"); ok { - enabled := val1.(string) - igmpSettings.State = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".status"); ok { - enabled := val1.(string) - igmpSettings.Status = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".category"); ok { - enabled := utils.NewNstring(val1.(string)) - igmpSettings.Category = enabled - } - - if val1, ok := d.GetOk(igmpSettingsPrefix + ".uri"); ok { - enabled := utils.NewNstring(val1.(string)) - igmpSettings.URI = enabled - } + rawigmpsetting := d.Get("igmp_settings").([]interface{}) + igmpSetting := ov.IgmpSettings{} + for _, val := range rawigmpsetting { - igmpSettings.Type = val.(string) - lig.IgmpSettings = &igmpSettings + rawlval := val.(map[string]interface{}) + igmpSetting.Created = rawlval["created"].(string) + igmpSetting.Category = utils.Nstring(rawlval["category"].(string)) + igmpSetting.Type = rawlval["type"].(string) + igmpSetting.ConsistencyChecking = rawlval["consistency_checking"].(string) + igmpSetting.Description = rawlval["description"].(string) + igmpSetting.ETAG = utils.Nstring(rawlval["etag"].(string)) + igmpSetting.EnableIgmpSnooping = GetBoolPointer(rawlval["igmp_snooping"].(bool)) + igmpSetting.EnablePreventFlooding = GetBoolPointer(rawlval["prevent_flooding"].(bool)) + igmpSetting.EnableProxyReporting = GetBoolPointer(rawlval["proxy_reporting"].(bool)) + igmpSetting.ID = rawlval["id"].(string) + igmpSetting.IgmpIdleTimeoutInterval = rawlval["igmp_idle_timeout_interval"].(int) + igmpSetting.IgmpSnoopingVlanIds = rawlval["igmp_snooping_vlan_ids"].(string) + igmpSetting.Modified = rawlval["modified"].(string) + igmpSetting.Name = rawlval["name"].(string) + igmpSetting.State = rawlval["state"].(string) + igmpSetting.Status = rawlval["status"].(string) + igmpSetting.URI = utils.Nstring(rawlval["uri"].(string)) } + lig.IgmpSettings = &igmpSetting - portFlapSettingsData := d.Get("port_flap_settings").(*schema.Set).List() - + portFlapSettingsData := d.Get("port_flap_settings").([]interface{}) for _, raw := range portFlapSettingsData { portFlapSettingRawData := raw.(map[string]interface{}) @@ -1307,87 +1406,151 @@ func resourceLogicalInterconnectGroupCreate(d *schema.ResourceData, meta interfa lig.PortFlapProtection = &portFlapSettingStructure } - qualityOfServicePrefix := fmt.Sprintf("quality_of_service.0") - activeQosConfig := ov.ActiveQosConfig{} - - if val, ok := d.GetOk(qualityOfServicePrefix + ".config_type"); ok { - activeQosConfig.ConfigType = val.(string) - } - - if val, ok := d.GetOk(qualityOfServicePrefix + ".uplink_classification_type"); ok { - activeQosConfig.UplinkClassificationType = val.(string) - } - - if val, ok := d.GetOk(qualityOfServicePrefix + ".downlink_classification_type"); ok { - activeQosConfig.DownlinkClassificationType = val.(string) - } - - qosTrafficClassCount := d.Get(qualityOfServicePrefix + ".qos_traffic_class.#").(int) - qosTrafficClassifiers := make([]ov.QosTrafficClassifier, 0, 1) - for i := 0; i < qosTrafficClassCount; i++ { - qosTrafficClassPrefix := fmt.Sprintf(qualityOfServicePrefix+".qos_traffic_class.%d", i) - qosTrafficClassifier := ov.QosTrafficClassifier{} - qosClassMap := ov.QosClassificationMap{} - qosTrafficClass := ov.QosTrafficClass{} - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".name"); ok { - qosTrafficClass.ClassName = val.(string) - } - classEnabled := d.Get(qosTrafficClassPrefix + ".enabled").(bool) - qosTrafficClass.Enabled = &classEnabled - - realTimeEnabled := d.Get(qosTrafficClassPrefix + ".real_time").(bool) - qosTrafficClass.RealTime = &realTimeEnabled - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".egress_dot1p_value"); ok { - qosTrafficClass.EgressDot1pValue = val.(int) - } - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".bandwidth_share"); ok { - qosTrafficClass.BandwidthShare = val.(string) - } - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".max_bandwidth"); ok { - qosTrafficClass.MaxBandwidth = val.(int) - } - - qosTrafficClassifier.QosTrafficClass = qosTrafficClass - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".qos_classification_map.0.dscp_class_map"); ok { - rawDscpClassMapping := val.(*schema.Set).List() - dscpClassMapping := make([]string, len(rawDscpClassMapping)) - for i, raw := range rawDscpClassMapping { - dscpClassMapping[i] = raw.(string) + if val, ok := d.GetOk("quality_of_service"); ok { + rawQoss := val.([]interface{}) + ovQos := ov.QosConfiguration{} + if len(rawQoss) != 0 { + for _, rawQosConfig := range rawQoss { + rawQos := rawQosConfig.(map[string]interface{}) + rawActiveQosConfigs := rawQos["active_qos_config"].([]interface{}) + ovActiveQosConfig := ov.ActiveQosConfig{} + if len(rawActiveQosConfigs) != 0 { + for _, rawActiveQosConfig := range rawActiveQosConfigs { + activeQosConfig := rawActiveQosConfig.(map[string]interface{}) + rawQosClassifiers := activeQosConfig["qos_traffic_classifiers"].([]interface{}) + ovQosTrafficClassifier := make([]ov.QosTrafficClassifier, 0) + if len(rawQosClassifiers) != 0 { + for _, rawQosClassifier := range rawQosClassifiers { + qosClassifier := rawQosClassifier.(map[string]interface{}) + ovQosClassificationMapping := ov.QosClassificationMapping{} + rawQosClassificationMappings := qosClassifier["qos_classification_mapping"].([]interface{}) + if rawQosClassificationMappings != nil { + for _, rawQosClassificationMapping := range rawQosClassificationMappings { + qosClassificationMapping := rawQosClassificationMapping.(map[string]interface{}) + rawDot1pClassMappings := qosClassificationMapping["dot1p_class_mapping"].([]interface{}) + if qosClassificationMapping["dot1p_class_mapping"] != nil { + dot1pClassMapping := make([]int, 0) + for _, raw := range rawDot1pClassMappings { + dot1pClassMapping = append(dot1pClassMapping, raw.(int)) + } + ovQosClassificationMapping.Dot1pClassMapping = dot1pClassMapping + } + rawDscpClassMappings := qosClassificationMapping["dscp_class_mapping"].([]interface{}) + if qosClassificationMapping["dscp_class_mapping"] != nil { + dscpClassMapping := make([]string, 0) + for _, raw := range rawDscpClassMappings { + dscpClassMapping = append(dscpClassMapping, raw.(string)) + } + ovQosClassificationMapping.DscpClassMapping = dscpClassMapping + } + } + } + ovQosTrafficClass := ov.QosTrafficClass{} + rawQosTrafficClasses := qosClassifier["qos_traffic_class"].([]interface{}) + if len(rawQosTrafficClasses) != 0 { + for _, rawQosTrafficClass := range rawQosTrafficClasses { + qosTrafficClass := rawQosTrafficClass.(map[string]interface{}) + rawDcbxConfigurations := qosTrafficClass["dcbx_configuration"].([]interface{}) + ovDcbxConfiguration := ov.DcbxConfigurations{} + if len(rawDcbxConfigurations) != 0 { + for _, rawDcbxConfiguration := range rawDcbxConfigurations { + dcbxConfiguration := rawDcbxConfiguration.(map[string]interface{}) + rawDcbxEtsPorts := dcbxConfiguration["dcbx_ets_port"].([]interface{}) + ovDcbxEtsPorts := make([]ov.DcbxEtsPort, 0) + if len(rawDcbxEtsPorts) != 0 { + for _, rawDcbxPort := range rawDcbxEtsPorts { + dcbxPort := rawDcbxPort.(map[string]interface{}) + ovDcbxEtsPorts = append(ovDcbxEtsPorts, ov.DcbxEtsPort{ + BayNumber: dcbxPort["bay_number"].(string), + EnclosureIndex: dcbxPort["enclosure_index"].(int), + IcmName: dcbxPort["icm_name"].(string), + MaxBandwidth: dcbxPort["max_bandwidth"].(string), + MinBandwidth: dcbxPort["min_bandwidth"].(string), + PortName: dcbxPort["port_name"].(string), + }) + } + } + ovDcbxConfiguration = ov.DcbxConfigurations{ + ApplicationProtocol: dcbxConfiguration["application_protocol"].(string), + DefaultMaximumBandwidth: dcbxConfiguration["default_max_bandwidth"].(string), + DefaultMinimumBandwidth: dcbxConfiguration["default_min_bandwidth"].(string), + PriorityCodePoint: dcbxConfiguration["priority_code_point"].(string), + PriorityFlowControl: dcbxConfiguration["priority_flow_control"].(string), + } + if len(ovDcbxEtsPorts) != 0 { + ovDcbxConfiguration.DcbxEtsPorts = ovDcbxEtsPorts + } + } + } + ovQosTrafficClass = ov.QosTrafficClass{ + BandwidthShare: qosTrafficClass["bandwidth_share"].(string), + ClassName: qosTrafficClass["class_name"].(string), + EgressDot1pValue: GetIntPointer(qosTrafficClass["egress_dot1p_value"].(int)), + Enabled: GetBoolPointer(qosTrafficClass["enabled"].(bool)), + MaxBandwidth: qosTrafficClass["max_bandwidth"].(int), + RealTime: GetBoolPointer(qosTrafficClass["real_time"].(bool)), + Roce: GetBoolPointer(qosTrafficClass["roce"].(bool)), + } + if !(reflect.DeepEqual(ovDcbxConfiguration, ov.DcbxConfigurations{})) { + ovQosTrafficClass.DcbxConfiguration = &ovDcbxConfiguration + } + } + } + if reflect.DeepEqual(ovQosClassificationMapping, ov.QosClassificationMapping{}) && ovQosTrafficClass == (ov.QosTrafficClass{}) { + continue + } else if reflect.DeepEqual(ovQosClassificationMapping, ov.QosClassificationMapping{}) { + ovQosTrafficClassifier = append(ovQosTrafficClassifier, ov.QosTrafficClassifier{ + QosTrafficClass: &ovQosTrafficClass, + }) + } else if ovQosTrafficClass == (ov.QosTrafficClass{}) { + ovQosTrafficClassifier = append(ovQosTrafficClassifier, ov.QosTrafficClassifier{ + QosClassificationMapping: &ovQosClassificationMapping, + }) + } else { + ovQosTrafficClassifier = append(ovQosTrafficClassifier, ov.QosTrafficClassifier{ + QosClassificationMapping: &ovQosClassificationMapping, + QosTrafficClass: &ovQosTrafficClass, + }) + } + } + } + ovActiveQosConfig = ov.ActiveQosConfig{ + Category: utils.NewNstring(activeQosConfig["category"].(string)), + ConfigType: activeQosConfig["config_type"].(string), + Created: activeQosConfig["created"].(string), + Description: utils.NewNstring(activeQosConfig["description"].(string)), + DownlinkClassificationType: activeQosConfig["downlink_classification_type"].(string), + ETAG: activeQosConfig["etag"].(string), + Modified: activeQosConfig["modified"].(string), + Name: activeQosConfig["name"].(string), + State: activeQosConfig["state"].(string), + Status: activeQosConfig["status"].(string), + Type: activeQosConfig["type"].(string), + UplinkClassificationType: activeQosConfig["uplink_classification_type"].(string), + URI: utils.NewNstring(activeQosConfig["uri"].(string)), + QosTrafficClassifiers: ovQosTrafficClassifier, + } + } + } + ovQos = ov.QosConfiguration{ + Category: rawQos["category"].(string), + ConsistencyChecking: rawQos["consistency_checking"].(string), + Created: rawQos["created"].(string), + Description: utils.NewNstring(rawQos["description"].(string)), + ETAG: rawQos["etag"].(string), + Modified: rawQos["modified"].(string), + Name: rawQos["name"].(string), + State: rawQos["state"].(string), + Status: rawQos["status"].(string), + Type: rawQos["type"].(string), + URI: utils.NewNstring(rawQos["uri"].(string)), + ActiveQosConfig: &ovActiveQosConfig, + } } - qosClassMap.DscpClassMapping = dscpClassMapping - } - if val, ok := d.GetOk(qosTrafficClassPrefix + ".qos_classification_map.0.dot1p_class_map"); ok { - rawDot1pClassMap := val.(*schema.Set).List() - dot1pClassMap := make([]int, len(rawDot1pClassMap)) - for i, raw := range rawDot1pClassMap { - dot1pClassMap[i] = raw.(int) - } - qosClassMap.Dot1pClassMapping = dot1pClassMap } - - qosTrafficClassifier.QosClassificationMapping = &qosClassMap - - qosTrafficClassifiers = append(qosTrafficClassifiers, qosTrafficClassifier) + lig.QosConfiguration = &ovQos } - activeQosConfig.QosTrafficClassifiers = qosTrafficClassifiers - - if val, ok := d.GetOk(qualityOfServicePrefix + ".active_qos_config_type"); ok { - activeQosConfig.Type = val.(string) - - qualityOfService := ov.QosConfiguration{ - Type: d.Get(qualityOfServicePrefix + ".type").(string), - ActiveQosConfig: activeQosConfig, - } - - lig.QosConfiguration = &qualityOfService - } - ligError := config.ovClient.CreateLogicalInterconnectGroup(lig) d.SetId(d.Get("name").(string)) if ligError != nil { @@ -1422,6 +1585,101 @@ func resourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interface d.Set("interconnect_bay_set", logicalInterconnectGroup.InterconnectBaySet) d.Set("redundancy_type", logicalInterconnectGroup.RedundancyType) + if logicalInterconnectGroup.QosConfiguration != nil { + qosTrafficClassifiers := make([]map[string]interface{}, 0, len(logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.QosTrafficClassifiers)) + for _, qosTrafficClassifier := range logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.QosTrafficClassifiers { + qosClassificationMapping := make([]map[string]interface{}, 0, 1) + if qosTrafficClassifier.QosClassificationMapping != nil { + dot1pClassMappings := make([]interface{}, 0) + if qosTrafficClassifier.QosClassificationMapping.Dot1pClassMapping != nil { + for _, dot1pClassMapping := range qosTrafficClassifier.QosClassificationMapping.Dot1pClassMapping { + dot1pClassMappings = append(dot1pClassMappings, dot1pClassMapping) + } + } + dscpClassMappings := make([]interface{}, 0) + if qosTrafficClassifier.QosClassificationMapping.DscpClassMapping != nil { + for _, dscpClassMapping := range qosTrafficClassifier.QosClassificationMapping.DscpClassMapping { + dscpClassMappings = append(dscpClassMappings, dscpClassMapping) + } + } + qosClassificationMapping = append(qosClassificationMapping, map[string]interface{}{ + "dot1p_class_mapping": dot1pClassMappings, + "dscp_class_mapping": dscpClassMappings, + }) + } + dcbxConfigurations := make([]map[string]interface{}, 0, 1) + if qosTrafficClassifier.QosTrafficClass.DcbxConfiguration != nil { + dcbxEtsPorts := make([]map[string]interface{}, 0, len(qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.DcbxEtsPorts)) + for _, dcbxEtsPort := range qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.DcbxEtsPorts { + dcbxEtsPorts = append(dcbxEtsPorts, map[string]interface{}{ + "bay_number": dcbxEtsPort.BayNumber, + "enclosure_index": dcbxEtsPort.EnclosureIndex, + "icm_name": dcbxEtsPort.IcmName, + "max_bandwidth": dcbxEtsPort.MaxBandwidth, + "min_bandwidth": dcbxEtsPort.MinBandwidth, + "port_name": dcbxEtsPort.PortName, + }) + } + dcbxConfigurations = append(dcbxConfigurations, map[string]interface{}{ + "application_protocol": qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.ApplicationProtocol, + "default_max_bandwidth": qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.DefaultMaximumBandwidth, + "default_min_bandwidth": qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.DefaultMinimumBandwidth, + "priority_code_point": qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.PriorityCodePoint, + "priority_flow_control": qosTrafficClassifier.QosTrafficClass.DcbxConfiguration.PriorityFlowControl, + "dcbx_ets_port": dcbxEtsPorts, + }) + } + qosTrafficClass := make([]map[string]interface{}, 0, 1) + qosTrafficClass = append(qosTrafficClass, map[string]interface{}{ + "bandwidth_share": qosTrafficClassifier.QosTrafficClass.BandwidthShare, + "class_name": qosTrafficClassifier.QosTrafficClass.ClassName, + "egress_dot1p_value": *qosTrafficClassifier.QosTrafficClass.EgressDot1pValue, + "enabled": *qosTrafficClassifier.QosTrafficClass.Enabled, + "max_bandwidth": qosTrafficClassifier.QosTrafficClass.MaxBandwidth, + "real_time": *qosTrafficClassifier.QosTrafficClass.RealTime, + "roce": *qosTrafficClassifier.QosTrafficClass.Roce, + "dcbx_configuration": dcbxConfigurations, + }) + qosTrafficClassifiers = append(qosTrafficClassifiers, map[string]interface{}{ + "qos_traffic_class": qosTrafficClass, + "qos_classification_mapping": qosClassificationMapping, + }) + } + activeQosConfig := make([]map[string]interface{}, 0, 1) + activeQosConfig = append(activeQosConfig, map[string]interface{}{ + "category": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Category, + "config_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.ConfigType, + "created": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Created, + "description": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Description, + "downlink_classification_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.DownlinkClassificationType, + "etag": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.ETAG, + "modified": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Modified, + "name": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Name, + "state": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.State, + "status": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Status, + "type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Type, + "uplink_classification_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.UplinkClassificationType, + "uri": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.URI, + "qos_traffic_classifiers": qosTrafficClassifiers, + }) + qosConfiguration := make([]map[string]interface{}, 0, 1) + qosConfiguration = append(qosConfiguration, map[string]interface{}{ + "type": logicalInterconnectGroup.QosConfiguration.Type, + "category": logicalInterconnectGroup.QosConfiguration.Category, + "consistency_checking": logicalInterconnectGroup.QosConfiguration.ConsistencyChecking, + "created": logicalInterconnectGroup.QosConfiguration.Created, + "description": logicalInterconnectGroup.QosConfiguration.Description, + "etag": logicalInterconnectGroup.QosConfiguration.ETAG, + "modified": logicalInterconnectGroup.QosConfiguration.Modified, + "name": logicalInterconnectGroup.QosConfiguration.Name, + "state": logicalInterconnectGroup.QosConfiguration.State, + "status": logicalInterconnectGroup.QosConfiguration.Status, + "uri": logicalInterconnectGroup.QosConfiguration.URI, + "active_qos_config": activeQosConfig, + }) + d.Set("quality_of_service", qosConfiguration) + } + enclosureIndexes := make([]interface{}, len(logicalInterconnectGroup.EnclosureIndexes)) for i, enclosureIndexVal := range logicalInterconnectGroup.EnclosureIndexes { enclosureIndexes[i] = enclosureIndexVal @@ -1775,62 +2033,6 @@ func resourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interface portFlapSettings = append(portFlapSettings, portFlapSetting) d.Set("port_flap_settings", portFlapSettings) } - - qosTrafficClasses := make([]map[string]interface{}, 0, 1) - for _, qosTrafficClass := range logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.QosTrafficClassifiers { - qosClassificationMap := make([]map[string]interface{}, 0, 1) - if qosTrafficClass.QosClassificationMapping != nil { - - dot1pClassMap := make([]interface{}, 0) - for _, raw := range qosTrafficClass.QosClassificationMapping.Dot1pClassMapping { - dot1pClassMap = append(dot1pClassMap, raw) - } - - dscpClassMap := make([]interface{}, 0) - for _, raw := range qosTrafficClass.QosClassificationMapping.DscpClassMapping { - dscpClassMap = append(dscpClassMap, raw) - } - - qosClassificationMap = append(qosClassificationMap, map[string]interface{}{ - "dot1p_class_map": dot1pClassMap, - "dscp_class_map": dscpClassMap, - }) - - } - - qosTrafficClasses = append(qosTrafficClasses, map[string]interface{}{ - "name": qosTrafficClass.QosTrafficClass.ClassName, - "enabled": *qosTrafficClass.QosTrafficClass.Enabled, - "egress_dot1p_value": qosTrafficClass.QosTrafficClass.EgressDot1pValue, - "real_time": *qosTrafficClass.QosTrafficClass.RealTime, - "bandwidth_share": qosTrafficClass.QosTrafficClass.BandwidthShare, - "max_bandwidth": qosTrafficClass.QosTrafficClass.MaxBandwidth, - "qos_classification_map": qosClassificationMap, - }) - } - qosTrafficClassCount := d.Get("quality_of_service.0.qos_traffic_class.#").(int) - oneviewTrafficClassCount := len(qosTrafficClasses) - for i := 0; i < qosTrafficClassCount; i++ { - currName := d.Get("quality_of_service.0.qos_traffic_class." + strconv.Itoa(i) + ".name").(string) - for j := 0; j < oneviewTrafficClassCount; j++ { - if currName == qosTrafficClasses[j]["name"] && i <= j { - qosTrafficClasses[i], qosTrafficClasses[j] = qosTrafficClasses[j], qosTrafficClasses[i] - } - } - } - - qualityOfService := make([]map[string]interface{}, 0, 1) - qualityOfService = append(qualityOfService, map[string]interface{}{ - "type": logicalInterconnectGroup.QosConfiguration.Type, - "active_qos_config_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.Type, - "config_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.ConfigType, - "uplink_classification_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.UplinkClassificationType, - "downlink_classification_type": logicalInterconnectGroup.QosConfiguration.ActiveQosConfig.DownlinkClassificationType, - "qos_traffic_class": qosTrafficClasses, - }) - - d.Set("quality_of_service", qualityOfService) - return nil } @@ -1844,6 +2046,16 @@ func resourceLogicalInterconnectGroupDelete(d *schema.ResourceData, meta interfa return nil } +// GetIntPointer returns pointer of integer value +func GetIntPointer(value int) *int { + return &value +} + +// GetBoolPointer returns pointer of boolean value +func GetBoolPointer(value bool) *bool { + return &value +} + func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) @@ -2019,8 +2231,7 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa telemetryConfiguration.SampleInterval = val.(int) } if val, ok := d.GetOk(telemetryConfigPrefix + ".enabled"); ok { - enabled := val.(bool) - telemetryConfiguration.EnableTelemetry = &enabled + telemetryConfiguration.EnableTelemetry = GetBoolPointer(val.(bool)) } if telemetryConfiguration != (ov.TelemetryConfiguration{}) { telemetryConfiguration.Type = d.Get(telemetryConfigPrefix + ".type").(string) @@ -2071,8 +2282,7 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa sflowCollector := ov.SflowCollector{} if val, ok := d.GetOk(sflowCollectorPrefix + ".collector_enabled"); ok { - enabled := val.(bool) - sflowCollector.CollectorEnabled = &enabled + sflowCollector.CollectorEnabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(sflowCollectorPrefix + ".collector_id"); ok { @@ -2157,8 +2367,7 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa sflowConfiguration.Description = utils.NewNstring(val.(string)) } if val, ok := d.GetOk(sflowConfigurationPrefix + ".enabled"); ok { - enabled := val.(bool) - sflowConfiguration.Enabled = &enabled + sflowConfiguration.Enabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(sflowConfigurationPrefix + ".name"); ok { sflowConfiguration.Name = val.(string) @@ -2181,12 +2390,10 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa snmpConfigPrefix := fmt.Sprintf("snmp_configuration.0") snmpConfiguration := ov.SnmpConfiguration{} if val, ok := d.GetOk(snmpConfigPrefix + ".enabled"); ok { - enabled := val.(bool) - snmpConfiguration.Enabled = &enabled + snmpConfiguration.Enabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(snmpConfigPrefix + ".v3_enabled"); ok { - v3Enabled := val.(bool) - snmpConfiguration.V3Enabled = &v3Enabled + snmpConfiguration.V3Enabled = GetBoolPointer(val.(bool)) } if val, ok := d.GetOk(snmpConfigPrefix + ".read_community"); ok { snmpConfiguration.ReadCommunity = val.(string) @@ -2266,13 +2473,11 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa interconnectSettings.EnablePauseFloodProtection = &pauseFloodProtectionEnabled if val1, ok := d.GetOk(interconnectSettingsPrefix + ".rich_tlv"); ok { - enabled := val1.(bool) - interconnectSettings.EnableRichTLV = &enabled + interconnectSettings.EnableRichTLV = GetBoolPointer(val1.(bool)) } if val1, ok := d.GetOk(interconnectSettingsPrefix + ".interconnect_utilization_alert"); ok { - enabled := val1.(bool) - interconnectSettings.EnableInterconnectUtilizationAlert = &enabled + interconnectSettings.EnableInterconnectUtilizationAlert = GetBoolPointer(val1.(bool)) } if val1, ok := d.GetOk(interconnectSettingsPrefix + ".mac_refresh_interval"); ok { @@ -2283,16 +2488,12 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa lig.EthernetSettings = &interconnectSettings } - rawigmpsetting := d.Get("igmp_settings").(*schema.Set).List() + rawigmpsetting := d.Get("igmp_settings").([]interface{}) igmpSetting := ov.IgmpSettings{} for _, val := range rawigmpsetting { rawlval := val.(map[string]interface{}) - enableigmpsnooping := rawlval["igmp_snooping"].(bool) - enablepreventflooding := rawlval["prevent_flooding"].(bool) - enableproxyreporting := rawlval["proxy_reporting"].(bool) - igmpSetting.Created = rawlval["created"].(string) igmpSetting.Category = utils.Nstring(rawlval["category"].(string)) igmpSetting.Type = rawlval["type"].(string) @@ -2300,9 +2501,9 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa igmpSetting.DependentResourceUri = ligCall.IgmpSettings.DependentResourceUri igmpSetting.Description = rawlval["description"].(string) igmpSetting.ETAG = utils.Nstring(rawlval["etag"].(string)) - igmpSetting.EnableIgmpSnooping = &enableigmpsnooping - igmpSetting.EnablePreventFlooding = &enablepreventflooding - igmpSetting.EnableProxyReporting = &enableproxyreporting + igmpSetting.EnableIgmpSnooping = GetBoolPointer(rawlval["igmp_snooping"].(bool)) + igmpSetting.EnablePreventFlooding = GetBoolPointer(rawlval["prevent_flooding"].(bool)) + igmpSetting.EnableProxyReporting = GetBoolPointer(rawlval["proxy_reporting"].(bool)) igmpSetting.ID = rawlval["id"].(string) igmpSetting.IgmpIdleTimeoutInterval = rawlval["igmp_idle_timeout_interval"].(int) igmpSetting.IgmpSnoopingVlanIds = rawlval["igmp_snooping_vlan_ids"].(string) @@ -2314,7 +2515,7 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa } lig.IgmpSettings = &igmpSetting - rawPortFlapSetting := d.Get("port_flap_settings").(*schema.Set).List() + rawPortFlapSetting := d.Get("port_flap_settings").([]interface{}) PortFlapSetting := ov.PortFlapProtection{} for _, val := range rawPortFlapSetting { @@ -2337,93 +2538,155 @@ func resourceLogicalInterconnectGroupUpdate(d *schema.ResourceData, meta interfa PortFlapSetting.Status = rawlval["status"].(string) } lig.PortFlapProtection = &PortFlapSetting - - qualityOfServicePrefix := fmt.Sprintf("quality_of_service.0") - activeQosConfig := ov.ActiveQosConfig{} - - if val, ok := d.GetOk(qualityOfServicePrefix + ".config_type"); ok { - activeQosConfig.ConfigType = val.(string) - } - - if val, ok := d.GetOk(qualityOfServicePrefix + ".uplink_classification_type"); ok { - activeQosConfig.UplinkClassificationType = val.(string) - } - - if val, ok := d.GetOk(qualityOfServicePrefix + ".downlink_classification_type"); ok { - activeQosConfig.DownlinkClassificationType = val.(string) - } - - qosTrafficClassCount := d.Get(qualityOfServicePrefix + ".qos_traffic_class.#").(int) - qosTrafficClassifiers := make([]ov.QosTrafficClassifier, 0, 1) - for i := 0; i < qosTrafficClassCount; i++ { - qosTrafficClassPrefix := fmt.Sprintf(qualityOfServicePrefix+".qos_traffic_class.%d", i) - qosTrafficClassifier := ov.QosTrafficClassifier{} - qosClassMap := ov.QosClassificationMap{} - qosTrafficClass := ov.QosTrafficClass{} - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".name"); ok { - qosTrafficClass.ClassName = val.(string) - } - classEnabled := d.Get(qosTrafficClassPrefix + ".enabled").(bool) - qosTrafficClass.Enabled = &classEnabled - - realTimeEnabled := d.Get(qosTrafficClassPrefix + ".real_time").(bool) - qosTrafficClass.RealTime = &realTimeEnabled - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".egress_dot1p_value"); ok { - qosTrafficClass.EgressDot1pValue = val.(int) - } - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".bandwidth_share"); ok { - qosTrafficClass.BandwidthShare = val.(string) - } - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".max_bandwidth"); ok { - qosTrafficClass.MaxBandwidth = val.(int) - } - - qosTrafficClassifier.QosTrafficClass = qosTrafficClass - - if val, ok := d.GetOk(qosTrafficClassPrefix + ".qos_classification_map.0.dscp_class_map"); ok { - rawDscpClassMapping := val.(*schema.Set).List() - dscpClassMapping := make([]string, len(rawDscpClassMapping)) - for i, raw := range rawDscpClassMapping { - dscpClassMapping[i] = raw.(string) + if val, ok := d.GetOk("quality_of_service"); ok { + rawQoss := val.([]interface{}) + ovQos := ov.QosConfiguration{} + if len(rawQoss) != 0 { + for _, rawQosConfig := range rawQoss { + rawQos := rawQosConfig.(map[string]interface{}) + rawActiveQosConfigs := rawQos["active_qos_config"].([]interface{}) + ovActiveQosConfig := ov.ActiveQosConfig{} + if len(rawActiveQosConfigs) != 0 { + for _, rawActiveQosConfig := range rawActiveQosConfigs { + activeQosConfig := rawActiveQosConfig.(map[string]interface{}) + rawQosClassifiers := activeQosConfig["qos_traffic_classifiers"].([]interface{}) + ovQosTrafficClassifier := make([]ov.QosTrafficClassifier, 0) + if len(rawQosClassifiers) != 0 { + for _, rawQosClassifier := range rawQosClassifiers { + qosClassifier := rawQosClassifier.(map[string]interface{}) + ovQosClassificationMapping := ov.QosClassificationMapping{} + rawQosClassificationMappings := qosClassifier["qos_classification_mapping"].([]interface{}) + if rawQosClassificationMappings != nil { + for _, rawQosClassificationMapping := range rawQosClassificationMappings { + qosClassificationMapping := rawQosClassificationMapping.(map[string]interface{}) + rawDot1pClassMappings := qosClassificationMapping["dot1p_class_mapping"].([]interface{}) + if qosClassificationMapping["dot1p_class_mapping"] != nil { + dot1pClassMapping := make([]int, 0) + for _, raw := range rawDot1pClassMappings { + dot1pClassMapping = append(dot1pClassMapping, raw.(int)) + } + ovQosClassificationMapping.Dot1pClassMapping = dot1pClassMapping + } + rawDscpClassMappings := qosClassificationMapping["dscp_class_mapping"].([]interface{}) + if qosClassificationMapping["dscp_class_mapping"] != nil { + dscpClassMapping := make([]string, 0) + for _, raw := range rawDscpClassMappings { + dscpClassMapping = append(dscpClassMapping, raw.(string)) + } + ovQosClassificationMapping.DscpClassMapping = dscpClassMapping + } + } + } + ovQosTrafficClass := ov.QosTrafficClass{} + rawQosTrafficClasses := qosClassifier["qos_traffic_class"].([]interface{}) + if len(rawQosTrafficClasses) != 0 { + for _, rawQosTrafficClass := range rawQosTrafficClasses { + qosTrafficClass := rawQosTrafficClass.(map[string]interface{}) + rawDcbxConfigurations := qosTrafficClass["dcbx_configuration"].([]interface{}) + ovDcbxConfiguration := ov.DcbxConfigurations{} + if len(rawDcbxConfigurations) != 0 { + for _, rawDcbxConfiguration := range rawDcbxConfigurations { + dcbxConfiguration := rawDcbxConfiguration.(map[string]interface{}) + rawDcbxEtsPorts := dcbxConfiguration["dcbx_ets_port"].([]interface{}) + ovDcbxEtsPorts := make([]ov.DcbxEtsPort, 0) + if len(rawDcbxEtsPorts) != 0 { + for _, rawDcbxPort := range rawDcbxEtsPorts { + dcbxPort := rawDcbxPort.(map[string]interface{}) + ovDcbxEtsPorts = append(ovDcbxEtsPorts, ov.DcbxEtsPort{ + BayNumber: dcbxPort["bay_number"].(string), + EnclosureIndex: dcbxPort["enclosure_index"].(int), + IcmName: dcbxPort["icm_name"].(string), + MaxBandwidth: dcbxPort["max_bandwidth"].(string), + MinBandwidth: dcbxPort["min_bandwidth"].(string), + PortName: dcbxPort["port_name"].(string), + }) + } + } + ovDcbxConfiguration = ov.DcbxConfigurations{ + ApplicationProtocol: dcbxConfiguration["application_protocol"].(string), + DefaultMaximumBandwidth: dcbxConfiguration["default_max_bandwidth"].(string), + DefaultMinimumBandwidth: dcbxConfiguration["default_min_bandwidth"].(string), + PriorityCodePoint: dcbxConfiguration["priority_code_point"].(string), + PriorityFlowControl: dcbxConfiguration["priority_flow_control"].(string), + } + if len(ovDcbxEtsPorts) != 0 { + ovDcbxConfiguration.DcbxEtsPorts = ovDcbxEtsPorts + } + } + } + ovQosTrafficClass = ov.QosTrafficClass{ + BandwidthShare: qosTrafficClass["bandwidth_share"].(string), + ClassName: qosTrafficClass["class_name"].(string), + EgressDot1pValue: GetIntPointer(qosTrafficClass["egress_dot1p_value"].(int)), + Enabled: GetBoolPointer(qosTrafficClass["enabled"].(bool)), + MaxBandwidth: qosTrafficClass["max_bandwidth"].(int), + RealTime: GetBoolPointer(qosTrafficClass["real_time"].(bool)), + Roce: GetBoolPointer(qosTrafficClass["roce"].(bool)), + } + if !(reflect.DeepEqual(ovDcbxConfiguration, ov.DcbxConfigurations{})) { + ovQosTrafficClass.DcbxConfiguration = &ovDcbxConfiguration + } + } + } + if reflect.DeepEqual(ovQosClassificationMapping, ov.QosClassificationMapping{}) && ovQosTrafficClass == (ov.QosTrafficClass{}) { + continue + } else if reflect.DeepEqual(ovQosClassificationMapping, ov.QosClassificationMapping{}) { + ovQosTrafficClassifier = append(ovQosTrafficClassifier, ov.QosTrafficClassifier{ + QosTrafficClass: &ovQosTrafficClass, + }) + } else if ovQosTrafficClass == (ov.QosTrafficClass{}) { + ovQosTrafficClassifier = append(ovQosTrafficClassifier, ov.QosTrafficClassifier{ + QosClassificationMapping: &ovQosClassificationMapping, + }) + } else { + ovQosTrafficClassifier = append(ovQosTrafficClassifier, ov.QosTrafficClassifier{ + QosClassificationMapping: &ovQosClassificationMapping, + QosTrafficClass: &ovQosTrafficClass, + }) + } + } + } + ovActiveQosConfig = ov.ActiveQosConfig{ + Category: utils.NewNstring(activeQosConfig["category"].(string)), + ConfigType: activeQosConfig["config_type"].(string), + Created: activeQosConfig["created"].(string), + Description: utils.NewNstring(activeQosConfig["description"].(string)), + DownlinkClassificationType: activeQosConfig["downlink_classification_type"].(string), + ETAG: activeQosConfig["etag"].(string), + Modified: activeQosConfig["modified"].(string), + Name: activeQosConfig["name"].(string), + State: activeQosConfig["state"].(string), + Status: activeQosConfig["status"].(string), + Type: activeQosConfig["type"].(string), + UplinkClassificationType: activeQosConfig["uplink_classification_type"].(string), + URI: utils.NewNstring(activeQosConfig["uri"].(string)), + QosTrafficClassifiers: ovQosTrafficClassifier, + } + } + } + ovQos = ov.QosConfiguration{ + Category: rawQos["category"].(string), + ConsistencyChecking: rawQos["consistency_checking"].(string), + Created: rawQos["created"].(string), + Description: utils.NewNstring(rawQos["description"].(string)), + ETAG: rawQos["etag"].(string), + Modified: rawQos["modified"].(string), + Name: rawQos["name"].(string), + State: rawQos["state"].(string), + Status: rawQos["status"].(string), + Type: rawQos["type"].(string), + URI: utils.NewNstring(rawQos["uri"].(string)), + ActiveQosConfig: &ovActiveQosConfig, + } } - qosClassMap.DscpClassMapping = dscpClassMapping - } - if val, ok := d.GetOk(qosTrafficClassPrefix + ".qos_classification_map.0.dot1p_class_map"); ok { - rawDot1pClassMap := val.(*schema.Set).List() - dot1pClassMap := make([]int, len(rawDot1pClassMap)) - for i, raw := range rawDot1pClassMap { - dot1pClassMap[i] = raw.(int) - } - qosClassMap.Dot1pClassMapping = dot1pClassMap } - - qosTrafficClassifier.QosClassificationMapping = &qosClassMap - - qosTrafficClassifiers = append(qosTrafficClassifiers, qosTrafficClassifier) + lig.QosConfiguration = &ovQos } - activeQosConfig.QosTrafficClassifiers = qosTrafficClassifiers - - if !reflect.DeepEqual(activeQosConfig, (ov.ActiveQosConfig{})) { - activeQosConfig.Type = d.Get(qualityOfServicePrefix + ".active_qos_config_type").(string) - - qualityOfService := ov.QosConfiguration{ - Type: d.Get(qualityOfServicePrefix + ".type").(string), - ActiveQosConfig: activeQosConfig, - } - - lig.QosConfiguration = &qualityOfService - } - err := config.ovClient.UpdateLogicalInterconnectGroup(lig) if err != nil { return err } d.SetId(d.Get("name").(string)) - return resourceLogicalInterconnectGroupRead(d, meta) }