diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-07-03 13:06:25 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-07-03 13:06:25 +0000 |
commit | 825c5c94200e48664033b52b00b72586b86cf4de (patch) | |
tree | 72a06fae9c52bdd5c0f29f9463914e5d945c25d8 | |
parent | 783ee69b5aefcaa01021ef8b6e4e0b6495b611ab (diff) | |
parent | 8718e51acba69e37eeddcc41fead334acfffef95 (diff) | |
download | nova-825c5c94200e48664033b52b00b72586b86cf4de.tar.gz |
Merge "Hyper-V: checks for existent Notes in list_instance_notes" into stable/juno
-rw-r--r-- | nova/tests/virt/hyperv/test_vmutils.py | 4 | ||||
-rw-r--r-- | nova/tests/virt/hyperv/test_vmutilsv2.py | 4 | ||||
-rw-r--r-- | nova/virt/hyperv/vmutils.py | 5 | ||||
-rw-r--r-- | nova/virt/hyperv/vmutilsv2.py | 4 |
4 files changed, 12 insertions, 5 deletions
diff --git a/nova/tests/virt/hyperv/test_vmutils.py b/nova/tests/virt/hyperv/test_vmutils.py index 4a2815cf41..fee46e4382 100644 --- a/nova/tests/virt/hyperv/test_vmutils.py +++ b/nova/tests/virt/hyperv/test_vmutils.py @@ -589,7 +589,9 @@ class VMUtilsTestCase(test.NoDBTestCase): attrs = {'ElementName': 'fake_name', 'Notes': '4f54fb69-d3a2-45b7-bb9b-b6e6b3d893b3'} vs.configure_mock(**attrs) - self._vmutils._conn.Msvm_VirtualSystemSettingData.return_value = [vs] + vs2 = mock.MagicMock(ElementName='fake_name2', Notes=None) + self._vmutils._conn.Msvm_VirtualSystemSettingData.return_value = [vs, + vs2] response = self._vmutils.list_instance_notes() self.assertEqual([(attrs['ElementName'], [attrs['Notes']])], response) diff --git a/nova/tests/virt/hyperv/test_vmutilsv2.py b/nova/tests/virt/hyperv/test_vmutilsv2.py index d247f70124..3ea22c34b4 100644 --- a/nova/tests/virt/hyperv/test_vmutilsv2.py +++ b/nova/tests/virt/hyperv/test_vmutilsv2.py @@ -124,7 +124,9 @@ class VMUtilsV2TestCase(test_vmutils.VMUtilsTestCase): attrs = {'ElementName': 'fake_name', 'Notes': ['4f54fb69-d3a2-45b7-bb9b-b6e6b3d893b3']} vs.configure_mock(**attrs) - self._vmutils._conn.Msvm_VirtualSystemSettingData.return_value = [vs] + vs2 = mock.MagicMock(ElementName='fake_name2', Notes=None) + self._vmutils._conn.Msvm_VirtualSystemSettingData.return_value = [vs, + vs2] response = self._vmutils.list_instance_notes() self.assertEqual([(attrs['ElementName'], attrs['Notes'])], response) diff --git a/nova/virt/hyperv/vmutils.py b/nova/virt/hyperv/vmutils.py index ebe33b83ce..82a941b4e6 100644 --- a/nova/virt/hyperv/vmutils.py +++ b/nova/virt/hyperv/vmutils.py @@ -108,8 +108,9 @@ class VMUtils(object): for vs in self._conn.Msvm_VirtualSystemSettingData( ['ElementName', 'Notes'], SettingType=self._VIRTUAL_SYSTEM_CURRENT_SETTINGS): - instance_notes.append((vs.ElementName, - [v for v in vs.Notes.split('\n') if v])) + if vs.Notes is not None: + instance_notes.append( + (vs.ElementName, [v for v in vs.Notes.split('\n') if v])) return instance_notes diff --git a/nova/virt/hyperv/vmutilsv2.py b/nova/virt/hyperv/vmutilsv2.py index 4156f622b6..1c196731ad 100644 --- a/nova/virt/hyperv/vmutilsv2.py +++ b/nova/virt/hyperv/vmutilsv2.py @@ -78,7 +78,9 @@ class VMUtilsV2(vmutils.VMUtils): for vs in self._conn.Msvm_VirtualSystemSettingData( ['ElementName', 'Notes'], VirtualSystemType=self._VIRTUAL_SYSTEM_TYPE_REALIZED): - instance_notes.append((vs.ElementName, [v for v in vs.Notes if v])) + if vs.Notes is not None: + instance_notes.append( + (vs.ElementName, [v for v in vs.Notes if v])) return instance_notes |