@@ -257,12 +257,34 @@ func (f *IBMPIVolumeClient) GetVolumeFlashCopyMappings(id string) (models.FlashC
257
257
258
258
// Bulk volume detach
259
259
func (f * IBMPIVolumeClient ) BulkVolumeDetach (pvmID string , body * models.VolumesDetach ) (* models.VolumesDetachmentResponse , error ) {
260
- return nil , fmt .Errorf ("operation not supported" )
260
+ params := p_cloud_volumes .NewPcloudV2PvminstancesVolumesDeleteParams ().
261
+ WithContext (f .ctx ).WithTimeout (helpers .PIDeleteTimeOut ).WithCloudInstanceID (f .cloudInstanceID ).WithPvmInstanceID (pvmID ).
262
+ WithBody (body )
263
+ resp , err := f .session .Power .PCloudVolumes .PcloudV2PvminstancesVolumesDelete (params , f .session .AuthInfo (f .cloudInstanceID ))
264
+ if err != nil {
265
+ return nil , ibmpisession .SDKFailWithAPIError (err , fmt .Errorf (errors .DetachVolumesOperationFailed , pvmID , f .cloudInstanceID , err ))
266
+ }
267
+ if resp == nil || resp .Payload == nil {
268
+ return nil , fmt .Errorf ("failed detaching volumes for %s" , pvmID )
269
+ }
270
+ return resp .Payload , nil
261
271
}
262
272
263
273
// Bulk volume delete
264
274
func (f * IBMPIVolumeClient ) BulkVolumeDelete (body * models.VolumesDelete ) (* models.VolumesDeleteResponse , error ) {
265
- return nil , fmt .Errorf ("operation not supported" )
275
+ params := p_cloud_volumes .NewPcloudV2VolumesDeleteParams ().WithContext (f .ctx ).WithTimeout (helpers .PIDeleteTimeOut ).
276
+ WithCloudInstanceID (f .cloudInstanceID ).WithBody (body )
277
+ respOk , respPartial , err := f .session .Power .PCloudVolumes .PcloudV2VolumesDelete (params , f .session .AuthInfo (f .cloudInstanceID ))
278
+ if err != nil {
279
+ return nil , ibmpisession .SDKFailWithAPIError (err , fmt .Errorf (errors .DeleteVolumeOperationFailed , body .VolumeIDs , err ))
280
+ }
281
+ if respOk != nil && respOk .Payload != nil {
282
+ return respOk .Payload , nil
283
+ }
284
+ if respPartial != nil && respPartial .Payload != nil {
285
+ return respPartial .Payload , nil
286
+ }
287
+ return nil , fmt .Errorf ("failed Deleting volumes : %s" , body .VolumeIDs )
266
288
}
267
289
268
290
// Bulk volutme attach
0 commit comments