Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
FROM redhat/ubi8
USER root
EXPOSE 6789 6800 6801 6802 6803 6804 6805 80 5000 8443 9283
RUN update-crypto-policies --set FIPS
RUN \
dnf update -y --setopt=install_weak_deps=0 --nodocs && \
dnf install -y gcc gcc-c++ git vim cmake ninja-build python3-pip && \

dnf install -y --setopt=install_weak_deps=0 --nodocs wget unzip util-linux python3-setuptools udev device-mapper && \
dnf install -y ca-certificates kmod lvm2 systemd-udev sg3_utils procps-ng hostname udev libibverbs sqlite-devel && \
yum --nogpgcheck --repofrompath=centos,http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/ install -y libibverbs-utils libibverbs-devel libudev-devel libblkid-devel libaio-devel libcap-ng-devel libicu-devel keyutils keyutils-libs-devel openldap-devel fuse-libs cryptsetup-luks snappy && \
dnf -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs install http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-6.el8.noarch.rpm http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-8-6.el8.noarch.rpm && dnf -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs install epel-release && \
dnf -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs install epel-release && \
dnf config-manager --set-enabled powertools && \
yum install -y snappy-devel lz4-devel curl-devel libbabeltrace-devel lua-devel libnl3-devel thrift-devel gperf librabbitmq-devel librdkafka-devel fuse-devel cryptsetup-devel re2-devel liboath-devel && \
yum install -y openssl-devel expat-devel python36-devel lttng-ust-devel
RUN mkdir /root/legacy
ADD legacy/* /root/legacy/.
ADD setup.py /root/setup.py
ADD test_rbd.py /root/test_rbd.py
RUN mkdir -p /usr/lib64/rados-classes
WORKDIR /
RUN git clone https://github.com/ceph/ceph.git \
&& cd ceph/ \
&& git checkout -b v17.2.6 tags/v17.2.6 && \
pip3 install sphinx pyyaml && \
pip3 install cython==3.0.0 && \
cp /root/setup.py /ceph/src/pybind/rbd/setup.py && \
cp /root/test_rbd.py /ceph/src/test/pybind/test_rbd.py && \
sed -i 's/CMAKE_INSTALL_LIBDIR/CMAKE_INSTALL_FULL_LIBDIR/g' /ceph/src/common/options/osd.yaml.in && \
sed -i 's/) with gil/) noexcept with gil/g' /ceph/src/pybind/rbd/rbd.pyx && \
cd /ceph && \
./do_cmake.sh && \
cp /root/legacy/* ./build/include/. && \
rm -rf /root/legacy && \
cd /ceph/build && \
ninja -j 3 && \
ninja src/ceph-volume/install && \
ninja src/pybind/mgr/install && \
shopt -s extglob && \
find bin -type f -iregex '.*test.*' -delete && \
find bin -type f -not \( -name 'ceph' -or -name 'init-ceph' -or -name 'ceph-debugpack' -or -name 'ceph-coverage' -or -name 'ceph-crash' -or -name 'ceph-post-file' \) -print0 | xargs -0 -I {} strip {} && \
find lib -type f -not -path "lib/cython_modules" -print0 | xargs -0 -I {} strip {} && \
cp -r bin/* /usr/bin/. && \
rm -rf lib/*.a && \
cp -r lib/libcls* /usr/lib64/rados-classes/. && \
rm -rf lib/libcls* && \
cp -r lib/* /usr/lib64/. && \
cd ../../ && \
rm -rf ceph/src/pybind/mgr && \
cp -r ceph/src/pybind/* /usr/lib/python3.6/site-packages/. && \
cp ceph/src/cephadm/cephadm /usr/sbin/. && \
cp -r ceph/share/* /usr/local/share/ceph/. && \
cp ceph/src/mount.fuse.ceph /sbin/. && \
cp ceph/src/rbdmap /usr/bin/rbdmap && \
find ceph/src/include/rados -maxdepth 1 -type l -delete && \
cp -r ceph/src/include/rados /usr/include/rados && \
cp -r ceph/src/include/buffer.h /usr/include/rados/. && \
cp -r ceph/src/include/buffer_fwd.h /usr/include/rados/. && \
cp -r ceph/src/include/crc32c.h /usr/include/rados/. && \
cp -r ceph/src/include/inline_memory.h /usr/include/rados/. && \
cp -r ceph/src/include/page.h /usr/include/rados/. && \
cp -r ceph/src/include/rbd /usr/include/rbd && \
cp -r ceph/src/include/cephfs /usr/include/cephfs && \
rm -rf ceph
WORKDIR /
RUN mkdir -p /etc/ceph
ADD rbdmap /etc/ceph/.
RUN cp -r /usr/lib64/rados-classes /usr/local/lib64/.
RUN cp -r /usr/local/lib/python3.6/site-packages/ceph-1.0.0-py3.6.egg/ceph /usr/lib/python3.6/site-packages/. \
&& rm -rf /usr/local/lib/python3.6/site-packages/ceph-1.0.0-py3.6.egg/ceph
RUN cp -r /usr/local/lib/python3.6/site-packages/ceph_volume-1.0.0-py3.6.egg/ceph_volume /usr/lib/python3.6/site-packages/. \
&& rm -rf /usr/local/lib/python3.6/site-packages/ceph_volume-1.0.0-py3.6.egg/ceph_volume
RUN cp -r /usr/lib64/cython_modules/lib.3/* /usr/lib/python3.6/site-packages/. \
&& rm -rf /usr/lib64/cython_modules/lib.3/*
RUN pip3 install typing-extensions==3.7.4.3
RUN pip3 install cherrypy
RUN cp -r /usr/local/lib64/python3.6/site-packages/cherrypy /usr/lib64/python3.6/site-packages/.
RUN dnf install -y python3-pecan python3-natsort python3-routes python3-bcrypt python3-jsonpatch python3-jwt python3-dateutil python3-werkzeug python3-scipy
RUN pip3 install --upgrade pip
RUN pip3 install pyOpenSSL
RUN mkdir -p /usr/local/lib64/ceph
RUN mkdir -p /usr/local/lib64/ceph/erasure-code
RUN mkdir -p /usr/local/lib64/ceph/compressor
RUN mkdir -p /usr/local/lib64/ceph/crypto
RUN mkdir -p /usr/local/lib64/ceph/denc
RUN mkdir -p /usr/local/lib64/ceph/librbd
RUN mv /usr/lib64/libec_* /usr/local/lib64/ceph/erasure-code/.
RUN mv /usr/lib64/libceph_lz4* /usr/local/lib64/ceph/compressor/.
RUN mv /usr/lib64/libceph_snappy* /usr/local/lib64/ceph/compressor/.
RUN mv /usr/lib64/libceph_zlib* /usr/local/lib64/ceph/compressor/.
RUN mv /usr/lib64/libceph_zstd* /usr/local/lib64/ceph/compressor/.
RUN mv /usr/lib64/libceph_crypto* /usr/local/lib64/ceph/crypto/.
RUN mv /usr/lib64/denc* /usr/local/lib64/ceph/denc/.
RUN mv /usr/lib64/libceph_librbd* /usr/local/lib64/ceph/librbd/.
RUN pip3 install prettytable
RUN groupadd -g 167 ceph && useradd -u 167 -g ceph ceph
RUN groupadd -g 993 cephadm && useradd -u 993 -g cephadm cephadm
RUN groupadd -g 992 libstoragemgmt && useradd -u 992 -g libstoragemgmt libstoragemgmt
RUN groupadd -g 991 ganesha && useradd -u 991 -g ganesha ganesha
RUN groupadd -g 32 rpc && useradd -u 32 -g rpc rpc
RUN mkdir -p /var/lib/ceph
RUN mkdir -p /var/lib/cephadm
WORKDIR /var/lib/ceph
RUN mkdir {mon,mgr,osd,mds,bootstrap-mds,bootstrap-osd,bootstrap-rbd-mirror,crash,tmp,bootstrap-mgr,bootstrap-rbd,bootstrap-rgw,radosgw}
WORKDIR /
RUN chown -R ceph:ceph /var/lib/ceph
RUN chown -R cephadm:cephadm /var/lib/cephadm
RUN mkdir -p /run/ceph
RUN mkdir -p /usr/local/share/ceph/mgr
RUN yum install -y logrotate
ADD ceph-log /etc/logrotate.d/ceph
RUN yum install -y nfs-utils
RUN cp /usr/bin/mount.ceph /sbin/mount.ceph
RUN \
if [ -f /usr/bin/ceph-dencoder ]; then gzip -9 /usr/bin/ceph-dencoder; fi && \
rm -f /usr/bin/ceph-dencoder
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
225 changes: 225 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
import os
import pkgutil
import shutil
import subprocess
import sys
import tempfile
import textwrap
if not pkgutil.find_loader('setuptools'):
from distutils.core import setup
from distutils.extension import Extension
else:
from setuptools import setup
from setuptools.extension import Extension
from distutils.ccompiler import new_compiler
from distutils.errors import CompileError, LinkError
from itertools import filterfalse, takewhile
from packaging import version
import distutils.sysconfig


def filter_unsupported_flags(compiler, flags):
args = takewhile(lambda argv: not argv.startswith('-'), [compiler] + flags)
if any('clang' in arg for arg in args):
return list(filterfalse(lambda f:
f in ('-mcet',
'-fstack-clash-protection',
'-fno-var-tracking-assignments',
'-Wno-deprecated-register',
'-Wno-gnu-designator') or
f.startswith('-fcf-protection'),
flags))
else:
return flags


def monkey_with_compiler(customize):
def patched(compiler):
customize(compiler)
if compiler.compiler_type != 'unix':
return
compiler.compiler[1:] = \
filter_unsupported_flags(compiler.compiler[0],
compiler.compiler[1:])
compiler.compiler_so[1:] = \
filter_unsupported_flags(compiler.compiler_so[0],
compiler.compiler_so[1:])
return patched


distutils.sysconfig.customize_compiler = \
monkey_with_compiler(distutils.sysconfig.customize_compiler)

# PEP 440 versioning of the RBD package on PyPI
# Bump this version, after every changeset

__version__ = '2.0.0'


def get_python_flags(libs):
py_libs = sum((libs.split() for libs in
distutils.sysconfig.get_config_vars('LIBS', 'SYSLIBS')), [])
ldflags = list(filterfalse(lambda lib: lib.startswith('-l'), py_libs))
py_libs = [lib.replace('-l', '') for lib in
filter(lambda lib: lib.startswith('-l'), py_libs)]
compiler = new_compiler()
distutils.sysconfig.customize_compiler(compiler)
return dict(
include_dirs=[distutils.sysconfig.get_python_inc()],
library_dirs=distutils.sysconfig.get_config_vars('LIBDIR', 'LIBPL'),
libraries=libs + py_libs,
extra_compile_args=filter_unsupported_flags(
compiler.compiler[0],
compiler.compiler[1:] + distutils.sysconfig.get_config_var('CFLAGS').split()),
extra_link_args=(distutils.sysconfig.get_config_var('LDFLAGS').split() +
ldflags))


def check_sanity():
"""
Test if development headers and library for rbd is available by compiling a dummy C program.
"""
CEPH_SRC_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'..',
'..'
)

tmp_dir = tempfile.mkdtemp(dir=os.environ.get('TMPDIR', os.path.dirname(__file__)))
tmp_file = os.path.join(tmp_dir, 'rbd_dummy.c')

with open(tmp_file, 'w') as fp:
dummy_prog = textwrap.dedent("""
#include <stddef.h>
#include <rbd/librbd.h>
int main(void) {
rados_t cluster;
rados_create(&cluster, NULL);
return 0;
}
""")
fp.write(dummy_prog)

compiler = new_compiler()
distutils.sysconfig.customize_compiler(compiler)

if 'CEPH_LIBDIR' in os.environ:
# The setup.py has been invoked by a top-level Ceph make.
# Set the appropriate CFLAGS and LDFLAGS
compiler.set_include_dirs([os.path.join(CEPH_SRC_DIR, 'include')])
compiler.set_library_dirs([os.environ.get('CEPH_LIBDIR')])
try:
compiler.define_macro('_FILE_OFFSET_BITS', '64')

link_objects = compiler.compile(
sources=[tmp_file],
output_dir=tmp_dir
)

compiler.link_executable(
objects=link_objects,
output_progname=os.path.join(tmp_dir, 'rbd_dummy'),
libraries=['rbd', 'rados'],
output_dir=tmp_dir,
)

except CompileError:
print('\nCompile Error: RBD development headers not found', file=sys.stderr)
return False
except LinkError:
print('\nLink Error: RBD library not found', file=sys.stderr)
return False
else:
return True
finally:
shutil.rmtree(tmp_dir)


if 'BUILD_DOC' in os.environ or 'READTHEDOCS' in os.environ:
ext_args = {}
cython_constants = dict(BUILD_DOC=True)
cythonize_args = dict(compile_time_env=cython_constants)
elif check_sanity():
ext_args = get_python_flags(['rados', 'rbd'])
cython_constants = dict(BUILD_DOC=False)
include_path = [os.path.join(os.path.dirname(__file__), "..", "rados")]
cythonize_args = dict(compile_time_env=cython_constants,
include_path=include_path)
else:
sys.exit(1)

cmdclass = {}
compiler_directives={'language_level': sys.version_info.major}
try:
from Cython.Build import cythonize
from Cython.Distutils import build_ext
from Cython import __version__ as cython_version

cmdclass = {'build_ext': build_ext}

# Needed for building with Cython 0.x and Cython 3 from the same file,
# preserving the same behavior.
# When Cython 0.x builds go away, replace this compiler directive with
# noexcept on rbd_callback_t and librbd_progress_fn_t (or consider doing
# something similar to except? -9000 on rbd_diff_iterate2() callback for
# progress callbacks to propagate exceptions).
if version.parse(cython_version) >= version.parse('3'):
compiler_directives['legacy_implicit_noexcept'] = True
except ImportError:
print("WARNING: Cython is not installed.")

if not os.path.isfile('rbd.c'):
print('ERROR: Cannot find Cythonized file rbd.c', file=sys.stderr)
sys.exit(1)
else:
def cythonize(x, **kwargs):
return x

source = "rbd.c"
else:
source = "rbd.pyx"

# Disable cythonification if we're not really building anything
if (len(sys.argv) >= 2 and
any(i in sys.argv[1:] for i in ('--help', 'clean', 'egg_info', '--version')
)):
def cythonize(x, **kwargs):
return x

setup(
name='rbd',
version=__version__,
description="Python bindings for the RBD library",
long_description=(
"This package contains Python bindings for interacting with the "
"RADOS Block Device (RBD) library. rbd is a utility for manipulating "
"rados block device images, used by the Linux rbd driver and the rbd "
"storage driver for QEMU/KVM. RBD images are simple block devices that "
"are striped over objects and stored in a RADOS object store. The size "
"of the objects the image is striped over must be a power of two."
),
url='https://github.com/ceph/ceph/tree/master/src/pybind/rbd',
license='LGPLv2+',
platforms='Linux',
ext_modules=cythonize(
[
Extension(
"rbd",
[source],
**ext_args
)
],
compiler_directives=compiler_directives,
build_dir=os.environ.get("CYTHON_BUILD_DIR", None),
**cythonize_args
),
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Cython',
'Programming Language :: Python :: 3'
],
cmdclass=cmdclass,
)
Loading