
This change adds a plugin interface so that driver can be loaded dynamically. Instead of importing each driver in the launcher, provider_manager and config, the Drivers class discovers and loads driver from the driver directory. This change also adds a reset() method to the driver Config interface to reset the os_client_config reference when reloading the OpenStack driver. Change-Id: Ia347aa2501de0e05b2a7dd014c4daf1b0a4e0fb5
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
# Copyright 2017 Red Hat
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import voluptuous as v
|
|
|
|
from nodepool.driver import ConfigValue
|
|
from nodepool.driver import ProviderConfig
|
|
|
|
|
|
class TestPool(ConfigValue):
|
|
pass
|
|
|
|
|
|
class TestConfig(ProviderConfig):
|
|
def __eq__(self, other):
|
|
return self.name == other.name
|
|
|
|
@staticmethod
|
|
def reset():
|
|
pass
|
|
|
|
def load(self, newconfig):
|
|
self.pools = {}
|
|
for pool in self.provider.get('pools', []):
|
|
testpool = TestPool()
|
|
testpool.name = pool['name']
|
|
testpool.provider = self
|
|
for label in pool['labels']:
|
|
newconfig.labels[label].pools.append(testpool)
|
|
self.pools[pool['name']] = testpool
|
|
|
|
def get_schema(self):
|
|
pool = {'name': str,
|
|
'labels': [str]}
|
|
return v.Schema({'pools': [pool]})
|