Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Snapshot location to compute snapshot #286

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plugins/modules/gcp_compute_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
kms_key_service_account:
description:
- The service account used for the encryption request for the given KMS key.
If absent, the Compute Engine Service Agent service account is used.
- If absent, the Compute Engine Service Agent service account is used.
required: false
type: str
disk_encryption_key:
Expand Down Expand Up @@ -182,7 +182,7 @@
kms_key_service_account:
description:
- The service account used for the encryption request for the given KMS key.
If absent, the Compute Engine Service Agent service account is used.
- If absent, the Compute Engine Service Agent service account is used.
required: false
type: str
source_snapshot:
Expand Down Expand Up @@ -418,7 +418,7 @@
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS key.
If absent, the Compute Engine Service Agent service account is used.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
sourceImageId:
Expand Down Expand Up @@ -465,7 +465,7 @@
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS key.
If absent, the Compute Engine Service Agent service account is used.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
sourceSnapshot:
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/gcp_compute_disk_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS
key. If absent, the Compute Engine Service Agent service account is used.
key.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
sourceImageId:
Expand Down Expand Up @@ -298,7 +299,8 @@
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS
key. If absent, the Compute Engine Service Agent service account is used.
key.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
sourceSnapshot:
Expand Down
78 changes: 72 additions & 6 deletions plugins/modules/gcp_compute_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
- An optional description of this resource.
required: false
type: str
storage_locations:
description:
- Cloud Storage bucket storage location of the snapshot (regional or multi-regional).
elements: str
required: false
type: list
labels:
description:
- Labels to apply to this Snapshot.
Expand Down Expand Up @@ -108,6 +114,12 @@
- The name of the encryption key that is stored in Google Cloud KMS.
required: false
type: str
kms_key_service_account:
description:
- The service account used for the encryption request for the given KMS key.
- If absent, the Compute Engine Service Agent service account is used.
required: false
type: str
source_disk_encryption_key:
description:
- The customer-supplied encryption key of the source snapshot. Required if the
Expand All @@ -126,6 +138,12 @@
- The name of the encryption key that is stored in Google Cloud KMS.
required: false
type: str
kms_key_service_account:
description:
- The service account used for the encryption request for the given KMS key.
- If absent, the Compute Engine Service Agent service account is used.
required: false
type: str
project:
description:
- The Google Cloud Platform project to use.
Expand Down Expand Up @@ -240,6 +258,11 @@
is expected to change with snapshot creation/deletion.
returned: success
type: int
storageLocations:
description:
- Cloud Storage bucket storage location of the snapshot (regional or multi-regional).
returned: success
type: list
licenses:
description:
- A list of public visible licenses that apply to this snapshot. This can be because
Expand Down Expand Up @@ -292,6 +315,12 @@
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS key.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
sourceDiskEncryptionKey:
description:
- The customer-supplied encryption key of the source snapshot. Required if the source
Expand All @@ -310,6 +339,12 @@
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS key.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
'''

################################################################################
Expand Down Expand Up @@ -341,11 +376,16 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, type='str'),
description=dict(type='str'),
storage_locations=dict(type='list', elements='str'),
labels=dict(type='dict'),
source_disk=dict(required=True, type='dict'),
zone=dict(type='str'),
snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
snapshot_encryption_key=dict(
type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'), kms_key_service_account=dict(type='str'))
),
source_disk_encryption_key=dict(
type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'), kms_key_service_account=dict(type='str'))
),
)
)

Expand Down Expand Up @@ -415,6 +455,7 @@ def resource_to_request(module):
u'zone': module.params.get('zone'),
u'name': module.params.get('name'),
u'description': module.params.get('description'),
u'storageLocations': module.params.get('storage_locations'),
u'labels': module.params.get('labels'),
}
return_vals = {}
Expand Down Expand Up @@ -492,6 +533,7 @@ def response_to_hash(module, response):
u'name': module.params.get('name'),
u'description': module.params.get('description'),
u'storageBytes': response.get(u'storageBytes'),
u'storageLocations': response.get(u'storageLocations'),
u'licenses': response.get(u'licenses'),
u'labels': response.get(u'labels'),
u'labelFingerprint': response.get(u'labelFingerprint'),
Expand Down Expand Up @@ -551,10 +593,22 @@ def __init__(self, request, module):
self.request = {}

def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
return remove_nones_from_dict(
{
u'rawKey': self.request.get('raw_key'),
u'kmsKeyName': self.request.get('kms_key_name'),
u'kmsKeyServiceAccount': self.request.get('kms_key_service_account'),
}
)

def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
return remove_nones_from_dict(
{
u'rawKey': self.request.get(u'rawKey'),
u'kmsKeyName': self.request.get(u'kmsKeyName'),
u'kmsKeyServiceAccount': self.request.get(u'kmsKeyServiceAccount'),
}
)


class SnapshotSourcediskencryptionkey(object):
Expand All @@ -566,10 +620,22 @@ def __init__(self, request, module):
self.request = {}

def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
return remove_nones_from_dict(
{
u'rawKey': self.request.get('raw_key'),
u'kmsKeyName': self.request.get('kms_key_name'),
u'kmsKeyServiceAccount': self.request.get('kms_key_service_account'),
}
)

def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
return remove_nones_from_dict(
{
u'rawKey': self.request.get(u'rawKey'),
u'kmsKeyName': self.request.get(u'kmsKeyName'),
u'kmsKeyServiceAccount': self.request.get(u'kmsKeyServiceAccount'),
}
)


if __name__ == '__main__':
Expand Down
19 changes: 19 additions & 0 deletions plugins/modules/gcp_compute_snapshot_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@
number is expected to change with snapshot creation/deletion.
returned: success
type: int
storageLocations:
description:
- Cloud Storage bucket storage location of the snapshot (regional or multi-regional).
returned: success
type: list
licenses:
description:
- A list of public visible licenses that apply to this snapshot. This can be
Expand Down Expand Up @@ -202,6 +207,13 @@
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS
key.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
sourceDiskEncryptionKey:
description:
- The customer-supplied encryption key of the source snapshot. Required if the
Expand All @@ -220,6 +232,13 @@
- The name of the encryption key that is stored in Google Cloud KMS.
returned: success
type: str
kmsKeyServiceAccount:
description:
- The service account used for the encryption request for the given KMS
key.
- If absent, the Compute Engine Service Agent service account is used.
returned: success
type: str
'''

################################################################################
Expand Down