Merge "Fix AWS driver equality check"
This commit is contained in:
commit
f45817e6ab
|
@ -29,17 +29,6 @@ class ProviderCloudImage(ConfigValue):
|
|||
self.connection_type = None
|
||||
self.connection_port = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, ProviderCloudImage):
|
||||
return (self.name == other.name
|
||||
and self.image_id == other.image_id
|
||||
and self.username == other.username
|
||||
and self.python_path == other.python_path
|
||||
and self.shell_type == other.shell_type
|
||||
and self.connection_type == other.connection_type
|
||||
and self.connection_port == other.connection_port)
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return "<ProviderCloudImage %s>" % self.name
|
||||
|
||||
|
@ -50,6 +39,8 @@ class ProviderCloudImage(ConfigValue):
|
|||
|
||||
|
||||
class ProviderLabel(ConfigValue):
|
||||
ignore_equality = ['pool']
|
||||
|
||||
def __init__(self):
|
||||
self.name = None
|
||||
self.cloud_image = None
|
||||
|
@ -64,27 +55,13 @@ class ProviderLabel(ConfigValue):
|
|||
self.pool = None
|
||||
self.tags = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, ProviderLabel):
|
||||
# NOTE(Shrews): We intentionally do not compare 'pool' here
|
||||
# since this causes recursive checks with ProviderPool.
|
||||
return (other.name == self.name
|
||||
and other.cloud_image == self.cloud_image
|
||||
and other.ebs_optimized == self.ebs_optimized
|
||||
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
|
||||
and other.userdata == self.userdata
|
||||
and other.iam_instance_profile == self.iam_instance_profile
|
||||
and other.tags == self.tags)
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return "<ProviderLabel %s>" % self.name
|
||||
|
||||
|
||||
class ProviderPool(ConfigPool):
|
||||
ignore_equality = ['provider']
|
||||
|
||||
def __init__(self):
|
||||
self.name = None
|
||||
self.max_cores = None
|
||||
|
@ -143,19 +120,6 @@ class ProviderPool(ConfigPool):
|
|||
]
|
||||
full_config.labels[label['name']].pools.append(self)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, ProviderPool):
|
||||
# NOTE(Shrews): We intentionally do not compare 'provider' here
|
||||
# since this causes recursive checks with OpenStackProviderConfig.
|
||||
return (super().__eq__(other)
|
||||
and other.name == self.name
|
||||
and other.subnet_id == self.subnet_id
|
||||
and other.security_group_id == self.security_group_id
|
||||
and other.public_ip == self.public_ip
|
||||
and other.host_key_checking == self.host_key_checking
|
||||
and other.labels == self.labels)
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return "<ProviderPool %s>" % self.name
|
||||
|
||||
|
@ -171,17 +135,6 @@ class AwsProviderConfig(ProviderConfig):
|
|||
self.cloud_images = {}
|
||||
super().__init__(provider)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, AwsProviderConfig):
|
||||
return (super().__eq__(other)
|
||||
and other.profile_name == self.profile_name
|
||||
and other.region_name == self.region_name
|
||||
and other.pools == self.pools
|
||||
and other.boot_timeout == self.boot_timeout
|
||||
and other.launch_retries == self.launch_retries
|
||||
and other.cloud_images == self.cloud_images)
|
||||
return False
|
||||
|
||||
@property
|
||||
def pools(self):
|
||||
return self.__pools
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
zookeeper-servers:
|
||||
- host: {zookeeper_host}
|
||||
port: {zookeeper_port}
|
||||
chroot: {zookeeper_chroot}
|
||||
|
||||
zookeeper-tls:
|
||||
ca: {zookeeper_ca}
|
||||
cert: {zookeeper_cert}
|
||||
key: {zookeeper_key}
|
||||
|
||||
labels:
|
||||
- name: ubuntu1404
|
||||
|
||||
providers:
|
||||
- name: ec2-us-west-2
|
||||
driver: aws
|
||||
region-name: us-west-2
|
||||
cloud-images:
|
||||
- name: ubuntu1404
|
||||
image-id: ami-1e749f67
|
||||
username: ubuntu
|
||||
pools:
|
||||
- name: main
|
||||
max-servers: 1
|
||||
subnet-id: 'subnetid'
|
||||
security-group-id: 'secgroupid'
|
||||
node-attributes:
|
||||
key1: value1
|
||||
key2: value2
|
||||
labels:
|
||||
- name: ubuntu1404
|
||||
cloud-image: ubuntu1404
|
||||
instance-type: t3.medium
|
||||
key-name: zuul
|
|
@ -25,6 +25,7 @@ import boto3
|
|||
from moto import mock_ec2
|
||||
import yaml
|
||||
|
||||
from nodepool import config as nodepool_config
|
||||
from nodepool import tests
|
||||
from nodepool import zk
|
||||
from nodepool.nodeutils import iterate_timeout
|
||||
|
@ -259,3 +260,10 @@ class TestDriverAws(tests.DBTestCase):
|
|||
def test_ec2_machine_shell_type(self):
|
||||
self._test_ec2_machine('ubuntu1404-with-shell-type',
|
||||
shell_type="csh")
|
||||
|
||||
def test_aws_config(self):
|
||||
configfile = self.setup_config('aws-config.yaml')
|
||||
config = nodepool_config.loadConfig(configfile)
|
||||
self.assertIn('ec2-us-west-2', config.providers)
|
||||
config2 = nodepool_config.loadConfig(configfile)
|
||||
self.assertEqual(config, config2)
|
||||
|
|
Loading…
Reference in New Issue