Skip to content

Commit

Permalink
구조변경중
Browse files Browse the repository at this point in the history
  • Loading branch information
idogfootman committed Mar 10, 2021
1 parent 6f0f8db commit e9ccb20
Show file tree
Hide file tree
Showing 83 changed files with 267 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
*.code-workspace
pkg
conf/
conf/*.env
conf/*.env
conf/setup.env
15 changes: 11 additions & 4 deletions conf/setup.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#반드시 Public IP로 설정하세요.
export SPIDER_URL=http://localhost:1024/spider
export TUMBLE_URL=http://localhost:1323/tumblebug
export DRAGONFLY_URL=http://localhost:9090/dragonfly
#export SPIDER_URL=http://localhost:1024/spider
#export TUMBLE_URL=http://localhost:1323/tumblebug
#export DRAGONFLY_URL=http://localhost:9090/dragonfly

#export API_GW=http://127.0.0.1:8000

export SPIDER_URL=http://54.248.3.145:1024/spider
export TUMBLE_URL=http://54.248.3.145:1323/tumblebug
export DRAGONFLY_URL=http://54.248.3.145:9090/dragonfly

export API_GW=http://54.248.3.145:8000

export API_GW=http://127.0.0.1:8000
export LADYBUG_URL=$API_GW/ladybug

export LoginEmail=admin
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.14
require (
github.com/cespare/reflex v0.3.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/foolin/echo-template v0.0.0-20190415034849-543a88245eec
github.com/go-session/echo-session v3.0.0+incompatible
github.com/go-session/session v3.1.2+incompatible // indirect
github.com/labstack/echo v3.3.10+incompatible
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dogfootman/cb-webtool v0.2.8 h1:BQvDHBjgX7hUQDnCNQXcwXPkB3pnYsTp8nQSFUZhx5o=
github.com/foolin/echo-template v0.0.0-20190415034849-543a88245eec h1:BurQ3oNjJkB5+zibQGHw97kZOBN/DLlAKYlvfsacBD0=
github.com/foolin/echo-template v0.0.0-20190415034849-543a88245eec/go.mod h1:4ePCtze3Ivy48ps0gJWfSByLgfqvT0rF+RpKQFe4Ja0=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-session/echo-session v3.0.0+incompatible h1:yJejVUrmpOF+sZSRfhO2fC/5TNCa3BkgQIVhMykwY44=
Expand Down
69 changes: 62 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

//"github.com/cloud-barista/cb-webtool/src/controller"
"github.com/cloud-barista/cb-webtool/src/controller"
echotemplate "github.com/foolin/echo-template"
echosession "github.com/go-session/echo-session"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
Expand Down Expand Up @@ -71,19 +72,64 @@ func main() {
renderer := &TemplateRender{
templates: template.Must(template.ParseGlob(`./src/views/*.html`)),
}

e.Renderer = renderer

// namespace 매핑할 middleware 추가
namespaceTemplate := echotemplate.NewMiddleware(echotemplate.TemplateConfig{
Root: "src/views",
Extension: ".html",
Master: "setting/namespaces/NameSpace",
Partials: []string{
"templates/Top",
"templates/Top_box",
"templates/LNB_popup",
"templates/Modal",
"templates/Header",
"templates/Menu_left",
"templates/Footer"}, //
DisableCache: true,
})

// dashboard 매핑할 middleware 추가
dashboardTemplate := echotemplate.NewMiddleware(echotemplate.TemplateConfig{
Root: "src/views/dashboards",
Extension: ".html",
Master: "src/layouts/master",
Partials: []string{},
DisableCache: true,
})

// mcis 매핑할 middleware 추가
manageMCISTemplate := echotemplate.NewMiddleware(echotemplate.TemplateConfig{
Root: "src/views/operation/manage",
Extension: ".html",
Master: "src/layouts/master",
Partials: []string{},
DisableCache: true,
})


/////////////////////////
// group에 templace set
// 해당 그룹.GET(경로, controller의 method)
// 해당 그룹.POST(경로, controller의 method)




e.GET("/", controller.IndexController)
e.GET("/Dashboard/Global", controller.GlobalDashBoard)
e.GET("/Dashboard/NS", controller.NSDashBoard)

//login 관련
e.GET("/login", controller.LoginForm)
e.POST("/login/proc", controller.LoginController)
e.POST("/regUser", controller.RegUserConrtoller)
e.GET("/logout", controller.LogoutForm)
e.GET("/logout/proc", controller.LoginController)

// Dashboard
e.GET("/Dashboard/Global", controller.GlobalDashBoard)
e.GET("/Dashboard/NS", controller.NSDashBoard)


// Monitoring Control
e.GET("/Monitoring/MCIS/list", controller.MornitoringListForm)
Expand All @@ -104,10 +150,19 @@ func main() {
e.GET("/SET/NS/:nsid", controller.SetNameSpace)

// 웹툴에서 처리할 NameSpace
e.GET("/NameSpace/NS/list", controller.NsListForm)
e.GET("/NS/reg", controller.NsRegForm)
e.POST("/NS/reg/proc", controller.NsRegController)
e.GET("/GET/ns", controller.GetNameSpace)
// e.GET("/NameSpace/NS/list", controller.NsListForm)
// e.GET("/NS/reg", controller.NsRegForm)
// e.POST("/NS/reg/proc", controller.NsRegController)
// e.GET("/GET/ns", controller.GetNameSpace)
namespaceGroup := e.Group("/NameSpace", namespaceTemplate)
namespaceGroup.GET("/NS/list", controller.NsListForm) // namespace 보여주는 form 표시. DashboardController로 이동?
namespaceGroup.GET("/GET/ns", controller.GetNameSpace) // 선택된 namespace 정보조회. Tumblebuck 호출
namespaceGroup.GET("/GET/nsList", controller.GetNameSpaceList) // 등록된 namespace 목록 조회. Tumblebuck 호출

namespaceGroup.GET("/SET/NS/:nsid", controller.SetNameSpace) // default namespace set
namespaceGroup.GET("/NS/reg", controller.NsRegForm) // namespace 등록 form 표시
namespaceGroup.POST("/NS/reg/proc", controller.NsRegProc) // namespace 등록 처리


// 웹툴에서 처리할 Connection
e.GET("/Cloud/Connection/list", controller.ConnectionListForm)
Expand Down
20 changes: 20 additions & 0 deletions src/controller/NameSpaceController.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"net/http"
_ "net/http"

echotemplate "github.com/foolin/echo-template"
echosession "github.com/go-session/echo-session"

"github.com/cloud-barista/cb-webtool/src/service"
"github.com/labstack/echo"
)
Expand Down Expand Up @@ -58,3 +61,20 @@ func NsListForm(c echo.Context) error {
//return c.Redirect(http.StatusPermanentRedirect, "/login")
return c.Redirect(http.StatusTemporaryRedirect, "/login")
}

func GetNameSpaceList(c echo.Context) error {
fmt.Println("====== GET NAMESPACE LIST ========")
store := echosession.FromContext(c)
nsInfoList, nsErr := service.GetNameSpaceList()
if nsErr != nil {
return c.JSON(http.StatusBadRequest, map[string]interface{}{
"message": "invalid tumblebug connection",
"status": "403",
})
} else {
store.Set("namespaceList", nsInfoList)
store.Save()
}

return c.JSON(http.StatusOK, nsInfoList)
}
10 changes: 10 additions & 0 deletions src/model/User.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

type User struct {
//user(username, password, email)
Username string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
}

type Users []User
3 changes: 3 additions & 0 deletions src/model/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module model

go 1.15
67 changes: 67 additions & 0 deletions src/service/NameSpaceHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (

"reflect"
//"github.com/davecgh/go-spew/spew"

//model "github.com/cloud-barista/cb-webtool/src/model"
model "github.com/dogfootman/cb-webtool/src/model"
// model "./src/model"

)

// var NameSpaceUrl = "http://15.165.16.67:1323"
Expand Down Expand Up @@ -130,3 +135,65 @@ func AuthenticationHandler() string {
return "Basic " + encA

}


// 사용자의 namespace 목록 조회
func GetNameSpaceList() ([]model.NSInfo, error) {
fmt.Println("GetNameSpaceList start")
url := NameSpaceUrl + "/ns"

body, err := HttpGetHandler(url)

fmt.Println("called HttpGetHandler")
fmt.Println(body)
if err != nil {
// Tumblebug 접속 확인하라고
return nil, err
}

//nsInfoList := map[string][]model.NSInfo{}
// nsInfoList := map[string][]model.NSInfo{}
// nserr := json.NewDecoder(body).Decode(&nsInfoList)
// if nserr != nil {
// return nil, nserr
// }
// fmt.Println(nsInfoList["ns"])

nsInfoList := map[string][]model.NSInfo{}
defer body.Close()
json.NewDecoder(body).Decode(&nsInfoList)
//spew.Dump(body)
fmt.Println(nsInfoList["ns"])

// nsInfo := map[string][]model.NSInfo{}
// defer body.Close()
// json.NewDecoder(body).Decode(&nsInfo)
// //spew.Dump(body)
// fmt.Println(nsInfo["ns"])
// return nsInfo["ns"]

//nsInfoList := map[string][]model.NSInfo{}
// nsInfoMap := map[string][]model.NSInfo{}

// nsInfoList := model.NSInfoList{}
// keys := []string{}
// for key, _ := range nsInfoMap {
// fmt.Println(key)
// // keys = append(keys, key)
// nsInfoList = append(nsInfoList, key)
// }
// //nsList := model.NsInfoList{}
// defer body.Close()

// err := json.NewDecoder(body).Decode(&nsInfo)
// if err != nil {
// return nil, err
// }
// //spew.Dump(body)
// fmt.Println(nsInfo)
//return nsInfo["ns"]
// 접속오류인지
// namespace가 생성되지 않았는지
// return nil, nil
return nsInfoList["ns"], nil
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
88 changes: 88 additions & 0 deletions src/views/templates/MenuLeft.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{define "Menu_left"}}

<div class="leftmenu">

<ul class="nav">
<li class="nav-item"><a class="nav-link " data-toggle="tab" href="#Operation">Operation</a></li>
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#Setting">Setting</a></li>
</ul>

<div class="tab-content">
<div class="tab-pane fade" id="Operation">
<ul class="menu">
<li id="Dashboard">
<a href="javascript:void(0);">Dashboard</a>
<ul>
<li id="NS"><a href="/Dashboard/NS">NS</a></li>
<li id="Global"><a href="/Dashboard/Global">Global</a></li>
</ul>
</li>
<li id="Manage">
<a href="javascript:void(0);">Manage</a>
<ul>
<li id="MCIS"><a href="/Manage/MCIS/list">MCIS</a></li>
<li id="MC-App"><a href="!#">MC-App</a></li>
</ul>
</li>
<li id="Monitoring">
<a href="javascript:void(0);">Monitoring</a>
<ul>
<li id="MCIS"><a href="/Monitoring/MCIS/list">MCIS</a></li>
<li id="MC-App"><a href="/operation/Monitoring_McApp.html">MC-App</a></li>
</ul>
</li>
<li id="Policy">
<a href="javascript:void(0);">Policy</a>
<ul>
<li><a href="../operation/Policy_Monitoring.html">Monitoring</a></li>
<li><a href="../operation/Policy_Threshold.html">Threshold</a></li>
<li><a href="../operation/Policy_Placement.html">Placement</a></li>
</ul>
</li>
<li id="About">
<a href="javascript:void(0);">About</a>
<ul>
<li><a href="../operation/About.html">About</a></li>
</ul>
</li>
</ul>
</div>

<div class="tab-pane fade show active" id="Setting">
<ul class="menu">
<li id="Resources">
<a href="javascript:void(0);">Resources</a>
<ul>
<li id="net"><a href="/Vpc/list">Network</a></li>
<li id="sg"><a href="/SecurityGroup/list">Security</a></li>
<li id="ssh"><a href="/SSH/list">SSH key</a></li>
<li id="image"><a href="/Image/list">(Server) Image</a></li>
<li id="spec"><a href="/Spec/list">(Server) Spec</a></li>
</ul>
</li>
<li id="AppRes">
<a href="javascript:void(0);">App Resource</a>
<ul>
<li><a href="!#">(Server) Image</a></li>
<li><a href="!#">Pod</a></li>
</ul>
</li>
<li id="Cloud">
<a href="javascript:void(0);">Cloud Connections</a>
<ul>
<li id="Connection"><a href="/Cloud/Connection/list">Cloud Connections</a></li>
</ul>
</li>
<li class="active" id="NameSpace">
<a href="javascript:void(0);">NameSpace</a>
<ul>
<li id="NS" class="on"><a href="/NameSpace/NS/list">NameSpace</a></li>
</ul>
</li>
</ul>
</div>
</div>

</div>
<!-- //menu -->
{{end}}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e9ccb20

Please sign in to comment.