示例#1
0
 def __init__(self, accessor, context):
     """
     Read the db cluster:ceph_conf, cluster:ceph_conf_md5, and cluster:ceph_conf_luts. If the cluster_id
     cannot be obtained, or if these db fields are not yet populated, just return an empty string for the
     contents and the md5 and zero for the timestamp, but don't throw an exception. Since content is stripped
     before being written to the db, there's no need to strip content on the way out here.
     :param accessor: the cluster id accessor to use to access the correct row in the cluster table.
     :param context: the database access context - for rights.
     """
     ConfigInfo.__init__(self)
     cluster_id = accessor.get_cluster_id()
     if cluster_id:
         self._content = db.cluster_get_ceph_conf(context, cluster_id)
         dbmeta = db.cluster_get_ceph_conf_metadata(context, cluster_id)
         if 'ceph_conf_md5sum' in dbmeta:
             self._md5sum = dbmeta['ceph_conf_md5sum']
         if 'ceph_conf_luts' in dbmeta:
             self._luts = dbmeta['ceph_conf_luts']
 def __init__(self, accessor, context):
     """
     Read the db cluster:ceph_conf, cluster:ceph_conf_md5, and cluster:ceph_conf_luts. If the cluster_id
     cannot be obtained, or if these db fields are not yet populated, just return an empty string for the
     contents and the md5 and zero for the timestamp, but don't throw an exception. Since content is stripped
     before being written to the db, there's no need to strip content on the way out here.
     :param accessor: the cluster id accessor to use to access the correct row in the cluster table.
     :param context: the database access context - for rights.
     """
     ConfigInfo.__init__(self)
     cluster_id = accessor.get_cluster_id()
     if cluster_id:
         self._content = db.cluster_get_ceph_conf(context, cluster_id)
         dbmeta = db.cluster_get_ceph_conf_metadata(context, cluster_id)
         if 'ceph_conf_md5sum' in dbmeta:
             self._md5sum = dbmeta['ceph_conf_md5sum']
         if 'ceph_conf_luts' in dbmeta:
             self._luts = dbmeta['ceph_conf_luts']
示例#3
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)