-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ceph-volume: zfs, the inital first submit.
Does nothing other than invoce the ceph-volume-zfs modules when called with 'ceph-volume zfs Like: > ceph-volume zfs list Use ZFS as the underlying technology for OSDs --verbose Increase the verbosity level ['list'] --> TypeError: main() takes exactly 2 arguments (1 given) Exit 1 Signed-off-by: Willem Jan Withagen <[email protected]>
- Loading branch information
1 parent
9e9f3ea
commit d37d8e2
Showing
15 changed files
with
311 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
distutils_install_module(ceph_volume_zfs | ||
INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include LICENSE | ||
|
||
recursive-include ceph_volume_zfs * | ||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[co] | ||
|
||
recursive-include *.rst conf.py Makefile *.jpg *.png *.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Top-level package for Ceph volume on ZFS.""" | ||
|
||
__author__ = """Willem Jan Withagen""" | ||
__email__ = '[email protected]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Device API that can be shared among other implementations. | ||
""" |
2 changes: 2 additions & 0 deletions
2
src/ceph-volume/plugin/zfs/ceph_volume_zfs/devices/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import zfs |
2 changes: 2 additions & 0 deletions
2
src/ceph-volume/plugin/zfs/ceph_volume_zfs/devices/zfs/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from .main import ZFS |
34 changes: 34 additions & 0 deletions
34
src/ceph-volume/plugin/zfs/ceph_volume_zfs/devices/zfs/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# -*- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pip==9.0.1 | ||
wheel==0.30.0 | ||
flake8==3.5.0 | ||
tox==2.9.1 | ||
coverage==4.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/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='[email protected]', | ||
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', | ||
], | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[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 | ||
|