Skip to content

Commit 7237654

Browse files
authored
Merge pull request #104 from mwfarb/sept_scionlab_next
[webapp] Packaging Updates for Scionlab Next Version
2 parents cdd02e7 + e5b917c commit 7237654

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+678
-262
lines changed

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
*~
1818

1919
# User-defined webapp node addresses
20-
clients_default.json
21-
clients_user.json
22-
servers_user.json
20+
webapp/web/config/clients_default.json
21+
webapp/web/config/clients_user.json
22+
webapp/web/config/servers_user.json
2323

2424
# Generated webapp data and logging
25-
webapp.db
26-
webapp/data
25+
webapp/web/webapp.db
26+
webapp/web/data
2727
.webapp
2828

2929
# IDE project files

camerapp/imageserver/paparazzi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22

33
from picamera import PiCamera, Color
44
from time import sleep

sensorapp/sensorserver/sensorreader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
HOST = "localhost"
@@ -38,7 +38,7 @@
3838
ambientlight = AmbientLight( AMBIENTLIGHT_UID, ipcon)
3939
uvlight = BrickletUVLight( UVLIGHT_UID, ipcon)
4040
motiondetect = BrickletMotionDetector( MOTIONDETECTOR_UID, ipcon)
41-
41+
4242
ipcon.connect(HOST, PORT) # Connect to brickd
4343

4444
while (True):

sensorapp/sensorserver/timereader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
import time

webapp/README.md

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,97 @@ Webapp AS Visualization
33

44
More installation and usage information is available on the [SCION Tutorials web page for webapp](https://netsec-ethz.github.io/scion-tutorials/as_visualization/webapp/).
55

6-
## Webapp Setup
6+
## Webapp
77
Webapp is a Go application that will serve up a static web portal to make it easy to visualize and experiment with SCIONLab test apps on a virtual machine.
88

9-
### Install
9+
10+
## Packaged Setup/Run
11+
For running `webapp` in a package environment, like the default [SCIONLab](https://www.scionlab.org) environment, it will require command-line options for `webapp` to find the tools its requires. In most cases, the default `scionlab` and `scion-apps` packages will need to be specified on the command-line.
12+
13+
To run the Go Web UI at a specific address `-a` and port `-p` like 0.0.0.0:8000 for a SCIONLab VM use:
14+
```shell
15+
webapp \
16+
-a 0.0.0.0 \
17+
-p 8000 \
18+
-r /var/lib/scion/webapp/web/data \
19+
-srvroot /var/lib/scion/webapp/web \
20+
-sabin /usr/bin \
21+
-sroot /etc/scion \
22+
-sbin /usr/bin \
23+
-sgen /etc/scion/gen \
24+
-sgenc /var/lib/scion \
25+
-slogs /var/log/scion
26+
```
27+
Now, open a web browser at [http://127.0.0.1:8000](http://127.0.0.1:8000), to begin.
28+
29+
30+
## Development Setup/Run
31+
For running `webapp` in a development environment for the SCION Infrastructure, follow the SCIONLab development install and run process at [https://github.com/netsec-ethz/netsec-scion](https://github.com/netsec-ethz/netsec-scion).
32+
33+
Then, follow these steps to install SCIONLab Apps to run `webapp` in development.
34+
35+
### Development Install
1036
```shell
1137
mkdir ~/go/src/github.com/netsec-ethz
1238
cd ~/go/src/github.com/netsec-ethz
1339
git clone https://github.com/netsec-ethz/scion-apps.git
1440
```
1541

16-
### Build
17-
Install all [SCIONLab apps](https://github.com/netsec-ethz/scion-apps) and dependancies, including `webapp`:
42+
### Development Build
43+
Install all [SCIONLab apps](https://github.com/netsec-ethz/scion-apps) and dependencies, including `webapp`:
1844
```shell
1945
cd scion-apps
2046
./deps.sh
2147
make install
2248
```
2349

24-
### Run
25-
!!! warning
26-
If the old [scion-viz](https://github.com/netsec-ethz/scion-viz) web server is running on your SCIONLab VM, port 8000 may still be in use. To remedy this, before `vagrant up`, make sure to edit your `vagrantfile` to provision an alternate port for the `webapp` web server. Add this line for a different port, say 8080 (for example, just choose any forwarding port not already in use by vagrant, and use that port everywhere below):
50+
### Development Run
51+
You can alter the defaults on the command line, all of which are listed below:
52+
```shell
53+
webapp \
54+
-a 127.0.0.1 \
55+
-p 8000 \
56+
-r . \
57+
-srvroot $GOPATH/src/github.com/netsec-ethz/scion-apps/webapp/web \
58+
-sabin $GOPATH/bin \
59+
-sroot $GOPATH/src/github.com/scionproto/scion \
60+
-sbin $GOPATH/src/github.com/scionproto/scion/bin \
61+
-sgen $GOPATH/src/github.com/scionproto/scion/gen \
62+
-sgenc $GOPATH/src/github.com/scionproto/scion/gen-cache \
63+
-slogs $GOPATH/src/github.com/scionproto/scion/logs
64+
```
65+
or can you run `webapp` like this, which will use the defaults above:
66+
```shell
67+
webapp
68+
```
2769

28-
```
29-
config.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: "tcp"
30-
```
70+
## Dependancies
71+
A list of dependencies for `webapp` can be found at [dependencies.md](./dependencies.md).
3172

32-
To run the Go Web UI at a specific address (-a) and port (-p) like 0.0.0.0:8000 for a SCIONLab VM use:
73+
## Help
3374
```shell
34-
cd webapp
35-
webapp -a 0.0.0.0 -p 8000
75+
Usage of webapp:
76+
-a string
77+
Address of server host. (default "127.0.0.1")
78+
-p int
79+
Port of server host. (default 8000)
80+
-r string
81+
Root path to read/browse from, CAUTION: read-access granted from -a and -p. (default ".")
82+
-sabin string
83+
Path to execute the installed scionlab apps binaries (default "/home/ubuntu/go/bin")
84+
-sbin string
85+
Path to execute SCION bin directory of infrastructure tools (default "/home/ubuntu/go/src/github.com/scionproto/scion/bin")
86+
-sgen string
87+
Path to read SCION gen directory of infrastructure config (default "/home/ubuntu/go/src/github.com/scionproto/scion/gen")
88+
-sgenc string
89+
Path to read SCION gen-cache directory of infrastructure run-time config (default "/home/ubuntu/go/src/github.com/scionproto/scion/gen-cache")
90+
-slogs string
91+
Path to read SCION logs directory of infrastructure logging (default "/home/ubuntu/go/src/github.com/scionproto/scion/logs")
92+
-sroot string
93+
Path to read SCION root directory of infrastructure (default "/home/ubuntu/go/src/github.com/scionproto/scion")
94+
-srvroot string
95+
Path to read/write web server files. (default "/home/ubuntu/go/src/github.com/netsec-ethz/scion-apps/webapp/web")
3696
```
37-
Now, open a web browser at [http://127.0.0.1:8000](http://127.0.0.1:8000), to begin.
3897

3998
## Related Links
4099
* [Webapp SCIONLab AS Visualization Tutorials](https://netsec-ethz.github.io/scion-tutorials/as_visualization/webapp/)

webapp/dependencies.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Webapp Dependencies
2+
3+
## Package Default CL
4+
```shell
5+
webapp \
6+
-a 0.0.0.0 \
7+
-p 8000 \
8+
-r /var/lib/scion/webapp/web/data \
9+
-srvroot /var/lib/scion/webapp/web \
10+
-sabin /usr/bin \
11+
-sroot /etc/scion \
12+
-sbin /usr/bin \
13+
-sgen /etc/scion/gen \
14+
-sgenc /var/lib/scion \
15+
-slogs /var/log/scion
16+
```
17+
18+
## Developer Default CL
19+
```shell
20+
webapp \
21+
-a 127.0.0.1 \
22+
-p 8000 \
23+
-r . \
24+
-srvroot $GOPATH/src/github.com/netsec-ethz/scion-apps/webapp/web \
25+
-sabin $GOPATH/bin \
26+
-sroot $GOPATH/src/github.com/scionproto/scion \
27+
-sbin $GOPATH/src/github.com/scionproto/scion/bin \
28+
-sgen $GOPATH/src/github.com/scionproto/scion/gen \
29+
-sgenc $GOPATH/src/github.com/scionproto/scion/gen-cache \
30+
-slogs $GOPATH/src/github.com/scionproto/scion/logs
31+
```
32+
33+
## System Binaries Used
34+
- bash
35+
- echo
36+
- cd
37+
- sed
38+
- date
39+
- curl
40+
- set
41+
- grep
42+
- python3
43+
- df
44+
- tr
45+
- free
46+
- sleep
47+
- cat
48+
- systemctl
49+
50+
## SCION Binaries Used/Checked
51+
- $sbin/scmp
52+
- $sabin/bwtestclient
53+
- $sabin/imagefetcher
54+
- $sabin/sensorfetcher
55+
56+
## Scripts/Directories Used/Checked
57+
- $sroot/scion.sh (deprecated)
58+
- $slogs/bs[IA]-1.log
59+
- $sgen/ISD*/AS* (scanning for local IAs)
60+
- $sgen/ISD[ISD]/AS[AS]/endhost/topology.json
61+
- $sgenc/*.crt
62+
- $sgenc/*.trc
63+
- $sgenc/ps[IA]-1.path.db
64+
- /run/shm/dispatcher/default.sock
65+
- /run/shm/sciond/default.sock
66+
67+
## Static Webserver Required
68+
- $srvroot/favico.ico
69+
- $srvroot/config/
70+
- $srvroot/static/css/
71+
- $srvroot/static/html/
72+
- $srvroot/static/img/
73+
- $srvroot/static/js/
74+
- $srvroot/template/
75+
- $srvroot/tests/health/
76+
77+
## Static Webserver Generated
78+
- $srvroot/webapp.db
79+
- $srvroot/data/
80+
- $srvroot/data/images/
81+
- $srvroot/logs/
82+
83+
84+
85+

webapp/lib/bwcont.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2019 ETH Zurich
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.package main
14+
115
package lib
216

317
import (
@@ -151,7 +165,7 @@ func ExtractBwtestRespData(resp string, d *model.BwTestItem, start time.Time) {
151165
}
152166

153167
// GetBwByTimeHandler request the bwtest results stored since provided time.
154-
func GetBwByTimeHandler(w http.ResponseWriter, r *http.Request, active bool, srcpath string) {
168+
func GetBwByTimeHandler(w http.ResponseWriter, r *http.Request, active bool) {
155169
r.ParseForm()
156170
since := r.PostFormValue("since")
157171
log.Info("Requesting bwtest data since", "timestamp", since)
@@ -187,10 +201,10 @@ func removeOuterQuotes(s string) string {
187201
}
188202

189203
// WriteCmdCsv appends the cmd data (bwtest or echo) in csv-format to srcpath.
190-
func WriteCmdCsv(d model.CmdItem, srcpath string, appSel string) {
204+
func WriteCmdCsv(d model.CmdItem, options *CmdOptions, appSel string) {
191205
// newfile name for every day
192206
dataFileCmd := "data/" + appSel + "-" + time.Now().Format("2006-01-02") + ".csv"
193-
cmdDataPath := path.Join(srcpath, dataFileCmd)
207+
cmdDataPath := path.Join(options.StaticRoot, dataFileCmd)
194208
// write headers if file is new
195209
writeHeader := false
196210
if _, err := os.Stat(dataFileCmd); os.IsNotExist(err) {

0 commit comments

Comments
 (0)