本文整理匯總了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
}