當前位置: 首頁>>代碼示例>>Golang>>正文


Golang entity.Service類代碼示例

本文整理匯總了Golang中github.com/citycloud/citycloud/cf-deploy-ui/entity.Service的典型用法代碼示例。如果您正苦於以下問題:Golang Service類的具體用法?Golang Service怎麽用?Golang Service使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Service類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: List

func (this *TemplatesDetailController) List(serviceId int64) {
	service := entity.Service{}
	service.Id = serviceId
	service.Load()

	template, errs := entity.LoadTemplateList(serviceId)
	this.Data["Template"] = template

	if errs != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", errs)
	}

	component, componenterrors := entity.LoadComponentList(serviceId)

	this.Data["Component"] = component
	if componenterrors != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", componenterrors)
	}

	if service.Where == utils.Deploy_On_Vms {
		operation := entity.Operation{}
		operation.Sid = serviceId
		operationerrors := operation.LoadBySid()

		this.Data["Operation"] = operation
		if operationerrors != nil {
			this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", operationerrors)
		}
	}
	this.TplName = "templates/index_detail.tpl"
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:31,代碼來源:templates_detail.go

示例2: Deploying

func (serviceDeploy *ServiceDeployWebSocketController) Deploying(ws *websocket.Conn, serviceIds string) {
	serviceId, err := strconv.ParseInt(serviceIds, 10, 64)
	if err != nil {
		writeStringMessage(ws, fmt.Sprintf("Error ServiceId,%s", err))
		return
	}
	//加載service
	writeStringMessage(ws, "Load Service")
	service := entity.Service{}
	service.Id = serviceId
	err = service.Load()

	if err != nil {
		writeStringMessage(ws, fmt.Sprintf("Error,%s", err))
		return
	}

	switch service.Where {
	case utils.Deploy_On_PaaS:
		serviceDeploy.Deploy2PaaS(ws, service)
	case utils.Deploy_On_Vms:
		serviceDeploy.Deploy2Vms(ws, service)
	default:
		writeStringMessage(ws, fmt.Sprintf("Unknow Platform %s", service.Where))
	}
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:26,代碼來源:service_deploy_websocket.go

示例3: LoadCustomServiceDetail

func (this *TemplatesController) LoadCustomServiceDetail() {
	id, err := this.GetInt64("id", 0)
	service := entity.Service{}
	if err == nil {
		service.Id = id
		err = service.Load()
		serviceDto := entity.ServiceDto{}
		serviceDto.Service = service
		err = serviceDto.Load()
		if err == nil {
			this.Data["json"] = &serviceDto
			this.ServeJSON()
		}
	}
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:15,代碼來源:templates.go

示例4: CheckService

func (this *TemplatesDetailController) CheckService(serviceId int64) bool {

	this.Data["ServiceId"] = serviceId
	if serviceId == 0 {
		this.TplName = "templates/404.tpl"
		return false
	}
	service := entity.Service{}
	service.Id = serviceId
	loaderr := service.Load()
	if loaderr != nil {
		this.TplName = "templates/404.tpl"
		return false
	}
	this.Data["Service"] = service
	return true
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:17,代碼來源:templates_detail.go

示例5: DeleteCustomService

func (this *TemplatesController) DeleteCustomService() {
	id, err := this.GetInt64("id", 0)
	service := entity.Service{}
	if err == nil && id != 0 {
		service.Id = id
		err = service.Load()
		if err == nil {
			serviceDto := entity.ServiceDto{}
			serviceDto.Service = service
			serviceDto.Load()
			if serviceDto.Service.Where == utils.Deploy_On_PaaS {
				serviceDto.OnPaaS.Delete()
			}
			if serviceDto.Service.Where == utils.Deploy_On_Vms {
				serviceDto.OnCustom.Delete()
			}
		}

		err = service.Delete()
		if err != nil {
			this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err)
		}
	}
	if err != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err)
	}
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:27,代碼來源:templates.go

示例6: Get

func (this *ServiceDeployController) Get() {
	this.Layout = "index.tpl"
	this.Data["NavBarFocus"] = "templates"
	this.Data["IaaSVersion"] = iaasVersion
	this.Data["DefaultVersion"] = defaultVersion

	this.Data["HOST"] = this.Ctx.Request.Host
	this.Data["AppName"] = globaleAppName
	this.Data["WebSocket"] = serviceDeployWebScoket
	this.Data["ServiceId"] = this.GetString("serviceId")

	serviceId, _ := this.GetInt64("serviceId", 0)
	service := entity.Service{}
	service.Id = serviceId
	loaderr := service.Load()

	if loaderr == nil {
		this.Data["Service"] = service
	}

	this.TplName = "templates/deploy.tpl"
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:22,代碼來源:service_deploy.go

示例7: Post

func (this *TemplatesController) Post() {
	action := this.GetString("action")
	switch action {
	case "":
		service := entity.Service{}
		service.Name = this.GetString("name")
		service.Description = this.GetString("description")
		service.Where = this.GetString("where")

		id, err := this.GetInt64("id", 0)
		if err == nil {
			if id == 0 {
				service.Save()
				if service.Where == utils.Deploy_On_PaaS {
					deployOnPaaS := entity.OnPaaS{}
					deployOnPaaS.Api = this.GetString("Api")
					deployOnPaaS.Sid = service.Id
					deployOnPaaS.User = this.GetString("UserName")
					deployOnPaaS.Passwd = this.GetString("Passwd")
					deployOnPaaS.Org = this.GetString("Org")
					deployOnPaaS.Space = this.GetString("Space")
					deployOnPaaS.Save()
				}
				if service.Where == utils.Deploy_On_Vms {
					deployOnCustom := entity.OnCustom{}
					deployOnCustom.Sid = service.Id
					deployOnCustom.Ip = this.GetString("ip")
					deployOnCustom.User = this.GetString("VmUserName")
					deployOnCustom.Passwd = this.GetString("VmPasswd")
					deployOnCustom.Save()
				}
			} else {
				service.Id = id
				service.Update()
				if service.Where == utils.Deploy_On_PaaS {
					paasid, _ := this.GetInt64("paasid", 0)
					deployOnPaaS := entity.OnPaaS{}
					deployOnPaaS.Id = paasid
					deployOnPaaS.Api = this.GetString("Api")
					deployOnPaaS.Sid = service.Id
					deployOnPaaS.User = this.GetString("UserName")
					deployOnPaaS.Passwd = this.GetString("Passwd")
					deployOnPaaS.Org = this.GetString("Org")
					deployOnPaaS.Space = this.GetString("Space")
					deployOnPaaS.Update()
				}
				if service.Where == utils.Deploy_On_Vms {
					vmid, _ := this.GetInt64("vmid", 0)
					deployOnCustom := entity.OnCustom{}
					deployOnCustom.Id = vmid
					deployOnCustom.Sid = service.Id
					deployOnCustom.Ip = this.GetString("ip")
					deployOnCustom.User = this.GetString("VmUserName")
					deployOnCustom.Passwd = this.GetString("VmPasswd")
					deployOnCustom.Update()
				}
			}
		}

	case "delete":
		this.DeleteCustomService()
	}
	this.Redirect("templates", 301) //this.Get()
}
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:64,代碼來源:templates.go

示例8:

package entity_test

import (
	"github.com/astaxie/beego/orm"
	"github.com/citycloud/citycloud.cf-deploy-ui/entity"
	_ "github.com/go-sql-driver/mysql"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Testing Service CRUD", func() {
	It("Service Save", func() {
		var service entity.Service = entity.Service{Name: "mysql-service", Description: "provide mysql store service"}
		err := service.Save()
		Expect(err).ToNot(HaveOccurred())

		err = service.Delete()
		Expect(err).ToNot(HaveOccurred())
	})
	It("Service Update", func() {
		service := entity.Service{Name: "mysql-service", Description: "provide mysql store service"}
		id, err := orm.NewOrm().Insert(&service)
		Expect(err).ToNot(HaveOccurred())
		service1 := entity.Service{}
		service1.Id = id
		errs := service1.Load()
		Expect(errs).ToNot(HaveOccurred())
		service1.Name = "New-mysql-service"
		errs = service1.Update()
		Expect(errs).ToNot(HaveOccurred())
		errs = service1.Load()
開發者ID:alex8023,項目名稱:citycloud.cf-deploy-ui,代碼行數:31,代碼來源:templates_test.go


注:本文中的github.com/citycloud/citycloud/cf-deploy-ui/entity.Service類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。