Always log via Flask application
Prior to this patch, sushy-emulator used two ways of logging: via Flask app object and via Python logging module. This arrangement seems to be leading to missing log messages in the CI. This patch makes sushy-emulator consistently logging via Flask app object. Change-Id: I9fdb038cc16147f9f7b248c48aa78a237cdba087
This commit is contained in:
parent
907c3ad6d5
commit
663559c7e8
|
@ -63,7 +63,7 @@ class Resources(object):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
cls.SYSTEMS = novadriver.OpenStackDriver.initialize(
|
cls.SYSTEMS = novadriver.OpenStackDriver.initialize(
|
||||||
app.config, os_cloud)
|
app.config, app.logger, os_cloud)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not libvirtdriver.is_loaded:
|
if not libvirtdriver.is_loaded:
|
||||||
|
@ -73,56 +73,63 @@ class Resources(object):
|
||||||
libvirt_uri = app.config.get('SUSHY_EMULATOR_LIBVIRT_URI', '')
|
libvirt_uri = app.config.get('SUSHY_EMULATOR_LIBVIRT_URI', '')
|
||||||
|
|
||||||
cls.SYSTEMS = libvirtdriver.LibvirtDriver.initialize(
|
cls.SYSTEMS = libvirtdriver.LibvirtDriver.initialize(
|
||||||
app.config, libvirt_uri)
|
app.config, app.logger, libvirt_uri)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized system resource backed by %s '
|
'Initialized system resource backed by %s '
|
||||||
'driver', cls.SYSTEMS().driver)
|
'driver', cls.SYSTEMS().driver)
|
||||||
|
|
||||||
if cls.MANAGERS is None:
|
if cls.MANAGERS is None:
|
||||||
cls.MANAGERS = mgrdriver.StaticDriver.initialize(app.config)
|
cls.MANAGERS = mgrdriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized manager resource backed by %s '
|
'Initialized manager resource backed by %s '
|
||||||
'driver', cls.MANAGERS().driver)
|
'driver', cls.MANAGERS().driver)
|
||||||
|
|
||||||
if cls.CHASSIS is None:
|
if cls.CHASSIS is None:
|
||||||
cls.CHASSIS = chsdriver.StaticDriver.initialize(app.config)
|
cls.CHASSIS = chsdriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized chassis resource backed by %s '
|
'Initialized chassis resource backed by %s '
|
||||||
'driver', cls.CHASSIS().driver)
|
'driver', cls.CHASSIS().driver)
|
||||||
|
|
||||||
if cls.INDICATORS is None:
|
if cls.INDICATORS is None:
|
||||||
cls.INDICATORS = inddriver.StaticDriver.initialize(app.config)
|
cls.INDICATORS = inddriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized indicators resource backed by %s '
|
'Initialized indicators resource backed by %s '
|
||||||
'driver', cls.INDICATORS().driver)
|
'driver', cls.INDICATORS().driver)
|
||||||
|
|
||||||
if cls.VMEDIA is None:
|
if cls.VMEDIA is None:
|
||||||
cls.VMEDIA = vmddriver.StaticDriver.initialize(app.config)
|
cls.VMEDIA = vmddriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized virtual media resource backed by %s '
|
'Initialized virtual media resource backed by %s '
|
||||||
'driver', cls.VMEDIA().driver)
|
'driver', cls.VMEDIA().driver)
|
||||||
|
|
||||||
if cls.STORAGE is None:
|
if cls.STORAGE is None:
|
||||||
cls.STORAGE = stgdriver.StaticDriver.initialize(app.config)
|
cls.STORAGE = stgdriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized storage resource backed by %s '
|
'Initialized storage resource backed by %s '
|
||||||
'driver', cls.STORAGE().driver)
|
'driver', cls.STORAGE().driver)
|
||||||
|
|
||||||
if cls.DRIVES is None:
|
if cls.DRIVES is None:
|
||||||
cls.DRIVES = drvdriver.StaticDriver.initialize(app.config)
|
cls.DRIVES = drvdriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized drive resource backed by %s '
|
'Initialized drive resource backed by %s '
|
||||||
'driver', cls.DRIVES().driver)
|
'driver', cls.DRIVES().driver)
|
||||||
|
|
||||||
if cls.VOLUMES is None:
|
if cls.VOLUMES is None:
|
||||||
cls.VOLUMES = voldriver.StaticDriver.initialize(app.config)
|
cls.VOLUMES = voldriver.StaticDriver.initialize(
|
||||||
|
app.config, app.logger)
|
||||||
|
|
||||||
app.logger.debug(
|
app.logger.debug(
|
||||||
'Initialized volumes resource backed by %s '
|
'Initialized volumes resource backed by %s '
|
||||||
|
|
|
@ -18,7 +18,7 @@ class DriverBase(object):
|
||||||
"""Common base for emulated Redfish resource drivers"""
|
"""Common base for emulated Redfish resource drivers"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, *args, **kwargs):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
"""Initialize class attributes
|
"""Initialize class attributes
|
||||||
|
|
||||||
Since drivers may need to cache thing short-term. The emulator
|
Since drivers may need to cache thing short-term. The emulator
|
||||||
|
@ -31,6 +31,8 @@ class DriverBase(object):
|
||||||
The `initialize` method is provided to set up the driver in a way
|
The `initialize` method is provided to set up the driver in a way
|
||||||
that would affect all the subsequent sessions.
|
that would affect all the subsequent sessions.
|
||||||
|
|
||||||
|
:params config: system configuration dict
|
||||||
|
:params logger: system logger object
|
||||||
:params *args: driver-specific parameters
|
:params *args: driver-specific parameters
|
||||||
:params **kwargs: driver-specific parameters
|
:params **kwargs: driver-specific parameters
|
||||||
:returns: initialized driver class
|
:returns: initialized driver class
|
||||||
|
|
|
@ -24,8 +24,9 @@ class AbstractChassisDriver(base.DriverBase):
|
||||||
"""Base class backing Redfish Chassis"""
|
"""Base class backing Redfish Chassis"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
@abc.abstractproperty
|
@abc.abstractproperty
|
||||||
|
|
|
@ -13,14 +13,11 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sushy_tools.emulator.resources.chassis.base import AbstractChassisDriver
|
from sushy_tools.emulator.resources.chassis.base import AbstractChassisDriver
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(AbstractChassisDriver):
|
class StaticDriver(AbstractChassisDriver):
|
||||||
"""Redfish chassis backed by configuration file"""
|
"""Redfish chassis backed by configuration file"""
|
||||||
|
@ -71,7 +68,7 @@ class StaticDriver(AbstractChassisDriver):
|
||||||
msg = ('Error finding chassis by UUID/Name/Id '
|
msg = ('Error finding chassis by UUID/Name/Id '
|
||||||
'"%(identity)s"' % {'identity': identity})
|
'"%(identity)s"' % {'identity': identity})
|
||||||
|
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
|
|
|
@ -13,22 +13,22 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sushy_tools.emulator.resources.base import DriverBase
|
from sushy_tools.emulator.resources.base import DriverBase
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(DriverBase):
|
class StaticDriver(DriverBase):
|
||||||
"""Redfish storage drives backed by configuration file"""
|
"""Redfish storage drives backed by configuration file"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
|
||||||
cls._drives = cls._config.get('SUSHY_EMULATOR_DRIVES', {})
|
cls._drives = cls._config.get('SUSHY_EMULATOR_DRIVES', {})
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -49,7 +49,7 @@ class StaticDriver(DriverBase):
|
||||||
msg = ('Error finding drive for System UUID "%s" and Storage ID '
|
msg = ('Error finding drive for System UUID "%s" and Storage ID '
|
||||||
'"%s"', identity, storage_id)
|
'"%s"', identity, storage_id)
|
||||||
|
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,10 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from sushy_tools.emulator import memoize
|
from sushy_tools.emulator import memoize
|
||||||
from sushy_tools.emulator.resources.base import DriverBase
|
from sushy_tools.emulator.resources.base import DriverBase
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(DriverBase):
|
class StaticDriver(DriverBase):
|
||||||
"""Redfish indicator LED simulator
|
"""Redfish indicator LED simulator
|
||||||
|
@ -29,17 +25,18 @@ class StaticDriver(DriverBase):
|
||||||
anything.
|
anything.
|
||||||
"""
|
"""
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
|
||||||
cls._indicators = memoize.PersistentDict()
|
cls._indicators = memoize.PersistentDict()
|
||||||
|
|
||||||
if hasattr(cls._indicators, 'make_permanent'):
|
if hasattr(cls._indicators, 'make_permanent'):
|
||||||
cls._indicators.make_permanent(
|
cls._indicators.make_permanent(
|
||||||
config.get('SUSHY_EMULATOR_STATE_DIR'), 'indicators')
|
cls._config.get('SUSHY_EMULATOR_STATE_DIR'), 'indicators')
|
||||||
|
|
||||||
cls._indicators.update(
|
cls._indicators.update(
|
||||||
config.get('SUSHY_EMULATOR_INDICATOR_LEDS', {}))
|
cls._config.get('SUSHY_EMULATOR_INDICATOR_LEDS', {}))
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ class AbstractManagersDriver(base.DriverBase):
|
||||||
"""Base class backing Redfish Managers"""
|
"""Base class backing Redfish Managers"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
@abc.abstractproperty
|
@abc.abstractproperty
|
||||||
|
|
|
@ -13,16 +13,12 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sushy_tools.emulator.resources.managers.base import AbstractManagersDriver
|
from sushy_tools.emulator.resources.managers.base import AbstractManagersDriver
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(AbstractManagersDriver):
|
class StaticDriver(AbstractManagersDriver):
|
||||||
"""Redfish manager backed by configuration file"""
|
"""Redfish manager backed by configuration file"""
|
||||||
|
|
||||||
|
@ -75,7 +71,7 @@ class StaticDriver(AbstractManagersDriver):
|
||||||
msg = ('Error finding manager by UUID/Name/Id '
|
msg = ('Error finding manager by UUID/Name/Id '
|
||||||
'"%(identity)s"' % {'identity': identity})
|
'"%(identity)s"' % {'identity': identity})
|
||||||
|
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
|
|
|
@ -13,22 +13,22 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sushy_tools.emulator.resources.base import DriverBase
|
from sushy_tools.emulator.resources.base import DriverBase
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(DriverBase):
|
class StaticDriver(DriverBase):
|
||||||
"""Redfish storage backed by configuration file"""
|
"""Redfish storage backed by configuration file"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
|
||||||
cls._storage = cls._config.get('SUSHY_EMULATOR_STORAGE', {})
|
cls._storage = cls._config.get('SUSHY_EMULATOR_STORAGE', {})
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -49,7 +49,7 @@ class StaticDriver(DriverBase):
|
||||||
msg = ('Error finding storage collection by UUID '
|
msg = ('Error finding storage collection by UUID '
|
||||||
'"%(identity)s"' % {'identity': identity})
|
'"%(identity)s"' % {'identity': identity})
|
||||||
|
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
@ -34,10 +33,6 @@ except ImportError:
|
||||||
|
|
||||||
is_loaded = bool(libvirt)
|
is_loaded = bool(libvirt)
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
BiosProcessResult = namedtuple('BiosProcessResult',
|
BiosProcessResult = namedtuple('BiosProcessResult',
|
||||||
['tree',
|
['tree',
|
||||||
'attributes_written',
|
'attributes_written',
|
||||||
|
@ -167,9 +162,12 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config, uri=None):
|
def initialize(cls, config, logger, uri=None, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
|
||||||
cls._uri = uri or cls.LIBVIRT_URI
|
cls._uri = uri or cls.LIBVIRT_URI
|
||||||
|
|
||||||
cls.BOOT_LOADER_MAP = cls._config.get(
|
cls.BOOT_LOADER_MAP = cls._config.get(
|
||||||
'SUSHY_EMULATOR_BOOT_LOADER_MAP', cls.BOOT_LOADER_MAP)
|
'SUSHY_EMULATOR_BOOT_LOADER_MAP', cls.BOOT_LOADER_MAP)
|
||||||
cls.KNOWN_BOOT_LOADERS = set(y for x in cls.BOOT_LOADER_MAP.values()
|
cls.KNOWN_BOOT_LOADERS = set(y for x in cls.BOOT_LOADER_MAP.values()
|
||||||
|
@ -194,7 +192,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
{'identity': identity,
|
{'identity': identity,
|
||||||
'uri': self._uri, 'err': ex})
|
'uri': self._uri, 'err': ex})
|
||||||
|
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
|
@ -519,10 +517,11 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
loader_path = self.BOOT_LOADER_MAP[boot_mode][os_arch]
|
loader_path = self.BOOT_LOADER_MAP[boot_mode][os_arch]
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning('Boot loader binary is not configured for '
|
self._logger.warning(
|
||||||
'boot mode %s and OS architecture %s. '
|
'Boot loader binary is not configured for '
|
||||||
'Assuming default boot loader for the domain.',
|
'boot mode %s and OS architecture %s. '
|
||||||
boot_mode, os_arch)
|
'Assuming default boot loader for the domain.',
|
||||||
|
boot_mode, os_arch)
|
||||||
loader_path = None
|
loader_path = None
|
||||||
|
|
||||||
loader_elements = os_element.findall('loader')
|
loader_elements = os_element.findall('loader')
|
||||||
|
@ -1030,7 +1029,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
'%(err)s' %
|
'%(err)s' %
|
||||||
{'path': vol_path, 'uri': self._uri,
|
{'path': vol_path, 'uri': self._uri,
|
||||||
'err': e})
|
'err': e})
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
return
|
return
|
||||||
disk_device = {
|
disk_device = {
|
||||||
'Name': vol.name(),
|
'Name': vol.name(),
|
||||||
|
@ -1052,7 +1051,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
msg = ('Error finding Storage Pool by name "%(name)s" at'
|
msg = ('Error finding Storage Pool by name "%(name)s" at'
|
||||||
'libvirt URI "%(uri)s": %(err)s' %
|
'libvirt URI "%(uri)s": %(err)s' %
|
||||||
{'name': pool_name, 'uri': self._uri, 'err': e})
|
{'name': pool_name, 'uri': self._uri, 'err': e})
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1063,7 +1062,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
': %(err)s' %
|
': %(err)s' %
|
||||||
{'name': vol_name, 'pName': pool_name,
|
{'name': vol_name, 'pName': pool_name,
|
||||||
'uri': self._uri, 'err': e})
|
'uri': self._uri, 'err': e})
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
return
|
return
|
||||||
disk_device = {
|
disk_device = {
|
||||||
'Name': vol.name(),
|
'Name': vol.name(),
|
||||||
|
@ -1128,7 +1127,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
msg = ('Error finding Storage Pool by name "%(name)s" at '
|
msg = ('Error finding Storage Pool by name "%(name)s" at '
|
||||||
'libvirt URI "%(uri)s": %(err)s' %
|
'libvirt URI "%(uri)s": %(err)s' %
|
||||||
{'name': poolName, 'uri': self._uri, 'err': ex})
|
{'name': poolName, 'uri': self._uri, 'err': ex})
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
vol = pool.storageVolLookupByName(data['libvirtVolName'])
|
vol = pool.storageVolLookupByName(data['libvirtVolName'])
|
||||||
|
@ -1136,7 +1135,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
|
|
||||||
msg = ('Creating storage volume with name: "%s"',
|
msg = ('Creating storage volume with name: "%s"',
|
||||||
data['libvirtVolName'])
|
data['libvirtVolName'])
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
pool_tree = ET.fromstring(pool.XMLDesc())
|
pool_tree = ET.fromstring(pool.XMLDesc())
|
||||||
|
|
||||||
|
@ -1146,7 +1145,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
msg = ('Missing "target/path" tag in the libvirt '
|
msg = ('Missing "target/path" tag in the libvirt '
|
||||||
'storage pool "%(pool)s"'
|
'storage pool "%(pool)s"'
|
||||||
'' % {'pool': poolName})
|
'' % {'pool': poolName})
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
vol_path = os.path.join(
|
vol_path = os.path.join(
|
||||||
|
@ -1161,6 +1160,6 @@ class LibvirtDriver(AbstractSystemsDriver):
|
||||||
if not vol:
|
if not vol:
|
||||||
msg = ('Error creating "%s" storage volume in "%s" pool',
|
msg = ('Error creating "%s" storage volume in "%s" pool',
|
||||||
data['libvirtVolName'], poolName)
|
data['libvirtVolName'], poolName)
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
return
|
return
|
||||||
return data['Id']
|
return data['Id']
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from sushy_tools.emulator import memoize
|
from sushy_tools.emulator import memoize
|
||||||
|
@ -29,8 +28,6 @@ except ImportError:
|
||||||
|
|
||||||
is_loaded = bool(openstack)
|
is_loaded = bool(openstack)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class OpenStackDriver(AbstractSystemsDriver):
|
class OpenStackDriver(AbstractSystemsDriver):
|
||||||
"""OpenStack driver"""
|
"""OpenStack driver"""
|
||||||
|
@ -55,10 +52,13 @@ class OpenStackDriver(AbstractSystemsDriver):
|
||||||
PERMANENT_CACHE = {}
|
PERMANENT_CACHE = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config, os_cloud, readonly=False):
|
def initialize(cls, config, logger, os_cloud, *args, **kwargs):
|
||||||
cls._cc = openstack.connect(cloud=os_cloud)
|
|
||||||
cls._os_cloud = os_cloud
|
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
cls._os_cloud = os_cloud
|
||||||
|
|
||||||
|
cls._cc = openstack.connect(cloud=os_cloud)
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
@memoize.memoize()
|
@memoize.memoize()
|
||||||
|
@ -74,7 +74,7 @@ class OpenStackDriver(AbstractSystemsDriver):
|
||||||
'cloud %(os_cloud)s"' % {'identity': identity,
|
'cloud %(os_cloud)s"' % {'identity': identity,
|
||||||
'os_cloud': self._os_cloud})
|
'os_cloud': self._os_cloud})
|
||||||
|
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
|
@ -339,7 +339,8 @@ class OpenStackDriver(AbstractSystemsDriver):
|
||||||
try:
|
try:
|
||||||
macs.add(adr['OS-EXT-IPS-MAC:mac_addr'])
|
macs.add(adr['OS-EXT-IPS-MAC:mac_addr'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning('Could not find MAC address in %s', adr)
|
self._logger.warning(
|
||||||
|
'Could not find MAC address in %s', adr)
|
||||||
return [{'id': mac, 'mac': mac}
|
return [{'id': mac, 'mac': mac}
|
||||||
for mac in macs]
|
for mac in macs]
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -25,8 +24,6 @@ from sushy_tools.emulator import memoize
|
||||||
from sushy_tools.emulator.resources.base import DriverBase
|
from sushy_tools.emulator.resources.base import DriverBase
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(DriverBase):
|
class StaticDriver(DriverBase):
|
||||||
"""Redfish virtual media simulator
|
"""Redfish virtual media simulator
|
||||||
|
@ -34,14 +31,15 @@ class StaticDriver(DriverBase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
|
||||||
cls._devices = memoize.PersistentDict()
|
cls._devices = memoize.PersistentDict()
|
||||||
|
|
||||||
if hasattr(cls._devices, 'make_permanent'):
|
if hasattr(cls._devices, 'make_permanent'):
|
||||||
cls._devices.make_permanent(
|
cls._devices.make_permanent(
|
||||||
config.get('SUSHY_EMULATOR_STATE_DIR'), 'vmedia')
|
cls._config.get('SUSHY_EMULATOR_STATE_DIR'), 'vmedia')
|
||||||
|
|
||||||
device_types = cls._config.get(
|
device_types = cls._config.get(
|
||||||
'SUSHY_EMULATOR_VMEDIA_DEVICES')
|
'SUSHY_EMULATOR_VMEDIA_DEVICES')
|
||||||
|
@ -188,10 +186,10 @@ class StaticDriver(DriverBase):
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
msg = 'Failed fetching image from URL %s: %s' % (image_url, ex)
|
msg = 'Failed fetching image from URL %s: %s' % (image_url, ex)
|
||||||
logger.error(msg)
|
self._logger.error(msg)
|
||||||
raise error.FishyError(msg)
|
raise error.FishyError(msg)
|
||||||
|
|
||||||
logger.debug(
|
self._logger.debug(
|
||||||
'Fetched image %(file)s for %(identity)s' % {
|
'Fetched image %(file)s for %(identity)s' % {
|
||||||
'identity': identity, 'file': local_file})
|
'identity': identity, 'file': local_file})
|
||||||
|
|
||||||
|
@ -224,6 +222,6 @@ class StaticDriver(DriverBase):
|
||||||
if local_file:
|
if local_file:
|
||||||
os.unlink(local_file)
|
os.unlink(local_file)
|
||||||
|
|
||||||
logger.debug(
|
self._logger.debug(
|
||||||
'Removed local file %(file)s for %(identity)s' % {
|
'Removed local file %(file)s for %(identity)s' % {
|
||||||
'identity': identity, 'file': local_file})
|
'identity': identity, 'file': local_file})
|
||||||
|
|
|
@ -12,15 +12,10 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from sushy_tools.emulator import memoize
|
from sushy_tools.emulator import memoize
|
||||||
from sushy_tools.emulator.resources.base import DriverBase
|
from sushy_tools.emulator.resources.base import DriverBase
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticDriver(DriverBase):
|
class StaticDriver(DriverBase):
|
||||||
"""Redfish Volumes emulated in libvirt backed by the config file
|
"""Redfish Volumes emulated in libvirt backed by the config file
|
||||||
|
@ -28,17 +23,18 @@ class StaticDriver(DriverBase):
|
||||||
Maintains the libvirt volumes in memory.
|
Maintains the libvirt volumes in memory.
|
||||||
"""
|
"""
|
||||||
@classmethod
|
@classmethod
|
||||||
def initialize(cls, config):
|
def initialize(cls, config, logger, *args, **kwargs):
|
||||||
cls._config = config
|
cls._config = config
|
||||||
|
cls._logger = logger
|
||||||
|
|
||||||
cls._volumes = memoize.PersistentDict()
|
cls._volumes = memoize.PersistentDict()
|
||||||
|
|
||||||
if hasattr(cls._volumes, 'make_permanent'):
|
if hasattr(cls._volumes, 'make_permanent'):
|
||||||
cls._volumes.make_permanent(
|
cls._volumes.make_permanent(
|
||||||
config.get('SUSHY_EMULATOR_STATE_DIR'), 'volumes')
|
cls._config.get('SUSHY_EMULATOR_STATE_DIR'), 'volumes')
|
||||||
|
|
||||||
cls._volumes.update(
|
cls._volumes.update(
|
||||||
config.get('SUSHY_EMULATOR_VOLUMES', {}))
|
cls._config.get('SUSHY_EMULATOR_VOLUMES', {}))
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
@ -59,7 +55,7 @@ class StaticDriver(DriverBase):
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
msg = ('Error finding volume collection by System UUID %s '
|
msg = ('Error finding volume collection by System UUID %s '
|
||||||
'and Storage ID %s' % (uu_identity, storage_id))
|
'and Storage ID %s' % (uu_identity, storage_id))
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
|
|
||||||
def add_volume(self, uu_identity, storage_id, vol):
|
def add_volume(self, uu_identity, storage_id, vol):
|
||||||
if not self._volumes[(uu_identity, storage_id)]:
|
if not self._volumes[(uu_identity, storage_id)]:
|
||||||
|
@ -75,7 +71,7 @@ class StaticDriver(DriverBase):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
msg = ('Error finding volume collection by System UUID %s '
|
msg = ('Error finding volume collection by System UUID %s '
|
||||||
'and Storage ID %s' % (uu_identity, storage_id))
|
'and Storage ID %s' % (uu_identity, storage_id))
|
||||||
logger.debug(msg)
|
self._logger.debug(msg)
|
||||||
else:
|
else:
|
||||||
vol_col.remove(vol)
|
vol_col.remove(vol)
|
||||||
self._volumes.update({(uu_identity, storage_id): vol_col})
|
self._volumes.update({(uu_identity, storage_id): vol_col})
|
||||||
|
|
|
@ -45,7 +45,8 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
self.mgr_uuid = self.uuid.replace('8', '2')
|
self.mgr_uuid = self.uuid.replace('8', '2')
|
||||||
|
|
||||||
test_driver = StaticDriver.initialize(
|
test_driver = StaticDriver.initialize(
|
||||||
{'SUSHY_EMULATOR_CHASSIS': self.chassis})
|
{'SUSHY_EMULATOR_CHASSIS': self.chassis},
|
||||||
|
mock.MagicMock())
|
||||||
|
|
||||||
self.test_driver = test_driver()
|
self.test_driver = test_driver()
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
from sushy_tools.emulator.resources.drives.staticdriver import StaticDriver
|
from sushy_tools.emulator.resources.drives.staticdriver import StaticDriver
|
||||||
|
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
|
from six.moves import mock
|
||||||
|
|
||||||
|
|
||||||
class StaticDriverTestCase(base.BaseTestCase):
|
class StaticDriverTestCase(base.BaseTestCase):
|
||||||
|
@ -42,12 +43,14 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_get_drives(self):
|
def test_get_drives(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
drv_col = test_driver.get_drives(self.SYSTEM_UUID, self.STORAGE_ID)
|
drv_col = test_driver.get_drives(self.SYSTEM_UUID, self.STORAGE_ID)
|
||||||
self.assertEqual(self.DRIVE_COL, drv_col)
|
self.assertEqual(self.DRIVE_COL, drv_col)
|
||||||
|
|
||||||
def test_get_all_drives(self):
|
def test_get_all_drives(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
drives = test_driver.get_all_drives()
|
drives = test_driver.get_all_drives()
|
||||||
self.assertEqual({('da69abcc-dae0-4913-9a7b-d344043097c0', '1',
|
self.assertEqual({('da69abcc-dae0-4913-9a7b-d344043097c0', '1',
|
||||||
'32ADF365C6C1B7BD'),
|
'32ADF365C6C1B7BD'),
|
||||||
|
|
|
@ -33,23 +33,27 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_indicators(self):
|
def test_indicators(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
indicators = test_driver.indicators
|
indicators = test_driver.indicators
|
||||||
self.assertEqual([self.UUID], indicators)
|
self.assertEqual([self.UUID], indicators)
|
||||||
|
|
||||||
def test_get_indicator_state(self):
|
def test_get_indicator_state(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
state = test_driver.get_indicator_state(self.UUID)
|
state = test_driver.get_indicator_state(self.UUID)
|
||||||
self.assertEqual('Off', state)
|
self.assertEqual('Off', state)
|
||||||
|
|
||||||
def test_set_indicator_state_ok(self):
|
def test_set_indicator_state_ok(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
test_driver.set_indicator_state(self.UUID, 'Lit')
|
test_driver.set_indicator_state(self.UUID, 'Lit')
|
||||||
state = test_driver.get_indicator_state(self.UUID)
|
state = test_driver.get_indicator_state(self.UUID)
|
||||||
self.assertEqual('Lit', state)
|
self.assertEqual('Lit', state)
|
||||||
|
|
||||||
def test_set_indicator_state_fail(self):
|
def test_set_indicator_state_fail(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
error.FishyError,
|
error.FishyError,
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
|
from six.moves import mock
|
||||||
|
|
||||||
from sushy_tools.emulator.resources.managers.staticdriver import StaticDriver
|
from sushy_tools.emulator.resources.managers.staticdriver import StaticDriver
|
||||||
from sushy_tools import error
|
from sushy_tools import error
|
||||||
|
@ -37,7 +38,9 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
self.name = self.managers[0]['Name']
|
self.name = self.managers[0]['Name']
|
||||||
|
|
||||||
test_driver = StaticDriver.initialize(
|
test_driver = StaticDriver.initialize(
|
||||||
{'SUSHY_EMULATOR_MANAGERS': self.managers})
|
{'SUSHY_EMULATOR_MANAGERS': self.managers},
|
||||||
|
mock.MagicMock())
|
||||||
|
|
||||||
self.test_driver = test_driver()
|
self.test_driver = test_driver()
|
||||||
|
|
||||||
super(StaticDriverTestCase, self).setUp()
|
super(StaticDriverTestCase, self).setUp()
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
from sushy_tools.emulator.resources.storage.staticdriver import StaticDriver
|
from sushy_tools.emulator.resources.storage.staticdriver import StaticDriver
|
||||||
|
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
|
from six.moves import mock
|
||||||
|
|
||||||
|
|
||||||
class StaticDriverTestCase(base.BaseTestCase):
|
class StaticDriverTestCase(base.BaseTestCase):
|
||||||
|
@ -40,11 +41,13 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_get_storage_col(self):
|
def test_get_storage_col(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
stg_col = test_driver.get_storage_col(self.UUID)
|
stg_col = test_driver.get_storage_col(self.UUID)
|
||||||
self.assertEqual(self.STORAGE_COL, stg_col)
|
self.assertEqual(self.STORAGE_COL, stg_col)
|
||||||
|
|
||||||
def test_get_all_storage(self):
|
def test_get_all_storage(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
stg = test_driver.get_all_storage()
|
stg = test_driver.get_all_storage()
|
||||||
self.assertEqual([(self.UUID, '1')], stg)
|
self.assertEqual([(self.UUID, '1')], stg)
|
||||||
|
|
|
@ -26,7 +26,8 @@ class LibvirtDriverTestCase(base.BaseTestCase):
|
||||||
uuid = 'c7a5fdbd-cdaf-9455-926a-d65c16db1809'
|
uuid = 'c7a5fdbd-cdaf-9455-926a-d65c16db1809'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
test_driver_class = LibvirtDriver.initialize({})
|
test_driver_class = LibvirtDriver.initialize(
|
||||||
|
{}, mock.MagicMock())
|
||||||
self.test_driver = test_driver_class()
|
self.test_driver = test_driver_class()
|
||||||
super(LibvirtDriverTestCase, self).setUp()
|
super(LibvirtDriverTestCase, self).setUp()
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class NovaDriverTestCase(base.BaseTestCase):
|
||||||
self.nova_patcher = mock.patch('openstack.connect', autospec=True)
|
self.nova_patcher = mock.patch('openstack.connect', autospec=True)
|
||||||
self.nova_mock = self.nova_patcher.start()
|
self.nova_mock = self.nova_patcher.start()
|
||||||
|
|
||||||
test_driver_class = OpenStackDriver.initialize({}, 'fake-cloud')
|
test_driver_class = OpenStackDriver.initialize(
|
||||||
|
{}, mock.MagicMock(), 'fake-cloud')
|
||||||
self.test_driver = test_driver_class()
|
self.test_driver = test_driver_class()
|
||||||
|
|
||||||
super(NovaDriverTestCase, self).setUp()
|
super(NovaDriverTestCase, self).setUp()
|
||||||
|
|
|
@ -43,27 +43,31 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_devices(self):
|
def test_devices(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
devices = test_driver.devices
|
devices = test_driver.devices
|
||||||
self.assertEqual(['Cd', 'Floppy'], sorted(devices))
|
self.assertEqual(['Cd', 'Floppy'], sorted(devices))
|
||||||
|
|
||||||
def test_get_device_name(self):
|
def test_get_device_name(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
device_name = test_driver.get_device_name(
|
device_name = test_driver.get_device_name(
|
||||||
self.UUID, 'Cd')
|
self.UUID, 'Cd')
|
||||||
self.assertEqual('Virtual CD', device_name)
|
self.assertEqual('Virtual CD', device_name)
|
||||||
|
|
||||||
def test_get_device_media_types(self):
|
def test_get_device_media_types(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
media_types = test_driver.get_device_media_types(
|
media_types = test_driver.get_device_media_types(
|
||||||
self.UUID, 'Cd')
|
self.UUID, 'Cd')
|
||||||
self.assertEqual(['CD', 'DVD'], media_types)
|
self.assertEqual(['CD', 'DVD'], media_types)
|
||||||
|
|
||||||
def test_get_device_image_info(self):
|
def test_get_device_image_info(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
dev_info = test_driver.get_device_image_info(
|
dev_info = test_driver.get_device_image_info(
|
||||||
self.UUID, 'Cd')
|
self.UUID, 'Cd')
|
||||||
|
@ -83,7 +87,8 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
'.staticdriver.requests', autospec=True)
|
'.staticdriver.requests', autospec=True)
|
||||||
def test_insert_image(self, mock_requests, mock_tempfile, mock_rename,
|
def test_insert_image(self, mock_requests, mock_tempfile, mock_rename,
|
||||||
mock_open, mock_get_device):
|
mock_open, mock_get_device):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
device_info = {}
|
device_info = {}
|
||||||
mock_get_device.return_value = device_info
|
mock_get_device.return_value = device_info
|
||||||
|
@ -119,7 +124,8 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
@mock.patch('sushy_tools.emulator.resources.vmedia'
|
@mock.patch('sushy_tools.emulator.resources.vmedia'
|
||||||
'.staticdriver.os.unlink', autospec=True)
|
'.staticdriver.os.unlink', autospec=True)
|
||||||
def test_eject_image(self, mock_unlink, mock_get_device):
|
def test_eject_image(self, mock_unlink, mock_get_device):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
|
|
||||||
device_info = {
|
device_info = {
|
||||||
'_local_file': '/tmp/fish.iso'
|
'_local_file': '/tmp/fish.iso'
|
||||||
|
|
|
@ -50,13 +50,15 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_get_volumes_col(self):
|
def test_get_volumes_col(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
vol_col = test_driver.get_volumes_col(self.SYSTEM_UUID,
|
vol_col = test_driver.get_volumes_col(self.SYSTEM_UUID,
|
||||||
self.STORAGE_ID)
|
self.STORAGE_ID)
|
||||||
self.assertEqual(self.VOLUMES_COL, vol_col)
|
self.assertEqual(self.VOLUMES_COL, vol_col)
|
||||||
|
|
||||||
def test_add_volume(self):
|
def test_add_volume(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
vol = {
|
vol = {
|
||||||
"libvirtPoolName": "sushyPool",
|
"libvirtPoolName": "sushyPool",
|
||||||
"libvirtVolName": "testVol2",
|
"libvirtVolName": "testVol2",
|
||||||
|
@ -71,7 +73,8 @@ class StaticDriverTestCase(base.BaseTestCase):
|
||||||
self.assertTrue(vol in vol_col)
|
self.assertTrue(vol in vol_col)
|
||||||
|
|
||||||
def test_delete_volume(self):
|
def test_delete_volume(self):
|
||||||
test_driver = StaticDriver.initialize(self.CONFIG)()
|
test_driver = StaticDriver.initialize(
|
||||||
|
self.CONFIG, mock.MagicMock())()
|
||||||
vol = {
|
vol = {
|
||||||
"libvirtPoolName": "sushyPool",
|
"libvirtPoolName": "sushyPool",
|
||||||
"libvirtVolName": "testVol",
|
"libvirtVolName": "testVol",
|
||||||
|
|
Loading…
Reference in New Issue