Copyright: None
License: Public domain
+Files: src/ceph-volume/plugin/zfs/*
+Copyright: 2018, Willem Jan Withagen
+License: BSD 3-clause
+
include(Distutils)
distutils_install_module(ceph_volume
INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR})
+
+if(FREEBSD)
+ add_subdirectory(plugin/zfs)
+endif()
+
--- /dev/null
+
+distutils_install_module(ceph_volume_zfs
+ INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR})
--- /dev/null
+
+
+BSD License
+
+Copyright (c) 2018, Willem Jan Withagen
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
--- /dev/null
+include LICENSE
+
+recursive-include ceph_volume_zfs *
+recursive-exclude * __pycache__
+recursive-exclude * *.py[co]
+
+recursive-include *.rst conf.py Makefile *.jpg *.png *.gif
--- /dev/null
+# -*- coding: utf-8 -*-
+
+"""Top-level package for Ceph volume on ZFS."""
+
+__author__ = """Willem Jan Withagen"""
+__email__ = 'wjw@digiware.nl'
--- /dev/null
+"""
+Device API that can be shared among other implementations.
+"""
--- /dev/null
+# -*- coding: utf-8 -*-
+from . import zfs
--- /dev/null
+# -*- coding: utf-8 -*-
+from .main import ZFS
--- /dev/null
+import argparse
+from textwrap import dedent
+from ceph_volume import terminal
+
+
+class ZFS(object):
+
+ help = 'Use ZFS to deploy OSDs'
+
+ _help = dedent("""
+ Use ZFS to deploy OSDs
+
+ {sub_help}
+ """)
+
+ mapper = {
+ }
+
+ def __init__(self, argv):
+ self.argv = argv
+
+ def print_help(self, sub_help):
+ return self._help.format(sub_help=sub_help)
+
+ def main(self):
+ terminal.dispatch(self.mapper, self.argv)
+ parser = argparse.ArgumentParser(
+ prog='ceph-volume zfs',
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ description=self.print_help(terminal.subhelp(self.mapper)),
+ )
+ parser.parse_args(self.argv)
+ if len(self.argv) <= 1:
+ return parser.print_help()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+import argparse
+import os
+import sys
+import logging
+
+import main
+from ceph_volume import log, conf, configuration
+from ceph_volume import exceptions
+from ceph_volume import terminal
+
+if __name__ == '__main__':
+ main.ZFSVOL()
+
+
+class ZFSVOL(object):
+
+ help_menu = 'Deploy OSDs with ZFS'
+ _help = """
+Use ZFS as the underlying technology for OSDs
+
+--verbose Increase the verbosity level
+ """
+ name = 'zfs'
+
+ def __init__(self, argv=None, parse=True):
+ self.mapper = {
+ }
+ if argv is None:
+ self.argv = sys.argv
+ else:
+ self.argv = argv
+ if parse:
+ self.main(self.argv)
+
+ def help(self, warning=False):
+ if warning:
+ warning = 'See "ceph-volume zfs --help" for full list of options.'
+ else:
+ warning = ''
+ return self._help.format(
+ warning=warning,
+ log_path=conf.log_path,
+ ceph_path=self.stat_ceph_conf(),
+ sub_help=terminal.subhelp(self.mapper),
+ environ_vars=self.get_environ_vars()
+ )
+
+ def get_environ_vars(self):
+ environ_vars = []
+ for key, value in os.environ.items():
+ if key.startswith('CEPH_'):
+ environ_vars.append("%s=%s" % (key, value))
+ if not environ_vars:
+ return ''
+ else:
+ environ_vars.insert(0, '\nEnviron Variables:')
+ return '\n'.join(environ_vars)
+
+ def load_ceph_conf_path(self, cluster_name='ceph'):
+ abspath = '/etc/ceph/%s.conf' % cluster_name
+ conf.path = os.getenv('CEPH_CONF', abspath)
+ conf.cluster = cluster_name
+
+ def stat_ceph_conf(self):
+ try:
+ configuration.load(conf.path)
+ return terminal.green(conf.path)
+ except exceptions.ConfigurationError as error:
+ return terminal.red(error)
+
+ def load_log_path(self):
+ conf.log_path = os.getenv('CEPH_VOLUME_LOG_PATH', '/var/log/ceph')
+
+ def _get_split_args(self):
+ subcommands = self.mapper.keys()
+ slice_on_index = len(self.argv) + 1
+ pruned_args = self.argv[1:]
+ for count, arg in enumerate(pruned_args):
+ if arg in subcommands:
+ slice_on_index = count
+ break
+ return pruned_args[:slice_on_index], pruned_args[slice_on_index:]
+
+ def main(self, argv):
+ self.load_ceph_conf_path()
+ # these need to be available for the help, which gets parsed super
+ # early
+ self.load_ceph_conf_path()
+ self.load_log_path()
+ main_args, subcommand_args = self._get_split_args()
+ # no flags where passed in, return the help menu instead of waiting for
+ # argparse which will end up complaning that there are no args
+ if len(argv) <= 1:
+ print(self.help(warning=True))
+ return
+ parser = argparse.ArgumentParser(
+ prog='ceph-volume-zfs',
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ description=self.help(),
+ )
+ parser.add_argument(
+ '--cluster',
+ default='ceph',
+ help='Cluster name (defaults to "ceph")',
+ )
+ parser.add_argument(
+ '--log-level',
+ default='debug',
+ help='Change the file log level (defaults to debug)',
+ )
+ parser.add_argument(
+ '--log-path',
+ default='/var/log/ceph/',
+ help='Change the log path (defaults to /var/log/ceph)',
+ )
+ args = parser.parse_args(main_args)
+ conf.log_path = args.log_path
+ if os.path.isdir(conf.log_path):
+ conf.log_path = os.path.join(args.log_path, 'ceph-volume-zfs.log')
+ log.setup()
+ logger = logging.getLogger(__name__)
+ logger.info("Running command: ceph-volume-zfs %s %s",
+ " ".join(main_args), " ".join(subcommand_args))
+ # set all variables from args and load everything needed according to
+ # them
+ self.load_ceph_conf_path(cluster_name=args.cluster)
+ try:
+ conf.ceph = configuration.load(conf.path)
+ except exceptions.ConfigurationError as error:
+ # we warn only here, because it is possible that the configuration
+ # file is not needed, or that it will be loaded by some other means
+ # (like reading from zfs tags)
+ logger.exception('ignoring inability to load ceph.conf')
+ terminal.red(error)
+ # dispatch to sub-commands
+ terminal.dispatch(self.mapper, subcommand_args)
--- /dev/null
+# -*- coding: utf-8 -*-
--- /dev/null
+pip==9.0.1
+wheel==0.30.0
+flake8==3.5.0
+tox==2.9.1
+coverage==4.5.1
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""The setup script."""
+
+from setuptools import setup, find_packages
+
+requirements = [ ]
+
+setup_requirements = [ ]
+
+setup(
+ author="Willem Jan Withagen",
+ author_email='wjw@digiware.nl',
+ classifiers=[
+ 'Development Status :: 2 - Pre-Alpha',
+ 'Environment :: Console',
+ 'Intended Audience :: Information Technology',
+ 'Intended Audience :: System Administrators',
+ 'Operating System :: POSIX :: FreeBSD',
+ 'License :: OSI Approved :: BSD License',
+ 'Natural Language :: English',
+ "Programming Language :: Python :: 2",
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ ],
+ description="Manage Ceph OSDs on ZFS pool/volume/filesystem",
+ install_requires=requirements,
+ license="BSD license",
+ include_package_data=True,
+ keywords='ceph-volume-zfs',
+ name='ceph-volume-zfs',
+ packages=find_packages(include=['ceph_volume_zfs']),
+ scripts=['bin/ceph-volume-zfs'],
+ setup_requires=setup_requirements,
+ url='https://github.com/ceph/ceph/src/ceph-volume/plugin/zfs',
+ version='0.1.0',
+ zip_safe=False,
+ entry_points = dict(
+ ceph_volume_handlers = [
+ 'zfs = ceph_volume_zfs.main:ZFSVOL',
+ ],
+ ),
+)
--- /dev/null
+[tox]
+envlist = py27, py34, py35, py36, flake8
+
+[travis]
+python =
+ 3.6: py36
+ 3.5: py35
+ 3.4: py34
+ 2.7: py27
+
+[testenv:flake8]
+basepython = python
+deps = flake8
+commands = flake8
+
+[testenv]
+setenv =
+ PYTHONPATH = {toxinidir}
+
+commands = python setup.py test
+