@@ -18,7 +18,9 @@ package cinder
18
18
19
19
import (
20
20
"errors"
21
+ "fmt"
21
22
"os"
23
+ "strings"
22
24
"time"
23
25
24
26
"github.com/golang/glog"
@@ -139,7 +141,26 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
139
141
// Cinder works with gigabytes, convert to GiB with rounding up
140
142
volSizeGB := int (volume .RoundUpSize (volSizeBytes , 1024 * 1024 * 1024 ))
141
143
name := volume .GenerateVolumeName (c .options .ClusterName , c .options .PVName , 255 ) // Cinder volume name can have up to 255 characters
142
- name , err = cloud .CreateVolume (name , volSizeGB , c .options .CloudTags )
144
+ vtype := ""
145
+ availability := ""
146
+ // Apply ProvisionerParameters (case-insensitive). We leave validation of
147
+ // the values to the cloud provider.
148
+ for k , v := range c .options .Parameters {
149
+ switch strings .ToLower (k ) {
150
+ case "type" :
151
+ vtype = v
152
+ case "availability" :
153
+ availability = v
154
+ default :
155
+ return "" , 0 , fmt .Errorf ("invalid option %q for volume plugin %s" , k , c .plugin .GetPluginName ())
156
+ }
157
+ }
158
+ // TODO: implement c.options.ProvisionerSelector parsing
159
+ if c .options .Selector != nil {
160
+ return "" , 0 , fmt .Errorf ("claim.Spec.Selector is not supported for dynamic provisioning on Cinder" )
161
+ }
162
+
163
+ name , err = cloud .CreateVolume (name , volSizeGB , vtype , availability , c .options .CloudTags )
143
164
if err != nil {
144
165
glog .V (2 ).Infof ("Error creating cinder volume: %v" , err )
145
166
return "" , 0 , err
0 commit comments