def add_osd_header(self,
                       journal_size=0,
                       osd_type='xfs',osd_heartbeat_interval=10,osd_heartbeat_grace=10):
        if self._parser.has_section('osd'):
            return

        self._parser.add_section('osd')
        # NOTE Do not add osd data here.
        self._parser.set('osd', 'osd journal size', str(journal_size))
        self._parser.set('osd', 'filestore xattr use omap', 'true')
        osd_data = "/var/lib/ceph/osd/osd$id"
        self._parser.set('osd', 'osd data', osd_data)
        # NOTE add keyring to support lower version of OSD.
        # keyring = /etc/ceph/keyring.$name
        self._parser.set('osd', 'keyring', '/etc/ceph/keyring.$name')
        self._parser.set('osd', 'osd heartbeat interval', str(osd_heartbeat_interval))
        self._parser.set('osd', 'osd heartbeat grace', str(osd_heartbeat_grace))
        self._parser.set('osd', 'osd mkfs type', osd_type)
        mount_option = utils.get_fs_options(osd_type)[1]
        self._parser.set('osd', 'osd mount options %s' % osd_type, mount_option)

        # Below is very important for set file system.
        # Do not change any of them.
        format_type = '-f'
        if osd_type.lower() == 'ext4':
            format_type = '-F'
        self._parser.set('osd', 'osd mkfs options %s' % osd_type, format_type)
Exemplo n.º 2
0
    def add_osd_header(self,
                       journal_size=0,
                       osd_type='xfs',
                       osd_heartbeat_interval=10,
                       osd_heartbeat_grace=10):
        if self._parser.has_section('osd'):
            return

        self._parser.add_section('osd')
        # NOTE Do not add osd data here.
        self._parser.set('osd', 'osd journal size', str(journal_size))
        self._parser.set('osd', 'filestore xattr use omap', 'true')
        osd_data = "/var/lib/ceph/osd/osd$id"
        self._parser.set('osd', 'osd data', osd_data)
        # NOTE add keyring to support lower version of OSD.
        # keyring = /etc/ceph/keyring.$name
        self._parser.set('osd', 'keyring', '/etc/ceph/keyring.$name')
        self._parser.set('osd', 'osd heartbeat interval',
                         str(osd_heartbeat_interval))
        self._parser.set('osd', 'osd heartbeat grace',
                         str(osd_heartbeat_grace))
        self._parser.set('osd', 'osd mkfs type', osd_type)
        mount_option = utils.get_fs_options(osd_type)[1]
        self._parser.set('osd', 'osd mount options %s' % osd_type,
                         mount_option)

        # Below is very important for set file system.
        # Do not change any of them.
        format_type = '-f'
        if osd_type.lower() == 'ext4':
            format_type = '-F'
        self._parser.set('osd', 'osd mkfs options %s' % osd_type, format_type)
    def add_osd_header(self, dict_kvs={}):
        if self._parser.has_section('osd'):
            return
        dict_kvs['journal_size'] = dict_kvs.get('journal_size',0)
        dict_kvs['osd_type'] = dict_kvs.get('osd_type','xfs')
        dict_kvs['osd_heartbeat_interval'] = dict_kvs.get('osd_heartbeat_interval',10)
        dict_kvs['osd_heartbeat_grace'] = dict_kvs.get('osd_heartbeat_grace',10)
        self._parser.add_section('osd')
        # NOTE Do not add osd data here.
        self._parser.set('osd', 'osd journal size', str(dict_kvs['journal_size']))
        self._parser.set('osd', 'filestore xattr use omap', 'true')
        self._parser.set('osd', 'osd crush update on start', 'false' )
        osd_data = "/var/lib/ceph/osd/osd$id"
        self._parser.set('osd', 'osd data', osd_data)
        # NOTE add keyring to support lower version of OSD.
        # keyring = /etc/ceph/keyring.$name
        self._parser.set('osd', 'keyring', '/etc/ceph/keyring.$name')
        self._parser.set('osd', 'osd heartbeat interval', str(dict_kvs['osd_heartbeat_interval']))
        self._parser.set('osd', 'osd heartbeat grace', str(dict_kvs['osd_heartbeat_grace']))
        self._parser.set('osd', 'osd mkfs type', dict_kvs['osd_type'])
        cluster = db.cluster_get_all(self.context)[0]
        mount_option = cluster['mount_option']
        if not mount_option:
            mount_option = utils.get_fs_options(dict_kvs['osd_type'])[1]
        self._parser.set('osd', 'osd mount options %s' % dict_kvs['osd_type'], mount_option)

        # Below is very important for set file system.
        # Do not change any of them.
        format_type = '-f'
        if dict_kvs['osd_type'].lower() == 'ext4':
            format_type = '-F'
        self._parser.set('osd', 'osd mkfs options %s' % dict_kvs['osd_type'], format_type)
        for key,value in dict_kvs.items():
            if key not in ['journal_size','osd_type','osd_heartbeat_interval','osd_heartbeat_grace']:
                self._parser.set('osd', key.replace("_",' '), str(value))
Exemplo n.º 4
0
    def add_osd_header(self, dict_kvs={}):
        if self._parser.has_section('osd'):
            return
        dict_kvs['journal_size'] = dict_kvs.get('journal_size', 0)
        dict_kvs['osd_type'] = dict_kvs.get('osd_type', 'xfs')
        dict_kvs['osd_heartbeat_interval'] = dict_kvs.get(
            'osd_heartbeat_interval', 10)
        dict_kvs['osd_heartbeat_grace'] = dict_kvs.get('osd_heartbeat_grace',
                                                       10)

        section = 'osd'
        if not self._parser.has_section(section):
            self._parser.add_section(section)
        # NOTE Do not add osd data here.
        self._parser.set(section, 'osd journal size',
                         str(dict_kvs['journal_size']))
        self._parser.set(section, 'filestore xattr use omap', 'true')
        self._parser.set(section, 'osd crush update on start', 'false')
        osd_data = "/var/lib/ceph/osd/osd$id"
        self._parser.set(section, 'osd data', osd_data)
        # NOTE add keyring to support lower version of OSD.
        # keyring = /etc/ceph/keyring.$name
        self._parser.set(section, 'keyring', '/etc/ceph/keyring.$name')
        self._parser.set(section, 'osd heartbeat interval',
                         str(dict_kvs['osd_heartbeat_interval']))
        self._parser.set(section, 'osd heartbeat grace',
                         str(dict_kvs['osd_heartbeat_grace']))
        self._parser.set(section, 'osd mkfs type', dict_kvs['osd_type'])
        cluster = db.cluster_get_all(self._context)[0]
        mount_option = cluster['mount_option']
        if not mount_option:
            mount_option = utils.get_fs_options(dict_kvs['osd_type'])[1]
        self._parser.set(section,
                         'osd mount options %s' % dict_kvs['osd_type'],
                         mount_option)

        # Below is very important for set file system.
        # Do not change any of them.
        format_type = '-f'
        if dict_kvs['osd_type'].lower() == 'ext4':
            format_type = '-F'
        self._parser.set(section, 'osd mkfs options %s' % dict_kvs['osd_type'],
                         format_type)
        for key, value in dict_kvs.items():
            if key not in [
                    'journal_size', 'osd_type', 'osd_heartbeat_interval',
                    'osd_heartbeat_grace'
            ]:
                self._parser.set(section, key, str(value))
Exemplo n.º 5
0
    def _load_ceph_conf_from_db(self):
        if not self.cluster_id:
            if not self._get_cluster_id():
                LOG.debug('Can not get cluster_id')
                return

        ceph_conf = db.cluster_get_ceph_conf(self.context, self.cluster_id)

        if not ceph_conf:
            return

        utils.write_file_as_root(FLAGS.ceph_conf, ceph_conf, 'w')

        # We try to update fstab here.
        utils.execute('sed',
                      '-i',
                      '/forvsmosd/d',
                      '/etc/fstab',
                      run_as_root=True)

        parser = Parser()
        parser.read(FLAGS.ceph_conf)
        fs_type = parser.get('osd', 'osd mkfs type', 'xfs')
        cluster = db.cluster_get_all(self.context)[0]
        mount_option = cluster['mount_option']
        if not mount_option:
            mount_option = utils.get_fs_options(fs_type)[1]
        mount_attr = parser.get('osd', 'osd mount options %s' % fs_type,
                                mount_option)

        for sec in parser.sections():
            if sec.find('osd.') != -1:
                osd_id = sec.split('.')[1]
                mount_path = os.path.join(FLAGS.osd_data_path,
                                          "osd%s" % osd_id)
                mount_disk = parser.get(sec, 'devs')
                mount_host = parser.get(sec, 'host')
                if FLAGS.host == mount_host:
                    line = mount_disk + ' ' + mount_path
                    line = line + ' ' + fs_type
                    line = line + ' ' + mount_attr + ' 0 0'
                    line = line + ' ' + '## forvsmosd'
                    utils.write_file_as_root('/etc/fstab', line)
    def _load_ceph_conf_from_db(self):
        if not self.cluster_id:
            if not self._get_cluster_id():
                LOG.debug('Can not get cluster_id')
                return

        ceph_conf = db.cluster_get_ceph_conf(self.context,
                                             self.cluster_id)

        if not ceph_conf:
            return

        utils.write_file_as_root(FLAGS.ceph_conf, ceph_conf, 'w')

        # We try to update fstab here.
        utils.execute('sed',
                      '-i',
                      '/forvsmosd/d',
                      '/etc/fstab',
                      run_as_root=True)

        parser = Parser()
        parser.read(FLAGS.ceph_conf)
        fs_type = parser.get('osd', 'osd mkfs type', 'xfs')
        cluster = db.cluster_get_all(self.context)[0]
        mount_option = cluster['mount_option']
        if not mount_option:
            mount_option = utils.get_fs_options(fs_type)[1]
        mount_attr = parser.get('osd', 'osd mount options %s' % fs_type, mount_option)

        for sec in parser.sections():
            if sec.find('osd.') != -1:
                osd_id = sec.split('.')[1]
                mount_path = os.path.join(FLAGS.osd_data_path, "osd%s" % osd_id)
                mount_disk = parser.get(sec, 'devs')
                mount_host = parser.get(sec, 'host')
                if FLAGS.host == mount_host:
                    line = mount_disk + ' ' + mount_path
                    line = line + ' ' + fs_type
                    line = line + ' ' + mount_attr + ' 0 0'
                    line = line + ' ' + '## forvsmosd'
                    utils.write_file_as_root('/etc/fstab', line)
    def add_osd_header(self,
                       journal_size=0,
                       osd_type='xfs'):
        if self._parser.has_section('osd'):
            return

        self._parser.add_section('osd')
        # NOTE Do not add osd data here.
        self._parser.set('osd', 'osd journal size', str(journal_size))
        self._parser.set('osd', 'filestore xattr use omap', 'true')
        # NOTE Do not add keyring here.
        self._parser.set('osd', 'osd mkfs type', osd_type)
        mount_option = utils.get_fs_options(osd_type)[1]
        self._parser.set('osd', 'osd mount options %s' % osd_type, mount_option)

        # Below is very important for set file system.
        # Do not change any of them.
        format_type = '-f'
        if osd_type.lower() == 'ext4':
            format_type = '-F'
        self._parser.set('osd', 'osd mkfs options %s' % osd_type, format_type)