NetApp: Define 'preferred' to False instead of none

Define preferred to false instead of none in the NetApp driver
as setting it to none will trigger a traceback later on because
the database doesn't allow null values to be inserted.
"preferred" export location metadata must be set to true or
false.  warning logging is also added to the SQLAlchemy API
if a none value is used to update the export location metadata.

Change-Id: Ie7420c9286cc42eaa1361eeffe607b9b5b6b3fbd
Closes-Bug: 1703660
(cherry picked from commit 4573826d36)
(cherry picked from commit 0a5d760ed5)
This commit is contained in:
Dave Hill 2017-07-11 15:02:13 -04:00 committed by Tom Barron
parent c5545e861c
commit 6dd4039a30
4 changed files with 13 additions and 2 deletions

View File

@ -2546,6 +2546,11 @@ def export_location_metadata_update(context, export_location_uuid, metadata,
# that will not take effect using one session and we will rewrite,
# in that case, single record - first one added with this call.
session = get_session()
if meta_value is None:
LOG.warning(_LW("%s should be properly defined in the driver."),
meta_key)
item = {"value": meta_value, "updated_at": timeutils.utcnow()}
meta_ref = _export_location_metadata_get_query(

View File

@ -683,7 +683,7 @@ class NetAppCmodeFileStorageLibrary(object):
if home_node:
preferred = interface.get('home-node') == home_node
else:
preferred = None
preferred = False
addresses[address] = {
'is_admin_only': is_admin_only,

View File

@ -1069,7 +1069,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
expected = copy.deepcopy(fake.INTERFACE_ADDRESSES_WITH_METADATA)
for key, value in expected.items():
value['preferred'] = None
value['preferred'] = False
self.assertEqual(expected, result)
mock_get_aggregate_node.assert_called_once_with(fake.POOL_NAME)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed the NetApp driver to report the correct value of the "preferred"
export location metadata where it cannot determine if there are any
"preferred" export locations.