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

aws: add customize_block_device_map to leave api to handle block device mapping #415

Merged
merged 1 commit into from
Jul 24, 2024
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
3 changes: 3 additions & 0 deletions os_tests/cfg/aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ tagname : os_tests_aws
# optional(imdsv1 and v2)|required(imdsv2 only)
httptokens : optional
# default root volume setting
# set customize_block_device_map to False to leave api to handle block device mapping.
# when customize_block_device_map is False, volume_type and volume_size will not be used
customize_block_device_map: True
# volume_type: 'standard'|'io1'|'io2'|'gp2'|'sc1'|'st1'|'gp3' or other supported
volume_type : 'gp3'
volume_size : 10
Expand Down
27 changes: 15 additions & 12 deletions os_tests/libs/resources_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, params, vendor="redhat"):
self.secondary_ip_list = []
# efa_support default set to False, will query instance property next
self.efa_support = False
self.customize_block_device_map = params.get('customize_block_device_map')
self.volume_type = params.get('volume_type') or 'gp3'
self.volume_size = params.get('volume_size') or 10
self.subscription_username = params.get('subscription_username')
Expand Down Expand Up @@ -129,18 +130,6 @@ def create(self, wait=True, enable_efa=True, enable_hibernation=False, enable_en
LOG.info('create with enclave enabled, change volume size to {}'.format(self.volume_size))
self.volume_size = 50
vm_kwargs = {
'BlockDeviceMappings':[
{
'DeviceName': self.root_device_name,
'Ebs': {
'DeleteOnTermination': True,
'VolumeType': self.volume_type,
'VolumeSize': self.volume_size,
# root disk must be encrypted when hibernation enabled
'Encrypted': enable_hibernation
},
},
],
"ImageId":self.ami_id,
"InstanceType":self.instance_type,
"MaxCount":1,
Expand Down Expand Up @@ -178,10 +167,24 @@ def create(self, wait=True, enable_efa=True, enable_hibernation=False, enable_en
'InstanceMetadataTags': 'enabled'
}
}

sshkey= sshkey or self.ssh_key_name
if sshkey and sshkey != "DoNotSet" :
vm_kwargs['KeyName'] = sshkey
userdata= userdata or self.user_data
if self.customize_block_device_map or enable_hibernation:
vm_kwargs['BlockDeviceMappings'] = [
{
'DeviceName': self.root_device_name,
'Ebs': {
'DeleteOnTermination': True,
'VolumeType': self.volume_type,
'VolumeSize': self.volume_size,
# root disk must be encrypted when hibernation enabled
'Encrypted': enable_hibernation
},
},
]
if userdata:
vm_kwargs['UserData'] = userdata
if self.efa_support:
Expand Down
Loading