Merge "Fewer mandatory methods in AbstractSystemsDriver"
This commit is contained in:
commit
a5f206858b
|
@ -363,16 +363,22 @@ def system_resource(identity):
|
|||
|
||||
app.logger.debug('Serving resources for system "%s"', identity)
|
||||
|
||||
def try_get(call):
|
||||
try:
|
||||
return call(identity)
|
||||
except error.NotSupportedError:
|
||||
return None
|
||||
|
||||
return flask.render_template(
|
||||
'system.json',
|
||||
identity=identity,
|
||||
name=app.systems.name(identity),
|
||||
uuid=app.systems.uuid(identity),
|
||||
power_state=app.systems.get_power_state(identity),
|
||||
total_memory_gb=app.systems.get_total_memory(identity),
|
||||
total_cpus=app.systems.get_total_cpus(identity),
|
||||
total_memory_gb=try_get(app.systems.get_total_memory),
|
||||
total_cpus=try_get(app.systems.get_total_cpus),
|
||||
boot_source_target=app.systems.get_boot_device(identity),
|
||||
boot_source_mode=app.systems.get_boot_mode(identity),
|
||||
boot_source_mode=try_get(app.systems.get_boot_mode),
|
||||
managers=app.managers.get_managers_for_system(identity),
|
||||
chassis=app.chassis.chassis[:1],
|
||||
indicator_led=app.indicators.get_indicator_state(
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
import abc
|
||||
|
||||
from sushy_tools import error
|
||||
|
||||
|
||||
class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
||||
"""Base class for all virtualization drivers"""
|
||||
|
@ -110,6 +112,7 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
:returns: either *UEFI* or *Legacy* as `str` or `None` if
|
||||
current boot mode can't be determined
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
def set_boot_mode(self, identity, boot_mode):
|
||||
"""Set computer system boot mode.
|
||||
|
@ -119,24 +122,24 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
|
||||
:raises: `FishyError` if boot mode can't be set
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_total_memory(self, identity):
|
||||
"""Get computer system total memory
|
||||
|
||||
:returns: available RAM in GiB as `int` or `None` if total memory
|
||||
count can't be determined
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_total_cpus(self, identity):
|
||||
"""Get computer system total count of available CPUs
|
||||
|
||||
:returns: available CPU count as `int` or `None` if CPU count
|
||||
can't be determined
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_bios(self, identity):
|
||||
"""Get BIOS attributes for the system
|
||||
|
||||
|
@ -144,8 +147,8 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
|
||||
:raises: `FishyError` if BIOS attributes cannot be processed
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def set_bios(self, identity, attributes):
|
||||
"""Update BIOS attributes
|
||||
|
||||
|
@ -153,22 +156,22 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
|
||||
:raises: `FishyError` if BIOS attributes cannot be processed
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def reset_bios(self, identity):
|
||||
"""Reset BIOS attributes to default
|
||||
|
||||
:raises: `FishyError` if BIOS attributes cannot be processed
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_nics(self, identity):
|
||||
"""Get list of NICs and their attributes
|
||||
|
||||
:returns: list of dictionaries of NICs and their attributes
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_boot_image(self, identity, device):
|
||||
"""Get backend VM boot image info
|
||||
|
||||
|
@ -178,8 +181,8 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
:returns: a `tuple` of (boot_image, write_protected, inserted)
|
||||
:raises: `error.FishyError` if boot device can't be accessed
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def set_boot_image(self, identity, device, boot_image=None,
|
||||
write_protected=True):
|
||||
"""Set backend VM boot image
|
||||
|
@ -193,13 +196,14 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
|
||||
:raises: `error.FishyError` if boot device can't be set
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_simple_storage_collection(self, identity):
|
||||
"""Get a dict of Simple Storage Controllers and their devices
|
||||
|
||||
:returns: dict of Simple Storage Controllers and their atributes
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
def find_or_create_storage_volume(self, data):
|
||||
"""Find/create volume based on existence in the virtualization backend
|
||||
|
@ -210,3 +214,4 @@ class AbstractSystemsDriver(metaclass=abc.ABCMeta):
|
|||
|
||||
:returns: Id of the volume if successfully found/created else None
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
|
|
@ -305,21 +305,6 @@ class OpenStackDriver(AbstractSystemsDriver):
|
|||
|
||||
return flavor.vcpus
|
||||
|
||||
def get_bios(self, identity):
|
||||
"""Not supported as Openstack SDK does not expose API for BIOS"""
|
||||
raise error.NotSupportedError(
|
||||
'Operation not supported by the virtualization driver')
|
||||
|
||||
def set_bios(self, identity, attributes):
|
||||
"""Not supported as Openstack SDK does not expose API for BIOS"""
|
||||
raise error.NotSupportedError(
|
||||
'Operation not supported by the virtualization driver')
|
||||
|
||||
def reset_bios(self, identity):
|
||||
"""Not supported as Openstack SDK does not expose API for BIOS"""
|
||||
raise error.NotSupportedError(
|
||||
'Operation not supported by the virtualization driver')
|
||||
|
||||
def get_nics(self, identity):
|
||||
"""Get server's network interfaces
|
||||
|
||||
|
@ -343,43 +328,3 @@ class OpenStackDriver(AbstractSystemsDriver):
|
|||
'Could not find MAC address in %s', adr)
|
||||
return [{'id': mac, 'mac': mac}
|
||||
for mac in macs]
|
||||
|
||||
def get_boot_image(self, identity, device):
|
||||
"""Get backend VM boot image info
|
||||
|
||||
:param identity: node name or ID
|
||||
:param device: device type (from
|
||||
`sushy_tools.emulator.constants`)
|
||||
:returns: a `tuple` of (boot_image, write_protected, inserted)
|
||||
:raises: `error.FishyError` if boot device can't be accessed
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
def set_boot_image(self, identity, device, boot_image=None,
|
||||
write_protected=True):
|
||||
"""Set backend VM boot image
|
||||
|
||||
:param identity: node name or ID
|
||||
:param device: device type (from
|
||||
`sushy_tools.emulator.constants`)
|
||||
:param boot_image: path to the image file or `None` to remove
|
||||
configured image entirely
|
||||
:param write_protected: expose media as read-only or writable
|
||||
|
||||
:raises: `error.FishyError` if boot device can't be set
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
def get_simple_storage_collection(self, identity):
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
||||
def find_or_create_storage_volume(self, data):
|
||||
"""Find/create volume based on existence in the virtualization backend
|
||||
|
||||
:param data: data about the volume in dict form with values for `Id`,
|
||||
`Name`, `CapacityBytes`, `VolumeType`, `libvirtPoolName`
|
||||
and `libvirtVolName`
|
||||
|
||||
:returns: Id of the volume if successfully found/created else None
|
||||
"""
|
||||
raise error.NotSupportedError('Not implemented')
|
||||
|
|
Loading…
Reference in New Issue