Group drivers modules by type
Change-Id: Id5fab5efa5dfbe155e559256faf465b7d0b76706
This commit is contained in:
parent
081499f8a1
commit
8bdb893209
@ -16,6 +16,7 @@ import re
|
|||||||
from os_faults.api import error
|
from os_faults.api import error
|
||||||
from os_faults.api import node_collection as node_collection_pkg
|
from os_faults.api import node_collection as node_collection_pkg
|
||||||
from os_faults.api import service as service_pkg
|
from os_faults.api import service as service_pkg
|
||||||
|
from os_faults.api import utils
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Human API understands commands like these (examples):
|
Human API understands commands like these (examples):
|
||||||
@ -42,8 +43,7 @@ Human API understands commands like these (examples):
|
|||||||
def list_actions(klazz):
|
def list_actions(klazz):
|
||||||
return set(m[0].replace('_', ' ') for m in inspect.getmembers(
|
return set(m[0].replace('_', ' ') for m in inspect.getmembers(
|
||||||
klazz,
|
klazz,
|
||||||
predicate=lambda o: ((inspect.isfunction(o) or inspect.ismethod(o)) and
|
predicate=utils.is_public))
|
||||||
hasattr(o, '__public__'))))
|
|
||||||
|
|
||||||
RANDOMNESS = {'one', 'random', 'some', 'single'}
|
RANDOMNESS = {'one', 'random', 'some', 'single'}
|
||||||
ANYTHING = {'all'}
|
ANYTHING = {'all'}
|
||||||
|
@ -16,7 +16,7 @@ import random
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from os_faults.api import error
|
from os_faults.api import error
|
||||||
from os_faults.api.util import public
|
from os_faults.api.utils import public
|
||||||
from os_faults import utils
|
from os_faults import utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -16,7 +16,7 @@ import abc
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from os_faults.api import base_driver
|
from os_faults.api import base_driver
|
||||||
from os_faults.api.util import public
|
from os_faults.api.utils import public
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
|
@ -11,7 +11,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
|
||||||
def public(funcobj):
|
|
||||||
funcobj.__public__ = True
|
def public(func):
|
||||||
return funcobj
|
func.__public__ = True
|
||||||
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
def is_public(obj):
|
||||||
|
return ((inspect.isfunction(obj) or inspect.ismethod(obj))
|
||||||
|
and hasattr(obj, '__public__'))
|
@ -17,7 +17,7 @@ from os_faults.ansible import executor
|
|||||||
from os_faults.api import cloud_management
|
from os_faults.api import cloud_management
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.api import node_discover
|
from os_faults.api import node_discover
|
||||||
from os_faults.common import service
|
from os_faults.drivers import service
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from os_faults.drivers import devstack
|
from os_faults.drivers.cloud import devstack
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -18,7 +18,7 @@ from os_faults.ansible import executor
|
|||||||
from os_faults.api import cloud_management
|
from os_faults.api import cloud_management
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.api import node_discover
|
from os_faults.api import node_discover
|
||||||
from os_faults.common import service
|
from os_faults.drivers import service
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -19,7 +19,7 @@ from os_faults.ansible import executor
|
|||||||
from os_faults.api import cloud_management
|
from os_faults.api import cloud_management
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.api import node_discover
|
from os_faults.api import node_discover
|
||||||
from os_faults.common import service
|
from os_faults.drivers import service
|
||||||
from os_faults import error
|
from os_faults import error
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
0
os_faults/drivers/nodes/__init__.py
Normal file
0
os_faults/drivers/nodes/__init__.py
Normal file
0
os_faults/drivers/power/__init__.py
Normal file
0
os_faults/drivers/power/__init__.py
Normal file
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from os_faults.api import error
|
from os_faults.api import error
|
||||||
from os_faults.api import power_management
|
from os_faults.api import power_management
|
||||||
|
|
||||||
@ -59,12 +61,11 @@ class LibvirtDriver(power_management.PowerDriver):
|
|||||||
|
|
||||||
def _get_connection(self):
|
def _get_connection(self):
|
||||||
if self._cached_conn is None:
|
if self._cached_conn is None:
|
||||||
try:
|
libvirt_module = importutils.try_import('libvirt')
|
||||||
import libvirt
|
if not libvirt_module:
|
||||||
except ImportError:
|
|
||||||
raise error.OSFError('libvirt-python is required '
|
raise error.OSFError('libvirt-python is required '
|
||||||
'to use LibvirtDriver')
|
'to use LibvirtDriver')
|
||||||
self._cached_conn = libvirt.open(self.connection_uri)
|
self._cached_conn = libvirt_module.open(self.connection_uri)
|
||||||
|
|
||||||
return self._cached_conn
|
return self._cached_conn
|
||||||
|
|
0
os_faults/tests/unit/drivers/cloud/__init__.py
Normal file
0
os_faults/tests/unit/drivers/cloud/__init__.py
Normal file
@ -17,7 +17,7 @@ import ddt
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import devstack
|
from os_faults.drivers.cloud import devstack
|
||||||
from os_faults.tests.unit import fakes
|
from os_faults.tests.unit import fakes
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
@ -15,8 +15,8 @@ import ddt
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import devstack_systemd
|
from os_faults.drivers.cloud import devstack_systemd
|
||||||
from os_faults.tests.unit.drivers import test_devstack
|
from os_faults.tests.unit.drivers.cloud import test_devstack
|
||||||
from os_faults.tests.unit import fakes
|
from os_faults.tests.unit import fakes
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
@ -17,7 +17,7 @@ import mock
|
|||||||
from os_faults.ansible import executor
|
from os_faults.ansible import executor
|
||||||
from os_faults.api import error
|
from os_faults.api import error
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import fuel
|
from os_faults.drivers.cloud import fuel
|
||||||
from os_faults.tests.unit import fakes
|
from os_faults.tests.unit import fakes
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
@ -16,7 +16,7 @@ import copy
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import fuel
|
from os_faults.drivers.cloud import fuel
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ import mock
|
|||||||
from os_faults.ansible import executor
|
from os_faults.ansible import executor
|
||||||
from os_faults.api import error
|
from os_faults.api import error
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import fuel
|
from os_faults.drivers.cloud import fuel
|
||||||
from os_faults.tests.unit import fakes
|
from os_faults.tests.unit import fakes
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
@ -16,7 +16,7 @@ import mock
|
|||||||
|
|
||||||
from os_faults.ansible import executor
|
from os_faults.ansible import executor
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import tcpcloud
|
from os_faults.drivers.cloud import tcpcloud
|
||||||
from os_faults.tests.unit import fakes
|
from os_faults.tests.unit import fakes
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
0
os_faults/tests/unit/drivers/nodes/__init__.py
Normal file
0
os_faults/tests/unit/drivers/nodes/__init__.py
Normal file
@ -12,7 +12,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import node_list
|
from os_faults.drivers.nodes import node_list
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
||||||
|
|
0
os_faults/tests/unit/drivers/power/__init__.py
Normal file
0
os_faults/tests/unit/drivers/power/__init__.py
Normal file
@ -17,7 +17,7 @@ from pyghmi import exceptions as pyghmi_exc
|
|||||||
|
|
||||||
import os_faults
|
import os_faults
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import ipmi
|
from os_faults.drivers.power import ipmi
|
||||||
from os_faults import error
|
from os_faults import error
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class IPMIDriverTestCase(test.TestCase):
|
|||||||
self.driver._run_set_power_cmd,
|
self.driver._run_set_power_cmd,
|
||||||
self.host, 'off', expected_state='off')
|
self.host, 'off', expected_state='off')
|
||||||
|
|
||||||
@mock.patch('os_faults.drivers.ipmi.IPMIDriver._run_set_power_cmd')
|
@mock.patch('os_faults.drivers.power.ipmi.IPMIDriver._run_set_power_cmd')
|
||||||
@ddt.data(('poweroff', 'off', 'off'),
|
@ddt.data(('poweroff', 'off', 'off'),
|
||||||
('poweron', 'on', 'on'),
|
('poweron', 'on', 'on'),
|
||||||
('reset', 'boot'),
|
('reset', 'boot'),
|
@ -15,12 +15,12 @@ import ddt
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.drivers import libvirt_driver
|
from os_faults.drivers.power import libvirt
|
||||||
from os_faults import error
|
from os_faults import error
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
DRIVER_PATH = 'os_faults.drivers.libvirt_driver'
|
DRIVER_PATH = 'os_faults.drivers.power.libvirt'
|
||||||
|
|
||||||
|
|
||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
@ -30,7 +30,7 @@ class LibvirtDriverTestCase(test.TestCase):
|
|||||||
super(LibvirtDriverTestCase, self).setUp()
|
super(LibvirtDriverTestCase, self).setUp()
|
||||||
|
|
||||||
self.params = {'connection_uri': 'fake_connection_uri'}
|
self.params = {'connection_uri': 'fake_connection_uri'}
|
||||||
self.driver = libvirt_driver.LibvirtDriver(self.params)
|
self.driver = libvirt.LibvirtDriver(self.params)
|
||||||
self.host = node_collection.Host(
|
self.host = node_collection.Host(
|
||||||
ip='10.0.0.2', mac='00:00:00:00:00:00', fqdn='node1.com')
|
ip='10.0.0.2', mac='00:00:00:00:00:00', fqdn='node1.com')
|
||||||
|
|
@ -22,12 +22,12 @@ from os_faults.api import cloud_management
|
|||||||
from os_faults.api import error
|
from os_faults.api import error
|
||||||
from os_faults.api import node_collection
|
from os_faults.api import node_collection
|
||||||
from os_faults.api import service
|
from os_faults.api import service
|
||||||
from os_faults.drivers import devstack
|
from os_faults.drivers.cloud import devstack
|
||||||
from os_faults.drivers import devstack_systemd
|
from os_faults.drivers.cloud import devstack_systemd
|
||||||
from os_faults.drivers import fuel
|
from os_faults.drivers.cloud import fuel
|
||||||
from os_faults.drivers import ipmi
|
from os_faults.drivers.nodes import node_list
|
||||||
from os_faults.drivers import libvirt_driver
|
from os_faults.drivers.power import ipmi
|
||||||
from os_faults.drivers import node_list
|
from os_faults.drivers.power import libvirt
|
||||||
from os_faults.tests.unit import test
|
from os_faults.tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class OSFaultsTestCase(test.TestCase):
|
|||||||
self.assertIsInstance(destructor.node_discover, fuel.FuelManagement)
|
self.assertIsInstance(destructor.node_discover, fuel.FuelManagement)
|
||||||
self.assertEqual(1, len(destructor.power_manager.power_drivers))
|
self.assertEqual(1, len(destructor.power_manager.power_drivers))
|
||||||
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
||||||
libvirt_driver.LibvirtDriver)
|
libvirt.LibvirtDriver)
|
||||||
|
|
||||||
def test_connect_fuel_with_ipmi_libvirt_and_node_list(self):
|
def test_connect_fuel_with_ipmi_libvirt_and_node_list(self):
|
||||||
cloud_config = {
|
cloud_config = {
|
||||||
@ -181,7 +181,7 @@ class OSFaultsTestCase(test.TestCase):
|
|||||||
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
||||||
ipmi.IPMIDriver)
|
ipmi.IPMIDriver)
|
||||||
self.assertIsInstance(destructor.power_manager.power_drivers[1],
|
self.assertIsInstance(destructor.power_manager.power_drivers[1],
|
||||||
libvirt_driver.LibvirtDriver)
|
libvirt.LibvirtDriver)
|
||||||
|
|
||||||
def test_connect_driver_not_found(self):
|
def test_connect_driver_not_found(self):
|
||||||
cloud_config = {
|
cloud_config = {
|
||||||
@ -207,7 +207,7 @@ class OSFaultsTestCase(test.TestCase):
|
|||||||
self.assertIsInstance(destructor, fuel.FuelManagement)
|
self.assertIsInstance(destructor, fuel.FuelManagement)
|
||||||
self.assertEqual(1, len(destructor.power_manager.power_drivers))
|
self.assertEqual(1, len(destructor.power_manager.power_drivers))
|
||||||
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
||||||
libvirt_driver.LibvirtDriver)
|
libvirt.LibvirtDriver)
|
||||||
|
|
||||||
@mock.patch.dict(os.environ, {'OS_FAULTS_CONFIG': '/my/conf.yaml'})
|
@mock.patch.dict(os.environ, {'OS_FAULTS_CONFIG': '/my/conf.yaml'})
|
||||||
@mock.patch('os.path.exists', return_value=True)
|
@mock.patch('os.path.exists', return_value=True)
|
||||||
@ -219,7 +219,7 @@ class OSFaultsTestCase(test.TestCase):
|
|||||||
self.assertIsInstance(destructor, fuel.FuelManagement)
|
self.assertIsInstance(destructor, fuel.FuelManagement)
|
||||||
self.assertEqual(1, len(destructor.power_manager.power_drivers))
|
self.assertEqual(1, len(destructor.power_manager.power_drivers))
|
||||||
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
self.assertIsInstance(destructor.power_manager.power_drivers[0],
|
||||||
libvirt_driver.LibvirtDriver)
|
libvirt.LibvirtDriver)
|
||||||
mock_os_faults_open.assert_called_once_with('/my/conf.yaml')
|
mock_os_faults_open.assert_called_once_with('/my/conf.yaml')
|
||||||
|
|
||||||
@mock.patch('os.path.exists', return_value=False)
|
@mock.patch('os.path.exists', return_value=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user