diff options
author | Zenghui Shi <zshi@redhat.com> | 2018-06-01 16:49:09 +0800 |
---|---|---|
committer | Zenghui Shi <zshi@redhat.com> | 2018-06-20 15:15:01 +0800 |
commit | b17c5280e1b750ea5cdaf72ad81cf74675676d7c (patch) | |
tree | ec64729316b8e23bd4a9d26375c9592dd4bb6d9e /ironic/drivers/modules/fake.py | |
parent | 585427ab8ec188c82562c20feace22f868eea532 (diff) | |
download | ironic-b17c5280e1b750ea5cdaf72ad81cf74675676d7c.tar.gz |
BIOS Settings: add sync_node_setting
sync_node_setting takes a list of bios settings as input
and sorts out a tuple of lists of create, update, delete
and nochange settings by comparing the given settings with
node 'bios_settings' database table.
This commit also modifies fake BIOS interface to use
sync_node_setting for testing purpose.
Change-Id: I831b3db8f4da24d88a81b4d85889f7fd6f83ffdb
Story: #1712032
Diffstat (limited to 'ironic/drivers/modules/fake.py')
-rw-r--r-- | ironic/drivers/modules/fake.py | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/ironic/drivers/modules/fake.py b/ironic/drivers/modules/fake.py index 016784564..2391cba0a 100644 --- a/ironic/drivers/modules/fake.py +++ b/ironic/drivers/modules/fake.py @@ -238,7 +238,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,13 +247,35 @@ class FakeBIOS(base.BIOSInterface): pass 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 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) @@ -261,6 +283,10 @@ class FakeBIOS(base.BIOSInterface): objects.BIOSSetting.delete(task.context, node_id, setting.name) 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 |