From 516e8cd176a2aeb70a17404585a808287602204f Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 6 Feb 2019 13:14:35 +0000 Subject: [PATCH] Rename aws flavor-name to instance-type The AWS term is instance-type, not flavor-name. Rename this while we don't have a huge userbase. While we're in there, rename a variable from image_name to image_id since we use image_id everywhere else. Change-Id: I1f7f16d2873982626d2434cf5ca1f6280adf739c --- doc/source/configuration.rst | 8 ++++---- nodepool/driver/aws/config.py | 8 ++++---- nodepool/driver/aws/provider.py | 8 ++++---- nodepool/tests/fixtures/aws.yaml | 2 +- nodepool/tests/fixtures/config_validate/good.yaml | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 09f755463..e4ab60b5f 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -1347,11 +1347,11 @@ section of the configuration. labels: - name: debian9 cloud-image: debian9 - flavor-name: t3.medium + instance-type: t3.medium key-name: zuul - name: debian9-large cloud-image: debian9 - flavor-name: t3.large + instance-type: t3.large key-name: zuul .. attr:: name @@ -1484,7 +1484,7 @@ section of the configuration. labels: - name: bionic - flavor-name: m5a.large + instance-type: m5a.large console-log: True Each entry is a dictionary with the following keys @@ -1505,7 +1505,7 @@ section of the configuration. configured entry from the ``cloud-images`` section of the provider. See :attr:`providers.[aws].cloud-images`. - .. attr:: flavor-name + .. attr:: instance-type :type: str :required: diff --git a/nodepool/driver/aws/config.py b/nodepool/driver/aws/config.py index 17a64e6dc..f3708fe12 100644 --- a/nodepool/driver/aws/config.py +++ b/nodepool/driver/aws/config.py @@ -51,7 +51,7 @@ class ProviderLabel(ConfigValue): def __init__(self): self.name = None self.cloud_image = None - self.flavor_name = None + self.instance_type = None self.key_name = None self.volume_size = None self.volume_type = None @@ -64,7 +64,7 @@ class ProviderLabel(ConfigValue): # since this causes recursive checks with ProviderPool. return (other.name == self.name and other.cloud_image == self.cloud_image - and other.flavor_name == self.flavor_name + and other.instance_type == self.instance_type and other.key_name == self.key_name and other.volume_size == self.volume_size and other.volume_type == self.volume_type) @@ -116,7 +116,7 @@ class ProviderPool(ConfigPool): else: cloud_image = None pl.cloud_image = cloud_image - pl.flavor_name = label['flavor-name'] + pl.instance_type = label['instance-type'] pl.key_name = label['key-name'] pl.volume_type = label.get('volume-type') pl.volume_size = label.get('volume-size') @@ -204,7 +204,7 @@ class AwsProviderConfig(ProviderConfig): pool_label = { v.Required('name'): str, v.Exclusive('cloud-image', 'label-image'): str, - v.Required('flavor-name'): str, + v.Required('instance-type'): str, v.Required('key-name'): str, 'volume-type': str, 'volume-size': int diff --git a/nodepool/driver/aws/provider.py b/nodepool/driver/aws/provider.py index 941508c6c..e25202628 100644 --- a/nodepool/driver/aws/provider.py +++ b/nodepool/driver/aws/provider.py @@ -107,13 +107,13 @@ class AwsProvider(Provider): return True def createInstance(self, label): - image_name = label.cloud_image.external_name + image_id = label.cloud_image.external_name args = dict( - ImageId=image_name, + ImageId=image_id, MinCount=1, MaxCount=1, KeyName=label.key_name, - InstanceType=label.flavor_name, + InstanceType=label.instance_type, NetworkInterfaces=[{ 'AssociatePublicIpAddress': True, 'DeviceIndex': 0}]) @@ -129,7 +129,7 @@ class AwsProvider(Provider): # We might need to supply our own mapping before lauching the instance. # We basically want to make sure DeleteOnTermination is true and be # able to set the volume type and size. - image = self.getImage(image_name) + image = self.getImage(image_id) # TODO: Flavors can also influence whether or not the VM spawns with a # volume -- we basically need to ensure DeleteOnTermination is true if hasattr(image, 'block_device_mappings'): diff --git a/nodepool/tests/fixtures/aws.yaml b/nodepool/tests/fixtures/aws.yaml index 7a5fc7af4..275056c31 100644 --- a/nodepool/tests/fixtures/aws.yaml +++ b/nodepool/tests/fixtures/aws.yaml @@ -22,5 +22,5 @@ providers: labels: - name: ubuntu1404 cloud-image: ubuntu1404 - flavor-name: t3.medium + instance-type: t3.medium key-name: zuul diff --git a/nodepool/tests/fixtures/config_validate/good.yaml b/nodepool/tests/fixtures/config_validate/good.yaml index 2dcbbfddc..3d1fb53f7 100644 --- a/nodepool/tests/fixtures/config_validate/good.yaml +++ b/nodepool/tests/fixtures/config_validate/good.yaml @@ -155,7 +155,7 @@ providers: labels: - name: centos-ami cloud-image: centos-ami - flavor-name: t2.micro + instance-type: t2.micro key-name: zuul volume-type: gp2 volume-size: 80