2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
4 // Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
18 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 // platform project (RICP).
27 "e2mgr/providers/httpmsghandlerprovider"
32 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
35 type ISymptomdataController interface {
36 GetSymptomData(writer http.ResponseWriter, r *http.Request)
39 type SymptomdataController struct {
41 handlerProvider *httpmsghandlerprovider.IncomingRequestHandlerProvider
42 rNibDataService services.RNibDataService
43 ranListManager managers.RanListManager
46 func NewSymptomdataController(l *logger.Logger, hp *httpmsghandlerprovider.IncomingRequestHandlerProvider, rnib services.RNibDataService, rl managers.RanListManager) *SymptomdataController {
47 return &SymptomdataController{
50 rNibDataService: rnib,
55 func (s *SymptomdataController) GetSymptomData(w http.ResponseWriter, r *http.Request) {
56 e2TList := s.handleRequest(httpmsghandlerprovider.GetE2TInstancesRequest)
57 nodeBList := s.ranListManager.GetNbIdentityList()
59 s.logger.Infof("nodeBList=%+v, e2TList=%+v", nodeBList, e2TList)
61 var NodebInfoList []entities.NodebInfo
62 for _, v := range nodeBList {
63 if n, err := s.rNibDataService.GetNodeb(v.InventoryName); err == nil {
64 NodebInfoList = append(NodebInfoList, *n)
67 s.logger.Infof("NodebInfoList=%+v", NodebInfoList)
69 symptomdata := struct {
70 E2TList models.IResponse `json:"e2TList"`
71 NodeBList []*entities.NbIdentity `json:"nodeBList"`
72 NodebInfoList []entities.NodebInfo `json:"nodeBInfo"`
79 w.Header().Set("Content-Type", "application/json")
80 w.Header().Set("Content-Disposition", "attachment; filename=platform/e2_info.json")
81 w.WriteHeader(http.StatusOK)
82 resp, _ := json.MarshalIndent(symptomdata, "", " ")
86 func (s *SymptomdataController) handleRequest(requestName httpmsghandlerprovider.IncomingRequest) models.IResponse {
87 handler, err := s.handlerProvider.GetHandler(requestName)
92 resp, err := handler.Handle(nil)