当前位置: 首页>>代码示例>>Golang>>正文


Golang mcnutils.WaitForSpecific函数代码示例

本文整理汇总了Golang中github.com/docker/machine/libmachine/mcnutils.WaitForSpecific函数的典型用法代码示例。如果您正苦于以下问题:Golang WaitForSpecific函数的具体用法?Golang WaitForSpecific怎么用?Golang WaitForSpecific使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WaitForSpecific函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: waitForDocker

func waitForDocker(p Provisioner, dockerPort int) error {
	if err := mcnutils.WaitForSpecific(checkDaemonUp(p, dockerPort), 10, 3*time.Second); err != nil {
		return NewErrDaemonAvailable(err)
	}

	return nil
}
开发者ID:cvstebut,项目名称:machine,代码行数:7,代码来源:utils.go

示例2: WaitForSSH

func WaitForSSH(d Driver) error {
	// Try to dial SSH for 30 seconds before timing out.
	if err := mcnutils.WaitForSpecific(sshAvailableFunc(d), 6, 5*time.Second); err != nil {
		return fmt.Errorf("Too many retries waiting for SSH to be available.  Last error: %s", err)
	}
	return nil
}
开发者ID:nlamirault,项目名称:docker-machine-scaleway,代码行数:7,代码来源:utils.go

示例3: Start

func (d *Driver) Start() error {
	s, err := d.GetState()
	if err != nil {
		return err
	}

	if s == state.Stopped {
		// check network to re-create if needed
		if err := d.setupHostOnlyNetwork(d.MachineName); err != nil {
			return fmt.Errorf("Error setting up host only network on machine start: %s", err)
		}
	}

	switch s {
	case state.Stopped, state.Saved:
		d.SSHPort, err = setPortForwarding(d, 1, "ssh", "tcp", 22, d.SSHPort)
		if err != nil {
			return err
		}
		if err := d.vbm("startvm", d.MachineName, "--type", "headless"); err != nil {
			return err
		}
		log.Infof("Starting VM...")
	case state.Paused:
		if err := d.vbm("controlvm", d.MachineName, "resume", "--type", "headless"); err != nil {
			return err
		}
		log.Infof("Resuming VM ...")
	default:
		log.Infof("VM not in restartable state")
	}

	// Verify that VT-X is not disabled in the started VM
	disabled, err := d.IsVTXDisabledInTheVM()
	if err != nil {
		return fmt.Errorf("Checking if hardware virtualization is enabled failed: %s", err)
	}

	if disabled {
		return ErrMustEnableVTX
	}

	// Wait for SSH over NAT to be available before returning to user
	if err := drivers.WaitForSSH(d); err != nil {
		return err
	}

	// Bail if we don't get an IP from DHCP after a given number of seconds.
	if err := mcnutils.WaitForSpecific(d.hostOnlyIPAvailable, 5, 4*time.Second); err != nil {
		return err
	}

	d.IPAddress, err = d.GetIP()

	return err
}
开发者ID:usmanismail,项目名称:machine,代码行数:56,代码来源:virtualbox.go

示例4: Provision

func (provisioner *WindowsProvisioner) Provision(swarmOptions swarm.Options, authOptions auth.Options, engineOptions engine.Options) error {
	provisioner.AuthOptions = authOptions

	log.Debug("Waiting to enable basic auth for WinRM")
	if err := mcnutils.WaitForSpecific(provisioner.enableBasicAuthForWinRM, 60, 3*time.Second); err != nil {
		log.Warn("failed to enable basic auth: ", err)
		return err
	}

	log.Debug("Waiting for docker daemon")
	if err := mcnutils.WaitForSpecific(provisioner.dockerDaemonResponding, 60, 3*time.Second); err != nil {
		log.Warn("failed to get docker daemon status: ", err)
		return err
	}

	log.Debug("Updating docker on host")
	if err := mcnutils.WaitForSpecific(provisioner.updateDocker, 60, 3*time.Second); err != nil {
		log.Warn("failed to update docker daemon: ", err)
		return err
	}

	provisioner.AuthOptions = setRemoteAuthOptions(provisioner)
	if err := ConfigureAuth(provisioner); err != nil {
		return err
	}

	log.Debug("Opening docker port on host")
	if err := mcnutils.WaitForSpecific(provisioner.openDockerPortOnHost, 60, 3*time.Second); err != nil {
		log.Warn("failed to update docker daemon: ", err)
		return err
	}

	log.Debug("Checking that docker version is as expected")
	if err := mcnutils.WaitForSpecific(provisioner.checkDockerVersion, 60, 3*time.Second); err != nil {
		log.Warn("failed to check docker version: ", err)
		return err
	}

	return nil
}
开发者ID:containerx,项目名称:machine,代码行数:40,代码来源:windows.go

示例5: Wait

func (w *sshIPWaiter) Wait(d *Driver) error {
	// Wait for SSH over NAT to be available before returning to user
	if err := drivers.WaitForSSH(d); err != nil {
		return err
	}

	// Bail if we don't get an IP from DHCP after a given number of seconds.
	if err := mcnutils.WaitForSpecific(d.hostOnlyIPAvailable, 5, 4*time.Second); err != nil {
		return err
	}

	var err error
	d.IPAddress, err = d.GetIP()

	return err
}
开发者ID:RaulKite,项目名称:machine,代码行数:16,代码来源:ip.go

示例6: Create

func (d *Driver) Create() error {
	log.Infof("Create UHost instance...")

	if d.Password == "" {
		d.Password = generateRandomPassword(16)
		log.Infof("password is not set, we use the random password instead, password:%s", d.Password)
	}

	// create keypair
	log.Infof("Creating key pair for instances...")
	if err := d.createKeyPair(); err != nil {
		return fmt.Errorf("unable to create key pair: %s", err)
	}

	// create uhost instance
	log.Infof("Creating uhost instance...")
	if err := d.createUHost(); err != nil {
		return fmt.Errorf("create UHost failed:%s", err)
	}

	// waiting for creating successful
	if err := mcnutils.WaitForSpecific(drivers.MachineInState(d, state.Running), 120, 3*time.Second); err != nil {
		return fmt.Errorf("wait for machine running failed: %s", err)
	}

	// create networks, like private ip, eip, and security group
	log.Infof("Creating networks...")
	//TODO: user the exist eip and security group to configure network
	if err := d.createUNet(); err != nil {
		return fmt.Errorf("create networks failed:%s", err)
	}

	// upload keypair
	if err := d.uploadKeyPair(); err != nil {
		return fmt.Errorf("upload keypair failed:%s", err)
	}

	return nil
}
开发者ID:ucloud,项目名称:docker-machine-ucloud,代码行数:39,代码来源:ucloud.go

示例7: waitFor

func waitFor(f func() bool) error {
	return mcnutils.WaitForSpecific(f, 120, 3*time.Second)
}
开发者ID:waterytowers,项目名称:machine-cloudformation,代码行数:3,代码来源:amazoncf.go

示例8: Create


//.........这里部分代码省略.........
		if err != nil {
			return err
		}
	}

	linodeIPListResponse, err := client.Ip.List(d.LinodeId, -1)
	if err != nil {
		return err
	}
	for _, fullIpAddress := range linodeIPListResponse.FullIPAddresses {
		if fullIpAddress.IsPublic == 1 {
			d.IPAddress = fullIpAddress.IPAddress
		}
	}

	if d.IPAddress == "" {
		return errors.New("Linode IP Address is not found.")
	}

	log.Debugf("Created linode ID %d, IP address %s",
		d.LinodeId,
		d.IPAddress)

	// Deploy distribution
	args := make(map[string]string)
	args["rootPass"] = d.RootPassword
	args["rootSSHKey"] = publicKey
	distributionId := d.DistributionId

	log.Debug("Create disk")
	createDiskJobResponse, err := d.client.Disk.CreateFromDistribution(distributionId, d.LinodeId, "Primary Disk", 24576-256, args)

	if err != nil {
		return err
	}

	jobId := createDiskJobResponse.DiskJob.JobId
	diskId := createDiskJobResponse.DiskJob.DiskId
	log.Debugf("Linode create disk task :%d.", jobId)

	// wait until the creation is finished
	err = d.waitForJob(jobId, "Create Disk Task", 60)
	if err != nil {
		return err
	}

	// create swap
	log.Debug("Create swap disk")
	createDiskJobResponse, err = d.client.Disk.Create(d.LinodeId, "swap", "Swap Disk", 256, nil)
	if err != nil {
		return err
	}

	jobId = createDiskJobResponse.DiskJob.JobId
	swapDiskId := createDiskJobResponse.DiskJob.DiskId
	log.Debugf("Linode create swap disk task :%d.", jobId)

	// wait until the creation is finished
	err = d.waitForJob(jobId, "Create Swap Disk Task", 60)
	if err != nil {
		return err
	}

	// create config
	log.Debug("Create configuration")
	args2 := make(map[string]string)
	args2["DiskList"] = fmt.Sprintf("%d,%d", diskId, swapDiskId)
	args2["RootDeviceNum"] = "1"
	args2["RootDeviceRO"] = "true"
	args2["helper_distro"] = "true"
	kernelId := d.KernelId
	_, err = d.client.Config.Create(d.LinodeId, kernelId, "My Docker Machine Configuration", args2)

	if err != nil {
		return err
	}

	log.Debugf("Linode configuration created.")

	// Boot
	log.Debug("Booting")
	jobResponse, err := d.client.Linode.Boot(d.LinodeId, -1)
	if err != nil {
		return err
	}
	jobId = jobResponse.JobId.JobId
	log.Debugf("Booting linode, job id: %v", jobId)
	// wait for boot
	err = d.waitForJob(jobId, "Booting linode", 60)
	if err != nil {
		return err
	}

	log.Debug("Waiting for Machine Running...")
	if err := mcnutils.WaitForSpecific(drivers.MachineInState(d, state.Running), 120, 3*time.Second); err != nil {
		return fmt.Errorf("wait for machine running failed: %s", err)
	}

	return nil
}
开发者ID:taoh,项目名称:docker-machine-linode,代码行数:101,代码来源:linode.go


注:本文中的github.com/docker/machine/libmachine/mcnutils.WaitForSpecific函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。