Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use default availability zone when creating EBS volumes #1437

Open
wants to merge 1 commit into from

2 participants

@rfkrocktk

Presently, in the EC2Connection.create_volume method, zone is a required parameter despite the fact that the CreateVolume describes it as being optional. Thus, with this patch, we only include it if it's not None.

@rfkrocktk rfkrocktk Use default availability zone when creating EBS volumes
Presently, in the `EC2Connection.create_volume` method, `zone` is a required parameter despite the fact that the [CreateVolume](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html) describes it as being optional. Thus, with this patch, we only include it if it's not `None`.
fd64fee
@toastdriven toastdriven commented on the diff
boto/ec2/connection.py
@@ -1662,7 +1662,7 @@ def modify_volume_attribute(self, volume_id, attribute, new_value):
params['AutoEnableIO.Value'] = new_value
return self.get_status('ModifyVolumeAttribute', params, verb='POST')
- def create_volume(self, size, zone, snapshot=None,
+ def create_volume(self, size, zone = None, snapshot=None,

PEP-8/consistency with the rest of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@toastdriven

Thanks for the pull request, patch looks good save for the one bit of feedback I had. However, to get this merged, we need some tests to make sure we don't regress as mentioned in the contributing guide.

If you could write some tests, that would help a lot. Otherwise this will have to wait until a core dev can find some time to write tests for this.

Thanks again for the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 11, 2013
  1. @rfkrocktk

    Use default availability zone when creating EBS volumes

    rfkrocktk authored
    Presently, in the `EC2Connection.create_volume` method, `zone` is a required parameter despite the fact that the [CreateVolume](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html) describes it as being optional. Thus, with this patch, we only include it if it's not `None`.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +6 −4 boto/ec2/connection.py
View
10 boto/ec2/connection.py
@@ -1662,7 +1662,7 @@ def modify_volume_attribute(self, volume_id, attribute, new_value):
params['AutoEnableIO.Value'] = new_value
return self.get_status('ModifyVolumeAttribute', params, verb='POST')
- def create_volume(self, size, zone, snapshot=None,
+ def create_volume(self, size, zone = None, snapshot=None,

PEP-8/consistency with the rest of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
volume_type=None, iops=None):
"""
Create a new EBS Volume.
@@ -1671,7 +1671,8 @@ def create_volume(self, size, zone, snapshot=None,
:param size: The size of the new volume, in GiB
:type zone: string or :class:`boto.ec2.zone.Zone`
- :param zone: The availability zone in which the Volume will be created.
+ :param zone: The availability zone in which the Volume will be created (optional).
+ If None, will be set to the default availability zone.
:type snapshot: string or :class:`boto.ec2.snapshot.Snapshot`
:param snapshot: The snapshot from which the new Volume will be
@@ -1685,9 +1686,10 @@ def create_volume(self, size, zone, snapshot=None,
:param iops: The provisioned IOPs you want to associate with
this volume. (optional)
"""
- if isinstance(zone, Zone):
+ if zone and isinstance(zone, Zone):
zone = zone.name
- params = {'AvailabilityZone': zone}
+ params = {'AvailabilityZone': zone}
+
if size:
params['Size'] = size
if snapshot:
Something went wrong with that request. Please try again.