Merge "Add SAN policy setter/getter"
This commit is contained in:
commit
c5ce9a6cf6
@ -238,3 +238,9 @@ SUPPORTED_SCSI_UID_FORMATS = [
|
||||
SCSI_UID_VENDOR_ID,
|
||||
SCSI_UID_VENDOR_SPECIFIC
|
||||
]
|
||||
|
||||
DISK_POLICY_UNKNOWN = 0
|
||||
DISK_POLICY_ONLINE_ALL = 1
|
||||
DISK_POLICY_OFFLINE_SHARED = 2
|
||||
DISK_POLICY_OFFLINE_ALL = 3
|
||||
DISK_POLICY_OFFLINE_INTERNAL = 4
|
||||
|
@ -369,3 +369,18 @@ class DiskUtilsTestCase(test_base.OsWinBaseTestCase):
|
||||
result = self._diskutils._select_supported_scsi_identifiers(
|
||||
identifiers)
|
||||
self.assertEqual(expected_identifiers, result)
|
||||
|
||||
def test_get_new_disk_policy(self):
|
||||
mock_setting_obj = mock.Mock()
|
||||
setting_cls = self._diskutils._conn_storage.MSFT_StorageSetting
|
||||
setting_cls.Get.return_value = (0, mock_setting_obj)
|
||||
|
||||
policy = self._diskutils.get_new_disk_policy()
|
||||
self.assertEqual(mock_setting_obj.NewDiskPolicy, policy)
|
||||
|
||||
def test_set_new_disk_policy(self):
|
||||
self._diskutils.set_new_disk_policy(mock.sentinel.policy)
|
||||
|
||||
setting_cls = self._diskutils._conn_storage.MSFT_StorageSetting
|
||||
setting_cls.Set.assert_called_once_with(
|
||||
NewDiskPolicy=mock.sentinel.policy)
|
||||
|
@ -301,3 +301,18 @@ class DiskUtils(baseutils.BaseUtils):
|
||||
selected_identifiers.append(identifier)
|
||||
|
||||
return selected_identifiers
|
||||
|
||||
def get_new_disk_policy(self):
|
||||
# This policy is also known as the 'SAN policy', describing
|
||||
# how new disks will be handled.
|
||||
storsetting = self._conn_storage.MSFT_StorageSetting.Get()[1]
|
||||
return storsetting.NewDiskPolicy
|
||||
|
||||
def set_new_disk_policy(self, policy):
|
||||
"""Sets the new disk policy, also known as SAN policy.
|
||||
|
||||
:param policy: an integer value, one of the DISK_POLICY_*
|
||||
values defined in os_win.constants.
|
||||
"""
|
||||
self._conn_storage.MSFT_StorageSetting.Set(
|
||||
NewDiskPolicy=policy)
|
||||
|
Loading…
x
Reference in New Issue
Block a user