Skip to content

Commit

Permalink
Multiple value support (#188)
Browse files Browse the repository at this point in the history
* multiple value support changes added
  • Loading branch information
AnikaAgiwal2711 committed Jun 13, 2024
1 parent b1c5d81 commit da21f45
Show file tree
Hide file tree
Showing 8 changed files with 348 additions and 78 deletions.
2 changes: 1 addition & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ Required:

- `is_mdm_or_tb` (String) Is Mdm Or Tb
- `operating_system` (String) Operating System
- `password` (String, Sensitive) Password used to log in to the node.

Optional:

Expand All @@ -227,6 +226,7 @@ Optional:
- `mdm_ips` (String) MDM IP addresses used to communicate with other PowerFlex components in the storage network. This is required for all MDMs, Tiebreakers and Standbys.Leave this field blank for hosts that are not part of the MDM cluster.
- `mdm_mgmt_ip` (String) This IP address is for the management-only network. The management ip is not required for Tiebreaker MDM, Standby Tiebreaker MDM and any host that is not an MDM.
- `mdm_name` (String) MDMName
- `password` (String, Sensitive) Password used to log in to the node.
- `perf_profile_for_mdm` (String) Performance Profile For MDM
- `perf_profile_for_sdc` (String) Performance Profile For SDC
- `perf_profile_for_sdr` (String) Performance Profile For SDR
Expand Down
21 changes: 21 additions & 0 deletions docs/resources/firmware_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ resource "powerflex_firmware_repository" "upload-test" {
- `id` (String) ID of the Firmware Repository
- `name` (String) Name of the Firmware Repository

## Import

Import is supported using the following syntax:

```shell
# /*
# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
# Licensed under the Mozilla Public License Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://mozilla.org/MPL/2.0/
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# */

# import firmware respository by it's id
terraform import powerflex_firmware_repository.fr_import_by_id "<id>"
```
17 changes: 17 additions & 0 deletions examples/resources/powerflex_firmware_repository/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# /*
# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
# Licensed under the Mozilla Public License Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://mozilla.org/MPL/2.0/
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# */

# import firmware respository by it's id
terraform import powerflex_firmware_repository.fr_import_by_id "<id>"


72 changes: 46 additions & 26 deletions powerflex/helper/cluster_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ func UpdateClusterState(plan models.ClusterResourceModel, gatewayClient *goscale
Name: types.StringValue(mdm.Name),
IP: types.StringValue(strings.Join(mdm.Node.NodeIPs, ",")),
MDMIP: types.StringValue(strings.Join(mdm.MdmIPs, ",")),
Role: types.StringValue(string("TieBreaker")),
Mode: types.StringValue(string("Standby")),
Role: types.StringValue("TieBreaker"),
Mode: types.StringValue("Standby"),
}

mdmList = append(mdmList, mdmData)
Expand All @@ -380,11 +380,12 @@ func UpdateClusterState(plan models.ClusterResourceModel, gatewayClient *goscale
mdmData := models.MDMModel{
ID: types.StringValue(id),
Name: types.StringValue(mastMDM.Name),
IP: types.StringValue(strings.Join(mastMDM.Node.NodeIPs, ",")),
IP: types.StringValue(getIP(mastMDM.ManagementIPs, mastMDM.Node.NodeIPs)),
MGMTIP: types.StringValue(strings.Join(mastMDM.ManagementIPs, ",")),
MDMIP: types.StringValue(strings.Join(mastMDM.MdmIPs, ",")),
VirtualIPNIC: types.StringValue(strings.Join(mastMDM.VirtIPIntfsList, ",")),
Role: types.StringValue(string("Manager")),
Mode: types.StringValue(string("Primary")),
Role: types.StringValue("Manager"),
Mode: types.StringValue("Primary"),
}

if len(clusteDetailResponse.ClusterDetails.VirtualIPs) > 0 {
Expand All @@ -406,6 +407,13 @@ func UpdateClusterState(plan models.ClusterResourceModel, gatewayClient *goscale
return state, diags
}

func getIP(managementIPs []string, nodeIPs []string) string {
if len(managementIPs) > 0 {
return strings.Join(managementIPs, ",")
}
return strings.Join(nodeIPs, ",")
}

// GetPDType returns the Protection Domain Detail type
func GetPDType() map[string]attr.Type {
return map[string]attr.Type{
Expand Down Expand Up @@ -584,7 +592,13 @@ func GetMDMIPFromClusterDetails(clusterInstallationDetailsDataModel []models.Clu

for _, item := range clusterInstallationDetailsDataModel {
if strings.EqualFold(item.IsMdmOrTb.ValueString(), "Primary") {
mdmIP = item.IP.ValueString()
if item.MDMMgmtIP.ValueString() != "" {
mdmIP = item.MDMMgmtIP.ValueString()
} else if item.MDMIP.ValueString() != "" {
mdmIP = item.MDMIP.ValueString()
} else {
mdmIP = item.IP.ValueString()
}
return mdmIP, nil
}
}
Expand Down Expand Up @@ -677,11 +691,17 @@ func ParseClusterCSVOperation(ctx context.Context, gatewayClient *goscaleio.Gate
// Check which columns have non-empty values in the current row
var columnsWithValues []int
for i, value := range data {
if value != "" {

if i == 2 {
//we have to add the Password column no matter if it's value is empty or not.
columnsWithValues = append(columnsWithValues, i)
filteredHeader = append(filteredHeader, header[i])
} else if i != 2 && value != "" {
columnsWithValues = append(columnsWithValues, i)
// Add the corresponding header to the filteredHeader
filteredHeader = append(filteredHeader, header[i])
}

}

// Update the header indices to write based on the current row's non-empty columns
Expand Down Expand Up @@ -834,47 +854,47 @@ func getFieldFromStorage(item models.StoragePoolDataModel, header string) string
func getFieldFromItem(item models.ClusterModel, header string) string {
switch header {
case "IPs":
return item.IP.ValueString()
return "\"" + item.IP.ValueString() + "\""
case "Username":
return item.UserName.ValueString()
case "Password":
return item.Password.ValueString()
case "Operating System":
return item.OperatingSystem.ValueString()
case "Is MDM/TB":
return item.IsMdmOrTb.ValueString()
return "\"" + item.IsMdmOrTb.ValueString() + "\""
case "MDM Mgmt IP":
return item.MDMMgmtIP.ValueString()
return "\"" + item.MDMMgmtIP.ValueString() + "\""
case "MDM IPs":
return item.MDMIP.ValueString()
return "\"" + item.MDMIP.ValueString() + "\""
case "MDM Name":
return item.MDMName.ValueString()
case "perfProfileForMDM":
return item.PerfProfileForMDM.ValueString()
case "Virtual IPs":
return item.VirtualIPs.ValueString()
return "\"" + item.VirtualIPs.ValueString() + "\""
case "Virtual IP NICs":
return item.VirtualIPNICs.ValueString()
return "\"" + item.VirtualIPNICs.ValueString() + "\""
case "Is SDS":
return item.IsSds.ValueString()
case "SDS Name":
return item.SDSName.ValueString()
case "SDS All IPs":
return item.SDSAllIPs.ValueString()
return "\"" + item.SDSAllIPs.ValueString() + "\""
case "SDS-SDS Only IPs":
return item.SDSToSDSOnlyIPs.ValueString()
return "\"" + item.SDSToSDSOnlyIPs.ValueString() + "\""
case "SDS-SDC Only IPs":
return item.SDSToSDCOnlyIPs.ValueString()
return "\"" + item.SDSToSDCOnlyIPs.ValueString() + "\""
case "Protection Domain":
return item.ProtectionDomain.ValueString()
case "Fault Set":
return item.FaultSet.ValueString()
case "SDS Storage Device List":
return item.SDSStorageDeviceList.ValueString()
return "\"" + item.SDSStorageDeviceList.ValueString() + "\""
case "StoragePool List":
return item.StoragePoolList.ValueString()
return "\"" + item.StoragePoolList.ValueString() + "\""
case "SDS Storage Device Names":
return item.SDSStorageDeviceNames.ValueString()
return "\"" + item.SDSStorageDeviceNames.ValueString() + "\""
case "perfProfileForSDS":
return item.PerfProfileForSDS.ValueString()
case "Is SDC":
Expand All @@ -886,21 +906,21 @@ func getFieldFromItem(item models.ClusterModel, header string) string {
case "RFcache":
return item.IsRFCache.ValueString()
case "RFcache SSD Device List":
return item.RFcacheSSDDeviceList.ValueString()
return "\"" + item.RFcacheSSDDeviceList.ValueString() + "\""
case "Is SDR":
return item.IsSdr.ValueString()
case "SDR Name":
return item.SDRName.ValueString()
case "SDR Port":
return item.SDRPort.ValueString()
return "\"" + item.SDRPort.ValueString() + "\""
case "SDR Application IPs":
return item.SDRApplicationIPs.ValueString()
return "\"" + item.SDRApplicationIPs.ValueString() + "\""
case "SDR Storage IPs":
return item.SDRStorageIPs.ValueString()
return "\"" + item.SDRStorageIPs.ValueString() + "\""
case "SDR External IPs":
return item.SDRExternalIPs.ValueString()
return "\"" + item.SDRExternalIPs.ValueString() + "\""
case "SDR All IPs":
return item.SDRAllIPS.ValueString()
return "\"" + item.SDRAllIPS.ValueString() + "\""
case "perfProfileForSDR":
return item.PerfProfileForSDR.ValueString()
default:
Expand All @@ -914,7 +934,7 @@ func GetClusterDetails(model models.ClusterResourceModel, gatewayClient *goscale
"mdmUser": "admin",
"mdmPassword": model.MdmPassword.ValueString(),
}
mapData["mdmIps"] = []string{mdmIP}
mapData["mdmIps"] = strings.Split(mdmIP, ",")

secureData := map[string]interface{}{
"allowNonSecureCommunicationWithMdm": model.AllowNonSecureCommunicationWithMdm.ValueBool(),
Expand Down
Loading

0 comments on commit da21f45

Please sign in to comment.