Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change raid type
Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
  • Loading branch information
hs0210 committed Jul 16, 2021
1 parent 78917d5 commit e30cfb1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ironic/resource_ironic_node_v1.go
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
baremetalhost "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic"
"github.com/mitchellh/mapstructure"
)

// Schema resource definition for an Ironic node.
Expand Down Expand Up @@ -177,7 +178,7 @@ func resourceNodeV1() *schema.Resource {
Computed: true,
},
"raid": {
Type: schema.TypeObject,
Type: schema.TypeMap,
Optional: true,
Computed: true,
},
Expand Down Expand Up @@ -609,8 +610,12 @@ func changePowerState(client *gophercloud.ServiceClient, d *schema.ResourceData,
// Call Ironic's API and clean the raid config
func setRAIDConfig(client *gophercloud.ServiceClient, d *schema.ResourceData) (err error) {
var logicalDisks []nodes.LogicalDisk
var raid *baremetalhost.RAIDConfig

raid := d.Get("raid").(*baremetalhost.RAIDConfig)
raidConfig := d.Get("raid").(map[string]interface{})
if err = mapstructure.Decode(raidConfig, &raid); err != nil {
return
}

// Build target for RAID configuration steps
logicalDisks, err = ironic.BuildTargetRAIDCfg(raid)
Expand All @@ -635,7 +640,12 @@ func setRAIDConfig(client *gophercloud.ServiceClient, d *schema.ResourceData) (e
}

func buildManualCleaningSteps(d *schema.ResourceData) (cleanSteps []nodes.CleanStep, err error) {
raid := d.Get("raid").(*baremetalhost.RAIDConfig)
var raid *baremetalhost.RAIDConfig

raidConfig := d.Get("raid").(map[string]interface{})
if err = mapstructure.Decode(raidConfig, &raid); err != nil {
return
}

// Build raid clean steps
if d.Get("raid_interface").(string) != "no-raid" {
Expand Down

0 comments on commit e30cfb1

Please sign in to comment.