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: volumes:
- name: html-volume - name: html-volume
awsElasticBlockStore: awsElasticBlockStore:
# Enter the volume region and ID below # Enter the volume ID below
volumeID: aws://{region}/{volume ID} volumeID: volume_ID
fsType: ext4 fsType: ext4

View File

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