Merge "Add boot interface in Ironic"
This commit is contained in:
commit
79cce6bd32
@ -88,6 +88,14 @@ class BaseDriver(object):
|
|||||||
"""
|
"""
|
||||||
standard_interfaces.append('management')
|
standard_interfaces.append('management')
|
||||||
|
|
||||||
|
boot = None
|
||||||
|
"""`Standard` attribute for boot related features.
|
||||||
|
|
||||||
|
A reference to an instance of :class:BootInterface.
|
||||||
|
May be None, if unsupported by a driver.
|
||||||
|
"""
|
||||||
|
standard_interfaces.append('boot')
|
||||||
|
|
||||||
vendor = None
|
vendor = None
|
||||||
"""Attribute for accessing any vendor-specific extensions.
|
"""Attribute for accessing any vendor-specific extensions.
|
||||||
|
|
||||||
@ -324,6 +332,86 @@ class DeployInterface(BaseInterface):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
|
class BootInterface(object):
|
||||||
|
"""Interface for boot-related actions."""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def get_properties(self):
|
||||||
|
"""Return the properties of the interface.
|
||||||
|
|
||||||
|
:returns: dictionary of <property name>:<property description> entries.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def validate(self, task):
|
||||||
|
"""Validate the driver-specific info for booting.
|
||||||
|
|
||||||
|
This method validates the driver-specific info for booting the
|
||||||
|
ramdisk and instance on the node. If invalid, raises an
|
||||||
|
exception; otherwise returns None.
|
||||||
|
|
||||||
|
:param task: a task from TaskManager.
|
||||||
|
:returns: None
|
||||||
|
:raises: InvalidParameterValue
|
||||||
|
:raises: MissingParameterValue
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def prepare_ramdisk(self, task, ramdisk_params):
|
||||||
|
"""Prepares the boot of Ironic ramdisk.
|
||||||
|
|
||||||
|
This method prepares the boot of the deploy ramdisk after
|
||||||
|
reading relevant information from the node's database.
|
||||||
|
|
||||||
|
:param task: a task from TaskManager.
|
||||||
|
:param ramdisk_params: the options to be passed to the ironic ramdisk.
|
||||||
|
Different implementations might want to boot the ramdisk in
|
||||||
|
different ways by passing parameters to them. For example,
|
||||||
|
* When DIB ramdisk is booted to deploy a node, it takes the
|
||||||
|
parameters iscsi_target_iqn, deployment_id, ironic_api_url, etc.
|
||||||
|
* When Agent ramdisk is booted to deploy a node, it takes the
|
||||||
|
parameters ipa-driver-name, ipa-api-url, root_device, etc.
|
||||||
|
Other implementations can make use of ramdisk_params to pass such
|
||||||
|
information. Different implementations of boot interface will
|
||||||
|
have different ways of passing parameters to the ramdisk.
|
||||||
|
:returns: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def clean_up_ramdisk(self, task):
|
||||||
|
"""Cleans up the boot of ironic ramdisk.
|
||||||
|
|
||||||
|
This method cleans up the environment that was setup for booting the
|
||||||
|
deploy ramdisk.
|
||||||
|
|
||||||
|
:param task: a task from TaskManager.
|
||||||
|
:returns: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def prepare_instance(self, task):
|
||||||
|
"""Prepares the boot of instance.
|
||||||
|
|
||||||
|
This method prepares the boot of the instance after reading
|
||||||
|
relevant information from the node's database.
|
||||||
|
|
||||||
|
:param task: a task from TaskManager.
|
||||||
|
:returns: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def clean_up_instance(self, task):
|
||||||
|
"""Cleans up the boot of instance.
|
||||||
|
|
||||||
|
This method cleans up the environment that was setup for booting
|
||||||
|
the instance.
|
||||||
|
|
||||||
|
:param task: a task from TaskManager.
|
||||||
|
:returns: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class PowerInterface(BaseInterface):
|
class PowerInterface(BaseInterface):
|
||||||
"""Interface for power-related actions."""
|
"""Interface for power-related actions."""
|
||||||
|
@ -56,6 +56,7 @@ class FakeDriver(base.BaseDriver):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.power = fake.FakePower()
|
self.power = fake.FakePower()
|
||||||
self.deploy = fake.FakeDeploy()
|
self.deploy = fake.FakeDeploy()
|
||||||
|
self.boot = fake.FakeBoot()
|
||||||
|
|
||||||
self.a = fake.FakeVendorA()
|
self.a = fake.FakeVendorA()
|
||||||
self.b = fake.FakeVendorB()
|
self.b = fake.FakeVendorB()
|
||||||
|
@ -54,6 +54,28 @@ class FakePower(base.PowerInterface):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FakeBoot(base.BootInterface):
|
||||||
|
"""Example implementation of a simple boot interface."""
|
||||||
|
|
||||||
|
def get_properties(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def validate(self, task):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def prepare_ramdisk(self, task):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def clean_up_ramdisk(self, task):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def prepare_instance(self, task):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def clean_up_instance(self, task):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FakeDeploy(base.DeployInterface):
|
class FakeDeploy(base.DeployInterface):
|
||||||
"""Class for a fake deployment driver.
|
"""Class for a fake deployment driver.
|
||||||
|
|
||||||
|
@ -2022,6 +2022,7 @@ class MiscTestCase(_ServiceSetUpMixin, _CommonMixIn, tests_db_base.DbTestCase):
|
|||||||
'power': {'result': True},
|
'power': {'result': True},
|
||||||
'inspect': {'result': True},
|
'inspect': {'result': True},
|
||||||
'management': {'result': True},
|
'management': {'result': True},
|
||||||
|
'boot': {'result': True},
|
||||||
'deploy': {'result': True}}
|
'deploy': {'result': True}}
|
||||||
self.assertEqual(expected, ret)
|
self.assertEqual(expected, ret)
|
||||||
mock_iwdi.assert_called_once_with(self.context, node.instance_info)
|
mock_iwdi.assert_called_once_with(self.context, node.instance_info)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user