summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/fake.py
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-06-21 04:38:13 +0000
committerGerrit Code Review <review@openstack.org>2018-06-21 04:38:13 +0000
commita7944340986205d1e0df157ac08970768c6968fb (patch)
tree11ad0fc37539b4a3f95ba1c3dbc46ef083de7306 /ironic/drivers/modules/fake.py
parente3d66818fac8608a00629eb9b1c17e95aab4496d (diff)
parentb17c5280e1b750ea5cdaf72ad81cf74675676d7c (diff)
downloadironic-a7944340986205d1e0df157ac08970768c6968fb.tar.gz
Merge "BIOS Settings: add sync_node_setting"
Diffstat (limited to 'ironic/drivers/modules/fake.py')
-rw-r--r--ironic/drivers/modules/fake.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/ironic/drivers/modules/fake.py b/ironic/drivers/modules/fake.py
index b6b5c10ee..d588675eb 100644
--- a/ironic/drivers/modules/fake.py
+++ b/ironic/drivers/modules/fake.py
@@ -234,7 +234,7 @@ class FakeRAID(base.RAIDInterface):
class FakeBIOS(base.BIOSInterface):
- """Example implementation of simple BIOSInterface."""
+ """Fake implementation of simple BIOSInterface."""
def get_properties(self):
return {}
@@ -247,14 +247,36 @@ class FakeBIOS(base.BIOSInterface):
'to contain a dictionary with name/value pairs'),
'required': True}})
def apply_configuration(self, task, settings):
+ # Note: the implementation of apply_configuration in fake interface
+ # is just for testing purpose, for real driver implementation, please
+ # refer to develop doc at https://docs.openstack.org/ironic/latest/
+ # contributor/bios_develop.html.
node_id = task.node.id
- try:
- objects.BIOSSettingList.create(task.context, node_id, settings)
- except exception.BIOSSettingAlreadyExists:
- objects.BIOSSettingList.save(task.context, node_id, settings)
+ create_list, update_list, delete_list, nochange_list = (
+ objects.BIOSSettingList.sync_node_setting(task.context, node_id,
+ settings))
+
+ if len(create_list) > 0:
+ objects.BIOSSettingList.create(task.context, node_id, create_list)
+ if len(update_list) > 0:
+ objects.BIOSSettingList.save(task.context, node_id, update_list)
+ if len(delete_list) > 0:
+ delete_names = [setting['name'] for setting in delete_list]
+ objects.BIOSSettingList.delete(task.context, node_id,
+ delete_names)
+
+ # nochange_list is part of return of sync_node_setting and it might be
+ # useful to the drivers to give a message if no change is required
+ # during application of settings.
+ if len(nochange_list) > 0:
+ pass
@base.clean_step(priority=0)
def factory_reset(self, task):
+ # Note: the implementation of factory_reset in fake interface is
+ # just for testing purpose, for real driver implementation, please
+ # refer to develop doc at https://docs.openstack.org/ironic/latest/
+ # contributor/bios_develop.html.
node_id = task.node.id
setting_objs = objects.BIOSSettingList.get_by_node_id(
task.context, node_id)
@@ -263,6 +285,10 @@ class FakeBIOS(base.BIOSInterface):
@base.clean_step(priority=0)
def cache_bios_settings(self, task):
+ # Note: the implementation of cache_bios_settings in fake interface
+ # is just for testing purpose, for real driver implementation, please
+ # refer to develop doc at https://docs.openstack.org/ironic/latest/
+ # contributor/bios_develop.html.
pass