本文整理汇总了Golang中github.com/Juniper/contrail-go-api/types.VirtualNetwork.GetInstanceIpBackRefs方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualNetwork.GetInstanceIpBackRefs方法的具体用法?Golang VirtualNetwork.GetInstanceIpBackRefs怎么用?Golang VirtualNetwork.GetInstanceIpBackRefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Juniper/contrail-go-api/types.VirtualNetwork
的用法示例。
在下文中一共展示了VirtualNetwork.GetInstanceIpBackRefs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateSubnetConfig
// Subnets can only be deleted if there are no instance-ips or floating-ips associated
// with the subnet.
func (m *NetworkManagerImpl) updateSubnetConfig(network *types.VirtualNetwork, prefix string) error {
prefixList, err := m.NetworkIPPrefixList(network)
if err != nil {
glog.Fatal(err)
}
add := true
for _, pfx := range prefixList {
if pfx == prefix {
add = false
continue
}
ipRefs, err := network.GetInstanceIpBackRefs()
if err != nil {
glog.Error(err)
continue
}
// TODO: filter the IP addresses associated with the subnet that we are
// attempting to delete.
if len(ipRefs) > 0 {
glog.Warningf(
"network %s %s is stale but there are %d instance-ips present",
network.GetName(), pfx, len(ipRefs))
continue
}
pool, err := m.LookupFloatingIpPool(network)
if err == nil {
floatRefs, err := pool.GetFloatingIps()
if err != nil {
glog.Error(err)
continue
}
// TODO: filter the floating-ips associated with the subnet that we
// are attempting to delete.
if len(floatRefs) > 0 {
glog.Warningf(
"network %s %s is stale but there are %d floating-ip addresses present",
network.GetName(), pfx, len(floatRefs))
continue
}
}
err = config.RemoveSubnet(m.client, network, pfx)
if err != nil {
glog.Error(err)
}
}
if add {
_, err := config.AddSubnet(m.client, network, m.config.PublicSubnet)
if err != nil {
glog.Error(err)
}
return err
}
return nil
}