Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume From Snapshot Development And Migration PR #4245

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/IBM/scc-go-sdk/v4 v4.0.2
github.com/IBM/schematics-go-sdk v0.2.1
github.com/IBM/secrets-manager-go-sdk v0.1.19
github.com/IBM/vpc-go-sdk v0.27.0
github.com/IBM/vpc-go-sdk v0.28.0
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
github.com/Shopify/sarama v1.29.1
github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ github.com/IBM/go-sdk-core/v5 v5.5.1/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723
github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek=
github.com/IBM/go-sdk-core/v5 v5.6.5/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek=
github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc0XQUqRO9Jc=
github.com/IBM/go-sdk-core/v5 v5.7.2/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc0XQUqRO9Jc=
github.com/IBM/go-sdk-core/v5 v5.8.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc0XQUqRO9Jc=
github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
Expand Down Expand Up @@ -106,6 +107,8 @@ github.com/IBM/secrets-manager-go-sdk v0.1.19 h1:0GPs5EoTaWNsjo4QPj64GNxlWfN8VHJ
github.com/IBM/secrets-manager-go-sdk v0.1.19/go.mod h1:eO3dBhzPrHkkt+yPex/jB2xD6qHZxBko+Aw+0tfqHeA=
github.com/IBM/vpc-go-sdk v0.27.0 h1:PBpgjh5bjxrMT5BlaHfyaiJ/71pvycbmVQMuPOQ33ZY=
github.com/IBM/vpc-go-sdk v0.27.0/go.mod h1:jYjS3EySPkC7DuOg33gMHtm8DcIf75Tc+Gxo3zmMBTQ=
github.com/IBM/vpc-go-sdk v0.28.0 h1:cOxzyxqjSZZqdSY0EiQEAzAGAVtYh2JBcvbve6OZguc=
github.com/IBM/vpc-go-sdk v0.28.0/go.mod h1:jYjS3EySPkC7DuOg33gMHtm8DcIf75Tc+Gxo3zmMBTQ=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
Expand Down
4 changes: 2 additions & 2 deletions ibm/service/vpc/data_source_ibm_is_instance_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
volumeAttach[isInstanceTemplateVolAttName] = *volume.Name
volumeAttach[isInstanceTemplateDeleteVolume] = *volume.DeleteVolumeOnInstanceDelete
volumeIntf := volume.Volume
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentVolumePrototypeInstanceContext)
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentPrototypeVolume)
newVolumeArr := []map[string]interface{}{}
newVolume := map[string]interface{}{}

Expand Down Expand Up @@ -817,7 +817,7 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
volumeAttach[isInstanceTemplateVolAttName] = *volume.Name
volumeAttach[isInstanceTemplateDeleteVolume] = *volume.DeleteVolumeOnInstanceDelete
volumeIntf := volume.Volume
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentVolumePrototypeInstanceContext)
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentPrototypeVolume)
newVolumeArr := []map[string]interface{}{}
newVolume := map[string]interface{}{}

Expand Down
2 changes: 1 addition & 1 deletion ibm/service/vpc/data_source_ibm_is_instance_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func dataSourceIBMISInstanceTemplatesRead(d *schema.ResourceData, meta interface
volumeAttach[isInstanceTemplateVolAttName] = *volume.Name
volumeAttach[isInstanceTemplateDeleteVolume] = *volume.DeleteVolumeOnInstanceDelete
volumeIntf := volume.Volume
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentVolumePrototypeInstanceContext)
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentPrototypeVolume)
newVolumeArr := []map[string]interface{}{}
newVolume := map[string]interface{}{}

Expand Down
50 changes: 50 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,38 @@ func DataSourceIBMISVolume() *schema.Resource {
Computed: true,
Description: "Link to documentation about this status reason",
},

isVolumeHealthReasons: {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
isVolumeHealthReasonsCode: {
Type: schema.TypeString,
Computed: true,
Description: "A snake case string succinctly identifying the reason for this health state.",
},

isVolumeHealthReasonsMessage: {
Type: schema.TypeString,
Computed: true,
Description: "An explanation of the reason for this health state.",
},

isVolumeHealthReasonsMoreInfo: {
Type: schema.TypeString,
Computed: true,
Description: "Link to documentation about the reason for this health state.",
},
},
},
},

isVolumeHealthState: {
Type: schema.TypeString,
Computed: true,
Description: "The health of this resource.",
},
},
},
},
Expand Down Expand Up @@ -271,6 +303,24 @@ func volumeGet(d *schema.ResourceData, meta interface{}, name string) error {
}
d.Set(isVolumeStatusReasons, statusReasonsList)
}
if vol.HealthReasons != nil {
healthReasonsList := make([]map[string]interface{}, 0)
for _, sr := range vol.HealthReasons {
currentSR := map[string]interface{}{}
if sr.Code != nil && sr.Message != nil {
currentSR[isVolumeHealthReasonsCode] = *sr.Code
currentSR[isVolumeHealthReasonsMessage] = *sr.Message
if sr.MoreInfo != nil {
currentSR[isVolumeHealthReasonsMoreInfo] = *sr.Message
}
healthReasonsList = append(healthReasonsList, currentSR)
}
}
d.Set(isVolumeHealthReasons, healthReasonsList)
}
if vol.HealthState != nil {
d.Set(isVolumeHealthState, *vol.HealthState)
}
controller, err := flex.GetBaseController(meta)
if err != nil {
return err
Expand Down
57 changes: 57 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,37 @@ func DataSourceIBMIsVolumes() *schema.Resource {
Set: flex.ResourceIBMVPCHash,
Description: "Access management tags for the volume instance",
},
isVolumeHealthReasons: {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
isVolumeHealthReasonsCode: {
Type: schema.TypeString,
Computed: true,
Description: "A snake case string succinctly identifying the reason for this health state.",
},

isVolumeHealthReasonsMessage: {
Type: schema.TypeString,
Computed: true,
Description: "An explanation of the reason for this health state.",
},

isVolumeHealthReasonsMoreInfo: {
Type: schema.TypeString,
Computed: true,
Description: "Link to documentation about the reason for this health state.",
},
},
},
},

isVolumeHealthState: {
Type: schema.TypeString,
Computed: true,
Description: "The health of this resource.",
},
},
},
},
Expand Down Expand Up @@ -639,13 +670,23 @@ func dataSourceVolumeCollectionVolumesToMap(volumesItem vpcv1.Volume, meta inter
if volumesItem.Status != nil {
volumesMap[isVolumesStatus] = volumesItem.Status
}
if volumesItem.HealthState != nil {
volumesMap[isVolumeHealthState] = volumesItem.HealthState
}
if volumesItem.StatusReasons != nil {
statusReasonsList := []map[string]interface{}{}
for _, statusReasonsItem := range volumesItem.StatusReasons {
statusReasonsList = append(statusReasonsList, dataSourceVolumeCollectionVolumesStatusReasonsToMap(statusReasonsItem))
}
volumesMap[isVolumesStatusReasons] = statusReasonsList
}
if volumesItem.HealthReasons != nil {
healthReasonsList := []map[string]interface{}{}
for _, healthReasonsItem := range volumesItem.HealthReasons {
healthReasonsList = append(healthReasonsList, dataSourceVolumeCollectionVolumesHealthReasonsToMap(healthReasonsItem))
}
volumesMap[isVolumeHealthReasons] = healthReasonsList
}
if volumesItem.VolumeAttachments != nil {
volumeAttachmentsList := []map[string]interface{}{}
for _, volumeAttachmentsItem := range volumesItem.VolumeAttachments {
Expand Down Expand Up @@ -812,6 +853,22 @@ func dataSourceVolumeCollectionVolumesStatusReasonsToMap(statusReasonsItem vpcv1
return statusReasonsMap
}

func dataSourceVolumeCollectionVolumesHealthReasonsToMap(statusReasonsItem vpcv1.VolumeHealthReason) (healthReasonsMap map[string]interface{}) {
healthReasonsMap = map[string]interface{}{}

if statusReasonsItem.Code != nil {
healthReasonsMap[isVolumeHealthReasonsCode] = statusReasonsItem.Code
}
if statusReasonsItem.Message != nil {
healthReasonsMap[isVolumeHealthReasonsMessage] = statusReasonsItem.Message
}
if statusReasonsItem.MoreInfo != nil {
healthReasonsMap[isVolumeHealthReasonsMoreInfo] = statusReasonsItem.MoreInfo
}

return healthReasonsMap
}

func dataSourceVolumeCollectionVolumesVolumeAttachmentsToMap(volumeAttachmentsItem vpcv1.VolumeAttachmentReferenceVolumeContext) (volumeAttachmentsMap map[string]interface{}) {
volumeAttachmentsMap = map[string]interface{}{}

Expand Down
10 changes: 5 additions & 5 deletions ibm/service/vpc/resource_ibm_is_instance_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,18 +741,18 @@ func instanceTemplateCreate(d *schema.ResourceData, meta interface{}, profile, n
// Handle volume attachments
if volsintf, ok := d.GetOk(isInstanceTemplateVolumeAttachments); ok {
vols := volsintf.([]interface{})
var intfs []vpcv1.VolumeAttachmentPrototypeInstanceContext
var intfs []vpcv1.VolumeAttachmentPrototype
for _, resource := range vols {
vol := resource.(map[string]interface{})
volInterface := &vpcv1.VolumeAttachmentPrototypeInstanceContext{}
volInterface := &vpcv1.VolumeAttachmentPrototype{}
deleteVolBool := vol[isInstanceTemplateVolumeDeleteOnInstanceDelete].(bool)
volInterface.DeleteVolumeOnInstanceDelete = &deleteVolBool
attachmentnamestr := vol[isInstanceTemplateVolAttachmentName].(string)
volInterface.Name = &attachmentnamestr
volIdStr := vol[isInstanceTemplateVolAttVol].(string)

if volIdStr != "" {
volInterface.Volume = &vpcv1.VolumeAttachmentVolumePrototypeInstanceContextVolumeIdentity{
volInterface.Volume = &vpcv1.VolumeAttachmentPrototypeVolume{
ID: &volIdStr,
}
} else {
Expand All @@ -761,7 +761,7 @@ func instanceTemplateCreate(d *schema.ResourceData, meta interface{}, profile, n
profileName := newvol[isInstanceTemplateVolAttVolProfile].(string)
capacity := int64(newvol[isInstanceTemplateVolAttVolCapacity].(int))

volPrototype := &vpcv1.VolumeAttachmentVolumePrototypeInstanceContextVolumePrototypeInstanceContext{
volPrototype := &vpcv1.VolumeAttachmentPrototypeVolumeVolumePrototypeInstanceContext{
Profile: &vpcv1.VolumeProfileIdentity{
Name: &profileName,
},
Expand Down Expand Up @@ -1215,7 +1215,7 @@ func instanceTemplateGet(d *schema.ResourceData, meta interface{}, ID string) er
newVolumeArr := []map[string]interface{}{}
newVolume := map[string]interface{}{}
volumeIntf := volume.Volume
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentVolumePrototypeInstanceContext)
volumeInst := volumeIntf.(*vpcv1.VolumeAttachmentPrototypeVolume)
if volumeInst.ID != nil {
volumeAttach[isInstanceTemplateVolAttVol] = *volumeInst.ID
}
Expand Down
Loading