Bug fixes for GCP modules (#56689)

This commit is contained in:
The Magician 2019-05-28 10:42:13 -07:00 committed by ansibot
parent 0ff62fd5c4
commit 713ac29054
18 changed files with 91 additions and 99 deletions

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -91,9 +91,8 @@ options:
For newer Windows images, the server might also populate this property with
the value WINDOWS to indicate that this is a Windows image. This value is
purely informational and does not enable or disable any features.
- 'Some valid choices include: "VIRTIO_SCSI_MULTIQUEUE"'
required: false
choices:
- VIRTIO_SCSI_MULTIQUEUE
image_encryption_key:
description:
- Encrypts the image using a customer-supplied encryption key.
@ -134,9 +133,8 @@ options:
- The format used to encode and transmit the block device, which should be
TAR. This is just a container and transmission format and not a runtime
format. Provided by the client when the disk image is created.
- 'Some valid choices include: "TAR"'
required: false
choices:
- TAR
sha1_checksum:
description:
- An optional SHA1 checksum of the disk image before unpackaging.
@ -179,9 +177,8 @@ options:
description:
- The type of the image used to create this disk. The default and only value is
RAW .
- 'Some valid choices include: "RAW"'
required: false
choices:
- RAW
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/images)'
@ -443,19 +440,16 @@ def main():
description=dict(type='str'),
disk_size_gb=dict(type='int'),
family=dict(type='str'),
guest_os_features=dict(type='list', elements='dict', options=dict(type=dict(type='str', choices=['VIRTIO_SCSI_MULTIQUEUE']))),
guest_os_features=dict(type='list', elements='dict', options=dict(type=dict(type='str'))),
image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
labels=dict(type='dict'),
licenses=dict(type='list', elements='str'),
name=dict(required=True, type='str'),
raw_disk=dict(
type='dict',
options=dict(container_type=dict(type='str', choices=['TAR']), sha1_checksum=dict(type='str'), source=dict(required=True, type='str')),
),
raw_disk=dict(type='dict', options=dict(container_type=dict(type='str'), sha1_checksum=dict(type='str'), source=dict(required=True, type='str'))),
source_disk=dict(type='dict'),
source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
source_disk_id=dict(type='str'),
source_type=dict(type='str', choices=['RAW']),
source_type=dict(type='str'),
)
)

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -157,18 +157,14 @@ options:
SCSI or NVME. The default is SCSI.
- Persistent disks must always use SCSI and the request will fail if you attempt
to attach a persistent disk in any other format than SCSI.
- 'Some valid choices include: "SCSI", "NVME"'
required: false
choices:
- SCSI
- NVME
mode:
description:
- The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If
not specified, the default is to attach the disk in READ_WRITE mode.
- 'Some valid choices include: "READ_WRITE", "READ_ONLY"'
required: false
choices:
- READ_WRITE
- READ_ONLY
source:
description:
- Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
@ -185,10 +181,8 @@ options:
description:
- Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
the default is PERSISTENT.
- 'Some valid choices include: "SCRATCH", "PERSISTENT"'
required: false
choices:
- SCRATCH
- PERSISTENT
guest_accelerators:
description:
- List of the type and count of accelerator cards attached to the instance .
@ -202,14 +196,11 @@ options:
description:
- Full or partial URL of the accelerator type resource to expose to this instance.
required: false
label_fingerprint:
labels:
description:
- A fingerprint for this request, which is essentially a hash of the metadata's
contents and used for optimistic locking. The fingerprint is initially generated
by Compute Engine and changes after every request to modify or update metadata.
You must always provide an up-to-date fingerprint hash in order to update or
change metadata.
- Labels to apply to this instance. A list of key->value pairs.
required: false
version_added: 2.9
metadata:
description:
- The metadata key/value pairs to assign to instances that are created from this
@ -270,9 +261,8 @@ options:
type:
description:
- The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- 'Some valid choices include: "ONE_TO_ONE_NAT"'
required: true
choices:
- ONE_TO_ONE_NAT
alias_ip_ranges:
description:
- An array of alias IP ranges for this network interface. Can only be specified
@ -370,16 +360,10 @@ options:
RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.'
- As a user, use RUNNING to keep a machine "on" and TERMINATED to turn a machine
off .
- 'Some valid choices include: "PROVISIONING", "STAGING", "RUNNING", "STOPPING",
"SUSPENDING", "SUSPENDED", "TERMINATED"'
required: false
version_added: 2.8
choices:
- PROVISIONING
- STAGING
- RUNNING
- STOPPING
- SUSPENDING
- SUSPENDED
- TERMINATED
tags:
description:
- A list of tags to apply to this instance. Tags are used to identify valid sources
@ -451,6 +435,8 @@ EXAMPLES = '''
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
cost-center: '12345'
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
@ -649,13 +635,15 @@ id:
type: int
labelFingerprint:
description:
- A fingerprint for this request, which is essentially a hash of the metadata's
contents and used for optimistic locking. The fingerprint is initially generated
by Compute Engine and changes after every request to modify or update metadata.
You must always provide an up-to-date fingerprint hash in order to update or change
metadata.
- The fingerprint used for optimistic locking of this resource. Used internally
during updates.
returned: success
type: str
labels:
description:
- Labels to apply to this instance. A list of key->value pairs.
returned: success
type: dict
metadata:
description:
- The metadata key/value pairs to assign to instances that are created from this
@ -901,14 +889,14 @@ def main():
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
),
),
interface=dict(type='str', choices=['SCSI', 'NVME']),
mode=dict(type='str', choices=['READ_WRITE', 'READ_ONLY']),
interface=dict(type='str'),
mode=dict(type='str'),
source=dict(type='dict'),
type=dict(type='str', choices=['SCRATCH', 'PERSISTENT']),
type=dict(type='str'),
),
),
guest_accelerators=dict(type='list', elements='dict', options=dict(accelerator_count=dict(type='int'), accelerator_type=dict(type='str'))),
label_fingerprint=dict(type='str'),
labels=dict(type='dict'),
metadata=dict(type='dict'),
machine_type=dict(type='str'),
min_cpu_platform=dict(type='str'),
@ -920,9 +908,7 @@ def main():
access_configs=dict(
type='list',
elements='dict',
options=dict(
name=dict(required=True, type='str'), nat_ip=dict(type='dict'), type=dict(required=True, type='str', choices=['ONE_TO_ONE_NAT'])
),
options=dict(name=dict(required=True, type='str'), nat_ip=dict(type='dict'), type=dict(required=True, type='str')),
),
alias_ip_ranges=dict(type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))),
network=dict(type='dict'),
@ -934,7 +920,7 @@ def main():
type='dict', options=dict(automatic_restart=dict(type='bool'), on_host_maintenance=dict(type='str'), preemptible=dict(type='bool'))
),
service_accounts=dict(type='list', elements='dict', options=dict(email=dict(type='str'), scopes=dict(type='list', elements='str'))),
status=dict(type='str', choices=['PROVISIONING', 'STAGING', 'RUNNING', 'STOPPING', 'SUSPENDING', 'SUSPENDED', 'TERMINATED']),
status=dict(type='str'),
tags=dict(type='dict', options=dict(fingerprint=dict(type='str'), items=dict(type='list', elements='str'))),
zone=dict(required=True, type='str'),
)
@ -987,10 +973,20 @@ def update(module, link, kind, fetch):
def update_fields(module, request, response):
if response.get('labels') != request.get('labels'):
label_fingerprint_update(module, request, response)
if response.get('machineType') != request.get('machineType'):
machine_type_update(module, request, response)
def label_fingerprint_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/instances/{name}/setLabels"]).format(**module.params),
{u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
)
def machine_type_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
@ -1010,7 +1006,7 @@ def resource_to_request(module):
u'canIpForward': module.params.get('can_ip_forward'),
u'disks': InstanceDisksArray(module.params.get('disks', []), module).to_request(),
u'guestAccelerators': InstanceGuestacceleratorsArray(module.params.get('guest_accelerators', []), module).to_request(),
u'labelFingerprint': module.params.get('label_fingerprint'),
u'labels': module.params.get('labels'),
u'metadata': module.params.get('metadata'),
u'machineType': machine_type_selflink(module.params.get('machine_type'), module.params),
u'minCpuPlatform': module.params.get('min_cpu_platform'),
@ -1096,6 +1092,7 @@ def response_to_hash(module, response):
u'guestAccelerators': InstanceGuestacceleratorsArray(response.get(u'guestAccelerators', []), module).from_response(),
u'id': response.get(u'id'),
u'labelFingerprint': response.get(u'labelFingerprint'),
u'labels': response.get(u'labels'),
u'metadata': response.get(u'metadata'),
u'machineType': response.get(u'machineType'),
u'minCpuPlatform': response.get(u'minCpuPlatform'),

View file

@ -258,13 +258,15 @@ resources:
type: int
labelFingerprint:
description:
- A fingerprint for this request, which is essentially a hash of the metadata's
contents and used for optimistic locking. The fingerprint is initially generated
by Compute Engine and changes after every request to modify or update metadata.
You must always provide an up-to-date fingerprint hash in order to update
or change metadata.
- The fingerprint used for optimistic locking of this resource. Used internally
during updates.
returned: success
type: str
labels:
description:
- Labels to apply to this instance. A list of key->value pairs.
returned: success
type: dict
metadata:
description:
- The metadata key/value pairs to assign to instances that are created from

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
zone:

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
zone:

View file

@ -180,18 +180,14 @@ options:
either SCSI or NVME. The default is SCSI.
- Persistent disks must always use SCSI and the request will fail if you
attempt to attach a persistent disk in any other format than SCSI.
- 'Some valid choices include: "SCSI", "NVME"'
required: false
choices:
- SCSI
- NVME
mode:
description:
- The mode in which to attach this disk, either READ_WRITE or READ_ONLY.
If not specified, the default is to attach the disk in READ_WRITE mode.
- 'Some valid choices include: "READ_WRITE", "READ_ONLY"'
required: false
choices:
- READ_WRITE
- READ_ONLY
source:
description:
- Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
@ -210,10 +206,8 @@ options:
description:
- Specifies the type of the disk, either SCRATCH or PERSISTENT. If not
specified, the default is PERSISTENT.
- 'Some valid choices include: "SCRATCH", "PERSISTENT"'
required: false
choices:
- SCRATCH
- PERSISTENT
machine_type:
description:
- The machine type to use in the VM instance template.
@ -281,9 +275,8 @@ options:
type:
description:
- The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- 'Some valid choices include: "ONE_TO_ONE_NAT"'
required: true
choices:
- ONE_TO_ONE_NAT
alias_ip_ranges:
description:
- An array of alias IP ranges for this network interface. Can only be
@ -875,10 +868,10 @@ def main():
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
),
),
interface=dict(type='str', choices=['SCSI', 'NVME']),
mode=dict(type='str', choices=['READ_WRITE', 'READ_ONLY']),
interface=dict(type='str'),
mode=dict(type='str'),
source=dict(type='dict'),
type=dict(type='str', choices=['SCRATCH', 'PERSISTENT']),
type=dict(type='str'),
),
),
machine_type=dict(required=True, type='str'),
@ -892,11 +885,7 @@ def main():
access_configs=dict(
type='list',
elements='dict',
options=dict(
name=dict(required=True, type='str'),
nat_ip=dict(type='dict'),
type=dict(required=True, type='str', choices=['ONE_TO_ONE_NAT']),
),
options=dict(name=dict(required=True, type='str'), nat_ip=dict(type='dict'), type=dict(required=True, type='str')),
),
alias_ip_ranges=dict(
type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))
@ -1090,14 +1079,19 @@ def raise_if_errors(response, err_path, module):
def encode_request(request, module):
if 'metadata' in request and request['metadata'] is not None:
request['metadata'] = metadata_encoder(request['metadata'])
if 'properties' in request and request['properties'] is not None and 'metadata' in request['properties'] and request['properties']['metadata'] is not None:
request['properties']['metadata'] = metadata_encoder(request['properties']['metadata'])
return request
def decode_response(response, module):
if 'metadata' in response and response['metadata'] is not None:
response['metadata'] = metadata_decoder(response['metadata'])
if (
'properties' in response
and response['properties'] is not None
and 'metadata' in response['properties']
and response['properties']['metadata'] is not None
):
response['properties']['metadata'] = metadata_decoder(response['properties']['metadata'])
return response

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -70,11 +70,8 @@ options:
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
- 'Some valid choices include: "DEDICATED", "PARTNER", "PARTNER_PROVIDER"'
required: false
choices:
- DEDICATED
- PARTNER
- PARTNER_PROVIDER
router:
description:
- URL of the cloud router to be used for dynamic routing. This router must be
@ -284,7 +281,7 @@ def main():
interconnect=dict(type='str'),
description=dict(type='str'),
edge_availability_domain=dict(type='str'),
type=dict(type='str', choices=['DEDICATED', 'PARTNER', 'PARTNER_PROVIDER']),
type=dict(type='str'),
router=dict(required=True, type='dict'),
name=dict(required=True, type='str'),
candidate_subnets=dict(type='list', elements='str'),

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
region:

View file

@ -94,10 +94,8 @@ options:
in the same region as the router. If set to `GLOBAL`, this network's cloud
routers will advertise routes with all subnetworks of this network, across
regions.
- 'Some valid choices include: "REGIONAL", "GLOBAL"'
required: true
choices:
- REGIONAL
- GLOBAL
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/networks)'
@ -213,7 +211,7 @@ def main():
ipv4_range=dict(type='str'),
name=dict(required=True, type='str'),
auto_create_subnetworks=dict(type='bool'),
routing_config=dict(type='dict', options=dict(routing_mode=dict(required=True, type='str', choices=['REGIONAL', 'GLOBAL']))),
routing_config=dict(type='dict', options=dict(routing_mode=dict(required=True, type='str'))),
),
mutually_exclusive=[['auto_create_subnetworks', 'ipv4_range']],
)

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
region:

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1
and filter2) .
extends_documentation_fragment: gcp

View file

@ -52,6 +52,8 @@
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
cost-center: '12345'
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
@ -75,6 +77,8 @@
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
cost-center: '12345'
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
@ -119,6 +123,8 @@
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
cost-center: '12345'
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
@ -148,6 +154,8 @@
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
cost-center: '12345'
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
@ -192,6 +200,8 @@
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
cost-center: '12345'
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs: