本文整理汇总了Golang中github.com/cloudawan/cloudone_utility/restclient.RequestGetWithStructure函数的典型用法代码示例。如果您正苦于以下问题:Golang RequestGetWithStructure函数的具体用法?Golang RequestGetWithStructure怎么用?Golang RequestGetWithStructure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RequestGetWithStructure函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Get
// @Title get
// @Description get all services
// @Success 200 {string} []Service
// @Failure 404 error reason
// @router / [get]
func (c *ListController) Get() {
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
namespace := c.GetSession("namespace").(string)
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/services/" + namespace
serviceSlice := make([]Service, 0)
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestGetWithStructure(url, &serviceSlice, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
c.Data["json"] = serviceSlice
c.ServeJSON()
}
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:37,代码来源:list.go
示例2: Get
// @Title get
// @Description get the autoscaler
// @Param kind path string true "The type of target autoscaler configured for"
// @Param name path string true "The name of target autoscaler configured for"
// @Success 200 {object} guirestapi.deploy.autoscaler.ReplicationControllerAutoScaler
// @Failure 404 error reason
// @router /:kind/:name [get]
func (c *EditController) Get() {
kind := c.GetString(":kind")
name := c.GetString(":name")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
namespace, _ := c.GetSession("namespace").(string)
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/autoscalers/" + namespace + "/" + kind + "/" + name
replicationControllerAutoScaler := ReplicationControllerAutoScaler{}
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestGetWithStructure(url, &replicationControllerAutoScaler, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
c.Data["json"] = replicationControllerAutoScaler
c.ServeJSON()
}
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:42,代码来源:edit.go
示例3: Get
// @Title get
// @Description get the cluster application template
// @Param name path string true "The name of cluster application template"
// @Success 200 {object} guirestapi.repository.thirdparty.Cluster
// @Failure 404 error reason
// @router /launchinformation/:name [get]
func (c *LaunchController) Get() {
name := c.GetString("name")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/clusterapplications/" + name
cluster := Cluster{}
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestGetWithStructure(url, &cluster, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
c.Data["json"] = cluster
c.ServeJSON()
}
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:37,代码来源:launch.go
示例4: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:60,代码来源:edit.go
示例5: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:59,代码来源:list.go
示例6: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:58,代码来源:list.go
示例7: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:58,代码来源:list.go
示例8: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:57,代码来源:list.go
示例9: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:55,代码来源:list.go
示例10: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:51,代码来源:index.go
示例11: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:51,代码来源:edit.go
示例12: Get
// @Title get
// @Description get related information
// @Success 200 {string} {}
// @Failure 404 error reason
// @router /selectinformation [get]
func (c *IndexController) Get() {
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
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} 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["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["cloudoneGUIProtocol"] = cloudoneGUIProtocol
c.Data["json"].(map[string]interface{})["cloudoneGUIHost"] = cloudoneGUIHost
c.Data["json"].(map[string]interface{})["cloudoneGUIPort"] = cloudoneGUIPort
c.Data["json"].(map[string]interface{})["replicationControllerNameSlice"] = replicationControllerNameSlice
c.ServeJSON()
}
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:53,代码来源:index.go
示例13: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:47,代码来源:select.go
示例14: GetAllNodeIP
func GetAllNodeIP(kubeApiServerEndPoint string, kubeApiServerToken string) (returnedIpSlice []string, returnedError error) {
defer func() {
if err := recover(); err != nil {
log.Error("GetAllNodeIP Error: %s", err)
log.Error(logger.GetStackTrace(4096, false))
returnedIpSlice = nil
returnedError = err.(error)
}
}()
jsonMap := make(map[string]interface{})
headerMap := make(map[string]string)
headerMap["Authorization"] = kubeApiServerToken
url := kubeApiServerEndPoint + "/api/v1/nodes/"
_, err := restclient.RequestGetWithStructure(url, &jsonMap, headerMap)
if err != nil {
log.Error(err)
return nil, err
}
ipSlice := make([]string, 0)
itemSlice, _ := jsonMap["items"].([]interface{})
for _, item := range itemSlice {
itemJsonMap, _ := item.(map[string]interface{})
statusJsonMap, _ := itemJsonMap["status"].(map[string]interface{})
addressesJsonSlice, _ := statusJsonMap["addresses"].([]interface{})
address := ""
for _, value := range addressesJsonSlice {
addressJsonMap, _ := value.(map[string]interface{})
addressType, _ := addressJsonMap["type"].(string)
addressAddress, _ := addressJsonMap["address"].(string)
if addressType == "InternalIP" {
address = addressAddress
break
}
}
if len(address) > 0 {
ipSlice = append(ipSlice, address)
}
}
return ipSlice, nil
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:47,代码来源:node.go
示例15: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:47,代码来源:create.go
示例16: Get
// @Title get
// @Description get the related selection in order to create a new deployment
// @Param name path string true "The name of image record"
// @Param oldVersion query string true "The current version to be replaced"
// @Success 200 {string} {}
// @Failure 404 error reason
// @router /updateinformation/:name [get]
func (c *UpdateController) Get() {
name := c.GetString(":name")
oldVersion := c.GetString("oldVersion")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/imagerecords/" + name
imageRecordSlice := make([]ImageRecord, 0)
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestGetWithStructure(url, &imageRecordSlice, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
versionEnvironmentMap := make(map[string]map[string]string)
versionSlice := make([]string, 0)
for _, imageRecord := range imageRecordSlice {
if imageRecord.Version != oldVersion {
versionSlice = append(versionSlice, imageRecord.Version)
versionEnvironmentMap[imageRecord.Version] = imageRecord.Environment
}
}
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["name"] = name
c.Data["json"].(map[string]interface{})["versionSlice"] = versionSlice
c.Data["json"].(map[string]interface{})["versionEnvironmentMap"] = versionEnvironmentMap
c.ServeJSON()
}
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:52,代码来源:update.go
示例17: Get
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)
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:43,代码来源:create.go
示例18: getCache
func getCache(token string) (*rbac.User, error) {
// Get from cache first
user := rbac.GetCache(token)
if user == nil {
// Not exist. Ask the authorization server.
cloudoneProtocol, ok := configuration.LocalConfiguration.GetString("cloudoneProtocol")
if ok == false {
log.Error("Unable to get configuration cloudoneProtocol")
return nil, errors.New("Unable to get configuration cloudoneProtocol")
}
cloudoneHost, ok := configuration.LocalConfiguration.GetString("cloudoneHost")
if ok == false {
log.Error("Unable to get configuration cloudoneHost")
return nil, errors.New("Unable to get configuration cloudoneHost")
}
cloudonePort, ok := configuration.LocalConfiguration.GetInt("cloudonePort")
if ok == false {
log.Error("Unable to get configuration cloudonePort")
return nil, errors.New("Unable to get configuration cloudonePort")
}
url := cloudoneProtocol + "://" + cloudoneHost + ":" + strconv.Itoa(cloudonePort) +
"/api/v1/authorizations/tokens/" + token + "/components/" + componentName
user := &rbac.User{}
_, err := restclient.RequestGetWithStructure(url, &user, nil)
if err != nil {
log.Debug(err)
return nil, err
} else {
// Set Cache
rbac.SetCache(token, user, cacheTTL)
log.Info("Cache user %s", user.Name)
return user, nil
}
} else {
return user, nil
}
}
开发者ID:cloudawan,项目名称:cloudone_analysis,代码行数:41,代码来源:restapi_authorization.go
示例19: Get
// @Title get
// @Description get all deployments
// @Success 200 {string} []DeployInformation
// @Failure 404 error reason
// @router / [get]
func (c *ListController) Get() {
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
namespace, _ := c.GetSession("namespace").(string)
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deploys/" + namespace
deployInformationSlice := make([]DeployInformation, 0)
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestGetWithStructure(url, &deployInformationSlice, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
// Only show those belonging to this namespace
filteredDeployInformationSlice := make([]DeployInformation, 0)
for _, deployInformation := range deployInformationSlice {
filteredDeployInformationSlice = append(filteredDeployInformationSlice, deployInformation)
}
c.Data["json"] = filteredDeployInformationSlice
c.ServeJSON()
}
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:43,代码来源:list.go
示例20: Get
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)
}
开发者ID:cloudawan,项目名称:c |
请发表评论