From 5dd6efbc78eee8b16595c1459cf6415834b2e2b5 Mon Sep 17 00:00:00 2001 From: nabhajit-ray Date: Wed, 4 Jan 2023 16:12:21 +0530 Subject: [PATCH 1/3] fix the issue #505 --- .../data_source_server_profile_template.go | 36 ++++++++++--------- oneview/resource_server_profile.go | 3 +- oneview/resource_server_profile_template.go | 13 +++++-- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/oneview/data_source_server_profile_template.go b/oneview/data_source_server_profile_template.go index 5184ae6e..f27f0164 100644 --- a/oneview/data_source_server_profile_template.go +++ b/oneview/data_source_server_profile_template.go @@ -1127,25 +1127,29 @@ func dataSourceServerProfileTemplateRead(d *schema.ResourceData, meta interface{ for i := 0; i < len(spt.ConnectionSettings.Connections); i++ { // Gets Boot for Connection iscsi := make([]map[string]interface{}, 0, 1) - if spt.ConnectionSettings.Connections[i].Boot.Iscsi != nil { - iscsi = append(iscsi, map[string]interface{}{ - "chap_level": spt.ConnectionSettings.Connections[i].Boot.Iscsi.Chaplevel, - "initiator_name_source": spt.ConnectionSettings.Connections[i].Boot.Iscsi.InitiatorNameSource, - "first_boot_target_ip": spt.ConnectionSettings.Connections[i].Boot.Iscsi.FirstBootTargetIp, - "first_boot_target_port": spt.ConnectionSettings.Connections[i].Boot.Iscsi.FirstBootTargetPort, - "second_boot_target_ip": spt.ConnectionSettings.Connections[i].Boot.Iscsi.SecondBootTargetIp, - "second_boot_target_port": spt.ConnectionSettings.Connections[i].Boot.Iscsi.SecondBootTargetPort, - }) - } - // Get Boot targets list targets := make([]map[string]interface{}, 0) - if len(spt.ConnectionSettings.Connections[i].Boot.Targets) != 0 { - for j := 0; j < len(spt.ConnectionSettings.Connections[i].Boot.Targets); j++ { - targets = append(targets, map[string]interface{}{ - "array_wwpn": spt.ConnectionSettings.Connections[i].Boot.Targets[j].ArrayWWPN, - "lun": spt.ConnectionSettings.Connections[i].Boot.Targets[j].LUN, + if spt.ConnectionSettings.Connections[i].Boot != nil { + if spt.ConnectionSettings.Connections[i].Boot.Iscsi != nil { + iscsi = append(iscsi, map[string]interface{}{ + "chap_level": spt.ConnectionSettings.Connections[i].Boot.Iscsi.Chaplevel, + "initiator_name_source": spt.ConnectionSettings.Connections[i].Boot.Iscsi.InitiatorNameSource, + "first_boot_target_ip": spt.ConnectionSettings.Connections[i].Boot.Iscsi.FirstBootTargetIp, + "first_boot_target_port": spt.ConnectionSettings.Connections[i].Boot.Iscsi.FirstBootTargetPort, + "second_boot_target_ip": spt.ConnectionSettings.Connections[i].Boot.Iscsi.SecondBootTargetIp, + "second_boot_target_port": spt.ConnectionSettings.Connections[i].Boot.Iscsi.SecondBootTargetPort, }) } + + // Get Boot targets list + + if len(spt.ConnectionSettings.Connections[i].Boot.Targets) != 0 { + for j := 0; j < len(spt.ConnectionSettings.Connections[i].Boot.Targets); j++ { + targets = append(targets, map[string]interface{}{ + "array_wwpn": spt.ConnectionSettings.Connections[i].Boot.Targets[j].ArrayWWPN, + "lun": spt.ConnectionSettings.Connections[i].Boot.Targets[j].LUN, + }) + } + } } // Gets Boot Settings diff --git a/oneview/resource_server_profile.go b/oneview/resource_server_profile.go index 1120c584..dc21ad80 100644 --- a/oneview/resource_server_profile.go +++ b/oneview/resource_server_profile.go @@ -2120,6 +2120,7 @@ func resourceServerProfileRead(d *schema.ResourceData, meta interface{}) error { } } // extracts MpSettings to re-set password + valmpp := flattenMp(d) if valmpp != nil { vals := valmpp["administrator_account"].([]interface{}) @@ -2377,7 +2378,7 @@ func resourceServerProfileRead(d *schema.ResourceData, meta interface{}) error { for _, connection := range serverProfile.ConnectionSettings.Connections { iscsi := make([]map[string]interface{}, 0, 1) connectionBoot := make([]map[string]interface{}, 0, 1) - bootTargets := make([]map[string]interface{}, 0, len(connection.Boot.Targets)) + bootTargets := make([]map[string]interface{}, 0, 1) // Gets Boot Settings if connection.Boot != nil { diff --git a/oneview/resource_server_profile_template.go b/oneview/resource_server_profile_template.go index 4025219e..65da8368 100644 --- a/oneview/resource_server_profile_template.go +++ b/oneview/resource_server_profile_template.go @@ -1745,9 +1745,16 @@ func resourceServerProfileTemplateCreate(d *schema.ResourceData, meta interface{ func flattenMp(d *schema.ResourceData) map[string]interface{} { if val, ok := d.GetOk("management_processor"); ok { valn := val.([]interface{}) - vall := valn[0].(map[string]interface{}) - valmp := vall["mp_settings"].([]interface{}) - return valmp[0].(map[string]interface{}) + if len(valn) != 0 { + vall := valn[0].(map[string]interface{}) + if len(vall) != 0 { + valmp := vall["mp_settings"].([]interface{}) + if len(valmp) != 0 { + return valmp[0].(map[string]interface{}) + } + } + } + } return nil } From c2d81ae5e9be5ecfd288386bf05aca4a04d2467c Mon Sep 17 00:00:00 2001 From: nabhajit-ray Date: Mon, 9 Jan 2023 11:11:27 +0530 Subject: [PATCH 2/3] fix the issue #505 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f09c516..4ecd391e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html - This release supports API4600 minimally where we can use OneView v8.10 with this SDK. #### Major Changes +### Bug fixes & Enhancements: + +- [#505](https://github.com/HewlettPackard/terraform-provider-oneview/issues/505) server profile changes for the management processor are not properly being handled + 1. Removed Image Streamer support. ### Oneview Features supported - Appliance SNMPv1 Trap Destinations From 82a5ca7e0848fa5e420009d4110517d8096e1a5d Mon Sep 17 00:00:00 2001 From: nabhajit-ray Date: Mon, 9 Jan 2023 11:12:26 +0530 Subject: [PATCH 3/3] fix the issue #505 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ecd391e..64bcb7c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html - This release supports API4600 minimally where we can use OneView v8.10 with this SDK. #### Major Changes +1. Removed Image Streamer support. + ### Bug fixes & Enhancements: - [#505](https://github.com/HewlettPackard/terraform-provider-oneview/issues/505) server profile changes for the management processor are not properly being handled - -1. Removed Image Streamer support. ### Oneview Features supported - Appliance SNMPv1 Trap Destinations - Appliance SNMPv3 Trap Destinations