示例#1
0
func (c *PodDeleteController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	namespace := c.GetString("namespace")
	pod := c.GetString("pod")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/pods/" + namespace + "/" + pod

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

	_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Pod " + pod + " is deleted")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/inventory/replicationcontroller/list")

	guimessage.RedirectMessage(c)
}
示例#2
0
func (c *UpgradeController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	imageInformationName := c.GetString("name")
	description := c.GetString("description")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/imageinformations/upgrade"

	deployUpgradeInput := DeployUpgradeInput{imageInformationName, description}

	resultJsonMap := make(map[string]interface{})

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

	_, err := restclient.RequestPutWithStructure(url, deployUpgradeInput, &resultJsonMap, tokenHeaderMap)

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

	if err != nil {
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess(imageInformationName + " is launched")
	}

	c.Ctx.Redirect(302, "/gui/repository/imageinformation/log?imageInformation="+imageInformationName)

	guimessage.RedirectMessage(c)
}
示例#3
0
func (c *EditController) Get() {
	c.TplName = "system/host/credential/edit.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	ip := c.GetString("ip")

	if ip == "" {
		c.Data["actionButtonValue"] = "Create"
		c.Data["pageHeader"] = "Create Host Credential"
		c.Data["createOrUpdate"] = "create"
		c.Data["fieldDisabledChecked"] = ""

		c.Data["sshPort"] = 22
	} else {
		cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
		cloudoneHost := beego.AppConfig.String("cloudoneHost")
		cloudonePort := beego.AppConfig.String("cloudonePort")

		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
			"/api/v1/hosts/credentials/" + ip

		credential := Credential{}

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

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

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

		if err != nil {
			// Error
			guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
			guimessage.OutputMessage(c.Data)
			return
		}

		c.Data["actionButtonValue"] = "Update"
		c.Data["pageHeader"] = "Update Host Credential"
		c.Data["createOrUpdate"] = "update"

		c.Data["ip"] = credential.IP
		c.Data["sshPort"] = credential.SSH.Port
		c.Data["sshUser"] = credential.SSH.User
		c.Data["sshPassword"] = credential.SSH.Password
		if credential.Disabled {
			c.Data["fieldDisabledChecked"] = "checked"
		} else {
			c.Data["fieldDisabledChecked"] = ""
		}

		c.Data["ipFieldReadOnly"] = "readonly"
	}

	guimessage.OutputMessage(c.Data)
}
示例#4
0
func (c *DeleteController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	ip := c.GetString("ip")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/hosts/credentials/" + ip

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

	_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Credential " + ip + " is deleted")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/system/host/credential/list")

	guimessage.RedirectMessage(c)
}
示例#5
0
func (c *EditController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	name := c.GetString("name")

	namespace := Namespace{name, false, false, "", "", "", ""}

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

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

	_, err := restclient.RequestPostWithStructure(url, namespace, nil, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Namespace " + name + " is edited")
	}

	c.Ctx.Redirect(302, "/gui/system/namespace/list")

	guimessage.RedirectMessage(c)
}
示例#6
0
func (c *ConfigureController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	name := c.GetString("name")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/slbs/daemons/" + name + "/configure"

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

	_, err := restclient.RequestPut(url, make(map[string]interface{}), tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("SLB daemon " + name + " is configured")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/system/slb/daemon/list")

	guimessage.RedirectMessage(c)
}
示例#7
0
func (c *DeleteController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	imageInformationName := c.GetString("name")
	imageRecordVersion := c.GetString("version")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/imagerecords/" + imageInformationName + "/" + imageRecordVersion

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

	_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Image record " + imageRecordVersion + " belonging to " + imageInformationName + " is deleted")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/repository/imagerecord/list?name="+imageInformationName)

	guimessage.RedirectMessage(c)
}
示例#8
0
func (c *DeleteController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	serverName := c.GetString("serverName")
	repositoryName := c.GetString("repositoryName")
	tag := c.GetString("tag")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/privateregistries/servers/" + serverName + "/repositories/" + repositoryName + "/tags/" + tag

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

	_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Image labeled with the tag " + tag + " is deleted")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/system/privateregistry/image/list?serverName="+serverName+"&repositoryName="+repositoryName)

	guimessage.RedirectMessage(c)
}
示例#9
0
func (c *DeleteController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	imageInformation := c.GetString("imageInformation")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/deploybluegreens/" + imageInformation

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

	_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Deploy blue green deployment " + imageInformation + " is deleted")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/deploy/deploybluegreen/list")

	guimessage.RedirectMessage(c)
}
示例#10
0
func (c *ResizeController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	namespace, _ := c.GetSession("namespace").(string)

	name := c.GetString("name")
	size, _ := c.GetInt("size")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/deploys/resize/" + namespace + "/" + name + "?size=" + strconv.Itoa(size)

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

	_, err := restclient.RequestPut(url, make(map[string]interface{}), tokenHeaderMap, false)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Application " + name + " is resized")
	}

	c.Ctx.Redirect(302, "/gui/deploy/deploy/list")

	guimessage.RedirectMessage(c)
}
示例#11
0
func (c *ResetController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	clusterName := c.GetString("clusterName")
	glusterfsVolume := c.GetString("glusterfsVolume")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/glusterfs/clusters/" + clusterName + "/volumes/" + glusterfsVolume

	jsonMap := make(map[string]interface{})

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

	_, err := restclient.RequestPut(url, jsonMap, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Glusterfs volume " + glusterfsVolume + " is reset")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/filesystem/glusterfs/volume/list?clusterName="+clusterName)

	guimessage.RedirectMessage(c)
}
示例#12
0
func (c *DeleteController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	name := c.GetString("name")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/notifiers/emailserversmtp/" + name

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

	_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Email server configuration " + name + " is deleted")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/system/notification/emailserver/list")

	guimessage.RedirectMessage(c)
}
示例#13
0
func (c *ListController) Get() {
	c.TplName = "repository/thirdparty/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiRepositoryThirdPartyEdit", user, "GET", "/gui/repository/thirdparty/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiRepositoryThirdPartyLaunch := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/thirdparty/launch")
	hasGuiRepositoryThirdPartyEdit := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/thirdparty/edit")
	hasGuiRepositoryThirdPartyDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/thirdparty/delete")

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

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

	thirdPartyApplicationSlice := make([]ThirdPartyApplication, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(thirdPartyApplicationSlice); i++ {
			if hasGuiRepositoryThirdPartyLaunch {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyLaunch = "<div class='btn-group'>"
			} else {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyLaunch = "<div hidden>"
			}
			if hasGuiRepositoryThirdPartyEdit {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyEdit = "<div class='btn-group'>"
			} else {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyEdit = "<div hidden>"
			}
			if hasGuiRepositoryThirdPartyDelete {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyDelete = "<div class='btn-group'>"
			} else {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyDelete = "<div hidden>"
			}
		}

		sort.Sort(ByThirdPartyApplication(thirdPartyApplicationSlice))
		c.Data["thirdPartyApplicationSlice"] = thirdPartyApplicationSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#14
0
func (c *UpdateController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	namespaces, _ := c.GetSession("namespace").(string)

	imageInformationName := c.GetString("name")
	version := c.GetString("version")
	description := c.GetString("description")

	keySlice := make([]string, 0)
	inputMap := c.Input()
	if inputMap != nil {
		for key, _ := range inputMap {
			// Only collect environment belonging to this version
			if strings.HasPrefix(key, version) {
				keySlice = append(keySlice, key)
			}
		}
	}

	environmentSlice := make([]ReplicationControllerContainerEnvironment, 0)
	length := len(version) + 1 // + 1 for _
	for _, key := range keySlice {
		value := c.GetString(key)
		if len(value) > 0 {
			environmentSlice = append(environmentSlice,
				ReplicationControllerContainerEnvironment{key[length:], value})
		}
	}

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/deploys/update/" + namespaces

	deployUpdateInput := DeployUpdateInput{imageInformationName, version, description, environmentSlice}

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

	_, err := restclient.RequestPutWithStructure(url, deployUpdateInput, nil, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Update deploy " + imageInformationName + " to version " + version + " success")
	}

	// Redirect to list
	c.Ctx.Redirect(302, "/gui/deploy/deploy/list")

	guimessage.RedirectMessage(c)
}
示例#15
0
func (c *ListController) Get() {
	c.TplName = "deploy/deploybluegreen/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	// Tag won't work in loop so need to be placed in data
	hasGuiDeployDeployBlueGreenSelect := user.HasPermission(identity.GetConponentName(), "GET", "/gui/deploy/deploybluegreen/select")
	hasGuiDeployDeployBlueGreenDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/deploy/deploybluegreen/delete")

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

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

	deployBlueGreenSlice := make([]DeployBlueGreen, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(deployBlueGreenSlice); i++ {
			if deployBlueGreenSlice[i].NodePort == 0 {
				deployBlueGreenSlice[i].NodePortDisplay = "Auto-generated"
			} else {
				deployBlueGreenSlice[i].NodePortDisplay = strconv.Itoa(deployBlueGreenSlice[i].NodePort)
			}

			if hasGuiDeployDeployBlueGreenSelect {
				deployBlueGreenSlice[i].HiddenTagGuiDeployDeployBlueGreenSelect = "<div class='btn-group'>"
			} else {
				deployBlueGreenSlice[i].HiddenTagGuiDeployDeployBlueGreenSelect = "<div hidden>"
			}
			if hasGuiDeployDeployBlueGreenDelete {
				deployBlueGreenSlice[i].HiddenTagGuiDeployDeployBlueGreenDelete = "<div class='btn-group'>"
			} else {
				deployBlueGreenSlice[i].HiddenTagGuiDeployDeployBlueGreenDelete = "<div hidden>"
			}
		}

		sort.Sort(ByDeployBlueGreen(deployBlueGreenSlice))
		c.Data["deployBlueGreenSlice"] = deployBlueGreenSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#16
0
func (c *ListController) Get() {
	c.TplName = "filesystem/glusterfs/volume/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiFileSystemGlusterfsClusterList", user, "GET", "/gui/filesystem/glusterfs/cluster/list")
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuifFileSystemGlusterfsVolumeCreate", user, "GET", "/gui/filesystem/glusterfs/volume/create")
	// Tag won't work in loop so need to be placed in data
	hasHiddenTagGuiFileSystemGlusterfsVolumeReset := user.HasPermission(identity.GetConponentName(), "GET", "/gui/filesystem/glusterfs/volume/reset")
	hasHiddenTagGuiFileSystemGlusterfsVolumeDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/filesystem/glusterfs/volume/delete")

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

	clusterName := c.GetString("clusterName")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/glusterfs/clusters/" + clusterName + "/volumes/"

	glusterfsVolumeSlice := make([]GlusterfsVolume, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(glusterfsVolumeSlice); i++ {
			glusterfsVolumeSlice[i].ClusterName = clusterName

			if hasHiddenTagGuiFileSystemGlusterfsVolumeReset {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeReset = "<div class='btn-group'>"
			} else {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeReset = "<div hidden>"
			}
			if hasHiddenTagGuiFileSystemGlusterfsVolumeDelete {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeDelete = "<div class='btn-group'>"
			} else {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeDelete = "<div hidden>"
			}
		}

		c.Data["glusterfsVolumeSlice"] = glusterfsVolumeSlice
		c.Data["clusterName"] = clusterName
	}

	guimessage.OutputMessage(c.Data)
}
示例#17
0
func (c *EditController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	namespace, _ := c.GetSession("namespace").(string)

	selectorName := c.GetString("name")
	replicaAmount, _ := c.GetInt("replicaAmount")
	image := c.GetString("image")
	containerPort, err := c.GetInt("containerPort")

	version := ""
	name := selectorName + version

	portName := "generated"

	replicationControllerContainerPortSlice := make([]ReplicationControllerContainerPort, 0)
	replicationControllerContainerPortSlice = append(replicationControllerContainerPortSlice, ReplicationControllerContainerPort{portName, containerPort})
	replicationControllerContainerSlice := make([]ReplicationControllerContainer, 0)
	replicationControllerContainerSlice = append(replicationControllerContainerSlice, ReplicationControllerContainer{name, image, replicationControllerContainerPortSlice})
	replicationController := ReplicationController{
		name,
		replicaAmount,
		ReplicationControllerSelector{
			selectorName,
			version,
		},
		ReplicationControllerLabel{
			name,
		},
		replicationControllerContainerSlice}

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/replicationcontrollers/" + namespace

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

	_, err = restclient.RequestPostWithStructure(url, replicationController, nil, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Replication Controller " + name + " is edited")
	}

	c.Ctx.Redirect(302, "/gui/inventory/replicationcontroller/list")

	guimessage.RedirectMessage(c)
}
示例#18
0
func (c *ListController) Get() {
	c.TplName = "system/privateregistry/image/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	serverName := c.GetString("serverName")
	repositoryName := c.GetString("repositoryName")

	c.Data["serverName"] = serverName

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiSystemPrivateRegistryRepositoryList", user, "GET", "/gui/system/privateregistry/repository/list")
	// Tag won't work in loop so need to be placed in data
	hasGuiSystemPrivateRegistryImageDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/privateregistry/image/delete")

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

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/privateregistries/servers/" + serverName + "/repositories/" + repositoryName + "/tags/"

	tagSlice := make([]string, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		imageSlice := make([]Image, 0)
		for _, tag := range tagSlice {
			imageSlice = append(imageSlice, Image{tag, serverName, repositoryName, ""})
		}

		for i := 0; i < len(imageSlice); i++ {
			if hasGuiSystemPrivateRegistryImageDelete {
				imageSlice[i].HiddenTagGuiSystemPrivateRegistryImageDelete = "<div class='btn-group'>"
			} else {
				imageSlice[i].HiddenTagGuiSystemPrivateRegistryImageDelete = "<div hidden>"
			}
		}

		sort.Sort(ByImage(imageSlice))
		c.Data["imageSlice"] = imageSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#19
0
func (c *ListController) Get() {
	c.TplName = "system/rbac/role/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// System RBAC tab menu
	user, _ := c.GetSession("user").(*rbac.User)
	c.Data["systemRBACTabMenu"] = identity.GetSystemRBACTabMenu(user, "role")
	// Authorization for Button
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiSystemRBACRoleEdit", user, "GET", "/gui/system/rbac/role/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiSystemRBACRoleEdit := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/rbac/role/edit")
	hasGuiSystemRBACRoleDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/rbac/role/delete")

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

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/authorizations/roles"

	simplifiedRoleSlice := make([]SimplifiedRole, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(simplifiedRoleSlice); i++ {
			if hasGuiSystemRBACRoleEdit {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleEdit = "<div class='btn-group'>"
			} else {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleEdit = "<div hidden>"
			}
			if hasGuiSystemRBACRoleDelete {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleDelete = "<div class='btn-group'>"
			} else {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleDelete = "<div hidden>"
			}
		}

		sort.Sort(BySimplifiedRole(simplifiedRoleSlice))
		c.Data["simplifiedRoleSlice"] = simplifiedRoleSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#20
0
func (c *SizeController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	namespace, _ := c.GetSession("namespace").(string)

	name := c.GetString("name")
	size := c.GetString("size")

	keySlice := make([]string, 0)
	inputMap := c.Input()
	if inputMap != nil {
		for key, _ := range inputMap {
			keySlice = append(keySlice, key)
		}
	}

	environmentSlice := make([]interface{}, 0)
	for _, key := range keySlice {
		value := c.GetString(key)
		if len(value) > 0 {
			environmentMap := make(map[string]string)
			environmentMap["name"] = key
			environmentMap["value"] = value
			environmentSlice = append(environmentSlice, environmentMap)
		}
	}

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/deployclusterapplications/size/" + namespace + "/" + name + "?size=" + size

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

	_, err := restclient.RequestPut(url, environmentSlice, tokenHeaderMap, true)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Cluster application " + name + " is resized")
	}

	c.Ctx.Redirect(302, "/gui/deploy/deployclusterapplication/list")

	guimessage.RedirectMessage(c)
}
示例#21
0
func (c *EditController) Get() {
	c.TplName = "system/privateregistry/server/edit.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	serverName := c.GetString("serverName")

	if serverName == "" {
		c.Data["actionButtonValue"] = "Create"
		c.Data["pageHeader"] = "Create Server Configuration"
		c.Data["createOrUpdate"] = "create"
	} else {
		cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
		cloudoneHost := beego.AppConfig.String("cloudoneHost")
		cloudonePort := beego.AppConfig.String("cloudonePort")

		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
			"/api/v1/privateregistries/servers/" + serverName

		privateRegistry := PrivateRegistry{}

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

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

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

		if err != nil {
			// Error
			guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
			guimessage.OutputMessage(c.Data)
			return
		}

		c.Data["actionButtonValue"] = "Update"
		c.Data["pageHeader"] = "Update Server Configuration"
		c.Data["createOrUpdate"] = "update"

		c.Data["name"] = privateRegistry.Name
		c.Data["host"] = privateRegistry.Host
		c.Data["port"] = privateRegistry.Port

		c.Data["nameFieldReadOnly"] = "readonly"
	}

	guimessage.OutputMessage(c.Data)
}
示例#22
0
func (c *IndexController) Get() {
	c.TplName = "monitor/container/index.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

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

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

	namespaces, _ := c.GetSession("namespace").(string)

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/replicationcontrollers/" + namespaces

	jsonMapSlice := make([]interface{}, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		replicationControllerNameSlice := make([]string, 0)
		replicationControllerNameSlice = append(replicationControllerNameSlice, allKeyword)

		for _, jsonMap := range jsonMapSlice {
			name, _ := jsonMap.(map[string]interface{})["Name"].(string)
			if name != "" {
				replicationControllerNameSlice = append(replicationControllerNameSlice, name)
			}
		}

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

	guimessage.OutputMessage(c.Data)
}
示例#23
0
func (c *CreateController) Get() {
	c.TplName = "filesystem/glusterfs/volume/create.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

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

	clusterName := c.GetString("clusterName")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/glusterfs/clusters/" + clusterName

	glusterfsCluster := cluster.GlusterfsCluster{}

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		hostList := ""
		length := len(glusterfsCluster.HostSlice)
		for index, host := range glusterfsCluster.HostSlice {
			if index == length-1 {
				hostList += host
			} else {
				hostList += host + ","
			}
		}

		c.Data["hostSlice"] = glusterfsCluster.HostSlice
		c.Data["clusterName"] = clusterName
		c.Data["hostList"] = hostList
	}

	guimessage.OutputMessage(c.Data)
}
示例#24
0
func (c *SelectController) Get() {
	c.TplName = "deploy/clone/select.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)

	currentNamespace, _ := c.GetSession("namespace").(string)

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

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

	nameSlice := make([]string, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
		guimessage.OutputMessage(c.Data)
		return
	}

	namespaceSlice := make([]string, 0)
	for _, name := range nameSlice {
		if user.HasResource(identity.GetConponentName(), "/namespaces/"+name) {
			namespaceSlice = append(namespaceSlice, name)
		}
	}

	c.Data["currentNamespace"] = currentNamespace
	c.Data["namespaceSlice"] = namespaceSlice

	guimessage.OutputMessage(c.Data)

}
示例#25
0
func (c *SelectController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	imageInformation := c.GetString("imageInformation")
	namespace := c.GetString("namespace")
	nodePort, _ := c.GetInt("nodePort")
	description := c.GetString("description")
	sessionAffinity := c.GetString("sessionAffinity")

	deployBlueGreen := DeployBlueGreen{
		imageInformation,
		namespace,
		nodePort,
		description,
		sessionAffinity,
		"",
		"",
		"",
	}

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

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

	_, err := restclient.RequestPutWithStructure(url, deployBlueGreen, nil, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Create blue green deployment " + imageInformation + " success")
	}

	c.Ctx.Redirect(302, "/gui/deploy/deploybluegreen/list")

	guimessage.RedirectMessage(c)
}
示例#26
0
func (c *CreateController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	name := c.GetString("name")
	account := c.GetString("account")
	password := c.GetString("password")
	host := c.GetString("host")
	port, _ := c.GetInt("port")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/notifiers/emailserversmtp/"

	emailServerSMTP := EmailServerSMTP{
		name,
		account,
		password,
		host,
		port,
		"",
	}

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

	_, err := restclient.RequestPostWithStructure(url, emailServerSMTP, nil, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Email server configuration " + name + " is created")
	}

	c.Ctx.Redirect(302, "/gui/system/notification/emailserver/list")

	guimessage.RedirectMessage(c)
}
示例#27
0
func (c *CreateController) Get() {
	c.TplName = "repository/imageinformation/create.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

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

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/privateregistries/servers/"

	privateRegistrySlice := make([]PrivateRegistry, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
		guimessage.RedirectMessage(c)
		c.Ctx.Redirect(302, "/gui/repository/imageinformation/list")
		return
	}

	if len(privateRegistrySlice) == 0 {
		guimessage.AddWarning("At least one private registry is required. Please configure it in system.")
		guimessage.RedirectMessage(c)
		c.Ctx.Redirect(302, "/gui/repository/imageinformation/list")
		return
	}

	c.Data["privateRegistrySlice"] = privateRegistrySlice

	guimessage.OutputMessage(c.Data)
}
示例#28
0
func (c *CreateController) Post() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

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

	name := c.GetString("name")
	urlPath := c.GetString("url")
	apiKey := c.GetString("apiKey")
	apiSecret := c.GetString("apiSecret")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/notifiers/smsnexmo/"

	smsNexmo := SMSNexmo{
		name,
		urlPath,
		apiKey,
		apiSecret,
		"",
	}

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

	_, err := restclient.RequestPostWithStructure(url, smsNexmo, nil, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("SMS configuration " + name + " is created")
	}

	c.Ctx.Redirect(302, "/gui/system/notification/sms/list")

	guimessage.RedirectMessage(c)
}
示例#29
0
func (c *AcknowledgeController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)

	namespace := c.GetString("namespace")
	id := c.GetString("id")
	acknowledge := c.GetString("acknowledge")

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

	url := cloudoneAnalysisProtocol + "://" + cloudoneAnalysisHost + ":" + cloudoneAnalysisPort +
		"/api/v1/historicalevents/" + namespace + "/" + id + "?acknowledge=" + acknowledge

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

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

	_, err := restclient.RequestPutWithStructure(url, nil, &jsonMapSlice, tokenHeaderMap)

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		guimessage.AddSuccess("Acknowledged event")
	}

	if acknowledge == "true" {
		c.Ctx.Redirect(302, "/gui/event/kubernetes/list?acknowledge=false")
	} else {
		c.Ctx.Redirect(302, "/gui/event/kubernetes/list?acknowledge=true")
	}

	guimessage.RedirectMessage(c)
}
示例#30
0
func (c *LogController) Get() {
	c.TplName = "repository/imagerecord/log.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	imageInformation := c.GetString("imageInformation")
	version := c.GetString("version")

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

	url := cloudoneAnalysisProtocol + "://" + cloudoneAnalysisHost + ":" + cloudoneAnalysisPort +
		"/api/v1/buildlogs/" + imageInformation + "/" + version

	buildLog := build.BuildLog{}

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		c.Data["log"] = buildLog.Content
	}

	c.Data["imageInformation"] = imageInformation

	guimessage.OutputMessage(c.Data)
}