本文整理汇总了Golang中github.com/zenoss/serviced.ControlClient.AddServiceDeployment方法的典型用法代码示例。如果您正苦于以下问题:Golang ControlClient.AddServiceDeployment方法的具体用法?Golang ControlClient.AddServiceDeployment怎么用?Golang ControlClient.AddServiceDeployment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zenoss/serviced.ControlClient
的用法示例。
在下文中一共展示了ControlClient.AddServiceDeployment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RestAddService
func RestAddService(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
var payload dao.Service
var serviceId string
err := r.DecodeJsonPayload(&payload)
if err != nil {
glog.V(1).Info("Could not decode service payload: ", err)
RestBadRequest(w)
return
}
service, err := dao.NewService()
if err != nil {
glog.Errorf("Could not create service: %v", err)
RestServerError(w)
return
}
now := time.Now()
service.Name = payload.Name
service.Description = payload.Description
service.Context = payload.Context
service.Tags = payload.Tags
service.PoolId = payload.PoolId
service.ImageId = payload.ImageId
service.Startup = payload.Startup
service.Instances = payload.Instances
service.ParentServiceId = payload.ParentServiceId
service.DesiredState = payload.DesiredState
service.Launch = payload.Launch
service.Endpoints = payload.Endpoints
service.ConfigFiles = payload.ConfigFiles
service.Volumes = payload.Volumes
service.CreatedAt = now
service.UpdatedAt = now
//for each endpoint, evaluate it's Application
if err = service.EvaluateEndpointTemplates(client); err != nil {
glog.Errorf("Unable to evaluate service endpoints: %v", err)
RestServerError(w)
return
}
//add the service to the data store
err = client.AddService(*service, &serviceId)
if err != nil {
glog.Errorf("Unable to add service: %v", err)
RestServerError(w)
return
}
//deploy the service, in other words start it
var unused int
sduuid, _ := dao.NewUuid()
deployment := dao.ServiceDeployment{sduuid, "", service.Id, now}
err = client.AddServiceDeployment(deployment, &unused)
if err != nil {
glog.Errorf("Unable to add service deployment: %v", err)
RestServerError(w)
return
}
glog.V(0).Info("Added service ", serviceId)
w.WriteJson(&SimpleResponse{"Added service", serviceLinks(serviceId)})
}