In basic zone CloudStack provides AWS EIP like functionality using static NAT (1:1 NAT) from public IP to VM's private IP. Below are the semantics of EIP as implemented in CloudStack.
In this semantics, by default a public IP is allocated for each VM created in basic zone with EIP service. For deployments where public IP's are scarce resource, allocating public IP for each VM will be expensive. Currently there is no provision in the CloudStack to modify this behaviour. This proposal provides flexibility to the cloud admins, where they can choose not to allocate public IP to the VM by default when using EIP service in basic zone. Below is the description of API, DB and EIP semantics changes that shall be required to achieve this flexibility.
'Bug : 265 provide option to turn-off automatic public IP assignment for each VM when using EIP service' is opened to track this feature.
http://management server IP:8080/client/api?command=createNetworkOffering&response=json&name=EIP-offering-with default-publicIP&displayText=EIP-offering-with-default-publicIP&guestIpType=Isolated&
servicecapabilitylist[0].service=StaticNat&servicecapabilitylist[0].capabilitytype=ElasticIp&servicecapabilitylist[0].capabilityvalue=true&servicecapabilitylist[1].service=StaticNat&servicecapabilitylist[1].capabilitytype=AssociatePublicIP&servicecapabilitylist[1].capabilityvalue=true&
supportedServices=Dhcp,Dns,Firewall,SourceNat,StaticNat&specifyVlan=false..................(rest of the parameters)..........
http://management server IP:8080/client/api?command=createNetworkOffering&response=json&name=EIP-offering-with default-publicIP&displayText=EIP-offering-with-default-publicIP&guestIpType=Isolated&
servicecapabilitylist[0].service=StaticNat&servicecapabilitylist[0].capabilitytype=ElasticIp&servicecapabilitylist[0].capabilityvalue=true&servicecapabilitylist[1].service=StaticNat&servicecapabilitylist[1].capabilitytype=AssociatePublicIP&servicecapabilitylist[1].capabilityvalue=false&
supportedServices=Dhcp,Dns,Firewall,SourceNat,StaticNat&specifyVlan=false..................(rest of the parameters)..........
In the 'network_offerings' table new boolean column named 'eip_associate_public_ip' shall be introduced with below schema change.
`eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.',
If in the network offering used to create shared network in the basic zone has the 'eip_associate_public_ip' column set to true, then for each VM launched in the basic zone a public IP is associated with VM by default. If in the network offering used to create shared network in the basic zone has the 'eip_associate_public_ip' column set to false, then by default a VM launched in the basic zone will only have a private IP and no public IP will be associated with it.
CreateNetworkOffering API called with AssociatePublicIP capability set to TRUE shall result in creating network offering in the DB with eip_associate_public_ip column set to 1. CreateNetworkOffering API called with AssociatePublicIP capability set to FALSE shall result in creating network offering in the DB with eip_associate_public_ip column set to 0.
EIP semantics are modified as below:
This feature should affect EIP semantics with respect to user VM's only. System VM's should continue to get both public IP and private by default irrespective of 'eip_associate_public_ip' is set or not in the network offering that is used to create a basic zone with EIP and ELB service.
For the existing basic zone deployments with EIP service, current behaviour is to assign a public IP with every user VM. After upgrade, existing functionality will be retained. So on upgrade network offerings with EIP service enabled shall be updated so that 'eip_associate_public_ip' column of of the network_offerings table is set to 1.
The default network offering created by CloudStack, for created shared networks with EIP and ELB service shall be updated so that network offering will have eip_associate_public_ip set to true. So the new deployments which uses default shared network offering with EIP and ELB service to create shared network in the basic zone, shall result in the old EIP semantics to the users, i.e. a public IP is allocated by default to each user VM.
Create network offering dialog box should have capability 'associate IP address' checkbox that is available in the UI when EIP service capability is chosen. Checkbox for the capability shall only show up when 'EIP service' capability is choosen.
when the checkbok checked should result in a createNetworkOffering API with AssociatePublicIP parameter is passed and value set to true
when the checkbok un-checked should result in a createNetworkOffering API with AssociatePublicIP parameter is passed and value set to false