当前位置: 首页>>代码示例>>Golang>>正文


Golang VirtualNetwork.GetInstanceIpBackRefs方法代码示例

本文整理汇总了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
}
开发者ID:pupapaik,项目名称:contrail-kubernetes,代码行数:60,代码来源:network.go


注:本文中的github.com/Juniper/contrail-go-api/types.VirtualNetwork.GetInstanceIpBackRefs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。