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


Golang Driver.DiscoverNew方法代碼示例

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


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

示例1: agentDriverNotify

func (c *controller) agentDriverNotify(d driverapi.Driver) {
	if c.agent == nil {
		return
	}

	d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
		Address: c.agent.bindAddr,
		Self:    true,
	})

	drvEnc := discoverapi.DriverEncryptionConfig{}
	for _, key := range c.keys {
		if key.Subsystem == "networking:gossip" /*"networking:ipsec"*/ {
			drvEnc.Keys = append(drvEnc.Keys, hex.EncodeToString(key.Key))
			drvEnc.Tags = append(drvEnc.Tags, strconv.FormatUint(key.LamportTime, 10))
		}
	}
	c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
		err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
		if err != nil {
			logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
		}
		return false
	})

}
開發者ID:amitshukla,項目名稱:docker,代碼行數:26,代碼來源:agent.go

示例2: agentDriverNotify

func (c *controller) agentDriverNotify(d driverapi.Driver) {
	if c.agent == nil {
		return
	}

	d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
		Address:     c.agent.advertiseAddr,
		BindAddress: c.agent.bindAddr,
		Self:        true,
	})

	drvEnc := discoverapi.DriverEncryptionConfig{}
	keys, tags := c.getKeys(subsysIPSec)
	drvEnc.Keys = keys
	drvEnc.Tags = tags

	c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
		err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
		if err != nil {
			logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
		}
		return false
	})

}
開發者ID:CWSpear,項目名稱:docker,代碼行數:25,代碼來源:agent.go

示例3: agentDriverNotify

func (c *controller) agentDriverNotify(d driverapi.Driver) {
	if c.agent == nil {
		return
	}

	d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
		Address: c.agent.bindAddr,
		Self:    true,
	})
}
開發者ID:RAMESHBABUK,項目名稱:docker,代碼行數:10,代碼來源:agent.go

示例4: pushNodeDiscovery

func (c *controller) pushNodeDiscovery(d driverapi.Driver, cap driverapi.Capability, nodes []net.IP, add bool) {
	var self net.IP
	if c.cfg != nil {
		addr := strings.Split(c.cfg.Cluster.Address, ":")
		self = net.ParseIP(addr[0])
	}

	if d == nil || cap.DataScope != datastore.GlobalScope || nodes == nil {
		return
	}

	for _, node := range nodes {
		nodeData := discoverapi.NodeDiscoveryData{Address: node.String(), Self: node.Equal(self)}
		var err error
		if add {
			err = d.DiscoverNew(discoverapi.NodeDiscovery, nodeData)
		} else {
			err = d.DiscoverDelete(discoverapi.NodeDiscovery, nodeData)
		}
		if err != nil {
			log.Debugf("discovery notification error : %v", err)
		}
	}
}
開發者ID:maxim28,項目名稱:docker,代碼行數:24,代碼來源:controller.go


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