Esempio n. 1
0
 def test_get_volume(self):
     get_response = 'Success'
     self._init_filer(get_response=get_response)
     ret = volumes.Volumes(self._filer).get(self._volume_1_name)
     self._filer.get.assert_called_once_with('/config/storage/volumes/' +
                                             self._volume_1_name)
     self.assertEqual(ret, get_response)
Esempio n. 2
0
 def test_add_encrypted_volume_default_args_single_device_success(self):
     add_response = 'Success'
     self._init_filer(add_response=add_response)
     self._filer.get = mock.MagicMock(
         side_effect=TestEdgeVolumes._mock_no_arrays_single_drive)
     track_volume_creation_status_mock = self.patch_call(
         "cterasdk.edge.volumes.track")
     ret = volumes.Volumes(self._filer).add(
         self._volume_1_name, passphrase=self._volume_passphrase)
     self._filer.get.assert_has_calls([
         mock.call('/status/storage/arrays'),
         mock.call('/status/storage/disks')
     ])
     track_volume_creation_status_mock.assert_called_once_with(
         self._filer,
         '/status/storage/volumes/' + self._volume_1_name + '/status',
         [VolumeStatus.Ok], [VolumeStatus.Formatting], [
             VolumeStatus.Mounting, VolumeStatus.Checking,
             VolumeStatus.Repairing
         ], [VolumeStatus.Corrupted, VolumeStatus.Unknown])
     self._filer.add.assert_called_once_with('/config/storage/volumes',
                                             mock.ANY)
     expected_param = self._get_add_volume_param(
         device=TestEdgeVolumes._drive_1,
         size=TestEdgeVolumes._drive_size,
         passphrase=self._volume_passphrase)
     actual_param = self._filer.add.call_args[0][1]
     self._assert_equal_objects(actual_param, expected_param)
     self.assertEqual(ret, add_response)
Esempio n. 3
0
 def test_modify_volume_not_found(self):
     self._init_filer()
     self._filer.get = mock.MagicMock(
         side_effect=exception.CTERAException())
     with self.assertRaises(exception.CTERAException) as error:
         volumes.Volumes(self._filer).modify(self._volume_1_name, 9999)
     self._filer.get.assert_called_once_with('/config/storage/volumes/' +
                                             self._volume_1_name)
     self.assertEqual('Failed to get the volume', error.exception.message)
Esempio n. 4
0
 def test_add_volume_no_devices(self):
     self._init_filer()
     self._filer.get = mock.MagicMock(
         side_effect=TestEdgeVolumes._mock_no_devices)
     with self.assertRaises(exception.CTERAException) as error:
         volumes.Volumes(self._filer).add(self._volume_1_name)
     self._filer.get.assert_has_calls([
         mock.call('/status/storage/arrays'),
         mock.call('/status/storage/disks')
     ])
     self.assertEqual('Could not find any drives or arrays',
                      error.exception.message)
Esempio n. 5
0
 def test_add_volume_must_specify_device_name(self):
     self._init_filer()
     self._filer.get = mock.MagicMock(
         side_effect=TestEdgeVolumes._mock_no_arrays_multiple_drive)
     with self.assertRaises(exception.CTERAException) as error:
         volumes.Volumes(self._filer).add(self._volume_1_name)
     self._filer.get.assert_has_calls([
         mock.call('/status/storage/arrays'),
         mock.call('/status/storage/disks')
     ])
     self.assertEqual('You must specify a drive or an array name',
                      error.exception.message)
Esempio n. 6
0
 def test_add_volume_invalid_device_name(self):
     self._init_filer()
     self._filer.get = mock.MagicMock(
         side_effect=TestEdgeVolumes._mock_no_arrays_multiple_drive)
     with self.assertRaises(exception.InputError) as error:
         volumes.Volumes(self._filer).add(self._volume_1_name,
                                          device='Invalid device name')
     self._filer.get.assert_has_calls([
         mock.call('/status/storage/arrays'),
         mock.call('/status/storage/disks')
     ])
     self.assertEqual('Invalid device name', error.exception.message)
Esempio n. 7
0
 def test_delete_volume_raise(self):
     self._init_filer()
     self._filer.delete = mock.MagicMock(
         side_effect=exception.CTERAException())
     taskmgr.by_name = mock.MagicMock(return_value=[])
     with self.assertRaises(exception.CTERAException) as error:
         volumes.Volumes(self._filer).delete(self._volume_1_name)
     taskmgr.by_name.assert_called_once_with(
         self._filer,
         ' '.join(['Mounting', self._volume_1_name, 'file system']))
     self._filer.delete.assert_called_once_with('/config/storage/volumes/' +
                                                self._volume_1_name)
     self.assertEqual('Volume deletion falied', error.exception.message)
Esempio n. 8
0
 def test_add_volume_exceeding_drive_size(self):
     self._init_filer()
     self._filer.get = mock.MagicMock(
         side_effect=TestEdgeVolumes._mock_no_arrays_single_drive)
     with self.assertRaises(exception.InputError) as error:
         volumes.Volumes(self._filer).add(self._volume_1_name,
                                          size=999999999)
     self._filer.get.assert_has_calls([
         mock.call('/status/storage/arrays'),
         mock.call('/status/storage/disks')
     ])
     self.assertEqual('You cannot exceed the available storage capacity',
                      error.exception.message)
Esempio n. 9
0
 def test_delete_all_volume_success(self):
     delete_response = 'Success'
     self._init_filer(get_response=self._get_volumes_response_param(),
                      delete_response=delete_response)
     taskmgr.running = mock.MagicMock(
         return_value=TestEdgeVolumes._get_pending_mount_tasks())
     taskmgr.by_name = mock.MagicMock()
     taskmgr.wait = mock.MagicMock()
     volumes.Volumes(self._filer).delete_all()
     self._filer.get.assert_called_once_with('/config/storage/volumes')
     taskmgr.running.assert_called_once_with(self._filer)
     self._filer.delete.assert_has_calls([
         mock.call('/config/storage/volumes/' + self._volume_1_name),
         mock.call('/config/storage/volumes/' + self._volume_2_name)
     ])
Esempio n. 10
0
 def test_delete_volume_success(self):
     delete_response = 'Success'
     self._init_filer(delete_response=delete_response)
     taskmgr.by_name = mock.MagicMock(return_value=[
         TestEdgeVolumes._get_pending_mount_task(self._mount_id)
     ])
     taskmgr.wait = mock.MagicMock()
     ret = volumes.Volumes(self._filer).delete(self._volume_1_name)
     taskmgr.by_name.assert_called_once_with(
         self._filer,
         ' '.join(['Mounting', self._volume_1_name, 'file system']))
     taskmgr.wait.assert_called_once_with(self._filer, self._mount_id)
     self._filer.delete.assert_called_once_with('/config/storage/volumes/' +
                                                self._volume_1_name)
     self.assertEqual(ret, delete_response)
Esempio n. 11
0
 def test_modify_volume_success(self):
     before_volume_size = 1000
     after_volume_size = 9999
     put_response = 'Success'
     self._init_filer(get_response=TestEdgeVolumes._get_volume_response(
         self._volume_1_name, before_volume_size),
                      put_response=put_response)
     ret = volumes.Volumes(self._filer).modify(self._volume_1_name, 9999)
     self._filer.get.assert_called_once_with('/config/storage/volumes/' +
                                             self._volume_1_name)
     self._filer.put.assert_called_once_with(
         '/config/storage/volumes/' + self._volume_1_name, mock.ANY)
     expected_param = TestEdgeVolumes._get_volume_response(
         self._volume_1_name, after_volume_size)
     actual_param = self._filer.put.call_args[0][1]
     self._assert_equal_objects(actual_param, expected_param)
     self.assertEqual(ret, put_response)
Esempio n. 12
0
 def test_delete_no_volumes_found(self):
     self._init_filer(get_response=[])
     taskmgr.running = mock.MagicMock(return_value=[])
     volumes.Volumes(self._filer).delete_all()
     self._filer.get.assert_called_once_with('/config/storage/volumes')