Skip to content

Commit

Permalink
Merge pull request kubernetes#18959 from jsafrane/devel/cinder-tags
Browse files Browse the repository at this point in the history
Auto commit by PR queue bot
  • Loading branch information
k8s-merge-robot committed Jan 21, 2016
2 parents 7f25a4f + 815d1e0 commit 0f6f521
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/cloudprovider/providers/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion pkg/cloudprovider/providers/openstack/openstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/cinder/cinder_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f6f521

Please sign in to comment.