X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fnbi%2Fhttpgetter.go;h=be2577c757fab293f65c4221edd71ad84bcb18fa;hb=cb93dbf2fac19dd49332847327b364be27d8bb71;hp=33db0f890226dee0c79749eb0455fcb5b651125a;hpb=92162653c9741f2417d1a36ec1c211d6863d0a68;p=ric-plt%2Frtmgr.git diff --git a/pkg/nbi/httpgetter.go b/pkg/nbi/httpgetter.go index 33db0f8..be2577c 100644 --- a/pkg/nbi/httpgetter.go +++ b/pkg/nbi/httpgetter.go @@ -14,12 +14,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + + This source code is part of the near-RT RIC (RAN Intelligent Controller) + platform project (RICP). + ================================================================================== */ /* Mnemonic: httpgetter.go Abstract: HTTPgetter NBI implementation - Simple HTTP getter solution. Only for testing purpose. + Simple HTTP getter solution. Date: 15 March 2019 */ @@ -27,28 +32,30 @@ package nbi import ( "encoding/json" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" "net/http" - "routing-manager/pkg/rtmgr" "routing-manager/pkg/rpe" + "routing-manager/pkg/rtmgr" "routing-manager/pkg/sdl" "time" + "sync" ) type HttpGetter struct { - NbiEngine - FetchAllXapps FetchAllXappsHandler + Engine + FetchAllXApps FetchAllXAppsHandler } func NewHttpGetter() *HttpGetter { instance := new(HttpGetter) - instance.FetchAllXapps = fetchAllXapps + instance.FetchAllXApps = fetchAllXApps return instance } var myClient = &http.Client{Timeout: 5 * time.Second} -func fetchAllXapps(xmurl string) (*[]rtmgr.XApp, error) { - rtmgr.Logger.Info("Invoked httpgetter.fetchXappList: " + xmurl) +func fetchAllXApps(xmurl string) (*[]rtmgr.XApp, error) { + xapp.Logger.Info("Invoked httpGetter.fetchXappList: " + xmurl) r, err := myClient.Get(xmurl) if err != nil { return nil, err @@ -56,22 +63,22 @@ func fetchAllXapps(xmurl string) (*[]rtmgr.XApp, error) { defer r.Body.Close() if r.StatusCode == 200 { - rtmgr.Logger.Debug("http client raw response: %v", r) - var xapps []rtmgr.XApp - err = json.NewDecoder(r.Body).Decode(&xapps) + xapp.Logger.Debug("http client raw response: %v", r) + var xApps []rtmgr.XApp + err = json.NewDecoder(r.Body).Decode(&xApps) if err != nil { - rtmgr.Logger.Warn("Json decode failed: " + err.Error()) + xapp.Logger.Warn("Json decode failed: " + err.Error()) } - rtmgr.Logger.Info("HTTP GET: OK") - rtmgr.Logger.Debug("httpgetter.fetchXappList returns: %v", xapps) - return &xapps, err + xapp.Logger.Info("HTTP GET: OK") + xapp.Logger.Debug("httpGetter.fetchXappList returns: %v", xApps) + return &xApps, err } - rtmgr.Logger.Warn("httpgetter got an unexpected http status code: %v", r.StatusCode) + xapp.Logger.Warn("httpGetter got an unexpected http status code: %v", r.StatusCode) return nil, nil } -func (g *HttpGetter) Initialize(xmurl string, nbiif string, fileName string, configfile string, - sdlEngine sdl.SdlEngine, rpeEngine rpe.RpeEngine, triggerSBI chan<- bool) error { +func (g *HttpGetter) Initialize(xmurl string, nbiif string, fileName string, configfile string, e2murl string, + sdlEngine sdl.Engine, rpeEngine rpe.Engine, triggerSBI chan<- bool, m *sync.Mutex) error { return nil }