// Retrieve Whether or not this subnet is associated with a router. Subnets that are not associated with a router cannot be routed.
497396
func (r Network_Subnet) GetBoundRouterFlag() (resp bool, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Subnet", "getBoundRouterFlag", nil, &r.Options, &resp)
	return
}
1091551
func (api *NetworksAPI) GetSubnets(networkID string, options *SubnetGetOptions) (result *Subnets, err error) {
	uri := api.client.Endpoint + networkUrl + networkID + "/subnets"
	if options != nil {
		uri += getQueryString(options)
	}
	res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions)
	if err != nil {
		return
	}

	result = &Subnets{}
	err = json.Unmarshal(res, result)
	return
}
877756
func (r Network_Customer_Subnet) GetIpAddresses() (resp []datatypes.Network_Customer_Subnet_IpAddress, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Customer_Subnet", "getIpAddresses", nil, &r.Options, &resp)
	return
}
130252
func (router *Router) RouteExists(ctx context.Context, method, path string) bool {
	return router.requestHandler.RouteExists(ctx, method, path)
}
1222037
func (c *Config) FindRouter(scope, namePrefix string) *Rule {
	for _, router := range c.Routers {
		if router.RouteTo(scope, namePrefix) {
			return router
		}
	}

	return c.findDefaultRouter()
}
133908
func (e *Environ) Subnets(ctx envcontext.ProviderCallContext, id instance.Id, subnets []network.Id) ([]network.SubnetInfo, error) {
	var results []network.SubnetInfo
	subIdSet := set.NewStrings()
	for _, subId := range subnets {
		subIdSet.Add(string(subId))
	}

	allSubnets, err := e.allSubnetsAsMap(e.Config().UUID())
	if err != nil {
		providerCommon.HandleCredentialError(err, ctx)
		return nil, errors.Trace(err)
	}
	hasSubnetList := false
	if len(subIdSet) > 0 {
		hasSubnetList = true
	}
	if id != instance.UnknownId {
		oInst, err := e.getOCIInstance(ctx, id)
		if err != nil {
			providerCommon.HandleCredentialError(err, ctx)
			return nil, errors.Trace(err)
		}

		vnics, err := oInst.getVnics()
		if err != nil {
			providerCommon.HandleCredentialError(err, ctx)
			return nil, errors.Trace(err)
		}
		for _, nic := range vnics {
			if nic.Vnic.SubnetId == nil {
				continue
			}
			if hasSubnetList {
				if !subIdSet.Contains(*nic.Vnic.SubnetId) {
					continue
				} else {
					subIdSet.Remove(*nic.Vnic.SubnetId)
				}
			}
			subnet, ok := allSubnets[*nic.Vnic.SubnetId]
			if !ok {
				continue
			}
			info := network.SubnetInfo{
				CIDR:       *subnet.CidrBlock,
				ProviderId: network.Id(*nic.Vnic.SubnetId),
			}
			results = append(results, info)
		}
	} else {
		for subnetId, subnet := range allSubnets {
			if hasSubnetList {
				if !subIdSet.Contains(subnetId) {
					continue
				} else {
					subIdSet.Remove(subnetId)
				}
			}
			if info, err := makeSubnetInfo(subnet); err == nil {
				results = append(results, info)
			}
		}
	}
	if hasSubnetList && !subIdSet.IsEmpty() {
		return nil, errors.Errorf("failed to find the following subnet ids: %v", subIdSet.Values())
	}

	// Sort the list of subnets to ensure consistency in what we display
	// to the user
	sort.Slice(results, func(i, j int) bool {
		return results[i].ProviderId < results[j].ProviderId
	})

	return results, nil
}
183631
func (r Network_Subnet_Registration) GetStatus() (resp datatypes.Network_Subnet_Registration_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Subnet_Registration", "getStatus", nil, &r.Options, &resp)
	return
}
111971
func (c *Cloud) findSubnets() ([]*ec2.Subnet, error) {
	request := &ec2.DescribeSubnetsInput{}
	filters := []*ec2.Filter{newEc2Filter("vpc-id", c.vpcID)}
	request.Filters = c.tagging.addFilters(filters)

	subnets, err := c.ec2.DescribeSubnets(request)
	if err != nil {
		return nil, fmt.Errorf("error describing subnets: %q", err)
	}

	var matches []*ec2.Subnet
	for _, subnet := range subnets {
		if c.tagging.hasClusterTag(subnet.Tags) {
			matches = append(matches, subnet)
		}
	}

	if len(matches) != 0 {
		return matches, nil
	}

	// Fall back to the current instance subnets, if nothing is tagged
	klog.Warningf("No tagged subnets found; will fall-back to the current subnet only.  This is likely to be an error in a future version of k8s.")

	request = &ec2.DescribeSubnetsInput{}
	filters = []*ec2.Filter{newEc2Filter("subnet-id", c.selfAWSInstance.subnetID)}
	request.Filters = filters

	subnets, err = c.ec2.DescribeSubnets(request)
	if err != nil {
		return nil, fmt.Errorf("error describing subnets: %q", err)
	}

	return subnets, nil
}
133452
func (c *Client) GetNetwork() (*Network, error) {
	network := &Network{}
	return network, c.Get("/", network)
}
39572
func determineSubnetURL(service *compute.Service, networkProjectID, networkName, region string) (string, error) {
	subnets, err := listSubnetworksOfNetwork(service, networkProjectID, networkName, region)
	if err != nil {
		return "", err
	}

	autoSubnets, err := subnetsInCIDR(subnets, autoSubnetIPRange)
	if err != nil {
		return "", err
	}

	if len(autoSubnets) == 0 {
		return "", fmt.Errorf("no subnet exists in auto CIDR")
	}

	if len(autoSubnets) > 1 {
		return "", fmt.Errorf("multiple subnetworks in the same region exist in auto CIDR")
	}

	return autoSubnets[0].SelfLink, nil
}
631192
func InSubnets(ip net.IP, subnets map[string]*net.IPNet) bool {
	for _, subnet := range subnets {
		if subnet.Contains(ip) {
			return true
		}
	}
	return false
}
596386
func (e Environ) Subnets(ctx context.ProviderCallContext, id instance.Id, subnets []network.Id) ([]network.SubnetInfo, error) {
	ret := []network.SubnetInfo{}
	found := make(map[string]bool)
	if id != instance.UnknownId {
		instanceNets, err := e.NetworkInterfaces(ctx, id)
		if err != nil {
			return ret, errors.Trace(err)
		}
		if len(subnets) == 0 {
			for _, val := range instanceNets {
				found[string(val.ProviderSubnetId)] = false
			}
		}
		for _, val := range instanceNets {
			if _, ok := found[string(val.ProviderSubnetId)]; !ok {
				continue
			} else {
				found[string(val.ProviderSubnetId)] = true
				subnetInfo := network.SubnetInfo{
					CIDR:            val.CIDR,
					ProviderId:      val.ProviderSubnetId,
					SpaceProviderId: val.ProviderSpaceId,
				}
				ret = append(ret, subnetInfo)
			}
		}
	} else {
		subnets, err := e.getSubnetInfoAsMap()
		if err != nil {
			return ret, errors.Trace(err)
		}
		if len(subnets) == 0 {
			for key := range subnets {
				found[key] = false
			}
		}
		for key, val := range subnets {
			if _, ok := found[key]; !ok {
				continue
			}
			found[key] = true
			ret = append(ret, val)
		}
	}
	missing := []string{}
	for key, ok := range found {
		if !ok {
			missing = append(missing, key)
		}
	}
	if len(missing) > 0 {
		return nil, errors.Errorf(
			"missing subnets: %s", strings.Join(missing, ","))
	}
	return ret, nil
}
1018285
func (s *Subnet) Contains(a Address) bool {
	if len(a) != len(s.address) {
		return false
	}
	for i := 0; i < len(a); i++ {
		if a[i]&s.mask[i] != s.address[i] {
			return false
		}
	}
	return true
}
169782
func (e Environ) getSubnetInfoAsMap() (map[string]network.SubnetInfo, error) {
	subnets, err := e.getSubnetInfo()
	if err != nil {
		return nil, err
	}
	ret := make(map[string]network.SubnetInfo, len(subnets))
	for _, val := range subnets {
		ret[string(val.ProviderId)] = val
	}
	return ret, nil
}
913878
func (r Network_Storage) GetAllowableSubnets(filterNetworkIdentifier *string) (resp []datatypes.Network_Subnet, err error) {
	params := []interface{}{
		filterNetworkIdentifier,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage", "getAllowableSubnets", params, &r.Options, &resp)
	return
}
854274
func (a *NetAddr) IsEmpty() bool {
	return a.Addr == "" && a.AddrNetwork == "" && a.Path == ""
}
498665
func (r Network_Vlan) GetNetwork() (resp datatypes.Network, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Vlan", "getNetwork", nil, &r.Options, &resp)
	return
}