In this tutorial, you will find out how to create an additional network in a
project that already has a private network, and then create a server that has
interfaces on the existing private network and the newly created one.

You will need to delve into the mysteries of ‘cloud-init’ a little to achieve
this. You’ll also learn how to perform another useful customisation -
changing who the default user is for an instance.

We need to create a network, and a subnet - and then boot an instance using
these plus an already existing private network. Unfortunately, it is not
sufficient simply to create networks and provide these to the instance at
creation time - only the first network is properly configured if this approach
is taken (this could be viewed as a bug). This can be worked around using the
the user_data property along with cloud-init:

## Deploying a network and a compute instance using Heat#heat_template_version:2013-05-23description:>Deploying new network, subnet and a server using Heat.parameters:key_name:type:stringdescription:Name of an existing key pair to use for the serverdefault:your-user-keyconstraints:-custom_constraint:nova.keypairflavor:type:stringdescription:Flavor for the server to be createddefault:c1.c2r2constraints:-custom_constraint:nova.flavorimage:type:stringdescription:Image ID or image name to use for the serverdefault:ubuntu-14.04-x86_64constraints:-custom_constraint:glance.imageuser:type:stringdescription:Default userdefault:myusernet1:type:stringdescription:(existing) network for the server to be createddefault:private-net1constraints:-custom_constraint:neutron.networknet2:type:stringdescription:(New) network for the server to be createddefault:private-net2subnetcidr:type:stringdescription:Subnet cidrdefault:10.0.99.0/24subnetstart:type:stringdescription:Start of subnet addressdefault:10.0.99.10subnetend:type:stringdescription:End of subnet addressdefault:10.0.99.100resources:private_net:type:OS::Neutron::Netproperties:name:{get_param:net2}private_subnet:type:OS::Neutron::Subnetproperties:name:{get_param:net2}network_id:{get_resource:private_net}cidr:{get_param:subnetcidr}allocation_pools:-start:{get_param:subnetstart}end:{get_param:subnetend}server:type:OS::Nova::Serverproperties:name:server1key_name:{get_param:key_name}image:{get_param:image}flavor:{get_param:flavor}networks:-network:{get_param:net1}-network:{get_resource:private_net}user_data:str_replace:template:|#cloud-configbootcmd:- "ifdir='/etc/network/interfaces.d'; for iface in $(ip -o link | cut -d: -f2 | tr -d ' ' | grep ^eth); do if [ ! -e ${ifdir}'/'${iface}'.cfg' ]; then echo 'Creating iface file for '${iface}; echo 'auto '${iface}'\niface '${iface}' inet dhcp\n' > $ifdir'/'$iface'.cfg'; ifup ${iface}; fi; done"runcmd:- "echo 'Complete' > /var/log/cloud-init-complete.txt"system_info:default_user:name: $USERshell: /bin/bashparams:$USER:{get_param:user}user_data_format:RAWoutputs:server_networks:description:The networks of the deployed servervalue:{get_attr:[server,networks]}