Exemple #1
0
    def get_connected_clients(self, id):
        share = self.datastore.get_by_id('shares', id)
        if not share:
            raise RpcException(errno.ENOENT, 'Share not found')

        return self.dispatcher.call_sync(
            'share.{0}.get_connected_clients'.format(share['type']), id)
Exemple #2
0
    def translate_path(self, share_id):
        share = self.datastore.get_by_id('shares', share_id)
        if not share:
            raise RpcException(errno.ENOENT,
                               'Share {0} not found'.format(share_id))

        return self.dispatcher.call_sync('share.expand_path',
                                         share['target_path'],
                                         share['target_type'])
Exemple #3
0
    def expand_path(self, path, type):
        root = self.dispatcher.call_sync('volume.get_volumes_root')
        if type == 'DATASET':
            return os.path.join(root, path)

        if type == 'ZVOL':
            return os.path.join('/dev/zvol', path)

        if type in ('DIRECTORY', 'FILE'):
            return path

        raise RpcException(errno.EINVAL, 'Invalid share target type {0}'.format(type))
Exemple #4
0
    def get_dir_by_path(self, path, type):
        root = self.dispatcher.call_sync('volume.get_volumes_root')
        if type == 'DATASET':
            return os.path.join(root, path)

        if type == 'ZVOL':
            return os.path.dirname(os.path.join(root, path))

        if type == 'DIRECTORY':
            return path

        if type == 'FILE':
            return os.path.dirname(path)

        raise RpcException(errno.EINVAL, 'Invalid share target type {0}'.format(type))