raise
-def platform_distro():
- """
- Returns a normalized, lower case string without any leading nor trailing
- whitespace that represents the distribution name of the current machine.
- """
- distro = platform_information()[0] or ''
- return distro.strip().lower()
-
-
-def platform_information():
- if FREEBSD:
- distro = platform.system()
- release = platform.version().split()[1]
- codename = platform.version().split()[3]
- version = platform.version().split('-')[0][:-1]
- major_version = version.split('.')[0]
- major, minor = release.split('.')
- else:
- distro, release, codename = platform.linux_distribution()
- # this could be an empty string in Debian
- if not codename and 'debian' in distro.lower():
- debian_codenames = {
- '8': 'jessie',
- '7': 'wheezy',
- '6': 'squeeze',
- }
- major_version = release.split('.')[0]
- codename = debian_codenames.get(major_version, '')
-
- # In order to support newer jessie/sid, wheezy/sid strings we test
- # this if sid is buried in the minor, we should use sid anyway.
- if not codename and '/' in release:
- major, minor = release.split('/')
- if minor == 'sid':
- codename = minor
- else:
- codename = major
- # this could be an empty string in Virtuozzo linux
- if not codename and 'virtuozzo linux' in distro.lower():
- codename = 'virtuozzo'
-
- return (
- str(distro).strip(),
- str(release).strip(),
- str(codename).strip()
- )
-
#
# An alternative block_path implementation would be
#
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.fill(textwrap.dedent("""\
If the --bluestore argument is given, a bluestore objectstore
- will be used instead of the legacy filestore objectstore.
+ will be created. If --filestore is provided, a legacy FileStore
+ objectstore will be created. If neither is specified, we default
+ to BlueStore.
When an entire device is prepared for bluestore, two
partitions are created. The first partition is for metadata,
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument(
'--bluestore',
- action='store_true', default=None,
+ dest='bluestore',
+ action='store_true', default=True,
help='bluestore objectstore',
)
+ parser.add_argument(
+ '--filestore',
+ dest='bluestore',
+ action='store_false',
+ help='filestore objectstore',
+ )
return parser
@staticmethod
super(PrepareBluestoreBlockDB, self).__init__(args)
def get_space_size(self):
- block_size = get_conf(
+ block_db_size = get_conf(
cluster=self.args.cluster,
variable='bluestore_block_db_size',
)
- if block_size is None:
- return 20480 # MB, default value
+ if block_db_size is None or int(block_db_size) == 0:
+ block_size = get_conf(
+ cluster=self.args.cluster,
+ variable='bluestore_block_size',
+ )
+ if block_size is None:
+ return 1024 # MB
+ size = int(block_size) / 100 / 1048576
+ return max(size, 1024) # MB
else:
- return int(block_size) / 1048576 # MB
+ return int(block_db_size) / 1048576 # MB
def desired_partition_number(self):
if getattr(self.args, 'block.db') == self.args.data:
self.set_data_partition()
self.populate_data_path_device(*to_prepare_list)
+ def populate_data_path(self, path, *to_prepare_list):
+ super(PrepareFilestoreData, self).populate_data_path(path,
+ *to_prepare_list)
+ write_one_line(path, 'type', 'filestore')
+
class PrepareBluestoreData(PrepareData):
'--setgroup', get_ceph_group(),
],
)
- else:
+ elif osd_type == 'filestore':
ceph_osd_mkfs(
[
'ceph-osd',
'--setgroup', get_ceph_group(),
],
)
+ else:
+ raise Error('unrecognized objectstore type %s' % osd_type)
def auth_key(
elif os.path.exists(os.path.join(path, 'bsdrc')):
command_check_call(
[
- '/usr/local/etc/rc.d/ceph start osd.{osd_id}'
- .format(osd_id=osd_id),
+ '/usr/sbin/service', 'ceph', 'start',
+ 'osd.{osd_id}'.format(osd_id=osd_id),
],
)
else:
def main_fix(args):
# A hash table containing 'path': ('uid', 'gid', blocking, recursive)
fix_table = [
- ('/etc/ceph', 'ceph', 'ceph', True, True),
+ ('/usr/bin/ceph-mon', 'root', 'root', True, False),
+ ('/usr/bin/ceph-mds', 'root', 'root', True, False),
+ ('/usr/bin/ceph-osd', 'root', 'root', True, False),
+ ('/usr/bin/radosgw', 'root', 'root', True, False),
+ ('/etc/ceph', 'root', 'root', True, True),
('/var/run/ceph', 'ceph', 'ceph', True, True),
('/var/log/ceph', 'ceph', 'ceph', True, True),
+ ('/var/log/radosgw', 'ceph', 'ceph', True, True),
('/var/lib/ceph', 'ceph', 'ceph', True, False),
]
# Use find to relabel + chown ~simultaenously
if args.all:
for directory, uid, gid, blocking, recursive in fix_table:
+ # Skip directories/files that are not installed
+ if not os.access(directory, os.F_OK):
+ continue
+
c = [
'find',
directory,
# Fix permissions
if args.permissions:
for directory, uid, gid, blocking, recursive in fix_table:
+ # Skip directories/files that are not installed
+ if not os.access(directory, os.F_OK):
+ continue
+
if recursive:
c = [
'chown',
# Fix SELinux labels
if args.selinux:
for directory, uid, gid, blocking, recursive in fix_table:
+ # Skip directories/files that are not installed
+ if not os.access(directory, os.F_OK):
+ continue
+
if recursive:
c = [
'restorecon',
path = os.environ.get('PATH', os.defpath)
os.environ['PATH'] = args.prepend_to_path + ":" + path
- setup_statedir(args.statedir)
+ if args.func.__name__ != 'main_trigger':
+ # trigger may run when statedir is unavailable and does not use it
+ setup_statedir(args.statedir)
setup_sysconfdir(args.sysconfdir)
global CEPH_PREF_USER