Skip to content

Commit

Permalink
Merge pull request #284 from HewlettPackard/LigIssue
Browse files Browse the repository at this point in the history
LIG Read Issue #285
  • Loading branch information
AsisBagga authored Mar 31, 2021
2 parents 7cdcceb + 25e1864 commit e75e9bf
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 25 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)

# [v6.1.0-12](Unreleased)
# [v6.1.0-12] (Unreleased)

### Bug fixes & Enhancements:
- [#277] (https://github.com/HewlettPackard/terraform-provider-oneview/issues/277) SPT Import configuration issue
- [#285] (https://github.com/HewlettPackard/terraform-provider-oneview/issues/285) Terraform crashes for Logical Interconnect Group Read.

# [v6.0.0-12]
### Notes
Expand Down
23 changes: 23 additions & 0 deletions data_source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
provider "oneview" {
ov_username = var.username
ov_password = var.password
ov_endpoint = var.endpoint
ov_sslverify = var.ssl_enabled
ov_apiversion = 2600
ov_ifmatch = "*"
}

# Test for data source
/*
data "oneview_logical_interconnect_group" "logical_interconnect_group" {
name = "TestLIG5"
}
output "lig_value" {
value = data.oneview_logical_interconnect_group.logical_interconnect_group.redundancy_type
}
*/
# Importing an existing resource from appliance
resource "oneview_logical_interconnect_group" "import_lig" {
}

52 changes: 28 additions & 24 deletions oneview/resource_logical_interconnect_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ func resourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interface

interconnectSettings := make([]map[string]interface{}, 0, 1)
interconnectSetting := map[string]interface{}{
"type": logicalInterconnectGroup.EthernetSettings.Type,
"type": logicalInterconnectGroup.EthernetSettings.Type,
"fast_mac_cache_failover": *logicalInterconnectGroup.EthernetSettings.EnableFastMacCacheFailover,
"network_loop_protection": *logicalInterconnectGroup.EthernetSettings.EnableNetworkLoopProtection,
"pause_flood_protection": *logicalInterconnectGroup.EthernetSettings.EnablePauseFloodProtection,
Expand All @@ -1729,16 +1729,16 @@ func resourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interface
if logicalInterconnectGroup.IgmpSettings != nil {
igmpSettings := make([]map[string]interface{}, 0, 1)
igmpSetting := map[string]interface{}{
"category": logicalInterconnectGroup.IgmpSettings.Category,
"consistency_checking": logicalInterconnectGroup.IgmpSettings.ConsistencyChecking,
"created": logicalInterconnectGroup.IgmpSettings.Created,
"dependent_resource_uri": logicalInterconnectGroup.IgmpSettings.DependentResourceUri,
"description": logicalInterconnectGroup.IgmpSettings.Description,
"etag": logicalInterconnectGroup.IgmpSettings.ETAG,
"igmp_snooping": *logicalInterconnectGroup.IgmpSettings.EnableIgmpSnooping,
"prevent_flooding": *logicalInterconnectGroup.IgmpSettings.EnablePreventFlooding,
"proxy_reporting": *logicalInterconnectGroup.IgmpSettings.EnableProxyReporting,
"id": logicalInterconnectGroup.IgmpSettings.ID,
"category": logicalInterconnectGroup.IgmpSettings.Category,
"consistency_checking": logicalInterconnectGroup.IgmpSettings.ConsistencyChecking,
"created": logicalInterconnectGroup.IgmpSettings.Created,
"dependent_resource_uri": logicalInterconnectGroup.IgmpSettings.DependentResourceUri,
"description": logicalInterconnectGroup.IgmpSettings.Description,
"etag": logicalInterconnectGroup.IgmpSettings.ETAG,
"igmp_snooping": *logicalInterconnectGroup.IgmpSettings.EnableIgmpSnooping,
"prevent_flooding": *logicalInterconnectGroup.IgmpSettings.EnablePreventFlooding,
"proxy_reporting": *logicalInterconnectGroup.IgmpSettings.EnableProxyReporting,
"id": logicalInterconnectGroup.IgmpSettings.ID,
"igmp_idle_timeout_interval": logicalInterconnectGroup.IgmpSettings.IgmpIdleTimeoutInterval,
"igmp_snooping_vlan_ids": logicalInterconnectGroup.IgmpSettings.IgmpSnoopingVlanIds,
"modified": logicalInterconnectGroup.IgmpSettings.Modified,
Expand Down Expand Up @@ -1778,21 +1778,25 @@ func resourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interface

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 {

dscpClassMap := make([]interface{}, len(qosTrafficClass.QosClassificationMapping.DscpClassMapping))
for i, dscpValue := range qosTrafficClass.QosClassificationMapping.DscpClassMapping {
dscpClassMap[i] = dscpValue
}
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,
})

dot1pClassMap := make([]interface{}, len(qosTrafficClass.QosClassificationMapping.Dot1pClassMapping))
for i, dot1pValue := range qosTrafficClass.QosClassificationMapping.Dot1pClassMapping {
dot1pClassMap[i] = dot1pValue
}
qosClassificationMap := make([]map[string]interface{}, 0, 1)
qosClassificationMap = append(qosClassificationMap, map[string]interface{}{
"dot1p_class_map": schema.NewSet(func(a interface{}) int { return a.(int) }, dot1pClassMap),
"dscp_class_map": schema.NewSet(schema.HashString, dscpClassMap),
})

qosTrafficClasses = append(qosTrafficClasses, map[string]interface{}{
"name": qosTrafficClass.QosTrafficClass.ClassName,
Expand All @@ -1817,7 +1821,7 @@ func resourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interface

qualityOfService := make([]map[string]interface{}, 0, 1)
qualityOfService = append(qualityOfService, map[string]interface{}{
"type": logicalInterconnectGroup.QosConfiguration.Type,
"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,
Expand Down

0 comments on commit e75e9bf

Please sign in to comment.