本文整理汇总了Golang中github.com/contiv/netplugin/netplugin/plugin.NetPlugin.CreateNetwork方法的典型用法代码示例。如果您正苦于以下问题:Golang NetPlugin.CreateNetwork方法的具体用法?Golang NetPlugin.CreateNetwork怎么用?Golang NetPlugin.CreateNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/netplugin/plugin.NetPlugin
的用法示例。
在下文中一共展示了NetPlugin.CreateNetwork方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processNetEvent
func processNetEvent(netPlugin *plugin.NetPlugin, nwCfg *mastercfg.CfgNetworkState,
isDelete bool) (err error) {
// take a lock to ensure we are programming one event at a time.
// Also network create events need to be processed before endpoint creates
// and reverse shall happen for deletes. That order is ensured by netmaster,
// so we don't need to worry about that here
netPlugin.Lock()
defer func() { netPlugin.Unlock() }()
operStr := ""
if isDelete {
err = netPlugin.DeleteNetwork(nwCfg.ID, nwCfg.NwType, nwCfg.PktTagType, nwCfg.PktTag, nwCfg.ExtPktTag,
nwCfg.Gateway, nwCfg.Tenant)
operStr = "delete"
} else {
err = netPlugin.CreateNetwork(nwCfg.ID)
operStr = "create"
}
if err != nil {
log.Errorf("Network operation %s failed. Error: %s", operStr, err)
} else {
log.Infof("Network operation %s succeeded", operStr)
}
return
}