/** * @return entry point to managing virtual networks */ public Networks networks() { return networkManager.networks(); }
/** * @return entry point to managing virtual networks */ public Networks networks() { return networkManager.networks(); }
public Network getNetwork() { String id = this.networkId(); if (id == null) { return null; } return this.networkManager.networks().getById(id); }
public Network getNetwork() { String id = this.networkId(); if (id == null) { return null; } return this.networkManager.networks().getById(id); }
List<Subnet> listAssociatedSubnets(List<SubnetInner> subnetRefs) { final Map<String, Network> networks = new HashMap<>(); final List<Subnet> subnets = new ArrayList<>(); if (subnetRefs != null) { for (SubnetInner subnetRef : subnetRefs) { String networkId = ResourceUtils.parentResourceIdFromResourceId(subnetRef.id()); Network network = networks.get(networkId.toLowerCase()); if (network == null) { network = this.networks().getById(networkId); networks.put(networkId.toLowerCase(), network); } String subnetName = ResourceUtils.nameFromResourceId(subnetRef.id()); subnets.add(network.subnets().get(subnetName)); } } return Collections.unmodifiableList(subnets); }
List<Subnet> listAssociatedSubnets(List<SubnetInner> subnetRefs) { final Map<String, Network> networks = new HashMap<>(); final List<Subnet> subnets = new ArrayList<>(); if (subnetRefs != null) { for (SubnetInner subnetRef : subnetRefs) { String networkId = ResourceUtils.parentResourceIdFromResourceId(subnetRef.id()); Network network = networks.get(networkId.toLowerCase()); if (network == null) { network = this.networks().getById(networkId); networks.put(networkId.toLowerCase(), network); } String subnetName = ResourceUtils.nameFromResourceId(subnetRef.id()); subnets.add(network.subnets().get(subnetName)); } } return Collections.unmodifiableList(subnets); }
Subnet getAssociatedSubnet(SubResource subnetRef) { if (subnetRef == null) { return null; } String vnetId = ResourceUtils.parentResourceIdFromResourceId(subnetRef.id()); String subnetName = ResourceUtils.nameFromResourceId(subnetRef.id()); if (vnetId == null || subnetName == null) { return null; } Network network = this.networks().getById(vnetId); if (network == null) { return null; } return network.subnets().get(subnetName); }
@Override public Network getPrimaryNetwork() throws IOException { String subnetId = primaryNicDefaultIPConfiguration().subnet().id(); String virtualNetworkId = ResourceUtils.parentResourceIdFromResourceId(subnetId); return this.networkManager .networks() .getById(virtualNetworkId); }
Subnet getAssociatedSubnet(SubResource subnetRef) { if (subnetRef == null) { return null; } String vnetId = ResourceUtils.parentResourceIdFromResourceId(subnetRef.id()); String subnetName = ResourceUtils.nameFromResourceId(subnetRef.id()); if (vnetId == null || subnetName == null) { return null; } Network network = this.networks().getById(vnetId); if (network == null) { return null; } return network.subnets().get(subnetName); }
@Override public Network getPrimaryNetwork() throws IOException { String subnetId = primaryNicDefaultIPConfiguration().subnet().id(); String virtualNetworkId = ResourceUtils.parentResourceIdFromResourceId(subnetId); return this.networkManager .networks() .getById(virtualNetworkId); }
@Override public Set<String> listAvailablePrivateIPAddresses() { Set<String> ipAddresses = new TreeSet<>(); String cidr = this.addressPrefix(); if (cidr == null) { return ipAddresses; // Should never happen, but just in case } String takenIPAddress = cidr.split("/")[0]; IPAddressAvailabilityResultInner result = this.parent().manager().networks().inner().checkIPAddressAvailability( this.parent().resourceGroupName(), this.parent().name(), takenIPAddress); if (result == null) { return ipAddresses; } ipAddresses.addAll(result.availableIPAddresses()); return ipAddresses; } }
@Override public Set<String> listAvailablePrivateIPAddresses() { Set<String> ipAddresses = new TreeSet<>(); String cidr = this.addressPrefix(); if (cidr == null) { return ipAddresses; // Should never happen, but just in case } String takenIPAddress = cidr.split("/")[0]; IPAddressAvailabilityResultInner result = this.parent().manager().networks().inner().checkIPAddressAvailability( this.parent().resourceGroupName(), this.parent().name(), takenIPAddress); if (result == null) { return ipAddresses; } ipAddresses.addAll(result.availableIPAddresses()); return ipAddresses; } }
private IPAddressAvailabilityResultInner checkIPAvailability(String ipAddress) { if (ipAddress == null) { return null; } IPAddressAvailabilityResultInner result = null; try { result = this.manager().networks().inner().checkIPAddressAvailability( this.resourceGroupName(), this.name(), ipAddress); } catch (CloudException e) { if (!e.body().code().equalsIgnoreCase("PrivateIPAddressNotInAnySubnet")) { throw e; // Rethrow if the exception reason is anything other than IP address not found } } return result; }
private IPAddressAvailabilityResultInner checkIPAvailability(String ipAddress) { if (ipAddress == null) { return null; } IPAddressAvailabilityResultInner result = null; try { result = this.manager().networks().inner().checkIPAddressAvailability( this.resourceGroupName(), this.name(), ipAddress); } catch (CloudException e) { if (!e.body().code().equalsIgnoreCase("PrivateIPAddressNotInAnySubnet")) { throw e; // Rethrow if the exception reason is anything other than IP address not found } } return result; }
private Creatable<Network> ensureDefaultNetworkDefinition() { if (this.creatableNetwork == null) { final String vnetName = SdkContext.randomResourceName("vnet", 10); this.creatableNetwork = this.manager().networks().define(vnetName) .withRegion(this.region()) .withExistingResourceGroup(this.resourceGroupName()) .withAddressSpace("10.0.0.0/24") .withSubnet(DEFAULT, "10.0.0.0/25") .withSubnet("apps", "10.0.0.128/25"); } return this.creatableNetwork; }
private Creatable<Network> ensureDefaultNetworkDefinition() { if (this.creatableNetwork == null) { final String vnetName = SdkContext.randomResourceName("vnet", 10); this.creatableNetwork = this.manager().networks().define(vnetName) .withRegion(this.region()) .withExistingResourceGroup(this.resourceGroupName()) .withAddressSpace("10.0.0.0/24") .withSubnet(DEFAULT, "10.0.0.0/25") .withSubnet("apps", "10.0.0.128/25"); } return this.creatableNetwork; }
@Override public VirtualNetworkGatewayImpl withNewNetwork(String name, String addressSpace, String subnetAddressSpaceCidr) { Network.DefinitionStages.WithGroup definitionWithGroup = this.manager().networks() .define(name) .withRegion(this.regionName()); Network.DefinitionStages.WithCreate definitionAfterGroup; if (this.newGroup() != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.newGroup()); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName()); } Creatable<Network> network = definitionAfterGroup.withAddressSpace(addressSpace).withSubnet(GATEWAY_SUBNET, subnetAddressSpaceCidr); return withNewNetwork(network); }
@Override public VirtualNetworkGatewayImpl withNewNetwork(String name, String addressSpace, String subnetAddressSpaceCidr) { Network.DefinitionStages.WithGroup definitionWithGroup = this.manager().networks() .define(name) .withRegion(this.regionName()); Network.DefinitionStages.WithCreate definitionAfterGroup; if (this.newGroup() != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.newGroup()); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName()); } Creatable<Network> network = definitionAfterGroup.withAddressSpace(addressSpace).withSubnet(GATEWAY_SUBNET, subnetAddressSpaceCidr); return withNewNetwork(network); }
@Override public NicIPConfigurationImpl withNewNetwork(String name, String addressSpaceCidr) { Network.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.networks() .define(name) .withRegion(this.parent().regionName()); Network.DefinitionStages.WithCreate definitionAfterGroup; if (this.parent().newGroup() != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.parent().newGroup()); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.parent().resourceGroupName()); } return withNewNetwork(definitionAfterGroup.withAddressSpace(addressSpaceCidr)); }
@Override public NicIPConfigurationImpl withNewNetwork(String name, String addressSpaceCidr) { Network.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.networks() .define(name) .withRegion(this.parent().regionName()); Network.DefinitionStages.WithCreate definitionAfterGroup; if (this.parent().newGroup() != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.parent().newGroup()); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.parent().resourceGroupName()); } return withNewNetwork(definitionAfterGroup.withAddressSpace(addressSpaceCidr)); }