Add handling of address_type and subnetwork parameters Signed-off-by: Quentin Pradet <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3d07b079 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3d07b079 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3d07b079 Branch: refs/heads/trunk Commit: 3d07b079ec00417b55ed45700319cc1a36c3ac08 Parents: 3e62d86 Author: Jeremy Solarz <[email protected]> Authored: Fri Feb 23 10:03:39 2018 +0000 Committer: Quentin Pradet <[email protected]> Committed: Sun Feb 25 09:00:55 2018 +0400 ---------------------------------------------------------------------- libcloud/compute/drivers/gce.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/3d07b079/libcloud/compute/drivers/gce.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 497e24c..790b234 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -2866,6 +2866,20 @@ class GCENodeDriver(NodeDriver): address_data['address'] = address if description: address_data['description'] = description + if address_type: + if address_type not in ['EXTERNAL', 'INTERNAL']: + raise ValueError('ADDRESS_TYPE_WRONG', + 'Address type must be either EXTERNAL or \ + INTERNAL') + else: + address_data['addressType'] = address_type + if subnetwork and address_type != 'INTERNAL': + raise ValueError('INVALID_ARGUMENT_COMBINATION', + 'Address type must be internal if subnetwork \ + provided') + if subnetwork and not hasattr(subnetwork, 'name'): + subnetwork = \ + self.ex_get_subnetwork(subnetwork, region) if region == 'global': request = '/global/addresses' else:
