def get_list(args): '''获取ceph资源池列表''' ret_list = [] storage_api = CephStorageAPI() center_api = CenterAPI() if not center_api.center_id_exists(args['center_id']): return {'res': False, 'err': ERR_CENTER_ID} center = center_api.get_center_by_id(args['center_id']) try: if not center.managed_by(args['req_user']): return {'res': False, 'err': ERR_AUTH_PERM} pool_list = storage_api.get_pool_list_by_center_id(args['center_id']) except Exception as e: print(e) raise e for pool in pool_list: ret_list.append({ 'id': pool.id, 'pool': pool.pool, 'type': pool.type, 'center_id': pool.center_id, 'host': pool.host, 'port': pool.port, 'uuid': pool.uuid }) return {'res': True, 'list': ret_list}
def get_list(args=None): '''获取分中心列表''' api = CenterAPI() center_list = api.get_center_list_in_perm(args['req_user']) ret_list = [] for center in center_list: ret_list.append({ 'id': center.id, 'name': center.name, 'location': center.location, 'desc': center.desc, 'order': center.order}) return {'res': True, 'list': ret_list}
def get_list(args=None): '''获取分中心列表''' api = CenterAPI() center_list = api.get_center_list_in_perm(args['req_user']) ret_list = [] for center in center_list: ret_list.append({ 'id': center.id, 'name': center.name, 'location': center.location, 'desc': center.desc, 'order': center.order }) return {'res': True, 'list': ret_list}
def _get_pool_list_by_group_id(args): '''获取指定计算集群(group)可使用的ceph资源池列表,即根据group可用的quota进行筛选''' ret_list = [] storage_api = StorageAPI() center_api = CenterAPI() volume_api = VolumeAPI() group_id = 'group_id' in args and args['group_id'] print(group_id) group = GroupAPI().get_group_by_id(group_id) if not group.managed_by(args['req_user']): return {'res': False, 'err': ERR_AUTH_PERM} quota_list = volume_api.quota.get_quota_list_by_group_id(group_id=group_id) print(quota_list) pool_list = [] for q in quota_list: if not q['cephpool_id']: continue try: pool = storage_api.get_pool_by_id(q['cephpool_id']) pool_list.append(pool) except Exception as e: print(e) for pool in pool_list: ret_list.append({ 'id': pool.id, 'pool': pool.pool, 'type': pool.type, 'center_id': pool.center_id, 'host': pool.host, 'port': pool.port, 'uuid': pool.uuid }) return {'res': True, 'list': ret_list}
#coding=utf-8 import logging from compute.api import CenterAPI, GroupAPI, VmAPI, HostAPI from compute.vm.vm import VIR_DOMAIN_HOST_DOWN from device.api import GPUAPI from volume.api import VolumeAPI from api.error import Error from api.error import ERROR_CN from .api import MonitoringAPI api = MonitoringAPI() center_api = CenterAPI() group_api = GroupAPI() vm_api = VmAPI() host_api = HostAPI() gpuapi = GPUAPI() volumeapi = VolumeAPI() def run_ha_monitoring(): """ 虚拟机高可用定时监控 lzx: 2018-09-25 """ global center_api, group_api, vm_api, gpuapi, volumeapi group_list = group_api.get_group_list()