Skip to content

Commit

Permalink
Add Attr_Provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptipowervs committed Mar 28, 2024
1 parent 2e4457c commit 22ab278
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
36 changes: 18 additions & 18 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ const (
Attr_VPCCRNs = "vpc_crns"
Attr_VPCEnabled = "vpc_enabled"
Attr_VirtualCoresAssigned = "virtual_cores_assigned"
Attr_VolumeAttachStatus = "volume_attach_status"
Attr_VolumeGroupName = "volume_group_name"
Attr_VolumeGroups = "volume_groups"
Attr_VolumeIDs = "volume_ids"
Attr_VolumePool = "volume_pool"
Attr_VolumeSnapshots = "volume_snapshots"
Attr_Volumes = "volumes"
Attr_WWN = "wwn"
Attr_Workspaces = "workspaces"
//Attr_VolumeAttachStatus = "volume_attach_status"
Attr_VolumeGroupName = "volume_group_name"
Attr_VolumeGroups = "volume_groups"
Attr_VolumeIDs = "volume_ids"
Attr_VolumePool = "volume_pool"
Attr_VolumeSnapshots = "volume_snapshots"
Attr_Volumes = "volumes"
Attr_WWN = "wwn"
Attr_Workspaces = "workspaces"

// TODO: Second Half Cleanup, remove extra variables

Expand Down Expand Up @@ -335,15 +335,15 @@ const (
PIPlacementGroupMembers = "members"

// Volume
PIAffinityPolicy = "pi_affinity_policy"
PIAffinityVolume = "pi_affinity_volume"
PIAffinityInstance = "pi_affinity_instance"
PIAntiAffinityInstances = "pi_anti_affinity_instances"
PIAntiAffinityVolumes = "pi_anti_affinity_volumes"
PIVolumeIds = "pi_volume_ids"
PIVolumeAllowableAttachStatus = "in-use"
PIVolumeProvisioning = "creating"
PIVolumeProvisioningDone = "available"
PIAffinityPolicy = "pi_affinity_policy"
PIAffinityVolume = "pi_affinity_volume"
PIAffinityInstance = "pi_affinity_instance"
PIAntiAffinityInstances = "pi_anti_affinity_instances"
PIAntiAffinityVolumes = "pi_anti_affinity_volumes"
PIVolumeIds = "pi_volume_ids"
Attr_VolumeAllowableAttachStatus = "in-use"
Attr_VolumeProvisioning = "creating"
Attr_VolumeProvisioningDone = "available"

// Volume Clone
PIVolumeCloneName = "pi_volume_clone_name"
Expand Down
16 changes: 8 additions & 8 deletions ibm/service/power/resource_ibm_pi_volume_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func resourceIBMPIVolumeAttachCreate(ctx context.Context, d *schema.ResourceData
log.Printf("Volume State /Status is permitted and hence attaching the volume to the instance")
}

if volinfo.State == PIVolumeAllowableAttachStatus && !*volinfo.Shareable {
if volinfo.State == Attr_VolumeAllowableAttachStatus && !*volinfo.Shareable {
return diag.Errorf("the volume cannot be attached in the current state. The volume must be in the *available* state. No other states are permissible")
}

Expand Down Expand Up @@ -173,8 +173,8 @@ func isWaitForIBMPIVolumeAttachAvailable(ctx context.Context, client *instance.I
log.Printf("Waiting for Volume (%s) to be available for attachment", id)

stateConf := &resource.StateChangeConf{
Pending: []string{"retry", PIVolumeProvisioning},
Target: []string{PIVolumeAllowableAttachStatus},
Pending: []string{"retry", Attr_VolumeProvisioning},
Target: []string{Attr_VolumeAllowableAttachStatus},
Refresh: isIBMPIVolumeAttachRefreshFunc(client, id, cloudInstanceID, pvmInstanceID),
Delay: 10 * time.Second,
MinTimeout: 30 * time.Second,
Expand All @@ -192,10 +192,10 @@ func isIBMPIVolumeAttachRefreshFunc(client *instance.IBMPIVolumeClient, id, clou
}

if vol.State == "in-use" && flex.StringContains(vol.PvmInstanceIDs, pvmInstanceID) {
return vol, PIVolumeAllowableAttachStatus, nil
return vol, Attr_VolumeAllowableAttachStatus, nil
}

return vol, PIVolumeProvisioning, nil
return vol, Attr_VolumeProvisioning, nil
}
}

Expand All @@ -204,7 +204,7 @@ func isWaitForIBMPIVolumeDetach(ctx context.Context, client *instance.IBMPIVolum

stateConf := &resource.StateChangeConf{
Pending: []string{"detaching", Attr_PowerVolumeAttachDeleting},
Target: []string{PIVolumeProvisioningDone},
Target: []string{Attr_VolumeProvisioningDone},
Refresh: isIBMPIVolumeDetachRefreshFunc(client, id, cloudInstanceID, pvmInstanceID),
Delay: 10 * time.Second,
MinTimeout: 30 * time.Second,
Expand All @@ -222,7 +222,7 @@ func isIBMPIVolumeDetachRefreshFunc(client *instance.IBMPIVolumeClient, id, clou
switch uErr.(type) {
case *p_cloud_volumes.PcloudCloudinstancesVolumesGetNotFound:
log.Printf("[DEBUG] volume does not exist while detaching %v", err)
return vol, PIVolumeProvisioningDone, nil
return vol, Attr_VolumeProvisioningDone, nil
}
return nil, "", err
}
Expand All @@ -232,7 +232,7 @@ func isIBMPIVolumeDetachRefreshFunc(client *instance.IBMPIVolumeClient, id, clou
// In case of Sharable Volume it can be `in-use` state
if !flex.StringContains(vol.PvmInstanceIDs, pvmInstanceID) &&
(*vol.Shareable || (!*vol.Shareable && vol.State == "available")) {
return vol, PIVolumeProvisioningDone, nil
return vol, Attr_VolumeProvisioningDone, nil
}

return vol, "detaching", nil
Expand Down

0 comments on commit 22ab278

Please sign in to comment.