|
|
|
@ -146,7 +146,8 @@ options:
|
|
|
|
|
required: false
|
|
|
|
|
source_disk:
|
|
|
|
|
description:
|
|
|
|
|
- A reference to Disk resource.
|
|
|
|
|
- Refers to a gcompute_disk object You must provide either this property or the rawDisk.source
|
|
|
|
|
property but not both to create an image.
|
|
|
|
|
required: false
|
|
|
|
|
source_disk_encryption_key:
|
|
|
|
|
description:
|
|
|
|
@ -182,25 +183,21 @@ extends_documentation_fragment: gcp
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
|
- name: create a disk
|
|
|
|
|
gcp_compute_disk:
|
|
|
|
|
name: 'disk-image'
|
|
|
|
|
name: "disk-image"
|
|
|
|
|
zone: us-central1-a
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: present
|
|
|
|
|
register: disk
|
|
|
|
|
|
|
|
|
|
- name: create a image
|
|
|
|
|
gcp_compute_image:
|
|
|
|
|
name: testObject
|
|
|
|
|
name: "test_object"
|
|
|
|
|
source_disk: "{{ disk }}"
|
|
|
|
|
project: testProject
|
|
|
|
|
auth_kind: service_account
|
|
|
|
|
service_account_file: /tmp/auth.pem
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
project: "test_project"
|
|
|
|
|
auth_kind: "service_account"
|
|
|
|
|
service_account_file: "/tmp/auth.pem"
|
|
|
|
|
state: present
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
@ -365,7 +362,8 @@ RETURN = '''
|
|
|
|
|
type: str
|
|
|
|
|
source_disk:
|
|
|
|
|
description:
|
|
|
|
|
- A reference to Disk resource.
|
|
|
|
|
- Refers to a gcompute_disk object You must provide either this property or the rawDisk.source
|
|
|
|
|
property but not both to create an image.
|
|
|
|
|
returned: success
|
|
|
|
|
type: dict
|
|
|
|
|
source_disk_encryption_key:
|
|
|
|
@ -448,6 +446,9 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if not module.params['scopes']:
|
|
|
|
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
|
|
|
|
|
|
|
|
|
state = module.params['state']
|
|
|
|
|
kind = 'compute#image'
|
|
|
|
|
|
|
|
|
@ -496,13 +497,13 @@ def resource_to_request(module):
|
|
|
|
|
u'description': module.params.get('description'),
|
|
|
|
|
u'diskSizeGb': module.params.get('disk_size_gb'),
|
|
|
|
|
u'family': module.params.get('family'),
|
|
|
|
|
u'guestOsFeatures': ImageGuestOsFeatuArray(module.params.get('guest_os_features', []), module).to_request(),
|
|
|
|
|
u'imageEncryptionKey': ImageImageEncryKey(module.params.get('image_encryption_key', {}), module).to_request(),
|
|
|
|
|
u'guestOsFeatures': ImageGuestOsFeaturesArray(module.params.get('guest_os_features', []), module).to_request(),
|
|
|
|
|
u'imageEncryptionKey': ImageImageEncryptionKey(module.params.get('image_encryption_key', {}), module).to_request(),
|
|
|
|
|
u'licenses': module.params.get('licenses'),
|
|
|
|
|
u'name': module.params.get('name'),
|
|
|
|
|
u'rawDisk': ImageRawDisk(module.params.get('raw_disk', {}), module).to_request(),
|
|
|
|
|
u'sourceDisk': replace_resource_dict(module.params.get(u'source_disk', {}), 'selfLink'),
|
|
|
|
|
u'sourceDiskEncryptionKey': ImagSourDiskEncrKey(module.params.get('source_disk_encryption_key', {}), module).to_request(),
|
|
|
|
|
u'sourceDiskEncryptionKey': ImageSourceDiskEncryptionKey(module.params.get('source_disk_encryption_key', {}), module).to_request(),
|
|
|
|
|
u'sourceDiskId': module.params.get('source_disk_id'),
|
|
|
|
|
u'sourceType': module.params.get('source_type')
|
|
|
|
|
}
|
|
|
|
@ -578,14 +579,14 @@ def response_to_hash(module, response):
|
|
|
|
|
u'description': response.get(u'description'),
|
|
|
|
|
u'diskSizeGb': response.get(u'diskSizeGb'),
|
|
|
|
|
u'family': response.get(u'family'),
|
|
|
|
|
u'guestOsFeatures': ImageGuestOsFeatuArray(response.get(u'guestOsFeatures', []), module).from_response(),
|
|
|
|
|
u'guestOsFeatures': ImageGuestOsFeaturesArray(response.get(u'guestOsFeatures', []), module).from_response(),
|
|
|
|
|
u'id': response.get(u'id'),
|
|
|
|
|
u'imageEncryptionKey': ImageImageEncryKey(response.get(u'imageEncryptionKey', {}), module).from_response(),
|
|
|
|
|
u'imageEncryptionKey': ImageImageEncryptionKey(response.get(u'imageEncryptionKey', {}), module).from_response(),
|
|
|
|
|
u'licenses': response.get(u'licenses'),
|
|
|
|
|
u'name': response.get(u'name'),
|
|
|
|
|
u'rawDisk': ImageRawDisk(response.get(u'rawDisk', {}), module).from_response(),
|
|
|
|
|
u'sourceDisk': response.get(u'sourceDisk'),
|
|
|
|
|
u'sourceDiskEncryptionKey': ImagSourDiskEncrKey(response.get(u'sourceDiskEncryptionKey', {}), module).from_response(),
|
|
|
|
|
u'sourceDiskEncryptionKey': ImageSourceDiskEncryptionKey(response.get(u'sourceDiskEncryptionKey', {}), module).from_response(),
|
|
|
|
|
u'sourceDiskId': response.get(u'sourceDiskId'),
|
|
|
|
|
u'sourceType': response.get(u'sourceType')
|
|
|
|
|
}
|
|
|
|
@ -603,7 +604,7 @@ def async_op_url(module, extra_data=None):
|
|
|
|
|
def wait_for_operation(module, response):
|
|
|
|
|
op_result = return_if_object(module, response, 'compute#operation')
|
|
|
|
|
if op_result is None:
|
|
|
|
|
return None
|
|
|
|
|
return {}
|
|
|
|
|
status = navigate_hash(op_result, ['status'])
|
|
|
|
|
wait_done = wait_for_completion(status, op_result, module)
|
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#image')
|
|
|
|
@ -655,7 +656,7 @@ class ImageDeprecated(object):
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImageGuestOsFeatuArray(object):
|
|
|
|
|
class ImageGuestOsFeaturesArray(object):
|
|
|
|
|
def __init__(self, request, module):
|
|
|
|
|
self.module = module
|
|
|
|
|
if request:
|
|
|
|
@ -686,7 +687,7 @@ class ImageGuestOsFeatuArray(object):
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImageImageEncryKey(object):
|
|
|
|
|
class ImageImageEncryptionKey(object):
|
|
|
|
|
def __init__(self, request, module):
|
|
|
|
|
self.module = module
|
|
|
|
|
if request:
|
|
|
|
@ -730,7 +731,7 @@ class ImageRawDisk(object):
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImagSourDiskEncrKey(object):
|
|
|
|
|
class ImageSourceDiskEncryptionKey(object):
|
|
|
|
|
def __init__(self, request, module):
|
|
|
|
|
self.module = module
|
|
|
|
|
if request:
|
|
|
|
|