Creating a Network Template

Establishing a private network requires you to create and connect multiple network resources. You can consolidate these tasks by building an Orchestration template. For an introduction to creating templates, see Creating an Orchestration Template.

There are four resources required for the private network preparation to launch instances: network, subnet, router, and router interface. The following template defines each network resource and a parameter for the public network.

  • network_A—establishes a private network.
  • subnet_A—represents an IP address block used for assigning IP addresses to instances. The subnet must provide an address for the CIDR property and must associate the subnet with the network (network_id).
  • router_A—passes network traffic between the public network and the private network subnet. Router properties include an external gateway to the public network defined in the parameters section.
  • interface_A—associates the private network subnet with the router.
heat_template_version: 2015-04-30

description: Demo private network setup

resources:
  network_A:
    type: OS::Neutron::Net
    properties:
      name: Network A
      shared: false

  subnet_A:
    type: OS::Neutron::Subnet
    properties:
      name: Subnet A
      network_id: { get_resource: network_A }
      cidr: "192.168.7.0/24"
      gateway_ip: "192.168.7.1"
      dns_nameservers: [8.8.8.8]
      ip_version: 4

  router_A:
    type: OS::Neutron::Router
    properties:
      name: Router A
      external_gateway_info: { "network": { get_param: public_network } }

  interface_A:
    type: OS::Neutron::RouterInterface
    properties:
      router_id: { get_resource: router_A }
      subnet: { get_resource: subnet_A }

parameters:
  public_network:
    type: string
    label: Public network
    description: Default public network
    default: PUBLIC EXTERNAL - DO NOT MODIFY

To launch your network template using the CLI:

 $ openstack stack create Stack_A -t launchnetwork.yaml
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | <stack_id>                           |
| stack_name          | Stack_A                              |
| description         | Demo private network setup           |
| creation_time       | 2017-06-30T20:42:54                  |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+