Skip to content

Commit

Permalink
Merge pull request ansible#48 from modular-magician/codegen-pr-337
Browse files Browse the repository at this point in the history
Switch compute/disk type to be a resource reference instead of string.
  • Loading branch information
nat-henderson committed Jul 10, 2018
2 parents 7cb378b + d46889b commit 3303fc5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/ansible/modules/cloud/google/gcp_compute_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@

from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
import json
import re
import time

################################################################################
Expand Down Expand Up @@ -471,7 +472,7 @@ def resource_to_request(module):
u'name': module.params.get('name'),
u'sizeGb': module.params.get('size_gb'),
u'sourceImage': module.params.get('source_image'),
u'type': module.params.get('type')
u'type': disk_type_selflink(module.params.get('type'), module.params)
}
return_vals = {}
for k, v in request.items():
Expand Down Expand Up @@ -554,6 +555,15 @@ def response_to_hash(module, response):
}


def disk_type_selflink(name, params):
if name is None:
return
url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/{zone}/diskTypes/[a-z1-9\-]*"
if not re.match(url, name):
name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/diskTypes/%s".format(**params) % name
return name


def async_op_url(module, extra_data=None):
if extra_data is None:
extra_data = {}
Expand Down

0 comments on commit 3303fc5

Please sign in to comment.