Beispiel #1
0
func (c *IndexController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)
	c.TplName = "dashboard/bluegreen/index.html"

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Dashboard tab menu
	user, _ := c.GetSession("user").(*rbac.User)
	c.Data["dashboardTabMenu"] = identity.GetDashboardTabMenu(user, "bluegreen")

	cloudoneGUIProtocol := beego.AppConfig.String("cloudoneGUIProtocol")
	cloudoneGUIHost, cloudoneGUIPort := dashboard.GetServerHostAndPortFromUserRequest(c.Ctx.Input)

	c.Data["cloudoneGUIProtocol"] = cloudoneGUIProtocol
	c.Data["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["cloudoneGUIPort"] = cloudoneGUIPort

	guimessage.OutputMessage(c.Data)
}
Beispiel #2
0
func (c *ListController) Get() {
	c.TplName = "dashboard/healthcheck/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Dashboard tab menu
	user, _ := c.GetSession("user").(*rbac.User)
	c.Data["dashboardTabMenu"] = identity.GetDashboardTabMenu(user, "healthcheck")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")
	cloudoneAnalysisProtocol := beego.AppConfig.String("cloudoneAnalysisProtocol")
	cloudoneAnalysisHost := beego.AppConfig.String("cloudoneAnalysisHost")
	cloudoneAnalysisPort := beego.AppConfig.String("cloudoneAnalysisPort")

	allErrorMessageSlice := make([]string, 0)

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/healthchecks/"

	cloudoneJsonMap := make(map[string]interface{}, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &cloudoneJsonMap, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		allErrorMessageSlice = append(allErrorMessageSlice, err.Error())
	}

	url = cloudoneAnalysisProtocol + "://" + cloudoneAnalysisHost + ":" + cloudoneAnalysisPort +
		"/api/v1/healthchecks/"

	cloudoneAnalysisJsonMap := make(map[string]interface{}, 0)

	_, err = restclient.RequestGetWithStructure(url, &cloudoneAnalysisJsonMap, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		allErrorMessageSlice = append(allErrorMessageSlice, err.Error())
	}

	componentStatus, errorMessageSlice := parseComponentStatus(cloudoneJsonMap, cloudoneAnalysisJsonMap)
	if len(errorMessageSlice) > 0 {
		// Error
		allErrorMessageSlice = append(allErrorMessageSlice, errorMessageSlice...)
	}

	componentStatusSlice := make([]ComponentStatus, 0)
	componentStatusSlice = append(componentStatusSlice, *componentStatus)

	kubernetesStatusSlice, errorMessageSlice := parseKubernetesStatusSlice(cloudoneJsonMap)
	if len(errorMessageSlice) > 0 {
		// Error
		allErrorMessageSlice = append(allErrorMessageSlice, errorMessageSlice...)
	}

	glusterfsClusterStatusSlice, errorMessageSlice := parseGlusterfsClusterStatusSlice(cloudoneJsonMap)
	if len(errorMessageSlice) > 0 {
		// Error
		allErrorMessageSlice = append(allErrorMessageSlice, errorMessageSlice...)
	}

	slbSetStatusSlice, errorMessageSlice := parseSLBSetStatusSlice(cloudoneJsonMap)
	if len(errorMessageSlice) > 0 {
		// Error
		allErrorMessageSlice = append(allErrorMessageSlice, errorMessageSlice...)
	}

	sort.Sort(SortKubernetesStatusByIP(kubernetesStatusSlice))
	sort.Sort(SortGlusterfsClusterStatusByName(glusterfsClusterStatusSlice))
	sort.Sort(SortSLBSetStatusByName(slbSetStatusSlice))

	c.Data["componentStatusSlice"] = componentStatusSlice
	c.Data["kubernetesStatusSlice"] = kubernetesStatusSlice
	c.Data["glusterfsClusterStatusSlice"] = glusterfsClusterStatusSlice
	c.Data["slbSetStatusSlice"] = slbSetStatusSlice

	if len(allErrorMessageSlice) > 0 {
		errorText := fmt.Sprintf("%v", allErrorMessageSlice)
		guimessage.AddDanger(errorText)
	}

	guimessage.OutputMessage(c.Data)
}