Skip to content

Commit

Permalink
Add Erase Windows VSS support to compute disk (#3898) (#283)
Browse files Browse the repository at this point in the history
Co-authored-by: Cameron Thornton <[email protected]>
Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Cameron Thornton <[email protected]>
  • Loading branch information
modular-magician and c2thorn authored Aug 27, 2020
1 parent 9b8a7f8 commit 3e06e18
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 18 deletions.
108 changes: 93 additions & 15 deletions plugins/modules/gcp_compute_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
- The source image used to create this disk. If the source image is deleted, this
field will not be set.
- 'To create a disk with one of the public operating system images, specify the
image by its family name. For example, specify family/debian-8 to use the latest
Debian 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively,
use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD
image by its family name. For example, specify family/debian-9 to use the latest
Debian 9 image: projects/debian-cloud/global/images/family/debian-9 Alternatively,
use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-9-stretch-vYYYYMMDD
To create a disk with a private image that you created, specify the image name
in the following format: global/images/my-private-image You can also specify
a private image by its image family, which returns the latest version of the
Expand Down Expand Up @@ -147,6 +147,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
disk_encryption_key:
description:
- Encrypts the disk using a customer-supplied encryption key.
Expand All @@ -173,6 +179,12 @@
must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
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_snapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
Expand Down Expand Up @@ -202,6 +214,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 @@ -358,9 +376,9 @@
- The source image used to create this disk. If the source image is deleted, this
field will not be set.
- 'To create a disk with one of the public operating system images, specify the
image by its family name. For example, specify family/debian-8 to use the latest
Debian 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively,
use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD
image by its family name. For example, specify family/debian-9 to use the latest
Debian 9 image: projects/debian-cloud/global/images/family/debian-9 Alternatively,
use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-9-stretch-vYYYYMMDD
To create a disk with a private image that you created, specify the image name
in the following format: global/images/my-private-image You can also specify a
private image by its image family, which returns the latest version of the image
Expand Down Expand Up @@ -397,6 +415,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
sourceImageId:
description:
- The ID value of the image used to create this disk. This value identifies the
Expand Down Expand Up @@ -438,6 +462,12 @@
must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
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
sourceSnapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
Expand Down Expand Up @@ -468,6 +498,12 @@
key that protects this resource.
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
sourceSnapshotId:
description:
- The unique ID of the snapshot used to create this disk. This value identifies
Expand Down Expand Up @@ -515,10 +551,16 @@ def main():
type=dict(type='str'),
source_image=dict(type='str'),
zone=dict(required=True, type='str'),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
source_image_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'))
),
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'))
),
source_snapshot=dict(type='dict'),
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
source_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'))
),
)
)

Expand Down Expand Up @@ -740,10 +782,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 DiskDiskencryptionkey(object):
Expand All @@ -755,10 +809,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 DiskSourcesnapshotencryptionkey(object):
Expand All @@ -770,10 +836,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
24 changes: 21 additions & 3 deletions plugins/modules/gcp_compute_disk_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@
- The source image used to create this disk. If the source image is deleted,
this field will not be set.
- 'To create a disk with one of the public operating system images, specify
the image by its family name. For example, specify family/debian-8 to use
the latest Debian 8 image: projects/debian-cloud/global/images/family/debian-8
the image by its family name. For example, specify family/debian-9 to use
the latest Debian 9 image: projects/debian-cloud/global/images/family/debian-9
Alternatively, use a specific version of a public operating system image:
projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To create a
projects/debian-cloud/global/images/debian-9-stretch-vYYYYMMDD To create a
disk with a private image that you created, specify the image name in the
following format: global/images/my-private-image You can also specify a private
image by its image family, which returns the latest version of the image in
Expand Down Expand Up @@ -247,6 +247,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
sourceImageId:
description:
- The ID value of the image used to create this disk. This value identifies
Expand Down Expand Up @@ -289,6 +295,12 @@
must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
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
sourceSnapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
Expand Down Expand Up @@ -319,6 +331,12 @@
key that protects this resource.
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
sourceSnapshotId:
description:
- The unique ID of the snapshot used to create this disk. This value identifies
Expand Down

0 comments on commit 3e06e18

Please sign in to comment.