本文整理汇总了Golang中github.com/contiv/netplugin/netmaster/gstate.Cfg.FreeVLAN方法的典型用法代码示例。如果您正苦于以下问题:Golang Cfg.FreeVLAN方法的具体用法?Golang Cfg.FreeVLAN怎么用?Golang Cfg.FreeVLAN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/netmaster/gstate.Cfg
的用法示例。
在下文中一共展示了Cfg.FreeVLAN方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeleteEndpointGroup
// DeleteEndpointGroup handles endpoint group deletes
func DeleteEndpointGroup(tenantName, groupName string) error {
// Get the state driver
stateDriver, err := utils.GetStateDriver()
if err != nil {
return err
}
epgKey := mastercfg.GetEndpointGroupKey(groupName, tenantName)
epgCfg := &mastercfg.EndpointGroupState{}
epgCfg.StateDriver = stateDriver
err = epgCfg.Read(epgKey)
if err != nil {
log.Errorf("error reading EPG key %s. Error: %s", epgKey, err)
return err
}
if epgCfg.EpCount != 0 {
return core.Errorf("Error: EPG %s has active endpoints", groupName)
}
// Delete the endpoint group state
gstate.GlobalMutex.Lock()
defer gstate.GlobalMutex.Unlock()
gCfg := gstate.Cfg{}
gCfg.StateDriver = stateDriver
err = gCfg.Read(epgCfg.TenantName)
if err != nil {
log.Errorf("error reading tenant cfg state. Error: %s", err)
return err
}
// if aci mode we allocate per-epg vlan. free it here.
aciMode, aErr := IsAciConfigured()
if aErr != nil {
return aErr
}
if aciMode {
if epgCfg.PktTagType == "vlan" {
err = gCfg.FreeVLAN(uint(epgCfg.PktTag))
if err != nil {
return err
}
log.Debugf("Freed vlan %v\n", epgCfg.PktTag)
}
}
// Delete endpoint group
err = epgCfg.Clear()
if err != nil {
log.Errorf("error writing epGroup config. Error: %v", err)
return err
}
if GetClusterMode() == "docker" {
return docknet.DeleteDockNet(epgCfg.TenantName, epgCfg.NetworkName, epgCfg.GroupName)
}
return nil
}
示例2: DeleteEndpointGroup
// DeleteEndpointGroup handles endpoint group deletes
func DeleteEndpointGroup(epgID int) error {
// Get the state driver
stateDriver, err := utils.GetStateDriver()
if err != nil {
return err
}
epgCfg := &mastercfg.EndpointGroupState{}
epgCfg.StateDriver = stateDriver
err = epgCfg.Read(strconv.Itoa(epgID))
if err != nil {
log.Errorf("EpGroup %v is not configured", epgID)
return err
}
gCfg := gstate.Cfg{}
gCfg.StateDriver = stateDriver
err = gCfg.Read(epgCfg.Tenant)
if err != nil {
log.Errorf("error reading tenant cfg state. Error: %s", err)
return err
}
// if aci mode we allocate per-epg vlan. free it here.
aciMode, aErr := IsAciConfigured()
if aErr != nil {
return aErr
}
if aciMode {
if epgCfg.PktTagType == "vlan" {
err = gCfg.FreeVLAN(uint(epgCfg.PktTag))
if err != nil {
return err
}
log.Debugf("Freed vlan %v\n", epgCfg.PktTag)
}
}
// Delete endpoint group
err = epgCfg.Clear()
if err != nil {
log.Errorf("error writing epGroup config. Error: %v", err)
return err
}
return docknet.DeleteDockNet(epgCfg.Tenant, epgCfg.NetworkName, epgCfg.Name)
}
示例3: freeNetworkResources
func freeNetworkResources(stateDriver core.StateDriver, nwCfg *mastercfg.CfgNetworkState, gCfg *gstate.Cfg) (err error) {
if nwCfg.PktTagType == "vlan" {
err = gCfg.FreeVLAN(uint(nwCfg.PktTag))
if err != nil {
return err
}
} else if nwCfg.PktTagType == "vxlan" {
log.Infof("freeing vlan %d vxlan %d", nwCfg.PktTag, nwCfg.ExtPktTag)
err = gCfg.FreeVXLAN(uint(nwCfg.ExtPktTag), uint(nwCfg.PktTag))
if err != nil {
return err
}
}
if err := gCfg.UnassignNetwork(nwCfg.ID); err != nil {
return err
}
return err
}