Bug fixes for GCP modules (#52616)

This commit is contained in:
The Magician 2019-02-20 13:27:05 -08:00 committed by ansibot
parent a94d16adef
commit a6752f002b
4 changed files with 118 additions and 7 deletions

View file

@ -435,6 +435,7 @@ sourceType:
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
import json import json
import re
import time import time
################################################################################ ################################################################################
@ -628,6 +629,15 @@ def response_to_hash(module, response):
} }
def license_selflink(name, params):
if name is None:
return
url = r"https://www.googleapis.com/compute/v1//projects/.*/global/licenses/[a-z1-9\-]*"
if not re.match(url, name):
name = "https://www.googleapis.com/compute/v1//projects/{project}/global/licenses/%s".format(**params) % name
return name
def async_op_url(module, extra_data=None): def async_op_url(module, extra_data=None):
if extra_data is None: if extra_data is None:
extra_data = {} extra_data = {}

View file

@ -54,6 +54,8 @@ options:
routes. routes.
required: false required: false
type: bool type: bool
aliases:
- ip_forward
disks: disks:
description: description:
- An array of disks that are associated with the instances that are created from - An array of disks that are associated with the instances that are created from
@ -137,6 +139,9 @@ options:
create a disk with one of the public operating system images, specify create a disk with one of the public operating system images, specify
the image by its family name. the image by its family name.
required: false required: false
aliases:
- image
- image_family
source_image_encryption_key: source_image_encryption_key:
description: description:
- The customer-supplied encryption key of the source image. Required if - The customer-supplied encryption key of the source image. Required if
@ -889,7 +894,7 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
can_ip_forward=dict(type='bool'), can_ip_forward=dict(type='bool', aliases=['ip_forward']),
disks=dict( disks=dict(
type='list', type='list',
elements='dict', elements='dict',
@ -905,7 +910,7 @@ def main():
disk_name=dict(type='str'), disk_name=dict(type='str'),
disk_size_gb=dict(type='int'), disk_size_gb=dict(type='int'),
disk_type=dict(type='str'), disk_type=dict(type='str'),
source_image=dict(type='str'), source_image=dict(type='str', aliases=['image', 'image_family']),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))), source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
), ),
), ),

View file

@ -51,12 +51,30 @@ options:
interconnect: interconnect:
description: description:
- URL of the underlying Interconnect object that this attachment's traffic will - URL of the underlying Interconnect object that this attachment's traffic will
traverse through. traverse through. Required if type is DEDICATED, must not be set if type is
required: true PARTNER.
required: false
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
required: false required: false
edge_availability_domain:
description:
- Desired availability domain for the attachment. Only available for type PARTNER,
at creation time. For improved reliability, customers should configure a pair
of attachments with one per availability domain. The selected availability domain
will be provided to the Partner via the pairing key so that the provisioned
circuit will lie in the specified domain. If not specified, the value will default
to AVAILABILITY_DOMAIN_ANY.
required: false
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
required: false
choices:
- DEDICATED
- PARTNER
- PARTNER_PROVIDER
router: router:
description: description:
- URL of the cloud router to be used for dynamic routing. This router must be - URL of the cloud router to be used for dynamic routing. This router must be
@ -128,7 +146,7 @@ customerRouterIpAddress:
interconnect: interconnect:
description: description:
- URL of the underlying Interconnect object that this attachment's traffic will - URL of the underlying Interconnect object that this attachment's traffic will
traverse through. traverse through. Required if type is DEDICATED, must not be set if type is PARTNER.
returned: success returned: success
type: str type: str
description: description:
@ -136,6 +154,30 @@ description:
- An optional description of this resource. - An optional description of this resource.
returned: success returned: success
type: str type: str
edgeAvailabilityDomain:
description:
- Desired availability domain for the attachment. Only available for type PARTNER,
at creation time. For improved reliability, customers should configure a pair
of attachments with one per availability domain. The selected availability domain
will be provided to the Partner via the pairing key so that the provisioned circuit
will lie in the specified domain. If not specified, the value will default to
AVAILABILITY_DOMAIN_ANY.
returned: success
type: str
pairingKey:
description:
- '[Output only for type PARTNER. Not present for DEDICATED]. The opaque identifier
of an PARTNER attachment used to initiate provisioning with a selected partner.
Of the form "XXXXX/region/domain" .'
returned: success
type: str
partnerAsn:
description:
- "[Output only for type PARTNER. Not present for DEDICATED]. Optional BGP ASN for
the router that should be supplied by a layer 3 Partner if they configured BGP
on behalf of the customer."
returned: success
type: str
privateInterconnectInfo: privateInterconnectInfo:
description: description:
- Information specific to an InterconnectAttachment. This property is populated - Information specific to an InterconnectAttachment. This property is populated
@ -149,6 +191,16 @@ privateInterconnectInfo:
going to and from this network and region. going to and from this network and region.
returned: success returned: success
type: int type: int
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
returned: success
type: str
state:
description:
- "[Output Only] The current state of this attachment's functionality."
returned: success
type: str
googleReferenceId: googleReferenceId:
description: description:
- Google reference ID, to be used when raising support tickets with Google or otherwise - Google reference ID, to be used when raising support tickets with Google or otherwise
@ -226,8 +278,10 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
interconnect=dict(required=True, type='str'), interconnect=dict(type='str'),
description=dict(type='str'), description=dict(type='str'),
edge_availability_domain=dict(type='str'),
type=dict(type='str', choices=['DEDICATED', 'PARTNER', 'PARTNER_PROVIDER']),
router=dict(required=True), router=dict(required=True),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
candidate_subnets=dict(type='list', elements='str'), candidate_subnets=dict(type='list', elements='str'),
@ -286,6 +340,8 @@ def resource_to_request(module):
u'kind': 'compute#interconnectAttachment', u'kind': 'compute#interconnectAttachment',
u'interconnect': module.params.get('interconnect'), u'interconnect': module.params.get('interconnect'),
u'description': module.params.get('description'), u'description': module.params.get('description'),
u'edgeAvailabilityDomain': module.params.get('edge_availability_domain'),
u'type': module.params.get('type'),
u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'), u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'),
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'candidateSubnets': module.params.get('candidate_subnets'), u'candidateSubnets': module.params.get('candidate_subnets'),
@ -359,7 +415,12 @@ def response_to_hash(module, response):
u'customerRouterIpAddress': response.get(u'customerRouterIpAddress'), u'customerRouterIpAddress': response.get(u'customerRouterIpAddress'),
u'interconnect': response.get(u'interconnect'), u'interconnect': response.get(u'interconnect'),
u'description': response.get(u'description'), u'description': response.get(u'description'),
u'edgeAvailabilityDomain': response.get(u'edgeAvailabilityDomain'),
u'pairingKey': response.get(u'pairingKey'),
u'partnerAsn': response.get(u'partnerAsn'),
u'privateInterconnectInfo': InterconnectAttachmentPrivateinterconnectinfo(response.get(u'privateInterconnectInfo', {}), module).from_response(), u'privateInterconnectInfo': InterconnectAttachmentPrivateinterconnectinfo(response.get(u'privateInterconnectInfo', {}), module).from_response(),
u'type': response.get(u'type'),
u'state': response.get(u'state'),
u'googleReferenceId': response.get(u'googleReferenceId'), u'googleReferenceId': response.get(u'googleReferenceId'),
u'router': response.get(u'router'), u'router': response.get(u'router'),
u'creationTimestamp': response.get(u'creationTimestamp'), u'creationTimestamp': response.get(u'creationTimestamp'),

View file

@ -84,7 +84,8 @@ items:
interconnect: interconnect:
description: description:
- URL of the underlying Interconnect object that this attachment's traffic will - URL of the underlying Interconnect object that this attachment's traffic will
traverse through. traverse through. Required if type is DEDICATED, must not be set if type is
PARTNER.
returned: success returned: success
type: str type: str
description: description:
@ -92,6 +93,30 @@ items:
- An optional description of this resource. - An optional description of this resource.
returned: success returned: success
type: str type: str
edgeAvailabilityDomain:
description:
- Desired availability domain for the attachment. Only available for type PARTNER,
at creation time. For improved reliability, customers should configure a pair
of attachments with one per availability domain. The selected availability
domain will be provided to the Partner via the pairing key so that the provisioned
circuit will lie in the specified domain. If not specified, the value will
default to AVAILABILITY_DOMAIN_ANY.
returned: success
type: str
pairingKey:
description:
- '[Output only for type PARTNER. Not present for DEDICATED]. The opaque identifier
of an PARTNER attachment used to initiate provisioning with a selected partner.
Of the form "XXXXX/region/domain" .'
returned: success
type: str
partnerAsn:
description:
- "[Output only for type PARTNER. Not present for DEDICATED]. Optional BGP ASN
for the router that should be supplied by a layer 3 Partner if they configured
BGP on behalf of the customer."
returned: success
type: str
privateInterconnectInfo: privateInterconnectInfo:
description: description:
- Information specific to an InterconnectAttachment. This property is populated - Information specific to an InterconnectAttachment. This property is populated
@ -105,6 +130,16 @@ items:
customer, going to and from this network and region. customer, going to and from this network and region.
returned: success returned: success
type: int type: int
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
returned: success
type: str
state:
description:
- "[Output Only] The current state of this attachment's functionality."
returned: success
type: str
googleReferenceId: googleReferenceId:
description: description:
- Google reference ID, to be used when raising support tickets with Google or - Google reference ID, to be used when raising support tickets with Google or