add ebs-optimized support for aws provider

Change-Id: I1f6330a71b85f23e6fbe3abd636764e5f3b8a61d
This commit is contained in:
Andy Ladjadj 2020-02-04 17:35:23 +01:00
parent 79388c2be8
commit 5bae6272f4
6 changed files with 31 additions and 1 deletions

View File

@ -1800,6 +1800,14 @@ section of the configuration.
configured entry from the ``cloud-images`` section of the configured entry from the ``cloud-images`` section of the
provider. See :attr:`providers.[aws].cloud-images`. provider. See :attr:`providers.[aws].cloud-images`.
.. attr:: ebs-optimized
:type: bool
:default: False
Indicates whether EBS optimization
(additional, dedicated throughput between Amazon EC2 and Amazon EBS,)
has been enabled for the instance.
.. attr:: instance-type .. attr:: instance-type
:type: str :type: str
:required: :required:

View File

@ -52,6 +52,7 @@ class ProviderLabel(ConfigValue):
def __init__(self): def __init__(self):
self.name = None self.name = None
self.cloud_image = None self.cloud_image = None
self.ebs_optimized = None
self.instance_type = None self.instance_type = None
self.key_name = None self.key_name = None
self.volume_size = None self.volume_size = None
@ -67,6 +68,7 @@ class ProviderLabel(ConfigValue):
# since this causes recursive checks with ProviderPool. # since this causes recursive checks with ProviderPool.
return (other.name == self.name return (other.name == self.name
and other.cloud_image == self.cloud_image and other.cloud_image == self.cloud_image
and other.ebs_optimized == self.ebs_optimized
and other.instance_type == self.instance_type and other.instance_type == self.instance_type
and other.key_name == self.key_name and other.key_name == self.key_name
and other.volume_size == self.volume_size and other.volume_size == self.volume_size
@ -123,6 +125,7 @@ class ProviderPool(ConfigPool):
else: else:
cloud_image = None cloud_image = None
pl.cloud_image = cloud_image pl.cloud_image = cloud_image
pl.ebs_optimized = bool(label.get('ebs-optimized', False))
pl.instance_type = label['instance-type'] pl.instance_type = label['instance-type']
pl.key_name = label['key-name'] pl.key_name = label['key-name']
pl.volume_type = label.get('volume-type') pl.volume_type = label.get('volume-type')
@ -236,6 +239,7 @@ class AwsProviderConfig(ProviderConfig):
v.Exclusive('cloud-image', 'label-image'): str, v.Exclusive('cloud-image', 'label-image'): str,
v.Required('instance-type'): str, v.Required('instance-type'): str,
v.Required('key-name'): str, v.Required('key-name'): str,
'ebs-optimized': bool,
'volume-type': str, 'volume-type': str,
'volume-size': int, 'volume-size': int,
'userdata': str, 'userdata': str,

View File

@ -167,6 +167,7 @@ class AwsProvider(Provider):
MinCount=1, MinCount=1,
MaxCount=1, MaxCount=1,
KeyName=label.key_name, KeyName=label.key_name,
EbsOptimized=label.ebs_optimized,
InstanceType=label.instance_type, InstanceType=label.instance_type,
NetworkInterfaces=[{ NetworkInterfaces=[{
'AssociatePublicIpAddress': label.pool.public_ip, 'AssociatePublicIpAddress': label.pool.public_ip,

View File

@ -9,6 +9,7 @@ labels:
- name: ubuntu1404-by-filters - name: ubuntu1404-by-filters
- name: ubuntu1404-by-capitalized-filters - name: ubuntu1404-by-capitalized-filters
- name: ubuntu1404-bad-config - name: ubuntu1404-bad-config
- name: ubuntu1404-ebs-optimized
- name: ubuntu1404-non-host-key-checking - name: ubuntu1404-non-host-key-checking
- name: ubuntu1404-private-ip - name: ubuntu1404-private-ip
- name: ubuntu1404-userdata - name: ubuntu1404-userdata
@ -45,6 +46,16 @@ providers:
- ubuntu* - ubuntu*
username: ubuntu username: ubuntu
pools: pools:
- name: ebs-optimized
max-servers: 1
subnet-id: null
security-group-id: null
labels:
- name: ubuntu1404-ebs-optimized
cloud-image: ubuntu1404
ebs-optimized: True
instance-type: t3.medium
key-name: zuul
- name: main - name: main
max-servers: 1 max-servers: 1
subnet-id: null subnet-id: null
@ -105,4 +116,4 @@ providers:
instance-type: t3.medium instance-type: t3.medium
key-name: zuul key-name: zuul
tags: tags:
has-tags: true has-tags: true

View File

@ -88,6 +88,8 @@ class TestDriverAws(tests.DBTestCase):
raw_config['providers'][0]['pools'][2]['security-group-id'] = sg_id raw_config['providers'][0]['pools'][2]['security-group-id'] = sg_id
raw_config['providers'][0]['pools'][3]['subnet-id'] = subnet_id raw_config['providers'][0]['pools'][3]['subnet-id'] = subnet_id
raw_config['providers'][0]['pools'][3]['security-group-id'] = sg_id raw_config['providers'][0]['pools'][3]['security-group-id'] = sg_id
raw_config['providers'][0]['pools'][4]['subnet-id'] = subnet_id
raw_config['providers'][0]['pools'][4]['security-group-id'] = sg_id
with tempfile.NamedTemporaryFile() as tf: with tempfile.NamedTemporaryFile() as tf:
tf.write(yaml.safe_dump( tf.write(yaml.safe_dump(

View File

@ -0,0 +1,4 @@
---
features:
- |
Add optional ebs-optimized on ec2 instances.