Remove _driver_factory class attribute

Remove the _driver_factory class property from NodeManager, after the
DriverFactory code refactor it should now be an instance attribute.

Change-Id: I89946dc4078778d23a1a645be95919a39174ed5d
This commit is contained in:
Lucas Alvares Gomes 2013-10-23 18:02:17 +01:00
parent bbefb22efd
commit 1eedfc290f
2 changed files with 26 additions and 18 deletions

View File

@ -45,7 +45,6 @@ class NodeManager(object):
"""The data model, state, and drivers to manage a Node."""
_nodes = {}
_driver_factory = None
def __init__(self, id, t, driver_name=None):
self._driver_factory = driver_factory.DriverFactory()
@ -102,7 +101,7 @@ class NodeManager(object):
:raises: DriverNotFound if any driver is not found.
"""
try:
driver = NodeManager._driver_factory[driver_name]
driver = self._driver_factory[driver_name]
except KeyError:
raise exception.DriverNotFound(driver_name=driver_name)

View File

@ -16,6 +16,7 @@
import contextlib
import mock
from ironic.common import driver_factory
from ironic.common import exception
from ironic.conductor import resource_manager
from ironic.tests import base
@ -48,9 +49,10 @@ class NodeManagerTestCase(base.TestCase):
def test_node_manager_init_id(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch("ironic.conductor.resource_manager.dbapi",
self.dbapi)):
@ -59,9 +61,10 @@ class NodeManagerTestCase(base.TestCase):
def test_node_manager_init_task(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch("ironic.conductor.resource_manager.dbapi",
self.dbapi)
@ -71,9 +74,10 @@ class NodeManagerTestCase(base.TestCase):
def test_node_manager_init_node(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch("ironic.conductor.resource_manager.dbapi",
self.dbapi)
@ -83,9 +87,10 @@ class NodeManagerTestCase(base.TestCase):
def test_node_manager_init_ports(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch("ironic.conductor.resource_manager.dbapi",
self.dbapi)
@ -95,9 +100,10 @@ class NodeManagerTestCase(base.TestCase):
def test_node_manager_init_driver(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch("ironic.conductor.resource_manager.dbapi",
self.dbapi)
@ -107,9 +113,10 @@ class NodeManagerTestCase(base.TestCase):
def test_node_manager_init_new_driver(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch("ironic.conductor.resource_manager.dbapi",
self.dbapi)
@ -121,9 +128,10 @@ class NodeManagerTestCase(base.TestCase):
def test_load_existing_driver(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch.object(NodeManager,
'__init__',
@ -138,9 +146,10 @@ class NodeManagerTestCase(base.TestCase):
def test_load_non_existing_driver(self):
NodeManager = resource_manager.NodeManager
DriverFactory = driver_factory.DriverFactory
with contextlib.nested(
mock.patch.object(NodeManager,
'_driver_factory',
mock.patch.object(DriverFactory,
'_extension_manager',
new=self.driver_factory),
mock.patch.object(NodeManager,
'__init__',