Skip to content

Commit

Permalink
Commit fix a bug alibaba#287: Added the drive encryption options Encr…
Browse files Browse the repository at this point in the history
…ypted and KMSKeyId.
  • Loading branch information
kostya-skw committed Nov 27, 2020
1 parent 32454e3 commit 2002daf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/ansible/modules/cloud/alicloud/ali_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def get_disk_detail(disk):
'description': disk.description,
'status': disk.status,
'type': disk.type,
'instance_id': disk.instance_id
'instance_id': disk.instance_id,
'encrypted': disk.encrypted,
'kms_key_id': disk.k_m_s_key_id,
}


Expand All @@ -252,7 +254,9 @@ def main():
snapshot_id=dict(type='str', aliases=['snapshot']),
description=dict(type='str', aliases=['disk_description']),
instance_id=dict(type='str', aliases=['instance']),
delete_with_instance=dict(type='bool', aliases=['delete_on_termination'], default=False)
delete_with_instance=dict(type='bool', aliases=['delete_on_termination'], default=False),
encrypted=dict(type='bool', default=False),
kms_key_id=dict(type='str', default=None),
)
)
module = AnsibleModule(argument_spec=argument_spec)
Expand All @@ -269,6 +273,8 @@ def main():
disk_name = module.params['disk_name']
delete_with_instance = module.params['delete_with_instance']
description = module.params['description']
encrypted = module.params['encrypted']
kms_key_id = module.params['kms_key_id']

changed = False
current_disk = None
Expand Down Expand Up @@ -321,7 +327,8 @@ def main():
try:
current_disk = ecs.create_disk(zone_id=zone_id, disk_name=disk_name,
description=description, disk_category=disk_category, size=size,
disk_tags=disk_tags, snapshot_id=snapshot_id, client_token=client_token)
disk_tags=disk_tags, snapshot_id=snapshot_id, client_token=client_token,
encrypted=encrypted, k_m_s_key_id=kms_key_id)
changed = True
except Exception as e:
module.fail_json(msg='Creating a new disk is failed, error: {0}'.format(e))
Expand Down

0 comments on commit 2002daf

Please sign in to comment.