def summary(self, req, cluster_id=None): LOG.info('vsm-summary.') context = req.environ['vsm.context'] #TODO: as we have only one cluster for now, the cluster_id #has been hardcoded. In furture, client should pass # the cluster id by url. try: if cluster_id: vsm_sum = db.summary_get_by_cluster_id_and_type( context, cluster_id, 'vsm') else: vsm_sum = db.summary_get_by_type_first(context, 'vsm') #vsm_sum = db.summary_get_by_cluster_id_and_type(context, 1, 'vsm') except exception.SummaryNotFound: vsm_sum = None try: if cluster_id: ceph_sum = db.summary_get_by_cluster_id_and_type( context, cluster_id, 'ceph') else: ceph_sum = db.summary_get_by_type_first(context, 'ceph') #ceph_sum = db.summary_get_by_cluster_id_and_type(context, 1, 'ceph') except exception.SummaryNotFound: ceph_sum = None get_data = lambda x: x['summary_data'] if x else None sum = None vsm_data = get_data(vsm_sum) ceph_data = get_data(ceph_sum) if vsm_data: sum = json.loads(vsm_data) if ceph_data: sum.update(json.loads(ceph_data)) else: sum['is_ceph_active'] = True elif ceph_data: sum = json.loads(ceph_data) if not vsm_data: sum['uptime'] = None if sum: try: sum['created_at'] = vsm_sum['created_at'].strftime( "%Y-%m-%d %H:%M:%S") sum_data = {'summary_data': json.dumps(sum)} except: pass else: sum_data = None LOG.info('vsm sum: %s' % sum_data) return sum_views.ViewBuilder().basic(sum_data, 'vsm')
def summary(self, req, cluster_id = None): LOG.info('vsm-summary.') context = req.environ['vsm.context'] #TODO: as we have only one cluster for now, the cluster_id #has been hardcoded. In furture, client should pass # the cluster id by url. try: if cluster_id: vsm_sum = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'vsm') else: vsm_sum = db.summary_get_by_type_first(context, 'vsm') #vsm_sum = db.summary_get_by_cluster_id_and_type(context, 1, 'vsm') except exception.SummaryNotFound: vsm_sum = None try: if cluster_id: ceph_sum = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'ceph') else: ceph_sum = db.summary_get_by_type_first(context, 'ceph') #ceph_sum = db.summary_get_by_cluster_id_and_type(context, 1, 'ceph') except exception.SummaryNotFound: ceph_sum = None get_data = lambda x: x['summary_data'] if x else None sum = None vsm_data = get_data(vsm_sum) ceph_data = get_data(ceph_sum) if vsm_data: sum = json.loads(vsm_data) if ceph_data: sum.update(json.loads(ceph_data)) else: sum['is_ceph_active'] = True elif ceph_data: sum = json.loads(ceph_data) if not vsm_data: sum['uptime'] = None try: sum['created_at'] = vsm_sum['created_at'].strftime("%Y-%m-%d %H:%M:%S") except: pass #str, error = utils.execute('rpm', '-qa', 'vsm') #version = str.strip() #sum['version'] = version[4:-11] sum_data = { 'summary_data': json.dumps(sum) } LOG.info('vsm sum: %s' % sum_data) return sum_views.ViewBuilder().basic(sum_data, 'vsm')
def summary(self, req, cluster_id=None): LOG.info('mon-summary.') context = req.environ['vsm.context'] if cluster_id: sum = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'mon') else: sum = db.summary_get_by_type_first(context, 'mon') #sum = db.summary_get_by_cluster_id_and_type(context, 1, 'mon') return sum_views.ViewBuilder().basic(sum, 'monitor')
def summary(self, req, body=None,cluster_id=None): LOG.info('CEPH_LOG mds-summary body %s ' % body) context = req.environ['vsm.context'] if cluster_id: mds = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'mds') else: mds = db.summary_get_by_type_first(context, 'mds') vb = summary_view.ViewBuilder() return vb.basic(mds, 'mds')
def summary(self, req, body = None, cluster_id = None): LOG.info('CEPH_LOG placement_group-summary body %s ' % body) context = req.environ['vsm.context'] if cluster_id: sum = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'pg') else: sum = db.summary_get_by_type_first(context, 'pg') #sum = db.summary_get_by_cluster_id_and_type(context, 1, 'pg') vb = summary_view.ViewBuilder() return vb.basic(sum, 'placement_group')
def summary(self, req, cluster_id = None): #LOG.info('osd-summary body %s ' % body) context = req.environ['vsm.context'] if cluster_id: sum = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'osd') else: sum = db.summary_get_by_type_first(context, 'osd') #sum = db.summary_get_by_cluster_id_and_type(context, 1, 'osd') vb = summary_view.ViewBuilder() return vb.basic(sum, 'osd')
def summary(self, req,cluster_id=None): #LOG.info('osd-summary body %s ' % body) context = req.environ['vsm.context'] #TODO: as we have only one cluster for now, the cluster_id #has been hardcoded. In furture, client should pass # the cluster id by url. if cluster_id: sum = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'cluster') else: sum = db.summary_get_by_type_first(context, 'cluster') vb = summary_view.ViewBuilder() return vb.basic(sum, 'cluster')
def _set_error(self, context, cluster_id = None): if cluster_id: summary = db.summary_get_by_cluster_id_and_type(context, cluster_id, 'cluster') else: summary = db.summary_get_by_type_first(context, 'cluster') #summary = db.summary_get_by_cluster_id_and_type(context, 1, 'cluster') if summary: sum_data = json.loads(summary['summary_data']) h_list = sum_data.get('health_list') if len(h_list) > 0: if h_list[0].find('ERROR') != -1: return h_list[0] return None