本文整理匯總了Golang中github.com/crunchydata/crunchy-postgresql-manager/types.Container.ID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Container.ID方法的具體用法?Golang Container.ID怎麽用?Golang Container.ID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/crunchydata/crunchy-postgresql-manager/types.Container
的用法示例。
在下文中一共展示了Container.ID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: provisionImpl
func provisionImpl(dbConn *sql.DB, params *swarmapi.DockerRunRequest, standby bool) (string, error) {
logit.Info.Println("PROFILE: provisionImpl starts 1")
var errorStr string
//make sure the container name is not already taken
_, err := admindb.GetContainerByName(dbConn, params.ContainerName)
if err != nil {
if err != sql.ErrNoRows {
return "", err
}
} else {
errorStr = "container name " + params.ContainerName + " already used can't provision"
logit.Error.Println(errorStr)
return "", errors.New(errorStr)
}
//get the pg data path
var pgdatapath types.Setting
pgdatapath, err = admindb.GetSetting(dbConn, "PG-DATA-PATH")
if err != nil {
logit.Error.Println(err.Error())
return "", err
}
var infoResponse swarmapi.DockerInfoResponse
infoResponse, err = swarmapi.DockerInfo()
servers := make([]types.Server, len(infoResponse.Output))
i := 0
for i = range infoResponse.Output {
servers[i].ID = infoResponse.Output[i]
servers[i].Name = infoResponse.Output[i]
servers[i].IPAddress = infoResponse.Output[i]
i++
}
//for database nodes, on the target server, we need to allocate
//a disk volume on all CPM servers for the /pgdata container volume to work with
//this causes a volume to be created with the directory
//named the same as the container name
params.PGDataPath = pgdatapath.Value + "/" + params.ContainerName
logit.Info.Println("PROFILE provisionImpl 2 about to provision volume " + params.PGDataPath)
if params.Image != "cpm-pgpool" {
preq := &cpmserverapi.DiskProvisionRequest{}
preq.Path = params.PGDataPath
var response cpmserverapi.DiskProvisionResponse
for _, each := range servers {
logit.Info.Println("Provision: provisionvolume on server " + each.Name)
response, err = cpmserverapi.DiskProvisionClient(each.Name, preq)
if err != nil {
logit.Info.Println("Provision: provisionvolume error" + err.Error())
logit.Error.Println(err.Error())
return "", err
}
logit.Info.Println("Provision: provisionvolume call response=" + response.Status)
}
}
logit.Info.Println("PROFILE provisionImpl 3 provision volume completed")
//run docker run to create the container
params.CPU, params.MEM, err = getDockerResourceSettings(dbConn, params.Profile)
if err != nil {
logit.Error.Println(err.Error())
return "", err
}
//inspect and remove any existing container
logit.Info.Println("PROFILE provisionImpl inspect 4")
inspectReq := &swarmapi.DockerInspectRequest{}
inspectReq.ContainerName = params.ContainerName
var inspectResponse swarmapi.DockerInspectResponse
inspectResponse, err = swarmapi.DockerInspect(inspectReq)
if err != nil {
logit.Error.Println(err.Error())
return "", err
}
if inspectResponse.RunningState != "not-found" {
logit.Info.Println("PROFILE provisionImpl remove existing container 4a")
rreq := &swarmapi.DockerRemoveRequest{}
rreq.ContainerName = params.ContainerName
_, err = swarmapi.DockerRemove(rreq)
if err != nil {
logit.Error.Println(err.Error())
return "", err
}
}
//pass any restore env vars to the new container
if params.RestoreJob != "" {
if params.EnvVars == nil {
//logit.Info.Println("making envvars map")
params.EnvVars = make(map[string]string)
}
params.EnvVars["RestoreJob"] = params.RestoreJob
params.EnvVars["RestoreRemotePath"] = params.RestoreRemotePath
params.EnvVars["RestoreRemoteHost"] = params.RestoreRemoteHost
params.EnvVars["RestoreRemoteUser"] = params.RestoreRemoteUser
params.EnvVars["RestoreDbUser"] = params.RestoreDbUser
//.........這裏部分代碼省略.........