本文整理匯總了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
}