Пример #1
0
    def add_ceph_mon_host(self):
        if settings.CEPH_ENABLED == True:
            # 判断是否启用ceph

            mon_db_dic = {}
            cc = ceph.Ceph()
            data = cc.mon_list()

            if data:
                for host_ip, v in data.items():
                    mon_db_dic[host_ip] = {}
                    host_id = asset_models.Host.objects.get(
                        ip_storage=host_ip).id
                    mon_db_dic[host_ip]['host_id'] = host_id
                    mon_db_dic[host_ip]['mon_id'] = v['id']
                # pdb.set_trace()
                for host, val in mon_db_dic.items():
                    print host,
                    print val
                    if not storage_models.CephMonitorStatus.objects.filter(
                      mon_id=val['mon_id']
                    ):
                        storage_models.CephMonitorStatus.objects.create(**val)

                        # 触发记录日志
                        hostname = asset_models.Host.objects.get(
                            id=val['host_id']).hostname
                        content = 'add ceph monitor %s , mon_id: %s' % (
                            hostname,
                            val['mon_id'])
                        event_osd.osd_info(hostname, content)
Пример #2
0
    def add_ceph_osd_host(self):
        print 'start add osd host'
        if settings.CEPH_ENABLED == True:
            cc = ceph.Ceph()
            data = cc.osd_list()
            # print data
            import pdb
            pdb.set_trace()
            for k, v in data.items():
                # print k
                # print v
                if not storage_models.CephOsdStatus.objects.filter(
                        osd_name=k):
                    storage_models.CephOsdStatus.objects.create(**v)

                    # 触发记录日志
                    hostname = \
                        asset_models.Host.objects.get(id=v['host_id']).hostname
                    content = '%s add osd: %s' % (hostname, k)
                    event_osd.osd_info(hostname, content)