@@ -18,11 +18,11 @@ import (
1818 log "github.com/sirupsen/logrus"
1919
2020 "github.com/docker/go-plugins-helpers/volume"
21- "github.com/gophercloud/gophercloud"
22- "github.com/gophercloud/gophercloud/openstack"
23- "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes"
24- "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions /volumeattach"
25- "github.com/gophercloud/gophercloud/pagination"
21+ "github.com/gophercloud/gophercloud/v2 "
22+ "github.com/gophercloud/gophercloud/v2/ openstack"
23+ "github.com/gophercloud/gophercloud/v2/ openstack/blockstorage/v3/volumes"
24+ "github.com/gophercloud/gophercloud/v2/ openstack/compute/v2/volumeattach"
25+ "github.com/gophercloud/gophercloud/v2/ pagination"
2626)
2727
2828type plugin struct {
@@ -98,10 +98,10 @@ func (d plugin) Create(r *volume.CreateRequest) error {
9898 }
9999 }
100100
101- vol , err := volumes .Create (d .blockClient , volumes.CreateOpts {
101+ vol , err := volumes .Create (context . TODO (), d .blockClient , volumes.CreateOpts {
102102 Size : size ,
103103 Name : r .Name ,
104- }).Extract ()
104+ }, volumes. SchedulerHintOpts {} ).Extract ()
105105
106106 if err != nil {
107107 logger .WithError (err ).Errorf ("Error creating volume: %s" , err .Error ())
@@ -142,7 +142,7 @@ func (d plugin) List() (*volume.ListResponse, error) {
142142 var vols []* volume.Volume
143143
144144 pager := volumes .List (d .blockClient , volumes.ListOpts {})
145- err := pager .EachPage (func (page pagination.Page ) (bool , error ) {
145+ err := pager .EachPage (context . TODO (), func (ctx context. Context , page pagination.Page ) (bool , error ) {
146146 vList , _ := volumes .ExtractVolumes (page )
147147
148148 for _ , v := range vList {
@@ -189,7 +189,7 @@ func (d plugin) Mount(r *volume.MountRequest) (*volume.MountResponse, error) {
189189 }
190190 }
191191
192- if vol , err = volumes .Get (d .blockClient , vol .ID ).Extract (); err != nil {
192+ if vol , err = volumes .Get (context . TODO (), d .blockClient , vol .ID ).Extract (); err != nil {
193193 return nil , err
194194 }
195195
@@ -216,7 +216,7 @@ func (d plugin) Mount(r *volume.MountRequest) (*volume.MountResponse, error) {
216216 // Attaching block volume to compute instance
217217
218218 opts := volumeattach.CreateOpts {VolumeID : vol .ID }
219- _ , err = volumeattach .Create (d .computeClient , d .config .MachineID , opts ).Extract ()
219+ _ , err = volumeattach .Create (context . TODO (), d .computeClient , d .config .MachineID , opts ).Extract ()
220220
221221 if err != nil {
222222 logger .WithError (err ).Errorf ("Error attaching volume: %s" , err .Error ())
@@ -312,7 +312,7 @@ func (d plugin) Remove(r *volume.RemoveRequest) error {
312312
313313 logger .Debug ("Deleting block volume..." )
314314
315- err = volumes .Delete (d .blockClient , vol .ID , volumes.DeleteOpts {}).ExtractErr ()
315+ err = volumes .Delete (context . TODO (), d .blockClient , vol .ID , volumes.DeleteOpts {}).ExtractErr ()
316316 if err != nil {
317317 logger .WithError (err ).Errorf ("Error deleting volume: %s" , err .Error ())
318318 return err
@@ -361,7 +361,7 @@ func (d plugin) getByName(name string) (*volumes.Volume, error) {
361361 var volume * volumes.Volume
362362
363363 pager := volumes .List (d .blockClient , volumes.ListOpts {Name : name })
364- err := pager .EachPage (func (page pagination.Page ) (bool , error ) {
364+ err := pager .EachPage (context . TODO (), func (ctx context. Context , page pagination.Page ) (bool , error ) {
365365 vList , err := volumes .ExtractVolumes (page )
366366
367367 if err != nil {
@@ -387,7 +387,7 @@ func (d plugin) getByName(name string) (*volumes.Volume, error) {
387387
388388func (d plugin ) detachVolume (ctx context.Context , vol * volumes.Volume ) (* volumes.Volume , error ) {
389389 for _ , att := range vol .Attachments {
390- err := volumeattach .Delete (d .computeClient , att .ServerID , att .ID ).ExtractErr ()
390+ err := volumeattach .Delete (ctx , d .computeClient , att .ServerID , att .ID ).ExtractErr ()
391391 if err != nil {
392392 return nil , err
393393 }
@@ -404,7 +404,7 @@ func (d plugin) waitOnVolumeState(ctx context.Context, vol *volumes.Volume, stat
404404 for i := 1 ; i <= 10 ; i ++ {
405405 time .Sleep (500 * time .Millisecond )
406406
407- vol , err := volumes .Get (d .blockClient , vol .ID ).Extract ()
407+ vol , err := volumes .Get (ctx , d .blockClient , vol .ID ).Extract ()
408408 if err != nil {
409409 return nil , err
410410 }
0 commit comments