Thursday, October 19, 2017

OpenStack Orchestration Heat to create a Subnet in a given Network OpenStack Newton


OpenStack Orchestration Heat to create a Subnet in a given Network 


Here is how to have a subnet using the heat stack.


---

Creation of the subnet using the heat stack 


Here is the stack to create the subnet



[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]# cat 05subnet.yml
---
# for Newton release of OpenStack
#
heat_template_version: 2016-10-14

description:  having a private subnet in a private network

resources:
  subnet:
    type: OS::Neutron::Subnet
    properties:
      cidr: '192.168.201.0/24'
      name: internalsubnet1
      enable_dhcp: true
      ip_version: 4
      allocation_pools:
        - { start: 192.168.201.5, end: 192.168.201.254 }
      network: internal1

outputs:
  subnet_info:
    value: { get_attr: [subnet]}
[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]#

  
----



  • Create the stack using the above YAML file to create a subnet in the network 'internal1'.
  • The subnet will be named as 'internalsubnet1'
  • The Subnet name is 'internalsubnet1'
  • The Subnet CIDR is 192.168.201.0/24
  • The Allocation Pool range start:ebdis 192.168.201.5-192.168.205.254


---


Create the stack


[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]# openstack stack create -t 05subnet.yml internalsubnet_1
+---------------------+----------------------------------------------+
| Field               | Value                                        |
+---------------------+----------------------------------------------+
| id                  | b1fe49e0-01d1-4df8-9a15-9243f31b7055         |
| stack_name          | internalsubnet_1                             |
| description         | having a private subnet in a private network |
| creation_time       | 2017-10-19T21:01:47Z                         |
| updated_time        | None                                         |
| stack_status        | CREATE_IN_PROGRESS                           |
| stack_status_reason | Stack CREATE started                         |
+---------------------+----------------------------------------------+
[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]#


---

See that the stack is created 


[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]# openstack stack list | grep -i internalsubnet_1
| b1fe49e0-01d1-4df8-9a15-9243f31b7055 | internalsubnet_1  | CREATE_COMPLETE | 2017-10-19T21:01:47Z | None         |
[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]#


--

Confirm that the subnet has been created also see the subnet using openstack subnet show


[root@newtonallinone HeatOrchestrationTemplates(keystone_admin)]# openstack subnet show internalsubnet1
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 192.168.201.5-192.168.201.254        |
| cidr              | 192.168.201.0/24                     |
| created_at        | 2017-10-19T21:01:48Z                 |
| description       |                                      |
| dns_nameservers   |                                      |
| enable_dhcp       | True                                 |
| gateway_ip        | 192.168.201.1                        |
| host_routes       |                                      |
| id                | 9480b504-db1f-4f05-97b6-4058c7b168c9 |
| ip_version | 4                            |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | internalsubnet1                      |
| network_id        | 216e5f0c-e0ed-4c04-b912-37c6967a0038 |
| project_id        | 49b25ce4022c492fa0c1eab4fc6c7419     |
| project_id        | 49b25ce4022c492fa0c1eab4fc6c7419     |
| revision_number   | 2                                    |
| service_types     | []                                   |
| subnetpool_id     | None                                 |
| updated_at        | 2017-10-19T21:01:48Z                 |
+-------------------+--------------------------------------+

No comments:

Post a Comment