use of com.microsoft.azure.management.network.IPAllocationMethod in project photon-model by vmware.
the class AzureInstanceService method newAzureNetworkInterface.
/**
* Converts Photon model constructs to underlying Azure NetworkInterface model.
*/
private NetworkInterfaceInner newAzureNetworkInterface(AzureInstanceContext ctx, AzureNicContext nicCtx) {
NetworkInterfaceDescription description = nicCtx.nicStateWithDesc.description;
NetworkInterfaceIPConfigurationInner ipConfig = new NetworkInterfaceIPConfigurationInner();
ipConfig.withName(AzureUtils.generateClusterCommonName(NICCONFIG_NAME_PREFIX, ctx));
ipConfig.withSubnet(nicCtx.subnet);
if (nicCtx.publicIP != null) {
// Public IP is not auto-assigned so check for existence
ipConfig.withPublicIPAddress(new SubResource().withId(nicCtx.publicIP.id()));
}
ipConfig.withPrivateIPAllocationMethod(new IPAllocationMethod(description.assignment.name()));
if (description.assignment == IpAssignment.STATIC) {
ipConfig.withPrivateIPAddress(description.address);
}
NetworkInterfaceInner nic = new NetworkInterfaceInner();
nic.withLocation(ctx.resourceGroup.location());
// Azure's custom serializers don't handle well collections constructed with
// Collections.singletonList(), so initialize an ArrayList
List<NetworkInterfaceIPConfigurationInner> ipConfigs = new ArrayList<>();
ipConfigs.add(ipConfig);
nic.withIpConfigurations(ipConfigs);
if (nicCtx.securityGroup != null) {
// Security group is optional so check for existence
nic.withNetworkSecurityGroup(new SubResource().withId(nicCtx.securityGroup.id()));
}
return nic;
}
use of com.microsoft.azure.management.network.IPAllocationMethod in project photon-model by vmware.
the class AzureInstanceService method newAzurePublicIPAddress.
/**
* Converts Photon model constructs to underlying Azure PublicIPAddress model.
*/
private PublicIPAddressInner newAzurePublicIPAddress(AzureInstanceContext ctx, AzureNicContext nicCtx) {
PublicIPAddressInner publicIPAddress = new PublicIPAddressInner();
publicIPAddress.withLocation(ctx.resourceGroup.location());
publicIPAddress.withPublicIPAllocationMethod(new IPAllocationMethod(nicCtx.nicStateWithDesc.description.assignment.name()));
return publicIPAddress;
}
Aggregations