本文整理汇总了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
}