Example #1
0
 def test_remove_disk(self):
     vsan.remove_capacity_from_diskgroup(
         self.mock_si, self.mock_host_ref, self.mock_diskgroup,
         [self.mock_cap_disk1, self.mock_cap_disk2])
     self.mock_remove_disk.assert_called_once_with(
         disk=[self.mock_cap_disk1, self.mock_cap_disk2],
         maintenanceSpec=self.mock_spec)
Example #2
0
 def test_maintenance_mode_no_action(self):
     vsan.remove_capacity_from_diskgroup(
         self.mock_si, self.mock_host_ref, self.mock_diskgroup,
         [self.mock_cap_disk1, self.mock_cap_disk2],
         data_evacuation=False)
     self.assertEqual(self.mock_spec.vsanMode.objectAction,
                      vim.VsanHostDecommissionModeObjectAction.noAction)
Example #3
0
 def test_maintenance_mode_evacuate_all_data(self):
     vsan.remove_capacity_from_diskgroup(
         self.mock_si, self.mock_host_ref, self.mock_diskgroup,
         [self.mock_cap_disk1, self.mock_cap_disk2])
     self.assertEqual(
         self.mock_spec.vsanMode.objectAction,
         vim.VsanHostDecommissionModeObjectAction.evacuateAllData)
Example #4
0
 def test_wait_for_tasks(self):
     mock_wait_for_task = MagicMock()
     with patch('salt.utils.vmware.wait_for_task', mock_wait_for_task):
         vsan.remove_capacity_from_diskgroup(
             self.mock_si, self.mock_host_ref, self.mock_diskgroup,
             [self.mock_cap_disk1, self.mock_cap_disk2])
     mock_wait_for_task.assert_called_once_with(self.mock_task,
                                                'fake_hostname',
                                                'remove_capacity')
Example #5
0
 def test_get_hostname(self):
     mock_get_managed_object_name = MagicMock(return_value='fake_hostname')
     with patch('salt.utils.vmware.get_managed_object_name',
                mock_get_managed_object_name):
         vsan.remove_capacity_from_diskgroup(
             self.mock_si, self.mock_host_ref, self.mock_diskgroup,
             [self.mock_cap_disk1, self.mock_cap_disk2])
     mock_get_managed_object_name.assert_called_once_with(
         self.mock_host_ref)
Example #6
0
 def test_remove_disk_raise_runtime_fault(self):
     err = vmodl.RuntimeFault()
     err.msg = 'runtime_fault'
     self.mock_host_vsan_system.RemoveDisk_Task = \
         MagicMock(side_effect=err)
     with self.assertRaises(VMwareRuntimeError) as excinfo:
         vsan.remove_capacity_from_diskgroup(
             self.mock_si, self.mock_host_ref, self.mock_diskgroup,
             [self.mock_cap_disk1, self.mock_cap_disk2])
     self.assertEqual(excinfo.exception.strerror, 'runtime_fault')
Example #7
0
 def test_remove_disk_mapping(self):
     vsan.remove_diskgroup(self.mock_si, self.mock_host_ref,
                           self.mock_diskgroup)
     vsan.remove_capacity_from_diskgroup(
         self.mock_si,
         self.mock_host_ref,
         self.mock_diskgroup,
         [self.mock_cap_disk1, self.mock_cap_disk2],
     )
     self.mock_remove_disk_mapping.assert_called_once_with(
         mapping=[self.mock_diskgroup], maintenanceSpec=self.mock_spec)
Example #8
0
 def test_remove_disk_raise_no_permission(self):
     err = vim.fault.NoPermission()
     err.privilegeId = 'Fake privilege'
     self.mock_host_vsan_system.RemoveDisk_Task = \
         MagicMock(side_effect=err)
     with self.assertRaises(VMwareApiError) as excinfo:
         vsan.remove_capacity_from_diskgroup(
             self.mock_si, self.mock_host_ref, self.mock_diskgroup,
             [self.mock_cap_disk1, self.mock_cap_disk2])
     self.assertEqual(excinfo.exception.strerror,
                      'Not enough permissions. Required privilege: '
                      'Fake privilege')
Example #9
0
 def test_remove_disk_raise_vim_fault(self):
     err = vim.fault.VimFault()
     err.msg = "vim_fault"
     self.mock_host_vsan_system.RemoveDisk_Task = MagicMock(side_effect=err)
     with self.assertRaises(VMwareApiError) as excinfo:
         vsan.remove_capacity_from_diskgroup(
             self.mock_si,
             self.mock_host_ref,
             self.mock_diskgroup,
             [self.mock_cap_disk1, self.mock_cap_disk2],
         )
     self.assertEqual(excinfo.exception.strerror, "vim_fault")
Example #10
0
 def test_result(self):
     res = vsan.remove_capacity_from_diskgroup(
         self.mock_si,
         self.mock_host_ref,
         self.mock_diskgroup,
         [self.mock_cap_disk1, self.mock_cap_disk2],
     )
     self.assertTrue(res)