Пример #1
0
func (c *DataController) Get() {
	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
		c.Data["json"].(map[string]interface{})["error"] = err.Error()
		c.ServeJSON()
		return
	}

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

	deployInformationSlice := make([]DeployInformation, 0)

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

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

	if err != nil {
		// Error
		c.Data["json"].(map[string]interface{})["error"] = err.Error()
		c.ServeJSON()
		return
	}

	deployInformationMap := make(map[string]DeployInformation)
	for _, deployInformation := range deployInformationSlice {
		deployInformationMap[deployInformation.ImageInformationName+"-"+deployInformation.Namespace] = deployInformation
	}

	// Json
	c.Data["json"] = make(map[string]interface{})
	c.Data["json"].(map[string]interface{})["bluegreenView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["errorMap"] = make(map[string]interface{})

	bluegreenJsonMap := make(map[string]interface{})
	bluegreenJsonMap["name"] = "B/G View"
	bluegreenJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["bluegreenView"] = append(c.Data["json"].(map[string]interface{})["bluegreenView"].([]interface{}), bluegreenJsonMap)

	leafAmount := 0
	for _, deployBlueGreen := range deployBlueGreenSlice {
		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
			"/api/v1/deploybluegreens/deployable/" + deployBlueGreen.ImageInformation

		namespaceSlice := make([]string, 0)

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

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

		if err != nil {
			c.Data["json"].(map[string]interface{})["error"] = "Get deployable namespace data error"
			c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[deployBlueGreen.ImageInformation] = err.Error()
		} else {
			blueGreenJsonMap := make(map[string]interface{})
			blueGreenJsonMap["name"] = deployBlueGreen.ImageInformation
			blueGreenJsonMap["color"] = dashboard.TextColorBlueGreen
			blueGreenJsonMap["children"] = make([]interface{}, 0)
			for _, namespace := range namespaceSlice {
				deployInformation := deployInformationMap[deployBlueGreen.ImageInformation+"-"+namespace]
				if deployInformation.CurrentVersion == "" {
					c.Data["json"].(map[string]interface{})["error"] = "Get deployInformation data error"
					errorMessage, _ := c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[deployBlueGreen.ImageInformation].(string)
					c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[deployBlueGreen.ImageInformation] = errorMessage + " Get deployInformation data from namespace " + namespace + " error"
				} else {
					namespaceJsonMap := make(map[string]interface{})
					namespaceJsonMap["name"] = namespace
					namespaceJsonMap["color"] = dashboard.TextColorNamespace
					namespaceJsonMap["children"] = make([]interface{}, 0)
					deployInformationJsonMap := make(map[string]interface{})
					deployInformationJsonMap["name"] = deployInformation.CurrentVersion + " " + deployInformation.CurrentVersionDescription
					deployInformationJsonMap["color"] = dashboard.TextColorDeployInformation
					if namespace == deployBlueGreen.Namespace {
						deployInformationJsonMap["children"] = make([]interface{}, 0)
						nodePortJsonMap := make(map[string]interface{})
						nodePortJsonMap["name"] = "bg_" + deployBlueGreen.ImageInformation + " " + strconv.Itoa(deployBlueGreen.NodePort)
						nodePortJsonMap["color"] = dashboard.TextColorPort
						deployInformationJsonMap["children"] = append(deployInformationJsonMap["children"].([]interface{}), nodePortJsonMap)
					}
					namespaceJsonMap["children"] = append(namespaceJsonMap["children"].([]interface{}), deployInformationJsonMap)
					blueGreenJsonMap["children"] = append(blueGreenJsonMap["children"].([]interface{}), namespaceJsonMap)
				}
				leafAmount++
			}
			bluegreenJsonMap["children"] = append(bluegreenJsonMap["children"].([]interface{}), blueGreenJsonMap)
		}
	}
	c.Data["json"].(map[string]interface{})["leafAmount"] = leafAmount

	dashboard.RecursiveSortTheDataInGraphJsonMap(c.Data["json"].(map[string]interface{}))

	c.ServeJSON()
}
Пример #2
0
func (c *DataController) Get() {
	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

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

	namespaceSlice := make([]string, 0)
	if scope == allKeyword {
		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort + "/api/v1/namespaces/"

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

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

		if err != nil {
			c.Data["json"].(map[string]interface{})["error"] = err.Error()
			c.ServeJSON()
			return
		}
	} else {
		namespace, _ := c.GetSession("namespace").(string)
		namespaceSlice = append(namespaceSlice, namespace)
	}

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

	deployInformationSlice := make([]DeployInformation, 0)

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

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

	if err != nil {
		c.Data["json"].(map[string]interface{})["error"] = err.Error()
		c.ServeJSON()
		return
	}

	// Json
	c.Data["json"] = make(map[string]interface{})
	c.Data["json"].(map[string]interface{})["applicationlView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["thirdpartyView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["errorMap"] = make(map[string]interface{})

	// Application view
	applicationJsonMap := make(map[string]interface{})
	applicationJsonMap["name"] = "App View"
	applicationJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["applicationlView"] = append(c.Data["json"].(map[string]interface{})["applicationlView"].([]interface{}), applicationJsonMap)

	// Third-party view
	thirdpartyJsonMap := make(map[string]interface{})
	thirdpartyJsonMap["name"] = "3rd Party View"
	thirdpartyJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["thirdpartyView"] = append(c.Data["json"].(map[string]interface{})["thirdpartyView"].([]interface{}), thirdpartyJsonMap)

	applicationViewLeafAmount := 0
	thirdpartyViewLeafAmount := 0
	for _, namespace := range namespaceSlice {
		// Application view
		applicationNamespaceJsonMap := make(map[string]interface{})
		applicationNamespaceJsonMap["name"] = namespace
		applicationNamespaceJsonMap["color"] = dashboard.TextColorNamespace
		applicationNamespaceJsonMap["children"] = make([]interface{}, 0)

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

		serviceSlice := make([]Service, 0)

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

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

		if err != nil {
			// Error
			c.Data["json"].(map[string]interface{})["error"] = "Get service data error"
			c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[namespace] = err.Error()
		} else {
			url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
				"/api/v1/replicationcontrollers/" + namespace

			replicationControllerAndRelatedPodSlice := make([]ReplicationControllerAndRelatedPod, 0)

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

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

			if err != nil {
				// Error
				c.Data["json"].(map[string]interface{})["error"] = "Get replication controller data error"
				c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[namespace] = err.Error()
			} else {
				namespaceOwnAmount := 0
				for _, deployInformation := range deployInformationSlice {
					if namespace == deployInformation.Namespace {
						namespaceOwnAmount++

						serviceName := "NO SERVICE"
						for _, service := range serviceSlice {
							if deployInformation.ImageInformationName == service.Name {
								serviceName = service.Name
								for _, port := range service.PortSlice {
									nodePortText := ""
									if port.NodePort >= 0 {
										nodePortText = strconv.Itoa(port.NodePort)
									}
									serviceName += " " + strconv.Itoa(port.Port) + "/" + nodePortText
								}
							}
						}

						serviceJsonMap := make(map[string]interface{})
						serviceJsonMap["name"] = serviceName
						serviceJsonMap["color"] = dashboard.TextColorService
						serviceJsonMap["children"] = make([]interface{}, 0)

						applicationNameJsonMap := make(map[string]interface{})
						applicationNameJsonMap["children"] = make([]interface{}, 0)

						instanceAmount := 0
						for _, replicationControllerAndRelatedPod := range replicationControllerAndRelatedPodSlice {
							if deployInformation.ImageInformationName+deployInformation.CurrentVersion == replicationControllerAndRelatedPod.Name {
								instanceAmount = replicationControllerAndRelatedPod.ReplicaAmount
								replicationControllerJsonMap := make(map[string]interface{})
								replicationControllerJsonMap["name"] = replicationControllerAndRelatedPod.Name + " (" + strconv.Itoa(instanceAmount) + ")"
								replicationControllerJsonMap["color"] = dashboard.TextColorReplicationController
								replicationControllerJsonMap["children"] = make([]interface{}, 0)
								applicationNameJsonMap["children"] = append(applicationNameJsonMap["children"].([]interface{}), replicationControllerJsonMap)
								applicationViewLeafAmount++
							}
						}

						applicationNameJsonMap["name"] = deployInformation.ImageInformationName + " (" + strconv.Itoa(instanceAmount) + ")"
						applicationNameJsonMap["color"] = dashboard.TextColorDeployInformation
						serviceJsonMap["children"] = append(serviceJsonMap["children"].([]interface{}), applicationNameJsonMap)
						applicationNamespaceJsonMap["children"] = append(applicationNamespaceJsonMap["children"].([]interface{}), serviceJsonMap)
					}
				}

				if namespaceOwnAmount == 0 {
					applicationViewLeafAmount++
				}

				applicationJsonMap["children"] = append(applicationJsonMap["children"].([]interface{}), applicationNamespaceJsonMap)
			}
		}

		// Third-party view
		thirdpartyNamespaceJsonMap := make(map[string]interface{})
		thirdpartyNamespaceJsonMap["name"] = namespace
		thirdpartyNamespaceJsonMap["color"] = dashboard.TextColorNamespace
		thirdpartyNamespaceJsonMap["children"] = make([]interface{}, 0)

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

		deployClusterApplicationSlice := make([]DeployClusterApplication, 0)

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

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

		if err != nil {
			// Error
			c.Data["json"].(map[string]interface{})["error"] = "Get third party application data error"
			c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[namespace] = err.Error()
		} else {
			for _, deployClusterApplication := range deployClusterApplicationSlice {

				serviceName := deployClusterApplication.ServiceName
				for _, service := range serviceSlice {
					if service.Name == deployClusterApplication.ServiceName {
						for _, port := range service.PortSlice {
							nodePortText := ""
							if port.NodePort >= 0 {
								nodePortText = strconv.Itoa(port.NodePort)
							}
							serviceName += " " + strconv.Itoa(port.Port) + "/" + nodePortText
						}
					}
				}

				serviceJsonMap := make(map[string]interface{})
				serviceJsonMap["name"] = serviceName
				serviceJsonMap["color"] = dashboard.TextColorService
				serviceJsonMap["children"] = make([]interface{}, 0)

				thirdpartyNameJsonMap := make(map[string]interface{})
				thirdpartyNameJsonMap["name"] = deployClusterApplication.Name + " (" + strconv.Itoa(deployClusterApplication.Size) + ")"
				thirdpartyNameJsonMap["color"] = dashboard.TextColorDeployClusterApplication
				thirdpartyNameJsonMap["children"] = make([]interface{}, 0)

				replicationControllerNameAmount := len(deployClusterApplication.ReplicationControllerNameSlice)
				for _, replicationControllerName := range deployClusterApplication.ReplicationControllerNameSlice {
					replicationControllerJsonMap := make(map[string]interface{})
					replicationControllerJsonMap["name"] = replicationControllerName + " (" + strconv.Itoa(deployClusterApplication.Size/replicationControllerNameAmount) + ")"
					replicationControllerJsonMap["color"] = dashboard.TextColorReplicationController
					replicationControllerJsonMap["children"] = make([]interface{}, 0)
					thirdpartyNameJsonMap["children"] = append(thirdpartyNameJsonMap["children"].([]interface{}), replicationControllerJsonMap)
					thirdpartyViewLeafAmount++
				}

				serviceJsonMap["children"] = append(serviceJsonMap["children"].([]interface{}), thirdpartyNameJsonMap)
				thirdpartyNamespaceJsonMap["children"] = append(thirdpartyNamespaceJsonMap["children"].([]interface{}), serviceJsonMap)
			}
			if len(deployClusterApplicationSlice) == 0 {
				thirdpartyViewLeafAmount++
			}
			thirdpartyJsonMap["children"] = append(thirdpartyJsonMap["children"].([]interface{}), thirdpartyNamespaceJsonMap)
		}
	}
	c.Data["json"].(map[string]interface{})["applicationViewLeafAmount"] = applicationViewLeafAmount
	c.Data["json"].(map[string]interface{})["thirdpartyViewLeafAmount"] = thirdpartyViewLeafAmount

	dashboard.RecursiveSortTheDataInGraphJsonMap(c.Data["json"].(map[string]interface{}))

	c.ServeJSON()
}
Пример #3
0
func (c *DataController) Get() {
	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	scope := c.GetString("scope")

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

	namespaceSlice := make([]string, 0)
	if scope == allKeyword {
		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort + "/api/v1/namespaces/"
		_, err := restclient.RequestGetWithStructure(url, &namespaceSlice, tokenHeaderMap)

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

		if err != nil {
			c.Data["json"].(map[string]interface{})["error"] = err.Error()
			c.ServeJSON()
			return
		}
	} else {
		namespace, _ := c.GetSession("namespace").(string)
		namespaceSlice = append(namespaceSlice, namespace)
	}

	// Json
	c.Data["json"] = make(map[string]interface{})
	c.Data["json"].(map[string]interface{})["logicalView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["physicalView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["errorMap"] = make(map[string]interface{})

	// Logical view
	logicalTopologyJsonMap := make(map[string]interface{})
	logicalTopologyJsonMap["name"] = "Logical View"
	logicalTopologyJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["logicalView"] = append(c.Data["json"].(map[string]interface{})["logicalView"].([]interface{}), logicalTopologyJsonMap)

	// Physical view
	physicalTopologyJsonMap := make(map[string]interface{})
	physicalTopologyJsonMap["name"] = "Physical View"
	physicalTopologyJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["physicalView"] = append(c.Data["json"].(map[string]interface{})["physicalView"].([]interface{}), physicalTopologyJsonMap)

	leafAmount := 0
	for _, namespace := range namespaceSlice {
		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort + "/api/v1/replicationcontrollers/" + namespace

		replicationControllerAndRelatedPodSlice := make([]ReplicationControllerAndRelatedPod, 0)

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

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

		if err != nil {
			c.Data["json"].(map[string]interface{})["error"] = "Get replication controller data error"
			c.Data["json"].(map[string]interface{})["errorMap"].(map[string]interface{})[namespace] = err.Error()
		} else {
			// Logical view
			logicalTopologyNamespaceJsonMap := make(map[string]interface{})
			logicalTopologyNamespaceJsonMap["name"] = namespace
			logicalTopologyNamespaceJsonMap["color"] = dashboard.TextColorNamespace
			logicalTopologyNamespaceJsonMap["children"] = make([]interface{}, 0)
			for _, replicationControllerAndRelatedPod := range replicationControllerAndRelatedPodSlice {
				replicationControllerJsonMap := make(map[string]interface{})
				replicationControllerJsonMap["name"] = replicationControllerAndRelatedPod.Name
				replicationControllerJsonMap["color"] = dashboard.TextColorReplicationController
				replicationControllerJsonMap["children"] = make([]interface{}, 0)
				for _, pod := range replicationControllerAndRelatedPod.PodSlice {
					podJsonMap := make(map[string]interface{})
					podJsonMap["name"] = pod.Name
					podJsonMap["color"] = dashboard.TextColorPod
					podJsonMap["children"] = make([]interface{}, 0)
					for _, container := range pod.ContainerSlice {
						containerJsonMap := make(map[string]interface{})
						containerJsonMap["name"] = container.Name
						containerJsonMap["color"] = dashboard.TextColorContainer
						containerJsonMap["children"] = make([]interface{}, 0)
						for _, port := range container.PortSlice {
							portJsonMap := make(map[string]interface{})
							portJsonMap["name"] = port.Name + " " + port.Protocol + " " + strconv.Itoa(port.ContainerPort)
							portJsonMap["color"] = dashboard.TextColorPort
							containerJsonMap["children"] = append(containerJsonMap["children"].([]interface{}), portJsonMap)
							leafAmount++
						}
						podJsonMap["children"] = append(podJsonMap["children"].([]interface{}), containerJsonMap)
					}
					replicationControllerJsonMap["children"] = append(replicationControllerJsonMap["children"].([]interface{}), podJsonMap)
				}
				logicalTopologyNamespaceJsonMap["children"] = append(logicalTopologyNamespaceJsonMap["children"].([]interface{}), replicationControllerJsonMap)
			}
			// Collect all nodes
			nodeMap := make(map[string]bool)
			for _, replicationControllerAndRelatedPod := range replicationControllerAndRelatedPodSlice {
				for _, pod := range replicationControllerAndRelatedPod.PodSlice {
					nodeMap[pod.HostIP] = true
				}
			}
			// Physical view
			for node, _ := range nodeMap {
				exist := false
				nodeJsonMap := make(map[string]interface{})
				for _, existingNodeJsonMap := range physicalTopologyJsonMap["children"].([]interface{}) {
					if existingNodeJsonMap.(map[string]interface{})["name"] == node {
						nodeJsonMap = existingNodeJsonMap.(map[string]interface{})
						exist = true
						break
					}
				}

				if exist == false {
					nodeJsonMap["name"] = node
					nodeJsonMap["color"] = dashboard.TextColorNode
					nodeJsonMap["children"] = make([]interface{}, 0)
				}

				for _, replicationControllerAndRelatedPod := range replicationControllerAndRelatedPodSlice {
					for _, pod := range replicationControllerAndRelatedPod.PodSlice {
						if pod.HostIP == node {
							podJsonMap := make(map[string]interface{})
							podJsonMap["name"] = pod.Name
							podJsonMap["color"] = dashboard.TextColorPod
							podJsonMap["children"] = make([]interface{}, 0)
							for _, container := range pod.ContainerSlice {
								containerJsonMap := make(map[string]interface{})
								containerJsonMap["name"] = container.Name
								containerJsonMap["color"] = dashboard.TextColorContainer
								containerJsonMap["children"] = make([]interface{}, 0)
								for _, port := range container.PortSlice {
									portJsonMap := make(map[string]interface{})
									portJsonMap["name"] = port.Name + " " + port.Protocol + " " + strconv.Itoa(port.ContainerPort)
									portJsonMap["color"] = dashboard.TextColorPort
									containerJsonMap["children"] = append(containerJsonMap["children"].([]interface{}), portJsonMap)
								}
								podJsonMap["children"] = append(podJsonMap["children"].([]interface{}), containerJsonMap)
							}
							nodeJsonMap["children"] = append(nodeJsonMap["children"].([]interface{}), podJsonMap)
						}
					}
				}
				if exist == false {
					physicalTopologyJsonMap["children"] = append(physicalTopologyJsonMap["children"].([]interface{}), nodeJsonMap)
				}
			}

			logicalTopologyJsonMap["children"] = append(logicalTopologyJsonMap["children"].([]interface{}), logicalTopologyNamespaceJsonMap)
		}
	}
	c.Data["json"].(map[string]interface{})["leafAmount"] = leafAmount

	dashboard.RecursiveSortTheDataInGraphJsonMap(c.Data["json"].(map[string]interface{}))

	c.ServeJSON()
}
Пример #4
0
func (c *DataController) Get() {
	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	// Json
	c.Data["json"] = make(map[string]interface{})
	c.Data["json"].(map[string]interface{})["applicationView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["thirdpartyView"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["errorMap"] = make(map[string]interface{})

	// Application view
	applicationJsonMap := make(map[string]interface{})
	applicationJsonMap["name"] = "App View"
	applicationJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["applicationView"] = append(c.Data["json"].(map[string]interface{})["applicationView"].([]interface{}), applicationJsonMap)

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

	deployInformationSlice := make([]DeployInformation, 0)

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

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

	if err != nil {
		c.Data["json"].(map[string]interface{})["error"] = err.Error()
		c.ServeJSON()
		return
	}

	deployInformationMap := make(map[string][]DeployInformation)
	for _, deployInformation := range deployInformationSlice {
		if deployInformationMap[deployInformation.ImageInformationName] == nil {
			deployInformationMap[deployInformation.ImageInformationName] = make([]DeployInformation, 0)
		}
		deployInformationMap[deployInformation.ImageInformationName] = append(deployInformationMap[deployInformation.ImageInformationName], deployInformation)
	}

	applicationViewLeafAmount := 0
	for key, deployInformationSlice := range deployInformationMap {
		deployInformationJsonMap := make(map[string]interface{})
		deployInformationJsonMap["name"] = key
		deployInformationJsonMap["color"] = dashboard.TextColorDeployInformation
		deployInformationJsonMap["children"] = make([]interface{}, 0)

		for _, deployInformation := range deployInformationSlice {
			namespaceJsonMap := make(map[string]interface{})
			namespaceJsonMap["name"] = deployInformation.Namespace + " (" + strconv.Itoa(deployInformation.ReplicaAmount) + ")"
			namespaceJsonMap["color"] = dashboard.TextColorNamespace
			namespaceJsonMap["children"] = make([]interface{}, 0)

			versionJsonMap := make(map[string]interface{})
			versionJsonMap["name"] = deployInformation.CurrentVersion + " " + deployInformation.CurrentVersionDescription
			versionJsonMap["color"] = dashboard.TextColorVersion
			versionJsonMap["children"] = make([]interface{}, 0)

			namespaceJsonMap["children"] = append(namespaceJsonMap["children"].([]interface{}), versionJsonMap)
			deployInformationJsonMap["children"] = append(deployInformationJsonMap["children"].([]interface{}), namespaceJsonMap)
		}

		applicationJsonMap["children"] = append(applicationJsonMap["children"].([]interface{}), deployInformationJsonMap)
		applicationViewLeafAmount += 1
	}

	// Third-party view
	thirdpartyJsonMap := make(map[string]interface{})
	thirdpartyJsonMap["name"] = "3rd party View"
	thirdpartyJsonMap["children"] = make([]interface{}, 0)
	c.Data["json"].(map[string]interface{})["thirdpartyView"] = append(c.Data["json"].(map[string]interface{})["thirdpartyView"].([]interface{}), thirdpartyJsonMap)

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

	deployClusterApplicationSlice := make([]DeployClusterApplication, 0)

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

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

	if err != nil {
		c.Data["json"].(map[string]interface{})["error"] = err.Error()
		c.ServeJSON()
		return
	}

	deployClusterApplicationMap := make(map[string][]DeployClusterApplication)
	for _, deployClusterApplication := range deployClusterApplicationSlice {
		if deployClusterApplicationMap[deployClusterApplication.Name] == nil {
			deployClusterApplicationMap[deployClusterApplication.Name] = make([]DeployClusterApplication, 0)
		}
		deployClusterApplicationMap[deployClusterApplication.Name] = append(deployClusterApplicationMap[deployClusterApplication.Name], deployClusterApplication)
	}

	thirdpartyViewLeafAmount := 0
	for deployClusterApplicationName, deployClusterApplicationSlice := range deployClusterApplicationMap {
		deployClusterApplicationJsonMap := make(map[string]interface{})
		deployClusterApplicationJsonMap["name"] = deployClusterApplicationName
		deployClusterApplicationJsonMap["color"] = dashboard.TextColorDeployClusterApplication
		deployClusterApplicationJsonMap["children"] = make([]interface{}, 0)

		for _, deployClusterApplication := range deployClusterApplicationSlice {
			namespaceJsonMap := make(map[string]interface{})
			namespaceJsonMap["name"] = deployClusterApplication.Namespace + " (" + strconv.Itoa(deployClusterApplication.Size) + ")"
			namespaceJsonMap["color"] = dashboard.TextColorNamespace
			namespaceJsonMap["children"] = make([]interface{}, 0)

			// Retrieve environment
			glusterfsEndpoint := ""
			glusterfsPathList := ""
			for _, environment := range deployClusterApplication.EnvironmentSlice {
				environmentJsonMap, _ := environment.(map[string]interface{})
				name, _ := environmentJsonMap["name"].(string)
				value, _ := environmentJsonMap["value"].(string)

				if name == "GLUSTERFS_ENDPOINTS" {
					glusterfsEndpoint = value
				} else if name == "GLUSTERFS_PATH_LIST" {
					glusterfsPathList = value
				}
			}

			// Glusterfs
			glusterfsPathSlice := make([]string, 0)
			if len(glusterfsEndpoint) > 0 && len(glusterfsPathList) > 0 {
				glusterfsPathSplits := strings.Split(glusterfsPathList, ",")
				for _, glusterfsPathSplit := range glusterfsPathSplits {
					glusterfsPathSlice = append(glusterfsPathSlice, strings.TrimSpace(glusterfsPathSplit))
				}
			}

			for _, replicationControllerName := range deployClusterApplication.ReplicationControllerNameSlice {
				replicationControllerNameJsonMap := make(map[string]interface{})
				replicationControllerNameJsonMap["name"] = replicationControllerName
				replicationControllerNameJsonMap["color"] = dashboard.TextColorReplicationController
				replicationControllerNameJsonMap["children"] = make([]interface{}, 0)

				// Glusterfs
				if len(glusterfsPathSlice) > 0 {
					nameSplits := strings.Split(replicationControllerName, "-")
					index, err := strconv.Atoi(nameSplits[len(nameSplits)-1])
					if err == nil && index < len(glusterfsPathSlice) {
						glusterfsJsonMap := make(map[string]interface{})
						glusterfsJsonMap["name"] = glusterfsEndpoint + " / " + glusterfsPathSlice[index]
						glusterfsJsonMap["color"] = dashboard.TextColorGlusterfs
						glusterfsJsonMap["children"] = make([]interface{}, 0)
						replicationControllerNameJsonMap["children"] = append(replicationControllerNameJsonMap["children"].([]interface{}), glusterfsJsonMap)
					}
				}

				namespaceJsonMap["children"] = append(namespaceJsonMap["children"].([]interface{}), replicationControllerNameJsonMap)

				thirdpartyViewLeafAmount += 1
			}

			deployClusterApplicationJsonMap["children"] = append(deployClusterApplicationJsonMap["children"].([]interface{}), namespaceJsonMap)
		}

		thirdpartyJsonMap["children"] = append(thirdpartyJsonMap["children"].([]interface{}), deployClusterApplicationJsonMap)
	}

	c.Data["json"].(map[string]interface{})["applicationViewLeafAmount"] = applicationViewLeafAmount
	c.Data["json"].(map[string]interface{})["thirdpartyViewLeafAmount"] = thirdpartyViewLeafAmount

	dashboard.RecursiveSortTheDataInGraphJsonMap(c.Data["json"].(map[string]interface{}))

	c.ServeJSON()
}