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'] 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))
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))
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 cluster_get_all(self, context): return db.cluster_get_all(context)
def create_storage_pool(self, context, body): #TO BE DONE body['cluster_id'] = db.cluster_get_all(context)[0]['id']#1 res = db.pool_create(context, body) return res
def create_storage_pool(self, context, body): #TO BE DONE body['cluster_id'] = db.cluster_get_all(context)[0]['id'] #1 res = db.pool_create(context, body) return res
class Main(object): def __init__(self): self.conductor_api = conductor.API() def main(self, context): storage_groups = map(lambda sg: sg['name'], self.conductor_api.storage_group_get_all(context)) storage_groups = list(set(storage_groups)) #LOG.info("storage_groups is: %s " % storage_groups) zones = map(lambda zone: zone['name'], self.conductor_api.zone_get_all(context)) zones = list(set(zones)) node_info = self.conductor_api.ceph_node_info(context, 1) print storage_groups print zones pprint.pprint(node_info) if __name__ == '__main__': flags.parse_args(sys.argv) _context = context.get_admin_context() nodes = db.cluster_get_all(_context) print nodes Main().main(_context)