Merge pull request #18959 from jsafrane/devel/cinder-tags

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-01-21 03:33:58 -08:00
commit 0f6f521beb
3 changed files with 9 additions and 3 deletions

View File

@ -1033,7 +1033,7 @@ func (os *OpenStack) getVolume(diskName string) (volumes.Volume, error) {
}
// Create a volume of given size (in GiB)
func (os *OpenStack) CreateVolume(size int) (volumeName string, err error) {
func (os *OpenStack) CreateVolume(size int, tags *map[string]string) (volumeName string, err error) {
sClient, err := openstack.NewBlockStorageV1(os.provider, gophercloud.EndpointOpts{
Region: os.region,
@ -1045,6 +1045,9 @@ func (os *OpenStack) CreateVolume(size int) (volumeName string, err error) {
}
opts := volumes.CreateOpts{Size: size}
if tags != nil {
opts.Metadata = *tags
}
vol, err := volumes.Create(sClient, opts).Extract()
if err != nil {
glog.Errorf("Failed to create a %d GB volume: %v", size, err)

View File

@ -210,7 +210,10 @@ func TestVolumes(t *testing.T) {
t.Fatalf("Failed to construct/authenticate OpenStack: %s", err)
}
vol, err := os.CreateVolume(1)
tags := map[string]string{
"test": "value",
}
vol, err := os.CreateVolume(1, &tags)
if err != nil {
t.Fatalf("Cannot create a new Cinder volume: %v", err)
}

View File

@ -150,7 +150,7 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
volSizeBytes := c.options.Capacity.Value()
// Cinder works with gigabytes, convert to GiB with rounding up
volSizeGB := int(volume.RoundUpSize(volSizeBytes, 1024*1024*1024))
name, err := cloud.CreateVolume(volSizeGB)
name, err := cloud.CreateVolume(volSizeGB, c.options.CloudTags)
if err != nil {
glog.V(2).Infof("Error creating cinder volume: %v", err)
return "", 0, err