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