本文整理汇总了Golang中github.com/contiv/netplugin/netmaster/mastercfg.CfgNetworkState.IncrEpCount方法的典型用法代码示例。如果您正苦于以下问题:Golang CfgNetworkState.IncrEpCount方法的具体用法?Golang CfgNetworkState.IncrEpCount怎么用?Golang CfgNetworkState.IncrEpCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/netmaster/mastercfg.CfgNetworkState
的用法示例。
在下文中一共展示了CfgNetworkState.IncrEpCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateEndpoint
// CreateEndpoint creates an endpoint
func CreateEndpoint(stateDriver core.StateDriver, nwCfg *mastercfg.CfgNetworkState,
ep *intent.ConfigEP) (*mastercfg.CfgEndpointState, error) {
epCfg := &mastercfg.CfgEndpointState{}
epCfg.StateDriver = stateDriver
epCfg.ID = getEpName(nwCfg.ID, ep)
err := epCfg.Read(epCfg.ID)
if err == nil {
// TODO: check for diffs and possible updates
return epCfg, nil
}
epCfg.NetID = nwCfg.ID
epCfg.ContName = ep.Container
epCfg.AttachUUID = ep.AttachUUID
epCfg.HomingHost = ep.Host
epCfg.ServiceName = ep.ServiceName
// Allocate addresses
err = allocSetEpAddress(ep, epCfg, nwCfg)
if err != nil {
log.Errorf("error allocating and/or reserving IP. Error: %s", err)
return nil, err
}
// Set endpoint group
// Skip for infra nw
if nwCfg.NwType != "infra" {
epCfg.EndpointGroupKey = mastercfg.GetEndpointGroupKey(ep.ServiceName, nwCfg.Tenant)
epCfg.EndpointGroupID, err = mastercfg.GetEndpointGroupID(stateDriver, ep.ServiceName, nwCfg.Tenant)
if err != nil {
log.Errorf("Error getting endpoint group for %s.%s. Err: %v", ep.ServiceName, nwCfg.ID, err)
return nil, err
}
}
err = nwCfg.IncrEpCount()
if err != nil {
log.Errorf("Error incrementing ep count. Err: %v", err)
return nil, err
}
err = epCfg.Write()
if err != nil {
log.Errorf("error writing ep config. Error: %s", err)
return nil, err
}
return epCfg, nil
}
示例2: CreateEndpoint
// CreateEndpoint creates an endpoint
func CreateEndpoint(stateDriver core.StateDriver, nwCfg *mastercfg.CfgNetworkState,
epReq *CreateEndpointRequest) (*mastercfg.CfgEndpointState, error) {
ep := &epReq.ConfigEP
epCfg := &mastercfg.CfgEndpointState{}
epCfg.StateDriver = stateDriver
epCfg.ID = getEpName(nwCfg.ID, ep)
err := epCfg.Read(epCfg.ID)
if err == nil {
// TODO: check for diffs and possible updates
return epCfg, nil
}
epCfg.NetID = nwCfg.ID
epCfg.EndpointID = ep.Container
epCfg.HomingHost = ep.Host
epCfg.ServiceName = ep.ServiceName
epCfg.EPCommonName = epReq.EPCommonName
// Allocate addresses
err = allocSetEpAddress(ep, epCfg, nwCfg)
if err != nil {
log.Errorf("error allocating and/or reserving IP. Error: %s", err)
return nil, err
}
// cleanup relies on var err being used for all error checking
defer freeAddrOnErr(nwCfg, epCfg.IPAddress, &err)
// Set endpoint group
// Skip for infra nw
if nwCfg.NwType != "infra" {
epCfg.EndpointGroupKey = mastercfg.GetEndpointGroupKey(ep.ServiceName, nwCfg.Tenant)
epCfg.EndpointGroupID, err = mastercfg.GetEndpointGroupID(stateDriver, ep.ServiceName, nwCfg.Tenant)
if err != nil {
log.Errorf("Error getting endpoint group ID for %s.%s. Err: %v", ep.ServiceName, nwCfg.ID, err)
return nil, err
}
if epCfg.EndpointGroupKey != "" {
epgCfg := &mastercfg.EndpointGroupState{}
epgCfg.StateDriver = stateDriver
err = epgCfg.Read(epCfg.EndpointGroupKey)
if err != nil {
log.Errorf("Error reading Epg info for EP: %+v. Error: %v", ep, err)
return nil, err
}
epgCfg.EpCount++
err = epgCfg.Write()
if err != nil {
log.Errorf("Error saving epg state: %+v", epgCfg)
return nil, err
}
}
}
err = nwCfg.IncrEpCount()
if err != nil {
log.Errorf("Error incrementing ep count. Err: %v", err)
return nil, err
}
err = epCfg.Write()
if err != nil {
log.Errorf("error writing ep config. Error: %s", err)
return nil, err
}
return epCfg, nil
}