Пример #1
0
 def check_for_setup_error(self):
     """Check root filesystem, NFS service and NFS share."""
     filesystem = self.nef.filesystems.get(self.root_path)
     if filesystem['mountPoint'] == 'none':
         message = (_('NFS root filesystem %(path)s is not writable') % {
             'path': filesystem['mountPoint']
         })
         raise jsonrpc.NefException(code='ENOENT', message=message)
     if not filesystem['isMounted']:
         message = (_('NFS root filesystem %(path)s is not mounted') % {
             'path': filesystem['mountPoint']
         })
         raise jsonrpc.NefException(code='ENOTDIR', message=message)
     payload = {}
     if filesystem['nonBlockingMandatoryMode']:
         payload['nonBlockingMandatoryMode'] = False
     if filesystem['smartCompression']:
         payload['smartCompression'] = False
     if payload:
         self.nef.filesystems.set(self.root_path, payload)
     service = self.nef.services.get('nfs')
     if service['state'] != 'online':
         message = (_('NFS server service is not online: %(state)s') % {
             'state': service['state']
         })
         raise jsonrpc.NefException(code='ESRCH', message=message)
     self._get_provisioned_capacity()
Пример #2
0
 def test_message_plus_kwargs(self):
     code = 'ENODEV'
     message1 = 'test message 4'
     message2 = 'test message 5'
     result = jsonrpc.NefException(message1, code=code, message=message2)
     self.assertEqual(code, result.code)
     self.assertIn(message2, result.msg)
Пример #3
0
    def test_create_share(self, delete_fs, create_fs, mount_fs):
        mount_path = '%s:/%s' % (self.cfg.nexenta_nas_host, SHARE_PATH)
        mount_fs.return_value = mount_path
        size = int(1 * units.Gi * 1.1)
        self.assertEqual([{
            'path': mount_path,
            'id': 'share-uuid'
        }], self.drv.create_share(self.ctx, SHARE))

        payload = {
            'recordSize': 131072,
            'compressionMode': self.cfg.nexenta_dataset_compression,
            'path': SHARE_PATH,
            'referencedQuotaSize': size,
            'nonBlockingMandatoryMode': False,
            'referencedReservationSize': size
        }
        self.drv.nef.filesystems.create.assert_called_with(payload)

        mount_fs.side_effect = jsonrpc.NefException('some error')
        self.assertRaises(jsonrpc.NefException, self.drv.create_share,
                          self.ctx, SHARE)
        delete_payload = {'force': True}
        self.drv.nef.filesystems.delete.assert_called_with(
            SHARE_PATH, delete_payload)
Пример #4
0
 def test_create_exist(self):
     payload = {'key': 'value'}
     expected = None
     self.proxy.post.side_effect = jsonrpc.NefException(code='EEXIST')
     result = self.instance.create(payload)
     self.proxy.post.assert_called_with(self.instance.root, payload)
     self.assertEqual(expected, result)
Пример #5
0
 def test_delete_error(self):
     name = 'parent/child'
     payload = {'key': 'value'}
     path = self.instance.path(name)
     self.proxy.delete.side_effect = jsonrpc.NefException(code='EINVAL')
     self.assertRaises(jsonrpc.NefException, self.instance.delete, name,
                       payload)
     self.proxy.delete.assert_called_with(path, payload)
Пример #6
0
 def test_delete_not_found(self):
     name = 'parent/child'
     payload = {'key': 'value'}
     path = self.instance.path(name)
     self.proxy.delete.side_effect = jsonrpc.NefException(code='ENOENT')
     result = self.instance.delete(name, payload)
     self.proxy.delete.assert_called_with(path, payload)
     self.assertIsNone(result)
Пример #7
0
    def test_create_share_from_snapshot_error(self, snap_clone, fs_delete,
                                              remount_fs, mount_fs):
        fs_delete.side_effect = jsonrpc.NefException('delete error')
        mount_fs.side_effect = jsonrpc.NefException('create error')
        self.assertRaises(jsonrpc.NefException,
                          self.drv.create_share_from_snapshot, self.ctx,
                          SHARE2, SNAPSHOT)

        size = int(SHARE2['size'] * units.Gi * 1.1)
        payload = {
            'targetPath': SHARE2_PATH,
            'referencedQuotaSize': size,
            'recordSize': self.cfg.nexenta_dataset_record_size,
            'compressionMode': self.cfg.nexenta_dataset_compression,
            'nonBlockingMandatoryMode': False,
            'referencedReservationSize': size
        }
        snap_clone.assert_called_once_with(SNAPSHOT['snapshot_path'], payload)
        payload = {'force': True}
        fs_delete.assert_called_once_with(SHARE2_PATH, payload)
Пример #8
0
 def test_delete_share(self, fs_delete, snap_list, snap_get, fs_promote):
     delete_payload = {'force': True, 'snapshots': True}
     snapshots_payload = {'parent': SHARE_PATH, 'fields': 'path'}
     clones_payload = {'fields': 'clones,creationTxg'}
     clone_path = '%s:/%s' % (self.cfg.nexenta_nas_host, 'path_to_fs')
     fs_delete.side_effect = [
         jsonrpc.NefException({
             'message': 'some_error',
             'code': 'EEXIST'}),
         None]
     snap_list.return_value = [{'path': '%s@snap1' % SHARE_PATH}]
     snap_get.return_value = {'clones': [clone_path], 'creationTxg': 1}
     self.assertIsNone(self.drv.delete_share(self.ctx, SHARE))
     fs_delete.assert_called_with(SHARE_PATH, delete_payload)
     fs_promote.assert_called_with(clone_path)
     snap_get.assert_called_with('%s@snap1' % SHARE_PATH, clones_payload)
     snap_list.assert_called_with(snapshots_payload)
Пример #9
0
 def test_dict(self):
     code = 'ENOENT'
     message = 'test message 4'
     result = jsonrpc.NefException({'code': code, 'message': message})
     self.assertEqual(code, result.code)
     self.assertIn(message, result.msg)
Пример #10
0
 def test_create_error(self):
     payload = {'key': 'value'}
     self.proxy.post.side_effect = jsonrpc.NefException(code='EBUSY')
     self.assertRaises(jsonrpc.NefException, self.instance.create, payload)
     self.proxy.post.assert_called_with(self.instance.root, payload)
Пример #11
0
 def test_no_message_kwargs(self):
     code = 'ESRCH'
     message = 'test message 3'
     result = jsonrpc.NefException(None, code=code, message=message)
     self.assertEqual(code, result.code)
     self.assertIn(message, result.msg)
Пример #12
0
 def test_message_kwargs(self):
     code = 'EAGAIN'
     message = 'test message 2'
     result = jsonrpc.NefException(message, code=code)
     self.assertEqual(code, result.code)
     self.assertIn(message, result.msg)
Пример #13
0
 def test_message(self):
     message = 'test message 1'
     result = jsonrpc.NefException(message)
     self.assertIn(message, result.msg)
Пример #14
0
 def test_defaults(self):
     code = 'EBADMSG'
     message = 'NexentaError'
     result = jsonrpc.NefException()
     self.assertEqual(code, result.code)
     self.assertIn(message, result.msg)
Пример #15
0
 def test_dict_kwargs(self):
     code = 'EINVAL'
     message = 'test message 6'
     result = jsonrpc.NefException({'code': code}, message=message)
     self.assertEqual(code, result.code)
     self.assertIn(message, result.msg)
Пример #16
0
 def test_kwargs(self):
     code = 'EPERM'
     message = 'test message 5'
     result = jsonrpc.NefException(code=code, message=message)
     self.assertEqual(code, result.code)
     self.assertIn(message, result.msg)