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


Golang Host.Driver方法代碼示例

本文整理匯總了Golang中github.com/docker/machine/libmachine/host.Host.Driver方法的典型用法代碼示例。如果您正苦於以下問題:Golang Host.Driver方法的具體用法?Golang Host.Driver怎麽用?Golang Host.Driver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/docker/machine/libmachine/host.Host的用法示例。


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

示例1: Save

func (s Filestore) Save(host *host.Host) error {
	if serialDriver, ok := host.Driver.(*drivers.SerialDriver); ok {
		// Unwrap Driver
		host.Driver = serialDriver.Driver

		// Re-wrap Driver when done
		defer func() {
			host.Driver = serialDriver
		}()
	}

	// TODO: Does this belong here?
	if rpcClientDriver, ok := host.Driver.(*rpcdriver.RPCClientDriver); ok {
		data, err := rpcClientDriver.GetConfigRaw()
		if err != nil {
			return fmt.Errorf("Error getting raw config for driver: %s", err)
		}
		host.RawDriver = data
	}

	data, err := json.MarshalIndent(host, "", "    ")
	if err != nil {
		return err
	}

	hostPath := filepath.Join(s.getMachinesDir(), host.Name)

	// Ensure that the directory we want to save to exists.
	if err := os.MkdirAll(hostPath, 0700); err != nil {
		return err
	}

	return s.saveToFile(data, filepath.Join(hostPath, "config.json"))
}
開發者ID:rogaha,項目名稱:machine,代碼行數:34,代碼來源:filestore.go

示例2: Create

func (f *fakeLibMachineAPI) Create(h *host.Host) error {
	if f.driverName == "amazonec2" {
		f.ec2Driver = h.Driver.(*amazonec2.Driver)
	}
	h.Driver = &fakedriver.Driver{
		MockName:  h.Name,
		MockState: state.Running,
		MockIP:    "192.168.10.3",
	}
	f.Save(h)
	return nil
}
開發者ID:tsuru,項目名稱:tsuru,代碼行數:12,代碼來源:suite_test.go

示例3: Save

func (ps PluginStore) Save(host *host.Host) error {
	if serialDriver, ok := host.Driver.(*drivers.SerialDriver); ok {
		// Unwrap Driver
		host.Driver = serialDriver.Driver

		// Re-wrap Driver when done
		defer func() {
			host.Driver = serialDriver
		}()
	}

	// TODO: Does this belong here?
	if rpcClientDriver, ok := host.Driver.(*rpcdriver.RPCClientDriver); ok {
		data, err := rpcClientDriver.GetConfigRaw()
		if err != nil {
			return fmt.Errorf("Error getting raw config for driver: %s", err)
		}
		host.RawDriver = data
	}

	return ps.Filestore.Save(host)
}
開發者ID:rowancarr,項目名稱:machine,代碼行數:22,代碼來源:plugin_store.go


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