Skip to content

Commit

Permalink
adjust url path
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaz authored and Jaz committed Mar 26, 2020
1 parent b3bf358 commit 2dbf8e0
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.11.2-alpine

WORKDIR /go/src/github.com/cloud-barista/cb-webtool
WORKDIR /go/src/github.com/cloud-barista/cb-webtool
COPY . .

RUN apk update && apk add git
Expand All @@ -12,4 +12,4 @@ RUN go get -u github.com/davecgh/go-spew/spew

EXPOSE 1234

CMD reflex -r '\.(html|go)' -s go run main.go
CMD reflex -r '\.(html|go)' -s go run main.go
6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ services:
ports:
- 1234:1234
container_name: cb-webtool
environment:
- API_GW=http://localhost:8000
- SPIDER_URL=http://localhost:8000/spider
- TUMBLE_URL=http://localhost:8000/tumblebug
- DRAGONFLY_URL=http://localhost:8000/dragonfly
- LADYBUG_URL=http://localhost:8000/ladybug


4 changes: 4 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
#setup config
echo "Setup config"
source ./conf/setup.env

#Run server
echo "start server:1234 by reflex"
reflex -r '\.(html|go)' -s go run main.go
3 changes: 0 additions & 3 deletions src/controller/CloudConnectionController.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package controller

import (
"fmt"
"os"

"net/http"

"github.com/labstack/echo"
)

var SpiderUrl = os.Getenv("SPIDER_URL")

// Driver Contorller
func DriverRegController(c echo.Context) error {
username := c.FormValue("username")
Expand Down
11 changes: 11 additions & 0 deletions src/controller/CommonHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controller
import (
"fmt"
"net/http"
"os"
"strconv"
"time"

Expand All @@ -26,6 +27,16 @@ type CommonURL struct {
LadyBugURL string
}

func GetCommonURL() CommonURL {
common_url := CommonURL{
SpiderURL: os.Getenv("SPIDER_URL"),
TumbleBugURL: os.Getenv("TUMBLE_URL"),
DragonFlyURL: os.Getenv("DRAGONFLY_URL"),
LadyBugURL: os.Getenv("LADYBUG_URL"),
}
return common_url
}

func GetCredentialInfo(c echo.Context, username string) CredentialInfo {
store := echosession.FromContext(c)
getObj, ok := store.Get(username)
Expand Down
9 changes: 7 additions & 2 deletions src/controller/McisController.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ type MCISRequest struct {
// }

func McisListForm(c echo.Context) error {

comURL := GetCommonURL()
if loginInfo := CallLoginInfo(c); loginInfo.Username != "" {
namespace := GetNameSpaceToString(c)

return c.Render(http.StatusOK, "MCISlist.html", map[string]interface{}{
"LoginInfo": loginInfo,
"NameSpace": namespace,

"comURL": comURL,
})

}
Expand All @@ -41,6 +42,7 @@ func McisListForm(c echo.Context) error {
func VMAddForm(c echo.Context) error {
mcis_id := c.Param("mcis_id")
mcis_name := c.Param("mcis_name")
comURL := GetCommonURL()
if mcis_id == "" && mcis_name == "" {
mcis_id = ""
mcis_name = ""
Expand All @@ -52,6 +54,7 @@ func VMAddForm(c echo.Context) error {
"NameSpace": namespace,
"McisID": mcis_id,
"McisName": mcis_name,
"comURL": comURL,
})

}
Expand All @@ -61,11 +64,13 @@ func VMAddForm(c echo.Context) error {
}

func McisRegForm(c echo.Context) error {
comURL := GetCommonURL()
if loginInfo := CallLoginInfo(c); loginInfo.Username != "" {
namespace := GetNameSpaceToString(c)
return c.Render(http.StatusOK, "MCISRegister.html", map[string]interface{}{
"LoginInfo": loginInfo,
"NameSpace": namespace,
"comURL": comURL,
})

}
Expand Down
2 changes: 2 additions & 0 deletions src/controller/MonitoringController.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
)

func MornitoringListForm(c echo.Context) error {
comURL := GetCommonURL()
if loginInfo := CallLoginInfo(c); loginInfo.Username != "" {
namespace := GetNameSpaceToString(c)
return c.Render(http.StatusOK, "Monitoring.html", map[string]interface{}{
"LoginInfo": loginInfo,
"NameSpace": namespace,
"comURL": comURL,
})

}
Expand Down
7 changes: 6 additions & 1 deletion src/controller/NameSpaceController.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ func NsRegController(c echo.Context) error {
}

func NsRegForm(c echo.Context) error {
comURL := GetCommonURL()
if loginInfo := CallLoginInfo(c); loginInfo.Username != "" {
return c.Render(http.StatusOK, "NSRegister.html", map[string]interface{}{
"LoginInfo": loginInfo,
"comURL": comURL,
})
}
return c.Redirect(http.StatusTemporaryRedirect, "/login")
Expand All @@ -30,11 +32,14 @@ func NsRegForm(c echo.Context) error {

func NsListForm(c echo.Context) error {
fmt.Println("=============start NsListForm =============")
comURL := GetCommonURL()
loginInfo := CallLoginInfo(c)
if loginInfo.Username != "" {
nsList := service.GetNSList()
return c.Render(http.StatusOK, "NSList.html", map[string]interface{}{
"LoginInfo": loginInfo, "NSList": nsList,
"LoginInfo": loginInfo,
"NSList": nsList,
"comURL": comURL,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import (

func ResourceBoard(c echo.Context) error {
fmt.Println("=========== ResourceBoard start ==============")
comURL := GetCommonURL()
if loginInfo := CallLoginInfo(c); loginInfo.Username != "" {
nameSpace := GetNameSpaceToString(c)
fmt.Println("Namespace : ", nameSpace)
return c.Render(http.StatusOK, "ResourceBoard.html", map[string]interface{}{
"LoginInfo": loginInfo,
"NameSpace": nameSpace,
"comURL": comURL,
})

}
Expand Down
13 changes: 3 additions & 10 deletions src/controller/loginController.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controller
import (
"fmt"
"net/http"
"os"
"strings"

echosession "github.com/go-session/echo-session"
Expand All @@ -15,23 +14,17 @@ type ReqInfo struct {
Password string `json:"password"`
}

var ComURL = CommonURL{
SpiderURL: os.Getenv("SPIDER_URL"),
TumbleBugURL: os.Getenv("TUMBLE_URL"),
DragonFlyURL: os.Getenv("DRAGONFLY_URL"),
LadyBugURL: os.Getenv("LADYBUG_URL"),
}

func LoginForm(c echo.Context) error {
fmt.Println("============== Login Form ===============")

comURL := GetCommonURL()
return c.Render(http.StatusOK, "login.html", map[string]interface{}{
"comURL": ComURL,
"comURL": comURL,
})
}

func LogoutForm(c echo.Context) error {
fmt.Println("============== Logout Form ===============")
//comURL := GetCommonURL()
return c.Render(http.StatusOK, "logout.html", nil)
}

Expand Down
4 changes: 3 additions & 1 deletion src/service/CloudConnectionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
)

var CloudConnectionUrl = "http://15.165.16.67:1024"
//var CloudConnectionUrl = "http://15.165.16.67:1024"
var CloudConnectionUrl = os.Getenv("SPIDER_URL")

type CloudConnectionInfo struct {
ID string `json:"id"`
Expand Down
10 changes: 7 additions & 3 deletions src/service/McisHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
)

var MCISUrl = "http://15.165.16.67:1323"
var SPiderUrl = "http://15.165.16.67:1024"
//var MCISUrl = "http://15.165.16.67:1323"
//var SPiderUrl = "http://15.165.16.67:1024"

var SpiderUrl = os.Getenv("SPIDER_URL")
var MCISUrl = os.Getenv("TUMBLE_URL")

type MCISInfo struct {
ID string `json:"id"`
Expand Down Expand Up @@ -48,7 +52,7 @@ func GetMCIS(nsid string, mcisId string) []MCISInfo {
}

func GetVMStatus(vm_name string, connectionConfig string) string {
url := SPiderUrl + "/vmstatus/" + vm_name + "?connection_name=" + connectionConfig
url := SpiderUrl + "/vmstatus/" + vm_name + "?connection_name=" + connectionConfig
resp, err := http.Get(url)
if err != nil {
fmt.Println("request URL : ", url)
Expand Down
6 changes: 3 additions & 3 deletions src/service/NameSpaceHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"

"reflect"
)

var NameSpaceUrl = "http://15.165.16.67:1323"
// var NameSpaceUrl = "http://15.165.16.67:1323"
var NameSpaceUrl = os.Getenv("TUMBLE_URL")

type NSInfo struct {
ID string `json:"id"`
Expand Down Expand Up @@ -48,8 +50,6 @@ func GetNSList() []NSInfo {

}



// func RegNS() error {

// }
Expand Down
6 changes: 3 additions & 3 deletions src/views/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
<title>Cloud Baristar</title>
</head>
<script>
const CommonURL = "http://15.165.16.67:1323";
const SpiderURL = "http://15.165.16.67:1024"
const CommonURL = "{{ .comURL.TumbleBugURL}}";
const SpiderURL = "{{ .comURL.SpiderURL}}"
const NAMESPACE ="{{with .LoginInfo}}{{ .NameSpace }}{{end}}";
console.log("namespace : ",NAMESPACE)
var btn_click_cnt = 1;
const DragonFlyURL = "http://182.252.133.22:9090"
const DragonFlyURL = "{{ .comURL.DragonFlyURL}}"


</script>
Expand Down
2 changes: 1 addition & 1 deletion src/views/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h1 class="display-4 mb-5 text-white">WELCOME <br/>Cloud Barista {{ .comURL.Tumb
if(result.data.status == "success"){
alert("Login Success");
//location.reload();
var url = "http://15.165.16.67:1323/ns"
var url = "{{ .comURL.TumbleBugURL}}"+"/ns";
axios.get(url).then(result=>{
console.log(result.data);
var data = result.data.ns;
Expand Down
2 changes: 1 addition & 1 deletion src/views/logout.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h1 class="display-4 mb-5 text-white">Logout Complete!<br/>Thanks!!</h1>
if(result.data.status == "success"){
alert("Login Success");
//location.reload();
var url = "http://15.165.16.67:1323/ns"
var url = "{{ .comURL.TumbleBugURL}}"+"/ns";
axios.get(url).then(result=>{
console.log(result.data);
var data = result.data.ns;
Expand Down

0 comments on commit 2dbf8e0

Please sign in to comment.