Move the fakeprovider module to the fake driver

This change is a follow-up to the drivers spec and it makes the fake provider
a real driver. The fakeprovider module is merged into the fake provider and
the get_one_cloud config loader is simplified.

Change-Id: I3f8ae12ea888e7c2a13f246ea5f85d4a809e8c8d
This commit is contained in:
Tristan Cacqueray 2017-07-27 13:42:38 +00:00
parent 9b5768311f
commit b01227c9d4
41 changed files with 310 additions and 282 deletions

View File

@ -21,7 +21,6 @@ from six.moves import configparser as ConfigParser
import time
import yaml
from nodepool import fakeprovider
from nodepool import zk
@ -204,19 +203,23 @@ def loadConfig(config_path):
l.pools = []
for provider in config.get('providers', []):
provider.setdefault('driver', 'openstack')
# Ensure legacy configuration still works when using fake name
if provider.get('name', '').startswith('fake'):
provider['driver'] = 'fake'
p = Provider()
p.name = provider['name']
p.driver = Driver()
p.driver.name = provider.get('driver', 'openstack')
p.driver.name = provider['driver']
p.driver.manage_images = False
newconfig.providers[p.name] = p
cloud_kwargs = _cloudKwargsFromProvider(provider)
p.cloud_config = None
p.image_type = None
if p.driver.name == 'openstack':
if p.driver.name in ('openstack', 'fake'):
p.driver.manage_images = True
p.cloud_config = _get_one_cloud(cloud_config, cloud_kwargs)
p.cloud_config = cloud_config.get_one_cloud(**cloud_kwargs)
p.image_type = p.cloud_config.config['image_format']
p.region_name = provider.get('region-name')
p.max_concurrency = provider.get('max-concurrency', -1)
@ -311,12 +314,6 @@ def _cloudKwargsFromProvider(provider):
for arg in ['region-name', 'cloud']:
if arg in provider:
cloud_kwargs[arg] = provider[arg]
if provider['driver'] == 'fake':
cloud_kwargs['validate'] = False
return cloud_kwargs
def _get_one_cloud(cloud_config, cloud_kwargs):
'''This is a function to allow for overriding it in tests.'''
if cloud_kwargs.get('cloud', '').startswith('fake'):
return fakeprovider.fake_get_one_cloud(cloud_config, cloud_kwargs)
return cloud_config.get_one_cloud(**cloud_kwargs)

View File

@ -0,0 +1,19 @@
# 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.
from nodepool.driver.openstack.handler import OpenStackNodeRequestHandler
class FakeNodeRequestHandler(OpenStackNodeRequestHandler):
pass

View File

@ -14,14 +14,247 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from nodepool import fakeprovider
import logging
import threading
import time
import uuid
import shade
from nodepool import exceptions
from nodepool.driver.openstack.provider import OpenStackProvider
class Dummy(object):
IMAGE = 'Image'
INSTANCE = 'Instance'
FLAVOR = 'Flavor'
LOCATION = 'Server.Location'
def __init__(self, kind, **kw):
self.__kind = kind
self.__kw = kw
for k, v in kw.items():
setattr(self, k, v)
try:
if self.should_fail:
raise shade.OpenStackCloudException('This image has '
'SHOULD_FAIL set to True.')
except AttributeError:
pass
def __repr__(self):
args = []
for k in self.__kw.keys():
args.append('%s=%s' % (k, getattr(self, k)))
args = ' '.join(args)
return '<%s %s %s>' % (self.__kind, id(self), args)
def __getitem__(self, key, default=None):
return getattr(self, key, default)
def __setitem__(self, key, value):
setattr(self, key, value)
def get(self, key, default=None):
return getattr(self, key, default)
def set(self, key, value):
setattr(self, key, value)
class FakeOpenStackCloud(object):
log = logging.getLogger("nodepool.FakeOpenStackCloud")
def __init__(self, images=None, networks=None):
self.pause_creates = False
self._image_list = images
if self._image_list is None:
self._image_list = [
Dummy(
Dummy.IMAGE,
id='fake-image-id',
status='READY',
name='Fake Precise',
metadata={})
]
if networks is None:
networks = [dict(id='fake-public-network-uuid',
name='fake-public-network-name'),
dict(id='fake-private-network-uuid',
name='fake-private-network-name'),
dict(id='fake-ipv6-network-uuid',
name='fake-ipv6-network-name')]
self.networks = networks
self._flavor_list = [
Dummy(Dummy.FLAVOR, id='f1', ram=8192, name='Fake Flavor'),
Dummy(Dummy.FLAVOR, id='f2', ram=8192, name='Unreal Flavor'),
]
self._server_list = []
def _get(self, name_or_id, instance_list):
self.log.debug("Get %s in %s" % (name_or_id, repr(instance_list)))
for instance in instance_list:
if instance.name == name_or_id or instance.id == name_or_id:
return instance
return None
def get_network(self, name_or_id, filters=None):
for net in self.networks:
if net['id'] == name_or_id or net['name'] == name_or_id:
return net
return self.networks[0]
def _create(
self, instance_list, instance_type=Dummy.INSTANCE,
done_status='ACTIVE', **kw):
should_fail = kw.get('SHOULD_FAIL', '').lower() == 'true'
nics = kw.get('nics', [])
addresses = None
# if keyword 'ipv6-uuid' is found in provider config,
# ipv6 address will be available in public addr dict.
for nic in nics:
if nic['net-id'] != 'fake-ipv6-network-uuid':
continue
addresses = dict(
public=[dict(version=4, addr='fake'),
dict(version=6, addr='fake_v6')],
private=[dict(version=4, addr='fake')]
)
public_v6 = 'fake_v6'
public_v4 = 'fake'
private_v4 = 'fake'
interface_ip = 'fake_v6'
break
if not addresses:
addresses = dict(
public=[dict(version=4, addr='fake')],
private=[dict(version=4, addr='fake')]
)
public_v6 = ''
public_v4 = 'fake'
private_v4 = 'fake'
interface_ip = 'fake'
s = Dummy(instance_type,
id=uuid.uuid4().hex,
name=kw['name'],
status='BUILD',
adminPass='fake',
addresses=addresses,
public_v4=public_v4,
public_v6=public_v6,
private_v4=private_v4,
interface_ip=interface_ip,
location=Dummy(Dummy.LOCATION, zone=kw.get('az')),
metadata=kw.get('meta', {}),
manager=self,
key_name=kw.get('key_name', None),
should_fail=should_fail,
event=threading.Event())
instance_list.append(s)
t = threading.Thread(target=self._finish,
name='FakeProvider create',
args=(s, 0.1, done_status))
t.start()
return s
def _delete(self, name_or_id, instance_list):
self.log.debug("Delete from %s" % (repr(instance_list),))
instance = None
for maybe in instance_list:
if maybe.name == name_or_id or maybe.id == name_or_id:
instance = maybe
if instance:
instance_list.remove(instance)
self.log.debug("Deleted from %s" % (repr(instance_list),))
def _finish(self, obj, delay, status):
self.log.debug("Pause creates %s", self.pause_creates)
if self.pause_creates:
self.log.debug("Pausing")
obj.event.wait()
self.log.debug("Continuing")
else:
time.sleep(delay)
obj.status = status
def create_image(self, **kwargs):
return self._create(
self._image_list, instance_type=Dummy.IMAGE,
done_status='READY', **kwargs)
def get_image(self, name_or_id):
return self._get(name_or_id, self._image_list)
def list_images(self):
return self._image_list
def delete_image(self, name_or_id):
if not name_or_id:
raise Exception('name_or_id is Empty')
self._delete(name_or_id, self._image_list)
def create_image_snapshot(self, name, server, **metadata):
# XXX : validate metadata?
return self._create(
self._image_list, instance_type=Dummy.IMAGE,
name=name, **metadata)
def list_flavors(self, get_extra=False):
return self._flavor_list
def get_openstack_vars(self, server):
server.public_v4 = 'fake'
server.public_v6 = 'fake'
server.private_v4 = 'fake'
server.interface_ip = 'fake'
return server
def create_server(self, **kw):
return self._create(self._server_list, **kw)
def get_server(self, name_or_id):
result = self._get(name_or_id, self._server_list)
return result
def wait_for_server(self, server, **kwargs):
while server.status == 'BUILD':
time.sleep(0.1)
return server
def list_servers(self):
return self._server_list
def delete_server(self, name_or_id, delete_ips=True):
self._delete(name_or_id, self._server_list)
def list_availability_zone_names(self):
return ['fake-az1', 'fake-az2']
class FakeUploadFailCloud(FakeOpenStackCloud):
log = logging.getLogger("nodepool.FakeUploadFailCloud")
def __init__(self, times_to_fail=None):
super(FakeUploadFailCloud, self).__init__()
self.times_to_fail = times_to_fail
self.times_failed = 0
def create_image(self, **kwargs):
if self.times_to_fail is None:
raise exceptions.BuilderError("Test fail image upload.")
self.times_failed += 1
if self.times_failed <= self.times_to_fail:
raise exceptions.BuilderError("Test fail image upload.")
else:
return super(FakeUploadFailCloud, self).create_image(**kwargs)
class FakeProvider(OpenStackProvider):
def __init__(self, provider, use_taskmanager):
self.createServer_fails = 0
self.__client = fakeprovider.FakeOpenStackCloud()
self.__client = FakeOpenStackCloud()
super(FakeProvider, self).__init__(provider, use_taskmanager)
def _getClient(self):

View File

@ -1,255 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2013 OpenStack Foundation
#
# 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 logging
import threading
import time
import uuid
import shade
from nodepool import exceptions
class Dummy(object):
IMAGE = 'Image'
INSTANCE = 'Instance'
FLAVOR = 'Flavor'
LOCATION = 'Server.Location'
def __init__(self, kind, **kw):
self.__kind = kind
self.__kw = kw
for k, v in kw.items():
setattr(self, k, v)
try:
if self.should_fail:
raise shade.OpenStackCloudException('This image has '
'SHOULD_FAIL set to True.')
except AttributeError:
pass
def __repr__(self):
args = []
for k in self.__kw.keys():
args.append('%s=%s' % (k, getattr(self, k)))
args = ' '.join(args)
return '<%s %s %s>' % (self.__kind, id(self), args)
def __getitem__(self, key, default=None):
return getattr(self, key, default)
def __setitem__(self, key, value):
setattr(self, key, value)
def get(self, key, default=None):
return getattr(self, key, default)
def set(self, key, value):
setattr(self, key, value)
def fake_get_one_cloud(cloud_config, cloud_kwargs):
cloud_kwargs['validate'] = False
return cloud_config.get_one_cloud(**cloud_kwargs)
class FakeOpenStackCloud(object):
log = logging.getLogger("nodepool.FakeOpenStackCloud")
def __init__(self, images=None, networks=None):
self.pause_creates = False
self._image_list = images
if self._image_list is None:
self._image_list = [
Dummy(
Dummy.IMAGE,
id='fake-image-id',
status='READY',
name='Fake Precise',
metadata={})
]
if networks is None:
networks = [dict(id='fake-public-network-uuid',
name='fake-public-network-name'),
dict(id='fake-private-network-uuid',
name='fake-private-network-name'),
dict(id='fake-ipv6-network-uuid',
name='fake-ipv6-network-name')]
self.networks = networks
self._flavor_list = [
Dummy(Dummy.FLAVOR, id='f1', ram=8192, name='Fake Flavor'),
Dummy(Dummy.FLAVOR, id='f2', ram=8192, name='Unreal Flavor'),
]
self._server_list = []
def _get(self, name_or_id, instance_list):
self.log.debug("Get %s in %s" % (name_or_id, repr(instance_list)))
for instance in instance_list:
if instance.name == name_or_id or instance.id == name_or_id:
return instance
return None
def get_network(self, name_or_id, filters=None):
for net in self.networks:
if net['id'] == name_or_id or net['name'] == name_or_id:
return net
return self.networks[0]
def _create(
self, instance_list, instance_type=Dummy.INSTANCE,
done_status='ACTIVE', **kw):
should_fail = kw.get('SHOULD_FAIL', '').lower() == 'true'
nics = kw.get('nics', [])
addresses = None
# if keyword 'ipv6-uuid' is found in provider config,
# ipv6 address will be available in public addr dict.
for nic in nics:
if nic['net-id'] != 'fake-ipv6-network-uuid':
continue
addresses = dict(
public=[dict(version=4, addr='fake'),
dict(version=6, addr='fake_v6')],
private=[dict(version=4, addr='fake')]
)
public_v6 = 'fake_v6'
public_v4 = 'fake'
private_v4 = 'fake'
interface_ip = 'fake_v6'
break
if not addresses:
addresses = dict(
public=[dict(version=4, addr='fake')],
private=[dict(version=4, addr='fake')]
)
public_v6 = ''
public_v4 = 'fake'
private_v4 = 'fake'
interface_ip = 'fake'
s = Dummy(instance_type,
id=uuid.uuid4().hex,
name=kw['name'],
status='BUILD',
adminPass='fake',
addresses=addresses,
public_v4=public_v4,
public_v6=public_v6,
private_v4=private_v4,
interface_ip=interface_ip,
location=Dummy(Dummy.LOCATION, zone=kw.get('az')),
metadata=kw.get('meta', {}),
manager=self,
key_name=kw.get('key_name', None),
should_fail=should_fail,
event=threading.Event())
instance_list.append(s)
t = threading.Thread(target=self._finish,
name='FakeProvider create',
args=(s, 0.1, done_status))
t.start()
return s
def _delete(self, name_or_id, instance_list):
self.log.debug("Delete from %s" % (repr(instance_list),))
instance = None
for maybe in instance_list:
if maybe.name == name_or_id or maybe.id == name_or_id:
instance = maybe
if instance:
instance_list.remove(instance)
self.log.debug("Deleted from %s" % (repr(instance_list),))
def _finish(self, obj, delay, status):
self.log.debug("Pause creates %s", self.pause_creates)
if self.pause_creates:
self.log.debug("Pausing")
obj.event.wait()
self.log.debug("Continuing")
else:
time.sleep(delay)
obj.status = status
def create_image(self, **kwargs):
return self._create(
self._image_list, instance_type=Dummy.IMAGE,
done_status='READY', **kwargs)
def get_image(self, name_or_id):
return self._get(name_or_id, self._image_list)
def list_images(self):
return self._image_list
def delete_image(self, name_or_id):
if not name_or_id:
raise Exception('name_or_id is Empty')
self._delete(name_or_id, self._image_list)
def create_image_snapshot(self, name, server, **metadata):
# XXX : validate metadata?
return self._create(
self._image_list, instance_type=Dummy.IMAGE,
name=name, **metadata)
def list_flavors(self, get_extra=False):
return self._flavor_list
def get_openstack_vars(self, server):
server.public_v4 = 'fake'
server.public_v6 = 'fake'
server.private_v4 = 'fake'
server.interface_ip = 'fake'
return server
def create_server(self, **kw):
return self._create(self._server_list, **kw)
def get_server(self, name_or_id):
result = self._get(name_or_id, self._server_list)
return result
def wait_for_server(self, server, **kwargs):
while server.status == 'BUILD':
time.sleep(0.1)
return server
def list_servers(self):
return self._server_list
def delete_server(self, name_or_id, delete_ips=True):
self._delete(name_or_id, self._server_list)
def list_availability_zone_names(self):
return ['fake-az1', 'fake-az2']
class FakeUploadFailCloud(FakeOpenStackCloud):
log = logging.getLogger("nodepool.FakeUploadFailCloud")
def __init__(self, times_to_fail=None):
super(FakeUploadFailCloud, self).__init__()
self.times_to_fail = times_to_fail
self.times_failed = 0
def create_image(self, **kwargs):
if self.times_to_fail is None:
raise exceptions.BuilderError("Test fail image upload.")
self.times_failed += 1
if self.times_failed <= self.times_to_fail:
raise exceptions.BuilderError("Test fail image upload.")
else:
return super(FakeUploadFailCloud, self).create_image(**kwargs)

View File

@ -28,6 +28,7 @@ from nodepool import provider_manager
from nodepool import stats
from nodepool import config as nodepool_config
from nodepool import zk
from nodepool.driver.fake.handler import FakeNodeRequestHandler
from nodepool.driver.openstack.handler import OpenStackNodeRequestHandler
@ -141,7 +142,9 @@ class PoolWorker(threading.Thread):
#----------------------------------------------------------------
def _get_node_request_handler(self, provider, request):
if provider.driver.name == 'openstack':
if provider.driver.name == 'fake':
return FakeNodeRequestHandler(self, request)
elif provider.driver.name == 'openstack':
return OpenStackNodeRequestHandler(self, request)
else:
raise RuntimeError("Unknown provider driver %s" % provider.driver)

View File

@ -23,7 +23,7 @@ from nodepool.driver.openstack.provider import OpenStackProvider
def get_provider(provider, use_taskmanager):
if provider.name.startswith('fake'):
if provider.driver.name == 'fake':
return FakeProvider(provider, use_taskmanager)
elif provider.driver.name == 'openstack':
return OpenStackProvider(provider, use_taskmanager)

View File

@ -32,7 +32,6 @@ import kazoo.client
import testtools
from nodepool import builder
from nodepool import fakeprovider
from nodepool import launcher
from nodepool import webapp
from nodepool import zk
@ -190,9 +189,6 @@ class BaseTestCase(testtools.TestCase):
self.setUpFakes()
def setUpFakes(self):
self.useFixture(fixtures.MonkeyPatch(
'nodepool.launcher._get_one_cloud',
fakeprovider.fake_get_one_cloud))
clouds_path = os.path.join(os.path.dirname(__file__),
'fixtures', 'clouds.yaml')
self.useFixture(fixtures.MonkeyPatch(

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
nodepool-id: foo

View File

@ -15,6 +15,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -14,6 +14,7 @@ labels:
providers:
- name: fake-provider1
cloud: fake
driver: fake
rate: 0.0001
diskimages:
- name: fake-image1
@ -31,6 +32,7 @@ providers:
- name: fake-provider2
cloud: fake
driver: fake
rate: 0.0001
diskimages:
- name: fake-image2

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -15,6 +15,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -15,6 +15,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -16,6 +16,7 @@ labels:
providers:
- name: fake-provider1
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
@ -34,6 +35,7 @@ providers:
- name: fake-provider2
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
@ -22,6 +23,7 @@ providers:
max-servers: 96
- name: fake-provider2
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
launch-retries: 2
rate: 0.0001

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -14,6 +14,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -15,6 +15,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
@ -26,6 +27,7 @@ providers:
min-ram: 8192
- name: fake-provider2
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
@ -27,6 +28,7 @@ providers:
- name: fake-provider2
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
cloud-images:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider1
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
@ -29,6 +30,7 @@ providers:
- name: fake-provider2
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider
cloud: fake-vhd
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -13,6 +13,7 @@ labels:
providers:
- name: fake-provider1
cloud: fake-vhd
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
@ -27,6 +28,7 @@ providers:
- name: fake-provider2
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:

View File

@ -17,7 +17,8 @@ import os
import uuid
import fixtures
from nodepool import builder, exceptions, fakeprovider, tests
from nodepool import builder, exceptions, tests
from nodepool.driver.fake import provider as fakeprovider
from nodepool import zk
@ -120,9 +121,6 @@ class TestNodePoolBuilder(tests.DBTestCase):
self.useFixture(fixtures.MonkeyPatch(
'nodepool.driver.fake.provider.FakeProvider._getClient',
get_fake_client))
self.useFixture(fixtures.MonkeyPatch(
'nodepool.launcher._get_one_cloud',
fakeprovider.fake_get_one_cloud))
configfile = self.setup_config('node.yaml')
pool = self.useNodepool(configfile, watermark_sleep=1)

View File

@ -91,7 +91,7 @@ class TestNodepoolCMD(tests.DBTestCase):
def fail_list(self):
raise RuntimeError('Fake list error')
self.useFixture(fixtures.MonkeyPatch(
'nodepool.fakeprovider.FakeOpenStackCloud.list_servers',
'nodepool.driver.fake.provider.FakeOpenStackCloud.list_servers',
fail_list))
configfile = self.setup_config("node_cmd.yaml")
@ -110,7 +110,7 @@ class TestNodepoolCMD(tests.DBTestCase):
def fail_list(self):
raise RuntimeError('Fake list error')
self.useFixture(fixtures.MonkeyPatch(
'nodepool.fakeprovider.FakeOpenStackCloud.list_servers',
'nodepool.driver.fake.provider.FakeOpenStackCloud.list_servers',
fail_list))
configfile = self.setup_config("node_cmd.yaml")

View File

@ -19,7 +19,6 @@ import fixtures
from nodepool import tests
from nodepool import zk
import nodepool.fakeprovider
import nodepool.launcher

View File

@ -21,6 +21,7 @@ labels:
providers:
- name: fake-provider
driver: fake
region-name: 'fake-region'
max-servers: 96
images:

View File

@ -23,6 +23,7 @@ labels:
providers:
- name: fake-provider
driver: fake
region-name: 'fake-region'
diskimages:
- name: fake-nodepool

View File

@ -22,6 +22,7 @@ labels:
providers:
- name: fake-provider
cloud: fake
driver: fake
diskimages:
- name: fake-nodepool
pools: