本文整理汇总了Golang中github.com/docker/machine/libmachine/provision.DetectProvisioner函数的典型用法代码示例。如果您正苦于以下问题:Golang DetectProvisioner函数的具体用法?Golang DetectProvisioner怎么用?Golang DetectProvisioner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DetectProvisioner函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Create
func (h *Host) Create(name string) error {
// create the instance
if err := h.Driver.Create(); err != nil {
return err
}
// save to store
if err := h.SaveConfig(); err != nil {
return err
}
// TODO: Not really a fan of just checking "none" here.
if h.Driver.DriverName() != "none" {
if err := utils.WaitFor(drivers.MachineInState(h.Driver, state.Running)); err != nil {
return err
}
if err := WaitForSSH(h); err != nil {
return err
}
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil {
return err
}
}
return nil
}
开发者ID:cdosso,项目名称:machine,代码行数:33,代码来源:host.go
示例2: Upgrade
func (h *Host) Upgrade() error {
machineState, err := h.Driver.GetState()
if err != nil {
return err
}
if machineState != state.Running {
return errMachineMustBeRunningForUpgrade
}
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return crashreport.CrashError{
Cause: err,
Command: "Upgrade",
Context: "provision.DetectProvisioner",
DriverName: h.Driver.DriverName(),
}
}
log.Info("Upgrading docker...")
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
return crashreport.CrashError{
Cause: err,
Command: "Upgrade",
Context: "provisioner.Package",
DriverName: h.Driver.DriverName(),
}
}
log.Info("Restarting docker...")
return provisioner.Service("docker", serviceaction.Restart)
}
开发者ID:sheltowt,项目名称:machine,代码行数:33,代码来源:host.go
示例3: WaitForDocker
func (h *Host) WaitForDocker() error {
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
return provision.WaitForDocker(provisioner, engine.DefaultPort)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:8,代码来源:host.go
示例4: Provision
func (h *Host) Provision() error {
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
return provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:8,代码来源:host.go
示例5: create
// Create is the wrapper method which covers all of the boilerplate around
// actually creating, provisioning, and persisting an instance in the store.
func create(store persist.Store, h *host.Host, callback func(*host.Host)) error {
if err := cert.BootstrapCertificates(h.HostOptions.AuthOptions); err != nil {
return fmt.Errorf("Error generating certificates: %s", err)
}
log.Info("Running pre-create checks...")
if err := h.Driver.PreCreateCheck(); err != nil {
return fmt.Errorf("Error with pre-create check: %s", err)
}
if err := store.Save(h); err != nil {
return fmt.Errorf("Error saving host to store before attempting creation: %s", err)
}
log.Info("Creating machine...")
if err := h.Driver.Create(); err != nil {
return fmt.Errorf("Error in driver during machine creation: %s", err)
}
if err := store.Save(h); err != nil {
return fmt.Errorf("Error saving host to store after attempting creation: %s", err)
}
// TODO: Not really a fan of just checking "none" here.
if h.Driver.DriverName() != "none" {
log.Info("Waiting for machine to be running, this may take a few minutes...")
if err := mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running)); err != nil {
return fmt.Errorf("Error waiting for machine to be running: %s", err)
}
log.Info("Machine is running, waiting for SSH to be available...")
if err := drivers.WaitForSSH(h.Driver); err != nil {
return fmt.Errorf("Error waiting for SSH: %s", err)
}
log.Info("Detecting operating system of created instance...")
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return fmt.Errorf("Error detecting OS: %s", err)
}
callback(h)
log.Info("Provisioning created instance...")
if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil {
return fmt.Errorf("Error running provisioning: %s", err)
}
}
log.Debug("Reticulating splines...")
return nil
}
开发者ID:chanwit,项目名称:gattai,代码行数:57,代码来源:provision.go
示例6: ConfigureAuth
func (h *Host) ConfigureAuth() error {
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
if err := provision.ConfigureAuth(provisioner, *h.HostOptions.AuthOptions); err != nil {
return err
}
return nil
}
开发者ID:Aorjoa,项目名称:Machine-Aiyara,代码行数:12,代码来源:host.go
示例7: ConfigureAuth
func (h *Host) ConfigureAuth() error {
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
// TODO: This is kind of a hack (or is it? I'm not really sure until
// we have more clearly defined outlook on what the responsibilities
// and modularity of the provisioners should be).
//
// Call provision to re-provision the certs properly.
return provisioner.Provision(swarm.Options{}, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions)
}
开发者ID:sheltowt,项目名称:machine,代码行数:13,代码来源:host.go
示例8: Upgrade
func (h *Host) Upgrade() error {
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
return err
}
if err := provisioner.Service("docker", pkgaction.Restart); err != nil {
return err
}
return nil
}
开发者ID:Aorjoa,项目名称:Machine-Aiyara,代码行数:15,代码来源:host.go
示例9: performCreate
func (api *Client) performCreate(h *host.Host) error {
if err := h.Driver.Create(); err != nil {
return fmt.Errorf("Error in driver during machine creation: %s", err)
}
if err := api.Save(h); err != nil {
return fmt.Errorf("Error saving host to store after attempting creation: %s", err)
}
// TODO: Not really a fan of just checking "none" here.
if h.Driver.DriverName() != "none" {
log.Info("Waiting for machine to be running, this may take a few minutes...")
if err := mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running)); err != nil {
return fmt.Errorf("Error waiting for machine to be running: %s", err)
}
log.Info("Machine is running, waiting for SSH to be available...")
if err := drivers.WaitForSSH(h.Driver); err != nil {
return fmt.Errorf("Error waiting for SSH: %s", err)
}
log.Info("Detecting operating system of created instance...")
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return fmt.Errorf("Error detecting OS: %s", err)
}
log.Infof("Provisioning with %s...", provisioner.String())
if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil {
return fmt.Errorf("Error running provisioning: %s", err)
}
// We should check the connection to docker here
log.Info("Checking connection to Docker...")
if _, _, err = check.DefaultConnChecker.Check(h, false); err != nil {
return fmt.Errorf("Error checking the host: %s", err)
}
log.Info("Docker is up and running!")
}
return nil
}
开发者ID:sergey-stratoscale,项目名称:machine,代码行数:45,代码来源:libmachine.go
示例10: Upgrade
func (h *Host) Upgrade() error {
machineState, err := h.Driver.GetState()
if err != nil {
return err
}
if machineState != state.Running {
return errMachineMustBeRunningForUpgrade
}
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
log.Info("Upgrading docker...")
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
return err
}
log.Info("Restarting docker...")
return provisioner.Service("docker", serviceaction.Restart)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:23,代码来源:host.go
示例11: Upgrade
func (h *Host) Upgrade() error {
machineState, err := h.Driver.GetState()
if err != nil {
return err
}
if machineState != state.Running {
log.Fatal(errMachineMustBeRunningForUpgrade)
}
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return err
}
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
return err
}
if err := provisioner.Service("docker", pkgaction.Restart); err != nil {
return err
}
return nil
}
开发者ID:cdosso,项目名称:machine,代码行数:24,代码来源:host.go
示例12: swarmManage
func swarmManage(h *host.Host, image string, token string) error {
provisioner, err := provision.DetectProvisioner(h.Driver)
dockerDir := provisioner.GetDockerOptionsDir()
authOptions := setRemoteAuthOptions(provisioner)
url, err := h.GetURL()
if err != nil {
return err
}
retryCount := 0
retry:
exec.Command(os.Args[0], []string{
"-H", url,
"--tlscacert=" + h.HostOptions.AuthOptions.CaCertPath,
"--tlscert=" + h.HostOptions.AuthOptions.ClientCertPath,
"--tlskey=" + h.HostOptions.AuthOptions.ClientKeyPath,
"--tlsverify=true",
"rm", "-f", "swarm-manager"}...).Output()
cmd := exec.Command(os.Args[0], []string{
"-H", url,
"--tlscacert=" + h.HostOptions.AuthOptions.CaCertPath,
"--tlscert=" + h.HostOptions.AuthOptions.ClientCertPath,
"--tlskey=" + h.HostOptions.AuthOptions.ClientKeyPath,
"--tlsverify=true",
"run", "-d", "--restart=always",
"--net=bridge",
"--name", "swarm-manager",
"-p", "3376:3376",
"-v", dockerDir + ":" + dockerDir,
image, "manage",
"--tlsverify",
"--tlscacert=" + authOptions.CaCertRemotePath,
"--tlscert=" + authOptions.ServerCertRemotePath,
"--tlskey=" + authOptions.ServerKeyRemotePath,
"-H", "0.0.0.0:3376",
token}...)
err = cmd.Run()
if err == nil {
fmt.Printf("Manager '%s' started successfully...\n", h.Name)
return nil
}
if _, ok := err.(*exec.ExitError); ok {
retryCount++
if retryCount <= 5 {
fmt.Printf("Failed to start manager. Retry: %d\n", retryCount)
goto retry
}
// if s, ok := exiterr.Sys().(syscall.WaitStatus); ok {
// if s.ExitCode == 8 {
// goto retry
// }
// }
}
return err
}
开发者ID:chanwit,项目名称:gattai,代码行数:62,代码来源:cluster.go
示例13: startZooKeeper
func startZooKeeper(args ...string) error {
p, err := machine.ReadProvision("provision.yml")
if err != nil {
log.Debugf("err: %s", err)
return err
}
// extract pattern
// fmt.Printf("args: %s\n",args)
machineList := p.GetMachineList(args...)
log.Debugf("machines: %s", machineList)
if len(machineList) == 0 {
return errors.New("no machine in list")
}
store := machine.GetDefaultStore(utils.GetBaseDir())
zooCfg := `
tickTime=2000
dataDir=/var/zookeeper/
clientPort=2181
initLimit=5
syncLimit=2
{{range $id, $ip := .}}server.{{ inc $id }}={{ $ip }}:2888:3888
{{ end }}
`
addHosts := []string{}
hosts := []*host.Host{}
for _, name := range machineList {
h, err := loadHost(store, name, utils.GetBaseDir())
if err != nil {
return err
}
hosts = append(hosts, h)
ip, err := h.Driver.GetIP()
if err != nil {
return err
}
addHosts = append(addHosts, "--add-host", name+":"+ip)
}
tmpl, err := template.New("zoo").Funcs(template.FuncMap{
"inc": func(i int) int { return i + 1 },
}).Parse(zooCfg)
if err != nil {
return err
}
var str bytes.Buffer
err = tmpl.Execute(&str, machineList) // change ips to machine name
if err != nil {
return err
}
for _, h := range hosts {
provisioner, err := provision.DetectProvisioner(h.Driver)
// dockerDir := provisioner.GetDockerOptionsDir()
// authOptions := setRemoteAuthOptions(provisioner)
url, err := h.GetURL()
if err != nil {
return err
}
exec.Command(os.Args[0], []string{
"-H", url,
"--tlscacert=" + h.HostOptions.AuthOptions.CaCertPath,
"--tlscert=" + h.HostOptions.AuthOptions.ClientCertPath,
"--tlskey=" + h.HostOptions.AuthOptions.ClientKeyPath,
"--tlsverify=true",
"rm", "-f", "swarm-discovery-service"}...).Output()
// skip error checking
provisioner.SSHCommand("sudo mkdir -p /opt/zookeeper/conf")
// copy zooCfg
transferCmdFmt := "printf '%%s' '%s' | sudo tee %s"
if _, err := provisioner.SSHCommand(fmt.Sprintf(transferCmdFmt, str.String(), "/opt/zookeeper/conf/zoo.cfg")); err != nil {
return err
}
cmd := exec.Command(os.Args[0], append([]string{
"-H", url,
"--tlscacert=" + h.HostOptions.AuthOptions.CaCertPath,
"--tlscert=" + h.HostOptions.AuthOptions.ClientCertPath,
"--tlskey=" + h.HostOptions.AuthOptions.ClientKeyPath,
"--tlsverify=true",
"run", "-d", "--restart=always",
"--name", "swarm-discovery-service",
"-v", "/opt/zookeeper/conf:/opt/zookeeper/conf"},
append(addHosts,
"-p", "2181:2181",
"-p", "2888:2888",
//.........这里部分代码省略.........
开发者ID:chanwit,项目名称:gattai,代码行数:101,代码来源:discovery.go
示例14: AddMaster
// install swarm master on the 'm' machine
func (d *Driver) AddMaster(m *machine.Machine) error {
cd := container.NewContainerDesc()
cd.SetRestartPolicy("always", 0)
p, err := provision.DetectProvisioner(m.Host.Driver)
if err != nil {
return err
}
swarmHost := d.options.String("host")
u, err := url.Parse(swarmHost)
if err != nil {
return err
}
parts := strings.Split(u.Host, ":")
port := parts[1]
bip := parts[0]
cd.AddPortBinding(bip, port, port, "tcp")
dockerDir := p.GetDockerOptionsDir()
b := fmt.Sprintf("%s:%s", dockerDir, dockerDir)
cd.AddBind(b)
cd.SetImage(d.options.String("image"))
authOptions := setRemoteAuthOptions(p)
cmds := []string{"manage",
"--tlsverify",
"--tlscacert", authOptions.CaCertRemotePath,
"--tlscert", authOptions.ServerCertRemotePath,
"--tlskey", authOptions.ServerKeyRemotePath,
"-H", swarmHost,
"--strategy", d.options.String("strategy"),
}
sopts := d.options.StringSlice("opt")
if len(sopts) > 0 {
cmds = append(cmds, sopts...)
}
cmds = append(cmds, d.options.String("discovery"))
cd.SetCmd(cmds...)
client, err := container.NewDockerClient(m)
if err != nil {
return err
}
name := "swarm-agent-master"
master, err := client.GetByName(name)
if err != nil {
return err
}
id, err := checkContainerStart(name, master, cd, client)
if err != nil {
return err
}
logrus.Infof("swarm master agent is running. name:%s, id:%s", name, id)
ip := m.GetCachedIp()
host := fmt.Sprintf("tcp://%s:%s", ip, port)
mc, err := container.NewDockerClientWithUrl(host, m)
if err != nil {
return err
}
d.masterClientChangeChan <- mc
logrus.Infof("swarm master added to cluster. host:%s, name:%s", host, name)
return nil
}
开发者ID:sdgdsffdsfff,项目名称:dockerf,代码行数:69,代码来源:swarm.go
注:本文中的github.com/docker/machine/libmachine/provision.DetectProvisioner函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论