Merge "Extract common config parsing for ProviderConfig"
This commit is contained in:
commit
264c3478fa
@ -14,6 +14,7 @@ import logging
|
||||
import voluptuous as v
|
||||
import yaml
|
||||
|
||||
from nodepool.driver import ProviderConfig
|
||||
from nodepool.config import get_provider_config
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -26,11 +27,7 @@ class ConfigValidator:
|
||||
self.config_file = config_file
|
||||
|
||||
def validate(self):
|
||||
provider = {
|
||||
'name': v.Required(str),
|
||||
'driver': str,
|
||||
'max-concurrency': int,
|
||||
}
|
||||
provider = ProviderConfig.getCommonSchemaDict()
|
||||
|
||||
label = {
|
||||
'name': str,
|
||||
|
@ -22,6 +22,7 @@ import importlib
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import voluptuous as v
|
||||
|
||||
from nodepool import zk
|
||||
from nodepool import exceptions
|
||||
@ -910,6 +911,14 @@ class ProviderConfig(ConfigValue, metaclass=abc.ABCMeta):
|
||||
def __repr__(self):
|
||||
return "<Provider %s>" % self.name
|
||||
|
||||
@classmethod
|
||||
def getCommonSchemaDict(self):
|
||||
return {
|
||||
v.Required('name'): str,
|
||||
'driver': str,
|
||||
'max-concurrency': int
|
||||
}
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def pools(self):
|
||||
|
@ -109,7 +109,10 @@ class KubernetesProviderConfig(ProviderConfig):
|
||||
v.Required('context'): str,
|
||||
'launch-retries': int,
|
||||
}
|
||||
return v.Schema(provider)
|
||||
|
||||
schema = ProviderConfig.getCommonSchemaDict()
|
||||
schema.update(provider)
|
||||
return v.Schema(schema)
|
||||
|
||||
def getSupportedLabels(self, pool_name=None):
|
||||
labels = set()
|
||||
|
@ -385,7 +385,8 @@ class OpenStackProviderConfig(ProviderConfig):
|
||||
'security-groups': [str]
|
||||
})
|
||||
|
||||
return v.Schema({
|
||||
schema = ProviderConfig.getCommonSchemaDict()
|
||||
schema.update({
|
||||
'region-name': str,
|
||||
v.Required('cloud'): str,
|
||||
'boot-timeout': int,
|
||||
@ -400,6 +401,7 @@ class OpenStackProviderConfig(ProviderConfig):
|
||||
'diskimages': [provider_diskimage],
|
||||
'cloud-images': [provider_cloud_images],
|
||||
})
|
||||
return v.Schema(schema)
|
||||
|
||||
def getSupportedLabels(self, pool_name=None):
|
||||
labels = set()
|
||||
|
@ -112,7 +112,9 @@ class StaticProviderConfig(ProviderConfig):
|
||||
'name': str,
|
||||
'nodes': [pool_node],
|
||||
})
|
||||
return v.Schema({'pools': [pool]})
|
||||
schema = ProviderConfig.getCommonSchemaDict()
|
||||
schema.update({'pools': [pool]})
|
||||
return v.Schema(schema)
|
||||
|
||||
def getSupportedLabels(self, pool_name=None):
|
||||
labels = set()
|
||||
|
@ -58,7 +58,9 @@ class TestConfig(ProviderConfig):
|
||||
'name': str,
|
||||
'labels': [str]
|
||||
})
|
||||
return v.Schema({'pools': [pool]})
|
||||
schema = ProviderConfig.getCommonSchemaDict()
|
||||
schema.update({'pools': [pool]})
|
||||
return v.Schema(schema)
|
||||
|
||||
def getSupportedLabels(self, pool_name=None):
|
||||
return self.labels
|
||||
|
Loading…
Reference in New Issue
Block a user