You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2019/07/18 09:23:09 UTC
[GitHub] [libcloud] Kami commented on a change in pull request #1205: [ec2]
Add subnet modification method
Kami commented on a change in pull request #1205: [ec2] Add subnet modification method
URL: https://github.com/apache/libcloud/pull/1205#discussion_r304819265
##########
File path: libcloud/compute/drivers/ec2.py
##########
@@ -2796,6 +2796,41 @@ def ex_create_subnet(self, vpc_id, cidr_block,
return subnet
+ def ex_modify_subnet_attribute(self, subnet, attribute='auto_public_ip',
+ value=False):
+ """
+ Modifies a subnet attribute.
+ You can only modify one attribute at a time.
+
+ :param subnet: The subnet to delete
+ :type subnet: :class:`.EC2NetworkSubnet`
+
+ :param attribute: The attribute to set on the subnet; one of:
+ ``'auto_public_ip'``: Automatically allocate a
+ public IP address when a server is created
+ ``'auto_ipv6'``: Automatically assign an IPv6
+ address when a server is created
+ :type attribute: ``str``
+
+ :param value: The value to set the subnet attribute to
+ (defaults to ``False``)
+ :type value: ``bool``
+
+ :rtype: ``bool``
+ """
+ params = {'Action': 'ModifySubnetAttribute', 'SubnetId': subnet.id}
+
+ if attribute == 'auto_public_ip':
+ params['MapPublicIpOnLaunch.Value'] = value
+ elif attribute == 'auto_ipv6':
+ params['AssignIpv6AddressOnCreation.Value'] = value
+ else:
+ return False
Review comment:
I think it would be better to throw in this case - e.g. ``raise ValueError('Unsupported attribute: %s' % (attribute))``.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services