Skip to content

Commit

Permalink
Merge pull request #336 from akutz/bugfix/rackspace-attachment-fix
Browse files Browse the repository at this point in the history
Rackspace Get Volumes Attachment States Fix
  • Loading branch information
akutz authored Nov 12, 2016
2 parents ccdd3a0 + 5428d7a commit 89fac40
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions drivers/storage/rackspace/storage/rackspace_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (d *driver) Volumes(
ctx types.Context,
opts *types.VolumesOpts) ([]*types.Volume, error) {
// always return attachments to align against other drivers for now
return d.getVolume(ctx, "", "", types.VolAttReqTrue)
return d.getVolume(ctx, "", "", opts.Attachments)
}

// // VolumeInspect inspects a single volume.
Expand Down Expand Up @@ -592,31 +592,21 @@ func (d *driver) createVolume(
//Reformats from volumes.Volume to types.Volume credit to github.com/MatMaul
func translateVolume(
volume *volumes.Volume,
includeAttachments types.VolumeAttachmentsTypes) *types.Volume {
attachments types.VolumeAttachmentsTypes) *types.Volume {

var attachments []*types.VolumeAttachment
if includeAttachments.Requested() {
for _, attachment := range volume.Attachments {
libstorageAttachment := &types.VolumeAttachment{
VolumeID: attachment["volume_id"].(string),
var atts []*types.VolumeAttachment
if attachments.Requested() {
for _, att := range volume.Attachments {
lsAtt := &types.VolumeAttachment{
VolumeID: att["volume_id"].(string),
InstanceID: &types.InstanceID{
ID: attachment["server_id"].(string),
ID: att["server_id"].(string),
Driver: rackspace.Name},
DeviceName: attachment["device"].(string),
Status: "",
}
attachments = append(attachments, libstorageAttachment)
}
} else {
for _, attachment := range volume.Attachments {
libstorageAttachment := &types.VolumeAttachment{
VolumeID: attachment["volume_id"].(string),
InstanceID: &types.InstanceID{ID: attachment["server_id"].(string), Driver: rackspace.Name},
DeviceName: "",
Status: "",
if attachments.Devices() {
lsAtt.DeviceName = att["device"].(string)
}
attachments = append(attachments, libstorageAttachment)
break
atts = append(atts, lsAtt)
}
}

Expand All @@ -628,7 +618,7 @@ func translateVolume(
Type: volume.VolumeType,
IOPS: 0,
Size: int64(volume.Size),
Attachments: attachments,
Attachments: atts,
}
}

Expand Down

0 comments on commit 89fac40

Please sign in to comment.