Use instance availability zone for AWS EBS

Signed-off-by: Sami Wagiaalla <swagiaal@redhat.com>
This commit is contained in:
Sami Wagiaalla 2015-06-22 12:29:33 -04:00
parent 7855d99bfd
commit 4a6a492281
2 changed files with 10 additions and 7 deletions

View File

@ -16,6 +16,6 @@ spec:
volumes:
- name: html-volume
awsElasticBlockStore:
# Enter the volume region and ID below
volumeID: aws://{region}/{volume ID}
# Enter the volume ID below
volumeID: volume_ID
fsType: ext4

View File

@ -1096,7 +1096,10 @@ type awsDisk struct {
az string
}
func newAWSDisk(ec2 EC2, name string) (*awsDisk, error) {
func newAWSDisk(aws *AWSCloud, name string) (*awsDisk, error) {
if !strings.HasPrefix(name, "aws://") {
name = "aws://" + aws.availabilityZone + "/" + name
}
// name looks like aws://availability-zone/id
url, err := url.Parse(name)
if err != nil {
@ -1123,7 +1126,7 @@ func newAWSDisk(ec2 EC2, name string) (*awsDisk, error) {
if az == "" {
return nil, fmt.Errorf("Invalid format for AWS volume (%s)", name)
}
disk := &awsDisk{ec2: ec2, name: name, awsID: awsID, az: az}
disk := &awsDisk{ec2: aws.ec2, name: name, awsID: awsID, az: az}
return disk, nil
}
@ -1246,7 +1249,7 @@ func (aws *AWSCloud) getAwsInstance(instanceName string) (*awsInstance, error) {
// Implements Volumes.AttachDisk
func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly bool) (string, error) {
disk, err := newAWSDisk(aws.ec2, diskName)
disk, err := newAWSDisk(aws, diskName)
if err != nil {
return "", err
}
@ -1301,7 +1304,7 @@ func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly b
// Implements Volumes.DetachDisk
func (aws *AWSCloud) DetachDisk(instanceName string, diskName string) error {
disk, err := newAWSDisk(aws.ec2, diskName)
disk, err := newAWSDisk(aws, diskName)
if err != nil {
return err
}
@ -1355,7 +1358,7 @@ func (aws *AWSCloud) CreateVolume(volumeOptions *VolumeOptions) (string, error)
// Implements Volumes.DeleteVolume
func (aws *AWSCloud) DeleteVolume(volumeName string) error {
awsDisk, err := newAWSDisk(aws.ec2, volumeName)
awsDisk, err := newAWSDisk(aws, volumeName)
if err != nil {
return err
}