本文整理匯總了Golang中github.com/contiv/netplugin/core.ResourceManager.AllocateResourceVal方法的典型用法代碼示例。如果您正苦於以下問題:Golang ResourceManager.AllocateResourceVal方法的具體用法?Golang ResourceManager.AllocateResourceVal怎麽用?Golang ResourceManager.AllocateResourceVal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/contiv/netplugin/core.ResourceManager
的用法示例。
在下文中一共展示了ResourceManager.AllocateResourceVal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AllocSubnet
// AllocSubnet allocates a new subnet. Returns a CIDR.
func (gc *Cfg) AllocSubnet(ra core.ResourceManager) (string, error) {
pair, err := ra.AllocateResourceVal(gc.Tenant, resources.AutoSubnetResource)
if err != nil {
return "", err
}
return pair.(resources.SubnetIPLenPair).IP.String(), err
}
示例2: AllocVLAN
// AllocVLAN allocates a new VLAN resource. Returns an ID.
func (gc *Cfg) AllocVLAN(ra core.ResourceManager) (uint, error) {
vlan, err := ra.AllocateResourceVal(gc.Tenant, resources.AutoVLANResource)
if err != nil {
log.Errorf("alloc vlan failed: %q", err)
return 0, err
}
return vlan.(uint), err
}
示例3: AllocVXLAN
// AllocVXLAN allocates a new vxlan; ids for both the vxlan and vlan are returned.
func (gc *Cfg) AllocVXLAN(ra core.ResourceManager) (vxlan uint,
localVLAN uint, err error) {
pair, err1 := ra.AllocateResourceVal(gc.Tenant, resources.AutoVXLANResource)
if err1 != nil {
return 0, 0, err1
}
g := &Oper{}
g.StateDriver = gc.StateDriver
err = g.Read(gc.Tenant)
if err != nil {
return 0, 0, err
}
vxlan = pair.(resources.VXLANVLANPair).VXLAN + g.FreeVXLANsStart
localVLAN = pair.(resources.VXLANVLANPair).VLAN
return
}