mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-26 14:41:29 -07:00
remove min_version from a bunch of fields that are in GA now
This commit is contained in:
parent
91dcd0d6f5
commit
f1a96adf23
111 changed files with 3604 additions and 3448 deletions
|
@ -18,311 +18,305 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
################################################################################
|
||||
# Documentation
|
||||
################################################################################
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ["preview"],
|
||||
'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: gcp_compute_region_disk
|
||||
description:
|
||||
- Persistent disks are durable storage devices that function similarly to the physical
|
||||
disks in a desktop or a server. Compute Engine manages the hardware behind these
|
||||
devices to ensure data redundancy and optimize performance for you. Persistent disks
|
||||
are available as either standard hard disk drives (HDD) or solid-state drives (SSD).
|
||||
- Persistent disks are located independently from your virtual machine instances,
|
||||
so you can detach or move persistent disks to keep your data even after you delete
|
||||
your instances. Persistent disk performance scales automatically with size, so you
|
||||
can resize your existing persistent disks or add more persistent disks to an instance
|
||||
to meet your performance and storage space requirements.
|
||||
- Add a persistent disk to your instance when you need reliable and affordable storage
|
||||
with consistent performance characteristics.
|
||||
- Persistent disks are durable storage devices that function similarly to the physical
|
||||
disks in a desktop or a server. Compute Engine manages the hardware behind these
|
||||
devices to ensure data redundancy and optimize performance for you. Persistent disks
|
||||
are available as either standard hard disk drives (HDD) or solid-state drives (SSD).
|
||||
- Persistent disks are located independently from your virtual machine instances,
|
||||
so you can detach or move persistent disks to keep your data even after you delete
|
||||
your instances. Persistent disk performance scales automatically with size, so you
|
||||
can resize your existing persistent disks or add more persistent disks to an instance
|
||||
to meet your performance and storage space requirements.
|
||||
- Add a persistent disk to your instance when you need reliable and affordable storage
|
||||
with consistent performance characteristics.
|
||||
short_description: Creates a GCP RegionDisk
|
||||
version_added: 2.8
|
||||
author: Google Inc. (@googlecloudplatform)
|
||||
requirements:
|
||||
- python >= 2.6
|
||||
- requests >= 2.18.4
|
||||
- google-auth >= 1.3.0
|
||||
- python >= 2.6
|
||||
- requests >= 2.18.4
|
||||
- google-auth >= 1.3.0
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- Whether the given object should exist in GCP
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
default: present
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource.
|
||||
required: false
|
||||
labels:
|
||||
description:
|
||||
- Labels to apply to this disk. A list of key->value pairs.
|
||||
required: false
|
||||
licenses:
|
||||
description:
|
||||
- Any applicable publicly visible licenses.
|
||||
required: false
|
||||
name:
|
||||
description:
|
||||
- Name of the resource. Provided by the client when the resource is created. The
|
||||
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
|
||||
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||
which means the first character must be a lowercase letter, and all following
|
||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
||||
which cannot be a dash.
|
||||
required: true
|
||||
size_gb:
|
||||
description:
|
||||
- Size of the persistent disk, specified in GB. You can specify this field when
|
||||
creating a persistent disk using the sourceImage or sourceSnapshot parameter,
|
||||
or specify it alone to create an empty persistent disk.
|
||||
- If you specify this field along with sourceImage or sourceSnapshot, the value
|
||||
of sizeGb must not be less than the size of the sourceImage or the size of the
|
||||
snapshot.
|
||||
required: false
|
||||
physical_block_size_bytes:
|
||||
description:
|
||||
- Physical block size of the persistent disk, in bytes. If not present in a request,
|
||||
a default value is used. Currently supported sizes are 4096 and 16384, other
|
||||
sizes may be added in the future.
|
||||
- If an unsupported value is requested, the error message will list the supported
|
||||
values for the caller's project.
|
||||
required: false
|
||||
replica_zones:
|
||||
description:
|
||||
- URLs of the zones where the disk should be replicated to.
|
||||
required: true
|
||||
type:
|
||||
description:
|
||||
- URL of the disk type resource describing which disk type to use to create the
|
||||
disk. Provide this when creating the disk.
|
||||
required: false
|
||||
region:
|
||||
description:
|
||||
- A reference to the region where the disk resides.
|
||||
required: true
|
||||
disk_encryption_key:
|
||||
description:
|
||||
- Encrypts the disk using a customer-supplied encryption key.
|
||||
- After you encrypt a disk with a customer-supplied key, you must provide the
|
||||
same key if you use the disk later (e.g. to create a disk snapshot or an image,
|
||||
or to attach the disk to a virtual machine).
|
||||
- Customer-supplied encryption keys do not protect access to metadata of the disk.
|
||||
- If you do not provide an encryption key when creating the disk, then the disk
|
||||
will be encrypted using an automatically generated key and you do not need to
|
||||
provide a key to use the disk later.
|
||||
required: false
|
||||
suboptions:
|
||||
raw_key:
|
||||
state:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
||||
base64 to either encrypt or decrypt this resource.
|
||||
required: false
|
||||
source_snapshot:
|
||||
- Whether the given object should exist in GCP
|
||||
choices: ['present', 'absent']
|
||||
default: 'present'
|
||||
description:
|
||||
- The source snapshot used to create this disk. You can provide this as a partial
|
||||
or full URL to the resource.
|
||||
- 'This field represents a link to a Snapshot resource in GCP. It can be specified
|
||||
in two ways. First, you can place a dictionary with key ''selfLink'' and value
|
||||
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
|
||||
to a gcp_compute_snapshot task and then set this source_snapshot field to "{{
|
||||
name-of-resource }}"'
|
||||
required: false
|
||||
source_snapshot_encryption_key:
|
||||
description:
|
||||
- The customer-supplied encryption key of the source snapshot. Required if the
|
||||
source snapshot is protected by a customer-supplied encryption key.
|
||||
required: false
|
||||
suboptions:
|
||||
raw_key:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
||||
base64 to either encrypt or decrypt this resource.
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource.
|
||||
required: false
|
||||
labels:
|
||||
description:
|
||||
- Labels to apply to this disk. A list of key->value pairs.
|
||||
required: false
|
||||
licenses:
|
||||
description:
|
||||
- Any applicable publicly visible licenses.
|
||||
required: false
|
||||
name:
|
||||
description:
|
||||
- Name of the resource. Provided by the client when the resource is created. The name
|
||||
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||
which means the first character must be a lowercase letter, and all following characters
|
||||
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||
be a dash.
|
||||
required: true
|
||||
size_gb:
|
||||
description:
|
||||
- Size of the persistent disk, specified in GB. You can specify this field when creating
|
||||
a persistent disk using the sourceImage or sourceSnapshot parameter, or specify
|
||||
it alone to create an empty persistent disk.
|
||||
- If you specify this field along with sourceImage or sourceSnapshot, the value of
|
||||
sizeGb must not be less than the size of the sourceImage or the size of the snapshot.
|
||||
required: false
|
||||
replica_zones:
|
||||
description:
|
||||
- URLs of the zones where the disk should be replicated to.
|
||||
required: true
|
||||
type:
|
||||
description:
|
||||
- URL of the disk type resource describing which disk type to use to create the disk.
|
||||
Provide this when creating the disk.
|
||||
required: false
|
||||
region:
|
||||
description:
|
||||
- A reference to the region where the disk resides.
|
||||
required: true
|
||||
disk_encryption_key:
|
||||
description:
|
||||
- Encrypts the disk using a customer-supplied encryption key.
|
||||
- After you encrypt a disk with a customer-supplied key, you must provide the same
|
||||
key if you use the disk later (e.g. to create a disk snapshot or an image, or to
|
||||
attach the disk to a virtual machine).
|
||||
- Customer-supplied encryption keys do not protect access to metadata of the disk.
|
||||
- If you do not provide an encryption key when creating the disk, then the disk will
|
||||
be encrypted using an automatically generated key and you do not need to provide
|
||||
a key to use the disk later.
|
||||
required: false
|
||||
suboptions:
|
||||
raw_key:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||
to either encrypt or decrypt this resource.
|
||||
required: false
|
||||
sha256:
|
||||
description:
|
||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||
that protects this resource.
|
||||
required: false
|
||||
source_snapshot:
|
||||
description:
|
||||
- 'The source snapshot used to create this disk. You can provide this as a partial or
|
||||
full URL to the resource. For example, the following are valid values: *
|
||||
`U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`)
|
||||
* `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .'
|
||||
- 'This field represents a link to a Snapshot resource in GCP. It can be specified
|
||||
in two ways. You can add `register: name-of-resource` to a gcp_compute_snapshot
|
||||
task and then set this source_snapshot field to "{{ name-of-resource }}" Alternatively,
|
||||
you can set this source_snapshot to a dictionary with the selfLink key where the
|
||||
value is the selfLink of your Snapshot.'
|
||||
required: false
|
||||
source_snapshot_encryption_key:
|
||||
description:
|
||||
- The customer-supplied encryption key of the source snapshot. Required if the source
|
||||
snapshot is protected by a customer-supplied encryption key.
|
||||
required: false
|
||||
suboptions:
|
||||
raw_key:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||
to either encrypt or decrypt this resource.
|
||||
required: false
|
||||
sha256:
|
||||
description:
|
||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||
that protects this resource.
|
||||
required: false
|
||||
extends_documentation_fragment: gcp
|
||||
notes:
|
||||
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)'
|
||||
- 'Adding or Resizing Regional Persistent Disks: U(https://cloud.google.com/compute/docs/disks/regional-persistent-disk)'
|
||||
- "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)"
|
||||
- "Adding or Resizing Regional Persistent Disks: U(https://cloud.google.com/compute/docs/disks/regional-persistent-disk)"
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: create a region disk
|
||||
gcp_compute_region_disk:
|
||||
name: test_object
|
||||
size_gb: 50
|
||||
disk_encryption_key:
|
||||
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
|
||||
region: us-central1
|
||||
replica_zones:
|
||||
- https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
|
||||
- https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
|
||||
project: test_project
|
||||
auth_kind: serviceaccount
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
name: "test_object"
|
||||
size_gb: 50
|
||||
disk_encryption_key:
|
||||
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
|
||||
region: us-central1
|
||||
replica_zones:
|
||||
- us-central1-a
|
||||
- us-central1-f
|
||||
project: "test_project"
|
||||
auth_kind: "serviceaccount"
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
labelFingerprint:
|
||||
description:
|
||||
- The fingerprint used for optimistic locking of this resource. Used internally
|
||||
during updates.
|
||||
returned: success
|
||||
type: str
|
||||
creationTimestamp:
|
||||
description:
|
||||
- Creation timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource.
|
||||
returned: success
|
||||
type: str
|
||||
id:
|
||||
description:
|
||||
- The unique identifier for the resource.
|
||||
returned: success
|
||||
type: int
|
||||
lastAttachTimestamp:
|
||||
description:
|
||||
- Last attach timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
lastDetachTimestamp:
|
||||
description:
|
||||
- Last dettach timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
labels:
|
||||
description:
|
||||
- Labels to apply to this disk. A list of key->value pairs.
|
||||
returned: success
|
||||
type: dict
|
||||
licenses:
|
||||
description:
|
||||
- Any applicable publicly visible licenses.
|
||||
returned: success
|
||||
type: list
|
||||
name:
|
||||
description:
|
||||
- Name of the resource. Provided by the client when the resource is created. The
|
||||
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
|
||||
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||
which means the first character must be a lowercase letter, and all following
|
||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
||||
which cannot be a dash.
|
||||
returned: success
|
||||
type: str
|
||||
sizeGb:
|
||||
description:
|
||||
- Size of the persistent disk, specified in GB. You can specify this field when
|
||||
creating a persistent disk using the sourceImage or sourceSnapshot parameter,
|
||||
or specify it alone to create an empty persistent disk.
|
||||
- If you specify this field along with sourceImage or sourceSnapshot, the value
|
||||
of sizeGb must not be less than the size of the sourceImage or the size of the
|
||||
snapshot.
|
||||
returned: success
|
||||
type: int
|
||||
users:
|
||||
description:
|
||||
- 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
|
||||
.'
|
||||
returned: success
|
||||
type: list
|
||||
physicalBlockSizeBytes:
|
||||
description:
|
||||
- Physical block size of the persistent disk, in bytes. If not present in a request,
|
||||
a default value is used. Currently supported sizes are 4096 and 16384, other sizes
|
||||
may be added in the future.
|
||||
- If an unsupported value is requested, the error message will list the supported
|
||||
values for the caller's project.
|
||||
returned: success
|
||||
type: int
|
||||
replicaZones:
|
||||
description:
|
||||
- URLs of the zones where the disk should be replicated to.
|
||||
returned: success
|
||||
type: list
|
||||
type:
|
||||
description:
|
||||
- URL of the disk type resource describing which disk type to use to create the
|
||||
disk. Provide this when creating the disk.
|
||||
returned: success
|
||||
type: str
|
||||
region:
|
||||
description:
|
||||
- A reference to the region where the disk resides.
|
||||
returned: success
|
||||
type: str
|
||||
diskEncryptionKey:
|
||||
description:
|
||||
- Encrypts the disk using a customer-supplied encryption key.
|
||||
- After you encrypt a disk with a customer-supplied key, you must provide the same
|
||||
key if you use the disk later (e.g. to create a disk snapshot or an image, or
|
||||
to attach the disk to a virtual machine).
|
||||
- Customer-supplied encryption keys do not protect access to metadata of the disk.
|
||||
- If you do not provide an encryption key when creating the disk, then the disk
|
||||
will be encrypted using an automatically generated key and you do not need to
|
||||
provide a key to use the disk later.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
rawKey:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
||||
base64 to either encrypt or decrypt this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sha256:
|
||||
description:
|
||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||
key that protects this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sourceSnapshot:
|
||||
description:
|
||||
- The source snapshot used to create this disk. You can provide this as a partial
|
||||
or full URL to the resource.
|
||||
returned: success
|
||||
type: dict
|
||||
sourceSnapshotEncryptionKey:
|
||||
description:
|
||||
- The customer-supplied encryption key of the source snapshot. Required if the source
|
||||
snapshot is protected by a customer-supplied encryption key.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
rawKey:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
||||
base64 to either encrypt or decrypt this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sha256:
|
||||
description:
|
||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
||||
key that protects this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sourceSnapshotId:
|
||||
description:
|
||||
- The unique ID of the snapshot used to create this disk. This value identifies
|
||||
the exact snapshot that was used to create this persistent disk. For example,
|
||||
if you created the persistent disk from a snapshot that was later deleted and
|
||||
recreated under the same name, the source snapshot ID would identify the exact
|
||||
version of the snapshot that was used.
|
||||
returned: success
|
||||
type: str
|
||||
labelFingerprint:
|
||||
description:
|
||||
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||
updates.
|
||||
returned: success
|
||||
type: str
|
||||
creationTimestamp:
|
||||
description:
|
||||
- Creation timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource.
|
||||
returned: success
|
||||
type: str
|
||||
id:
|
||||
description:
|
||||
- The unique identifier for the resource.
|
||||
returned: success
|
||||
type: int
|
||||
lastAttachTimestamp:
|
||||
description:
|
||||
- Last attach timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
lastDetachTimestamp:
|
||||
description:
|
||||
- Last dettach timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
labels:
|
||||
description:
|
||||
- Labels to apply to this disk. A list of key->value pairs.
|
||||
returned: success
|
||||
type: dict
|
||||
licenses:
|
||||
description:
|
||||
- Any applicable publicly visible licenses.
|
||||
returned: success
|
||||
type: list
|
||||
name:
|
||||
description:
|
||||
- Name of the resource. Provided by the client when the resource is created. The name
|
||||
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||
which means the first character must be a lowercase letter, and all following characters
|
||||
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||
be a dash.
|
||||
returned: success
|
||||
type: str
|
||||
sizeGb:
|
||||
description:
|
||||
- Size of the persistent disk, specified in GB. You can specify this field when creating
|
||||
a persistent disk using the sourceImage or sourceSnapshot parameter, or specify
|
||||
it alone to create an empty persistent disk.
|
||||
- If you specify this field along with sourceImage or sourceSnapshot, the value of
|
||||
sizeGb must not be less than the size of the sourceImage or the size of the snapshot.
|
||||
returned: success
|
||||
type: int
|
||||
users:
|
||||
description:
|
||||
- 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
|
||||
.'
|
||||
returned: success
|
||||
type: list
|
||||
replicaZones:
|
||||
description:
|
||||
- URLs of the zones where the disk should be replicated to.
|
||||
returned: success
|
||||
type: list
|
||||
type:
|
||||
description:
|
||||
- URL of the disk type resource describing which disk type to use to create the disk.
|
||||
Provide this when creating the disk.
|
||||
returned: success
|
||||
type: str
|
||||
region:
|
||||
description:
|
||||
- A reference to the region where the disk resides.
|
||||
returned: success
|
||||
type: str
|
||||
diskEncryptionKey:
|
||||
description:
|
||||
- Encrypts the disk using a customer-supplied encryption key.
|
||||
- After you encrypt a disk with a customer-supplied key, you must provide the same
|
||||
key if you use the disk later (e.g. to create a disk snapshot or an image, or to
|
||||
attach the disk to a virtual machine).
|
||||
- Customer-supplied encryption keys do not protect access to metadata of the disk.
|
||||
- If you do not provide an encryption key when creating the disk, then the disk will
|
||||
be encrypted using an automatically generated key and you do not need to provide
|
||||
a key to use the disk later.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
rawKey:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||
to either encrypt or decrypt this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sha256:
|
||||
description:
|
||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||
that protects this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sourceSnapshot:
|
||||
description:
|
||||
- 'The source snapshot used to create this disk. You can provide this as a partial or
|
||||
full URL to the resource. For example, the following are valid values: *
|
||||
`U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`)
|
||||
* `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .'
|
||||
returned: success
|
||||
type: dict
|
||||
sourceSnapshotEncryptionKey:
|
||||
description:
|
||||
- The customer-supplied encryption key of the source snapshot. Required if the source
|
||||
snapshot is protected by a customer-supplied encryption key.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
rawKey:
|
||||
description:
|
||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||
to either encrypt or decrypt this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sha256:
|
||||
description:
|
||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||
that protects this resource.
|
||||
returned: success
|
||||
type: str
|
||||
sourceSnapshotId:
|
||||
description:
|
||||
- The unique ID of the snapshot used to create this disk. This value identifies the
|
||||
exact snapshot that was used to create this persistent disk. For example, if you
|
||||
created the persistent disk from a snapshot that was later deleted and recreated
|
||||
under the same name, the source snapshot ID would identify the exact version of
|
||||
the snapshot that was used.
|
||||
returned: success
|
||||
type: str
|
||||
'''
|
||||
|
||||
################################################################################
|
||||
|
@ -350,13 +344,18 @@ def main():
|
|||
licenses=dict(type='list', elements='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
size_gb=dict(type='int'),
|
||||
physical_block_size_bytes=dict(type='int'),
|
||||
replica_zones=dict(required=True, type='list', elements='str'),
|
||||
type=dict(type='str'),
|
||||
region=dict(required=True, type='str'),
|
||||
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
|
||||
disk_encryption_key=dict(type='dict', options=dict(
|
||||
raw_key=dict(type='str'),
|
||||
sha256=dict(type='str')
|
||||
)),
|
||||
source_snapshot=dict(type='dict'),
|
||||
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
|
||||
source_snapshot_encryption_key=dict(type='dict', options=dict(
|
||||
raw_key=dict(type='str'),
|
||||
sha256=dict(type='str')
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -397,7 +396,8 @@ def create(module, link, kind):
|
|||
|
||||
|
||||
def update(module, link, kind, fetch):
|
||||
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
||||
update_fields(module, resource_to_request(module),
|
||||
response_to_hash(module, fetch))
|
||||
return fetch_resource(module, self_link(module), kind)
|
||||
|
||||
|
||||
|
@ -411,16 +411,27 @@ def update_fields(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}/regions/{region}/disks/{name}/setLabels"]).format(**module.params),
|
||||
{u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/regions/{region}/disks/{name}/setLabels"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'labelFingerprint': response.get('labelFingerprint'),
|
||||
u'labels': module.params.get('labels')
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def size_gb_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/disks/{name}/resize"]).format(**module.params),
|
||||
{u'sizeGb': module.params.get('size_gb')},
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/regions/{region}/disks/{name}/resize"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'sizeGb': module.params.get('size_gb')
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
@ -432,20 +443,19 @@ def delete(module, link, kind):
|
|||
def resource_to_request(module):
|
||||
request = {
|
||||
u'kind': 'compute#disk',
|
||||
u'diskEncryptionKey': RegionDiskDiskencryptionkey(module.params.get('disk_encryption_key', {}), module).to_request(),
|
||||
u'sourceSnapshotEncryptionKey': RegionDiskSourcesnapshotencryptionkey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(),
|
||||
u'diskEncryptionKey': RegionDiskDiskEncryptionKey(module.params.get('disk_encryption_key', {}), module).to_request(),
|
||||
u'sourceSnapshotEncryptionKey': RegionDiskSourceSnapshotEncryptionKey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(),
|
||||
u'description': module.params.get('description'),
|
||||
u'labels': module.params.get('labels'),
|
||||
u'licenses': module.params.get('licenses'),
|
||||
u'name': module.params.get('name'),
|
||||
u'sizeGb': module.params.get('size_gb'),
|
||||
u'physicalBlockSizeBytes': module.params.get('physical_block_size_bytes'),
|
||||
u'replicaZones': module.params.get('replica_zones'),
|
||||
u'type': region_disk_type_selflink(module.params.get('type'), module.params),
|
||||
u'type': region_disk_type_selflink(module.params.get('type'), module.params)
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
if v or v is False:
|
||||
if v:
|
||||
return_vals[k] = v
|
||||
|
||||
return return_vals
|
||||
|
@ -476,8 +486,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
|||
try:
|
||||
module.raise_for_status(response)
|
||||
result = response.json()
|
||||
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
||||
|
||||
if navigate_hash(result, ['error', 'errors']):
|
||||
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
|
||||
|
@ -518,9 +528,8 @@ def response_to_hash(module, response):
|
|||
u'name': module.params.get('name'),
|
||||
u'sizeGb': response.get(u'sizeGb'),
|
||||
u'users': response.get(u'users'),
|
||||
u'physicalBlockSizeBytes': response.get(u'physicalBlockSizeBytes'),
|
||||
u'replicaZones': response.get(u'replicaZones'),
|
||||
u'type': response.get(u'type'),
|
||||
u'type': response.get(u'type')
|
||||
}
|
||||
|
||||
|
||||
|
@ -564,9 +573,11 @@ def wait_for_completion(status, op_result, module):
|
|||
op_id = navigate_hash(op_result, ['name'])
|
||||
op_uri = async_op_url(module, {'op_id': op_id})
|
||||
while status != 'DONE':
|
||||
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
||||
time.sleep(1.0)
|
||||
op_result = fetch_resource(module, op_uri, 'compute#operation', False)
|
||||
if status not in ['PENDING', 'RUNNING', 'DONE']:
|
||||
module.fail_json(msg="Invalid result %s" % status)
|
||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||
status = navigate_hash(op_result, ['status'])
|
||||
return op_result
|
||||
|
||||
|
@ -577,7 +588,7 @@ def raise_if_errors(response, err_path, module):
|
|||
module.fail_json(msg=errors)
|
||||
|
||||
|
||||
class RegionDiskDiskencryptionkey(object):
|
||||
class RegionDiskDiskEncryptionKey(object):
|
||||
def __init__(self, request, module):
|
||||
self.module = module
|
||||
if request:
|
||||
|
@ -586,13 +597,19 @@ class RegionDiskDiskencryptionkey(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
|
||||
return remove_nones_from_dict({
|
||||
u'rawKey': self.request.get('raw_key'),
|
||||
u'sha256': self.request.get('sha256')
|
||||
})
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
|
||||
return remove_nones_from_dict({
|
||||
u'rawKey': self.request.get(u'rawKey'),
|
||||
u'sha256': self.request.get(u'sha256')
|
||||
})
|
||||
|
||||
|
||||
class RegionDiskSourcesnapshotencryptionkey(object):
|
||||
class RegionDiskSourceSnapshotEncryptionKey(object):
|
||||
def __init__(self, request, module):
|
||||
self.module = module
|
||||
if request:
|
||||
|
@ -601,10 +618,16 @@ class RegionDiskSourcesnapshotencryptionkey(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
|
||||
return remove_nones_from_dict({
|
||||
u'rawKey': self.request.get('raw_key'),
|
||||
u'sha256': self.request.get('sha256')
|
||||
})
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
|
||||
return remove_nones_from_dict({
|
||||
u'rawKey': self.request.get(u'rawKey'),
|
||||
u'sha256': self.request.get(u'sha256')
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue