Skip to content

Commit

Permalink
Merge pull request #44 from asadarafat/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
asadarafat authored Jan 30, 2024
2 parents 8348a5d + a775bba commit eaefa25
Show file tree
Hide file tree
Showing 9 changed files with 7,897 additions and 434 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ vscode ➜ /workspaces/topoViewer (development ✗) go run go_cloudshellwrapper/
## Run TopoViewer Binary
```Shell
[aarafat@nsp-clab1 topoViewer]$ sudo topoviewer clab --allowed-hostnames 149.204.21.68 --clab-user aarafat --server-port 8087 --topology-file-json /home/aarafat/topoViewer/rawTopoFile/clab/nokia-MultiAccessGateway-lab/clab-nokia-MAGc-lab/topology-data.json
```
```

17 changes: 17 additions & 0 deletions go_cloudshellwrapper/cmdClab.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"strings"
"sync"
"syscall"
"time"

topoengine "github.com/asadarafat/topoViewer/go_topoengine"
Expand Down Expand Up @@ -169,7 +170,23 @@ func reader(conn *websocket.Conn) {
}
}

func checkSudoAccess() {
euid := syscall.Geteuid()

if euid == 0 {
log.Infof("Yo, this app is running with sudo access (as root).")
} else {
log.Infof("This app ain't got no sudo powers, bro.")
os.Exit(1)

}
}

func Clab(_ *cobra.Command, _ []string) error {

//check sudo
checkSudoAccess()

// initialise the cloudshellLogger
// tools.InitCloudShellLog(tools.Format(confClab.GetString("log-format")), tools.Level(confClab.GetString("log-level")))

Expand Down
4 changes: 2 additions & 2 deletions go_cloudshellwrapper/cmdNsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
xtermjs "github.com/asadarafat/topoViewer/go_xtermjs"
"github.com/usvc/go-config"

log "github.com/asadarafat/topoViewer/go_tools"
log "github.com/sirupsen/logrus"

"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -505,7 +505,7 @@ func Nsp(_ *cobra.Command, _ []string) error {
sourceImageFolder := htmlStaticPrefixPath + "images"
destinationImageFolder := htmlPublicPrefixPath + "IetfTopology-L2" + "/images"
err := cp.Copy(sourceImageFolder, destinationImageFolder)
log.Debugf("Copying images folder error: ", err)
log.Debugf("Copying images folder error: %s", err)

// topoPrefixName := "NspIetfTopoLayer2" // should be added with NSP server ip address

Expand Down
8 changes: 0 additions & 8 deletions go_cloudshellwrapper/constants.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
package cloudshellwrapper

<<<<<<< HEAD
var VersionInfo string = "nightly-24.01.26"
=======
<<<<<<< HEAD
var VersionInfo string = "nightly-24.01.21p"
=======
var VersionInfo string = "nightly-24.01.21p"
>>>>>>> 086a68742ab98e626a7a3b18058f719644aaaddd
>>>>>>> d14e5c344ebf83e4b4ac85b517d7e5ae5238600f
6 changes: 3 additions & 3 deletions go_cloudshellwrapper/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
func FileExists(filename string) bool {
f, err := os.Stat(filename)
if err != nil {
log.Debug("error while trying to access file %v: %v", filename, err)
log.Debugf("error while trying to access file %v: %v", filename, err)
return false
}

Expand Down Expand Up @@ -67,14 +67,14 @@ func createMemoryLog() tools.Logger {

func addIncomingRequestLogging(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
then := time.Now()
startTime := time.Now()
defer func() {
if recovered := recover(); recovered != nil {
createRequestLog(r).Info("request errored out")
}
}()
next.ServeHTTP(w, r)
duration := time.Now().Sub(then)
duration := time.Since(startTime)
createRequestLog(r).Infof("request completed in %vms", float64(duration.Nanoseconds())/1000000)
})
}
Expand Down
Loading

0 comments on commit eaefa25

Please sign in to comment.