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


Golang drivers.RunSSHCommandFromDriver函數代碼示例

本文整理匯總了Golang中github.com/docker/machine/drivers.RunSSHCommandFromDriver函數的典型用法代碼示例。如果您正苦於以下問題:Golang RunSSHCommandFromDriver函數的具體用法?Golang RunSSHCommandFromDriver怎麽用?Golang RunSSHCommandFromDriver使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: GetIP

func (d *Driver) GetIP() (string, error) {
	// DHCP is used to get the IP, so virtualbox hosts don't have IPs unless
	// they are running
	s, err := d.GetState()
	if err != nil {
		return "", err
	}
	if s != state.Running {
		return "", drivers.ErrHostIsNotRunning
	}

	output, err := drivers.RunSSHCommandFromDriver(d, "ip addr show dev eth1")
	if err != nil {
		return "", err
	}

	log.Debugf("SSH returned: %s\nEND SSH\n", output)

	// parse to find: inet 192.168.59.103/24 brd 192.168.59.255 scope global eth1
	lines := strings.Split(output, "\n")
	for _, line := range lines {
		vals := strings.Split(strings.TrimSpace(line), " ")
		if len(vals) >= 2 && vals[0] == "inet" {
			return vals[1][:strings.Index(vals[1], "/")], nil
		}
	}

	return "", fmt.Errorf("No IP address found %s", output)
}
開發者ID:Kast0rTr0y,項目名稱:docker-machine,代碼行數:29,代碼來源:virtualbox.go

示例2: Kill

func (d *Driver) Kill() error {
	log.Debug("Killing...")

	if _, err := drivers.RunSSHCommandFromDriver(d, "sudo shutdown -P now"); err != nil {
		return err
	}

	return nil
}
開發者ID:cdosso,項目名稱:machine,代碼行數:9,代碼來源:generic.go

示例3: Restart

func (d *Driver) Restart() error {
	log.Debug("Restarting...")

	if _, err := drivers.RunSSHCommandFromDriver(d, "sudo shutdown -r now"); err != nil {
		return err
	}

	return nil
}
開發者ID:cdosso,項目名稱:machine,代碼行數:9,代碼來源:generic.go

示例4: DetectProvisioner

func DetectProvisioner(d drivers.Driver) (Provisioner, error) {
	osReleaseOut, err := drivers.RunSSHCommandFromDriver(d, "cat /etc/os-release")
	if err != nil {
		return nil, fmt.Errorf("Error getting SSH command: %s", err)
	}

	osReleaseInfo, err := NewOsRelease([]byte(osReleaseOut))
	if err != nil {
		return nil, fmt.Errorf("Error parsing /etc/os-release file: %s", err)
	}

	for _, p := range provisioners {
		provisioner := p.New(d)
		provisioner.SetOsReleaseInfo(osReleaseInfo)

		if provisioner.CompatibleWithHost() {
			log.Debugf("found compatible host: %s", osReleaseInfo.Id)
			return provisioner, nil
		}
	}

	return nil, ErrDetectionFailed
}
開發者ID:justintung,項目名稱:machine,代碼行數:23,代碼來源:provisioner.go

示例5: SSHCommand

func (provisioner *Boot2DockerProvisioner) SSHCommand(args string) (string, error) {
	return drivers.RunSSHCommandFromDriver(provisioner.Driver, args)
}
開發者ID:robebeye,項目名稱:machine,代碼行數:3,代碼來源:boot2docker.go

示例6: RunSSHCommand

func (h *Host) RunSSHCommand(command string) (string, error) {
	return drivers.RunSSHCommandFromDriver(h.Driver, command)
}
開發者ID:cdosso,項目名稱:machine,代碼行數:3,代碼來源:host.go


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