Skip to content

Commit 58b1341

Browse files
uibmhkantare
authored andcommitted
Added support for volume bandwidth in vpc resources
1 parent b10da8b commit 58b1341

23 files changed

+803
-52
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.10
4444
github.com/IBM/vmware-go-sdk v0.1.3
4545
github.com/IBM/vpc-beta-go-sdk v0.8.0
46-
github.com/IBM/vpc-go-sdk v0.65.0
46+
github.com/IBM/vpc-go-sdk v0.66.0
4747
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
4848
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2
4949
github.com/akamai/AkamaiOPEN-edgegrid-golang/v5 v5.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ github.com/IBM/vmware-go-sdk v0.1.3 h1:uJL3kwzM0jAKsT6Gj9tE5xT9SZBVXVaJvZdxrSMx8
176176
github.com/IBM/vmware-go-sdk v0.1.3/go.mod h1:OyQKRInGGsBaOyE5LIZCqH7b1DZ01BvIYa8BgGy+wWo=
177177
github.com/IBM/vpc-beta-go-sdk v0.8.0 h1:cEPpv4iw3Ba5W2d0AWg3TIbKeJ8y1nPuUuibR5Jt9eE=
178178
github.com/IBM/vpc-beta-go-sdk v0.8.0/go.mod h1:hORgIyTFRzXrZIK9IohaWmCRBBlYiDRagsufi7M6akE=
179-
github.com/IBM/vpc-go-sdk v0.65.0 h1:wCOm4pPdrsPnnHlpLHrqntLdzEmyjafK5BfZdke/ntI=
180-
github.com/IBM/vpc-go-sdk v0.65.0/go.mod h1:VL7sy61ybg6tvA60SepoQx7TFe20m7JyNUt+se2tHP4=
179+
github.com/IBM/vpc-go-sdk v0.66.0 h1:S0HW+f6Qf6OLSGESQ7WRgWLq1bDgvs+vvOJ7AWgUMbw=
180+
github.com/IBM/vpc-go-sdk v0.66.0/go.mod h1:VL7sy61ybg6tvA60SepoQx7TFe20m7JyNUt+se2tHP4=
181181
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
182182
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
183183
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=

ibm/service/vpc/data_source_ibm_is_instance_template.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ func DataSourceIBMISInstanceTemplate() *schema.Resource {
292292
Computed: true,
293293
Description: "The globally unique name for the volume profile to use for this volume.",
294294
},
295+
"bandwidth": {
296+
Type: schema.TypeInt,
297+
Computed: true,
298+
},
295299
isInstanceTemplateVolAttVolCapacity: {
296300
Type: schema.TypeInt,
297301
Computed: true,
@@ -856,6 +860,10 @@ func DataSourceIBMISInstanceTemplate() *schema.Resource {
856860
Type: schema.TypeInt,
857861
Computed: true,
858862
},
863+
"bandwidth": {
864+
Type: schema.TypeInt,
865+
Computed: true,
866+
},
859867
isInstanceTemplateBootProfile: {
860868
Type: schema.TypeString,
861869
Computed: true,
@@ -1242,7 +1250,10 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
12421250
if volumeInst.ID != nil {
12431251
volumeAttach[isInstanceTemplateVolAttVolume] = *volumeInst.ID
12441252
}
1245-
1253+
// bandwidth changes
1254+
if volumeInst.Bandwidth != nil {
1255+
newVolume["bandwidth"] = volumeInst.Bandwidth
1256+
}
12461257
if volumeInst.Capacity != nil {
12471258
newVolume[isInstanceTemplateVolAttVolCapacity] = *volumeInst.Capacity
12481259
}
@@ -1278,6 +1289,10 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
12781289
volumeIntf := instance.BootVolumeAttachment.Volume
12791290
bootVol[isInstanceTemplateName] = volumeIntf.Name
12801291
bootVol[isInstanceTemplateVol] = volumeIntf.Name
1292+
// bandwidth changes
1293+
if volumeIntf.Bandwidth != nil {
1294+
bootVol["bandwidth"] = volumeIntf.Bandwidth
1295+
}
12811296
bootVol[isInstanceTemplateBootSize] = volumeIntf.Capacity
12821297
if instance.BootVolumeAttachment.Volume.Profile != nil {
12831298
volProfIntf := instance.BootVolumeAttachment.Volume.Profile
@@ -1579,7 +1594,10 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
15791594
if volumeInst.ID != nil {
15801595
volumeAttach[isInstanceTemplateVolAttVolume] = *volumeInst.ID
15811596
}
1582-
1597+
// bandwidth changes
1598+
if volumeInst.Bandwidth != nil {
1599+
newVolume["bandwidth"] = volumeInst.Bandwidth
1600+
}
15831601
if volumeInst.Capacity != nil {
15841602
newVolume[isInstanceTemplateVolAttVolCapacity] = *volumeInst.Capacity
15851603
}
@@ -1615,6 +1633,10 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
16151633
volumeIntf := instance.BootVolumeAttachment.Volume
16161634
bootVol[isInstanceTemplateName] = volumeIntf.Name
16171635
bootVol[isInstanceTemplateVol] = volumeIntf.Name
1636+
// bandwidth changes
1637+
if volumeIntf.Bandwidth != nil {
1638+
bootVol["bandwidth"] = volumeIntf.Bandwidth
1639+
}
16181640
bootVol[isInstanceTemplateBootSize] = volumeIntf.Capacity
16191641
if instance.BootVolumeAttachment.Volume.Profile != nil {
16201642
volProfIntf := instance.BootVolumeAttachment.Volume.Profile

ibm/service/vpc/data_source_ibm_is_instance_templates.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
314314
Computed: true,
315315
Description: "The maximum I/O operations per second (IOPS) for the volume.",
316316
},
317+
"bandwidth": {
318+
Type: schema.TypeInt,
319+
Computed: true,
320+
},
317321
isInstanceTemplateVolAttVolProfile: {
318322
Type: schema.TypeString,
319323
Computed: true,
@@ -914,6 +918,10 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
914918
Type: schema.TypeString,
915919
Computed: true,
916920
},
921+
"bandwidth": {
922+
Type: schema.TypeInt,
923+
Computed: true,
924+
},
917925
isInstanceTemplateBootVolumeTags: {
918926
Type: schema.TypeSet,
919927
Computed: true,
@@ -1246,7 +1254,10 @@ func dataSourceIBMISInstanceTemplatesRead(d *schema.ResourceData, meta interface
12461254
profile := volumeInst.Profile.(*vpcv1.VolumeProfileIdentity)
12471255
newVolume[isInstanceTemplateVolAttVolProfile] = profile.Name
12481256
}
1249-
1257+
// bandwidth changes
1258+
if volumeInst.Bandwidth != nil {
1259+
newVolume["bandwidth"] = volumeInst.Bandwidth
1260+
}
12501261
if volumeInst.Iops != nil {
12511262
newVolume[isInstanceTemplateVolAttVolIops] = *volumeInst.Iops
12521263
}
@@ -1280,6 +1291,10 @@ func dataSourceIBMISInstanceTemplatesRead(d *schema.ResourceData, meta interface
12801291
volProfInst := volProfIntf.(*vpcv1.VolumeProfileIdentity)
12811292
bootVol[isInstanceTemplateBootProfile] = volProfInst.Name
12821293
}
1294+
// bandwidth changes
1295+
if volumeIntf.Bandwidth != nil {
1296+
bootVol["bandwidth"] = volumeIntf.Bandwidth
1297+
}
12831298
if instance.BootVolumeAttachment.Volume.UserTags != nil {
12841299
bootVol[isInstanceTemplateBootVolumeTags] = instance.BootVolumeAttachment.Volume.UserTags
12851300
}

ibm/service/vpc/data_source_ibm_is_instance_volume_attachment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ func DataSourceIBMISInstanceVolumeAttachment() *schema.Resource {
7575
Computed: true,
7676
Description: "The type of volume attachment one of [ boot, data ]",
7777
},
78+
"bandwidth": {
79+
Type: schema.TypeInt,
80+
Computed: true,
81+
Description: "The maximum bandwidth (in megabits per second) for the volume when attached to this instance. This may be lower than the volume bandwidth depending on the configuration of the instance.",
82+
},
7883

7984
isInstanceVolumeAttVolumeReference: {
8085
Type: schema.TypeList,
@@ -142,6 +147,8 @@ func instanceVolumeAttachmentGetByName(d *schema.ResourceData, meta interface{},
142147
if *volumeAtt.Name == name {
143148
d.SetId(makeTerraformVolAttID(instanceId, *volumeAtt.ID))
144149
d.Set(isInstanceVolAttName, *volumeAtt.Name)
150+
// bandwidth changes
151+
d.Set("bandwidth", *volumeAtt.Bandwidth)
145152
d.Set(isInstanceVolumeDeleteOnInstanceDelete, *volumeAtt.DeleteVolumeOnInstanceDelete)
146153
d.Set(isInstanceVolumeAttDevice, *volumeAtt.Device.ID)
147154
d.Set(isInstanceVolumeAttHref, *volumeAtt.Href)

ibm/service/vpc/data_source_ibm_is_instance_volume_attachments.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func DataSourceIBMISInstanceVolumeAttachments() *schema.Resource {
3838
Computed: true,
3939
Description: "The user-defined name for this volume attachment.",
4040
},
41+
"bandwidth": {
42+
Type: schema.TypeInt,
43+
Computed: true,
44+
Description: "The maximum bandwidth (in megabits per second) for the volume when attached to this instance. This may be lower than the volume bandwidth depending on the configuration of the instance.",
45+
},
4146

4247
isInstanceVolumeAttDevice: {
4348
Type: schema.TypeString,
@@ -137,6 +142,8 @@ func instanceGetVolumeAttachments(d *schema.ResourceData, meta interface{}, inst
137142
for _, volumeAtt := range allrecs {
138143
currentVolAtt := map[string]interface{}{}
139144
currentVolAtt[isInstanceVolAttName] = *volumeAtt.Name
145+
// bandwidth changes
146+
currentVolAtt["bandwidth"] = *volumeAtt.Bandwidth
140147
currentVolAtt[isInstanceVolumeDeleteOnInstanceDelete] = *volumeAtt.DeleteVolumeOnInstanceDelete
141148
currentVolAtt[isInstanceVolumeAttDevice] = *volumeAtt.Device.ID
142149
currentVolAtt[isInstanceVolumeAttHref] = *volumeAtt.Href

0 commit comments

Comments
 (0)