Skip to content

Commit a775bba

Browse files
author
Your Name
committed
dev
1 parent a7c8bf4 commit a775bba

File tree

8 files changed

+7897
-426
lines changed

8 files changed

+7897
-426
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ vscode ➜ /workspaces/topoViewer (development ✗) go run go_cloudshellwrapper/
124124
## Run TopoViewer Binary
125125
```Shell
126126
[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
127-
```
127+
```
128+

go_cloudshellwrapper/cmdClab.go

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strconv"
1212
"strings"
1313
"sync"
14+
"syscall"
1415
"time"
1516

1617
topoengine "github.com/asadarafat/topoViewer/go_topoengine"
@@ -169,7 +170,23 @@ func reader(conn *websocket.Conn) {
169170
}
170171
}
171172

173+
func checkSudoAccess() {
174+
euid := syscall.Geteuid()
175+
176+
if euid == 0 {
177+
log.Infof("Yo, this app is running with sudo access (as root).")
178+
} else {
179+
log.Infof("This app ain't got no sudo powers, bro.")
180+
os.Exit(1)
181+
182+
}
183+
}
184+
172185
func Clab(_ *cobra.Command, _ []string) error {
186+
187+
//check sudo
188+
checkSudoAccess()
189+
173190
// initialise the cloudshellLogger
174191
// tools.InitCloudShellLog(tools.Format(confClab.GetString("log-format")), tools.Level(confClab.GetString("log-level")))
175192

go_cloudshellwrapper/cmdNsp.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
xtermjs "github.com/asadarafat/topoViewer/go_xtermjs"
1919
"github.com/usvc/go-config"
2020

21-
log "github.com/asadarafat/topoViewer/go_tools"
21+
log "github.com/sirupsen/logrus"
2222

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

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

go_cloudshellwrapper/utils.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
func FileExists(filename string) bool {
2020
f, err := os.Stat(filename)
2121
if err != nil {
22-
log.Debug("error while trying to access file %v: %v", filename, err)
22+
log.Debugf("error while trying to access file %v: %v", filename, err)
2323
return false
2424
}
2525

@@ -67,14 +67,14 @@ func createMemoryLog() tools.Logger {
6767

6868
func addIncomingRequestLogging(next http.Handler) http.Handler {
6969
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
70-
then := time.Now()
70+
startTime := time.Now()
7171
defer func() {
7272
if recovered := recover(); recovered != nil {
7373
createRequestLog(r).Info("request errored out")
7474
}
7575
}()
7676
next.ServeHTTP(w, r)
77-
duration := time.Now().Sub(then)
77+
duration := time.Since(startTime)
7878
createRequestLog(r).Infof("request completed in %vms", float64(duration.Nanoseconds())/1000000)
7979
})
8080
}

html-static/template/clab/button.tmpl

+416-416
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)