[VOL-3880] Correctly reporting software image status in OMCI Get
[VOL-3900] OMCI ONU Software Image Download

Change-Id: I8d91be832f3a89404d0af0dd98e6b53359e6a738
diff --git a/internal/bbsim/responders/webserver/webserver.go b/internal/bbsim/responders/webserver/webserver.go
new file mode 100644
index 0000000..2c5d29b
--- /dev/null
+++ b/internal/bbsim/responders/webserver/webserver.go
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+
+package webserver
+
+import (
+	"github.com/gorilla/mux"
+	"github.com/opencord/bbsim/internal/bbsim/devices"
+	"github.com/opencord/bbsim/internal/bbsim/responders/sadis"
+	"github.com/opencord/bbsim/internal/common"
+	log "github.com/sirupsen/logrus"
+	"net/http"
+	"sync"
+)
+
+var logger = log.WithFields(log.Fields{
+	"module": "WEBSERVER",
+})
+
+// StartRestServer starts REST server which esposes:
+// - a SADIS configuration for the currently simulated OLT
+// - static files for software image download
+func StartRestServer(olt *devices.OltDevice, wg *sync.WaitGroup) {
+	addr := common.Config.BBSim.SadisRestAddress
+	logger.Infof("WEBSERVER server listening on %s", addr)
+	s := &sadis.SadisServer{
+		Olt: olt,
+	}
+
+	router := mux.NewRouter().StrictSlash(true)
+
+	// sadis routes
+	router.HandleFunc("/{version}/cfg", s.ServeBaseConfig)
+	router.HandleFunc("/{version}/static", s.ServeStaticConfig)
+	router.HandleFunc("/{version}/subscribers/{ID}", s.ServeEntry)
+	router.HandleFunc("/{version}/bandwidthprofiles/{ID}", s.ServeBWPEntry)
+
+	// Choose the folder to serve (this is the location inside the container)
+	staticDir := "/app/configs/"
+
+	// Create the route
+	router.
+		PathPrefix("/images/").
+		Handler(http.StripPrefix("/images/", http.FileServer(http.Dir(staticDir))))
+
+	log.Fatal(http.ListenAndServe(addr, router))
+
+	wg.Done()
+}