本文整理匯總了Golang中github.com/contiv/netplugin/netmaster/gstate.Cfg.GetVxlansInUse方法的典型用法代碼示例。如果您正苦於以下問題:Golang Cfg.GetVxlansInUse方法的具體用法?Golang Cfg.GetVxlansInUse怎麽用?Golang Cfg.GetVxlansInUse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/contiv/netplugin/netmaster/gstate.Cfg
的用法示例。
在下文中一共展示了Cfg.GetVxlansInUse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: processResource
// processResource handles resource commands
func processResource(stateDriver core.StateDriver, rsrcName, rsrcVal string) error {
// Read global config
gCfg := gstate.Cfg{}
gCfg.StateDriver = stateDriver
err := gCfg.Read("")
if err != nil {
log.Errorf("error reading tenant cfg state. Error: %s", err)
return err
}
// process resource based on name
if rsrcName == "vlan" {
numVlans, vlansInUse := gCfg.GetVlansInUse()
fmt.Printf("Num Vlans: %d\n Current Vlans in Use: %s\n", numVlans, vlansInUse)
// see if we need to set the resource
if rsrcVal != "" {
values, err := parseRange(rsrcVal)
if err != nil {
log.Errorf("Error parsing range: %v", err)
return err
}
log.Infof("Setting vlan values: %v", values)
// set vlan values
for _, val := range values {
_, err = gCfg.AllocVLAN(val)
if err != nil {
log.Errorf("Error setting vlan: %d. Err: %v", val, err)
}
}
log.Infof("Finished setting VLANs")
}
} else if rsrcName == "vxlan" {
numVxlans, vxlansInUse := gCfg.GetVxlansInUse()
fmt.Printf("Num Vxlans: %d\n Current Vxlans in Use: %s\n", numVxlans, vxlansInUse)
// see if we need to set the resource
if rsrcVal != "" {
values, err := parseRange(rsrcVal)
if err != nil {
log.Errorf("Error parsing range: %v", err)
return err
}
log.Infof("Setting vxlan values: %v", values)
// set vlan values
for _, val := range values {
_, _, err = gCfg.AllocVXLAN(val)
if err != nil {
log.Errorf("Error setting vxlan: %d. Err: %v", val, err)
}
}
log.Infof("Finished setting VXLANs")
}
} else {
log.Errorf("Unknown resource: %v", rsrcName)
return fmt.Errorf("Unknown resource")
}
return nil
}