Chapter 5: Neutron - Basic Commands - Part 1

The basic build blocks in Neutron are Networks, Subnets, Ports .

Good article for basic concepts,

http://superuser.openstack.org/articles/everything-you-need-to-know-to-get-started-with-neutron-f90e2797-26b7-4d1c-84d8-effef03f11d2/

Genaral Notes:

Note1 : neutron cli supports verbose option "-v". Its applicable on all the commands. verbose shows debug prints/api transcation details for the command.

Note2: To know the detailed options for neutron command, use "neutron help <command name>". Ex neutron help net-create

Note3: The output of the command is displayed in Table format, sometimes it may not be displayed properly due to too many fields or data size. "table-formatter" options are availble in all the commands to control the display issues. Example: "--fit-width" option fit the display in the screen.


Commands :

1. Networks :

To create a network,

simple syntax:

neutron net-create <network name>

Example:

neutron net-create LabNetwork

To List the networks,

neutron net-list

Note: filter options helps to filter out the list by "tenant-id","status", "shared", "name","router:external"

Example:

To List the networks which status are "ERROR"

neutron net-list --status ERROR

To show the network,

Simple Syntax:

neutron net-show <network name>

Example:

neutron net-show LabNetwork

To update the existing network,

existing network parameters(descripton, qos_policy,dns) can be updated

Example:

neutron net-update  LabNetwork --description "Lab Network - Restricted access"

2. Subnets :

To create a subnet,

Simple Syntax:

neutron subnet-create --name <subnet name> <Network Name> <cidr>

Example:

neutron subnet-create --name LabSubnet LabNetwork 10.10.20.0/24

The default options are , Gateway IP is set as the "First IP in this subnet", In this example, 10.10.20.1.

DHCP Pools uses all the remaining IPs. In this example 10.10.20.2 to 10.10.20.254.

To override this default behavior, use the explicit definition for gateway, allocation-pool, enable/disable dhcp, dns server etc.

To create a subnet with gatway and pool,

neutron subnet-create --name LabSubnet --gateway 10.20.20.254 --allocation-pool start=10.10.20.50,end=10.10.20.100 LabNetwork 10.10.20.0/24

In the above example, set the gateway IP as 10.10.20.254, and dhcp pool for 10.10.20.50 to 10.20.20.100.

To List the subnets,

neutron subnet-list
neutron subnet-list --fit-width

To Show the subnet,

Syntax:

neutron subnet-show <subnet name or id>

Example:

neutron subnet-show LabSubnet

To update the existing subnet,

Existing subnet parameters(name,description, allocation-pools, dns-server, gateway) details can be modified using this command.

options are similar to subnet-create command

Example:

neutron subnet-update LabSubnet --gateway 10.l0.20.1

3. Ports :

To List the ports,

neutron port-list

To create a port,

Syntax:

neutron port-create <netowork or name> [options]

There are many options are available, --fixed-ip, --security-group are most used one.

Create a port with fixed ip:

neutron port-create --fixed-ip subnet_id=S1,ip_address=10.10.10.101 --security-group default N1

To delete a port,

syntax:

neutron port-delete <port name or id>

neutron port-delete ffacc801-0b97-4e3a-9768-fe5d58713b6e

To Update a port parameter,

Todo


Execution Logs:

1. Networks :

(osclient)cloud@db:~/osclient$ neutron net-create LabNetwork
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new network:
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2017-08-12T07:12:11Z                 |
| description             |                                      |
| id                      | 7f287247-1497-48a1-a129-026cc359c75c |
| ipv4_address_scope      |                                      |
| ipv6_address_scope      |                                      |
| mtu                     | 1450                                 |
| name                    | LabNetwork                           |
| port_security_enabled   | True                                 |
| project_id              | bccf45eee4544264a526c4bca56fdb3c     |
| revision_number         | 3                                    |
| router:external         | False                                |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    |                                      |
| tenant_id               | bccf45eee4544264a526c4bca56fdb3c     |
| updated_at              | 2017-08-12T07:12:11Z                 |
+-------------------------+--------------------------------------+
(osclient)cloud@db:~/osclient$

(osclient)cloud@db:~/osclient$ neutron net-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+------------+----------------------------------------------------------+
| id                                   | name       | subnets                                                  |
+--------------------------------------+------------+----------------------------------------------------------+
| 166d0427-cfc5-4234-b61c-b3bb8f6e3a32 | private    | 91c773a1-a4e2-4f14-946d-401c1f7ee627 10.0.0.0/26         |
|                                      |            | dea60d2b-6809-43eb-a687-d1877e04f679 fd25:cc32:b8d7::/64 |
| 7f287247-1497-48a1-a129-026cc359c75c | LabNetwork |                                                          |
| 975dd3d1-3576-4c34-991e-eaf24f45295e | public     | 543ef8a3-5717-44d1-81f9-70c5057e889c                     |
|                                      |            | 8171e8c6-2953-4ffa-beab-8f07b43a08c4                     |
| a46e7660-c764-41cd-ba0e-2c3e1180c329 | N2         |                                                          |
| c9d8294c-26d6-42dd-aaf8-e3fd56848100 | N1         | 3f5cb4cb-3524-48c3-8b1c-45ae37531289 10.10.10.0/24       |
+--------------------------------------+------------+----------------------------------------------------------+
(osclient)cloud@db:~/osclient$


(osclient)cloud@db:~/osclient$ neutron net-list --status ERROR
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.

(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron net-update N2 --description "Lab network - Restricted Network"                        
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Updated network: N2
(osclient)cloud@db:~/osclient$

2. Subnets :

(osclient)cloud@db:~/osclient$ neutron subnet-create --name LabSubnet LabNetwork 10.10.20.0/24                                 
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new subnet:
+-------------------+------------------------------------------------+
| Field             | Value                                          |
+-------------------+------------------------------------------------+
| allocation_pools  | {"start": "10.10.20.2", "end": "10.10.20.254"} |
| cidr              | 10.10.20.0/24                                  |
| created_at        | 2017-08-12T07:14:45Z                           |
| description       |                                                |
| dns_nameservers   |                                                |
| enable_dhcp       | True                                           |
| gateway_ip        | 10.10.20.1                                     |
| host_routes       |                                                |
| id                | fa16ebfa-c66a-4570-8198-e9af42c68840           |
| ip_version        | 4                                              |
| ipv6_address_mode |                                                |
| ipv6_ra_mode      |                                                |
| name              | LabSubnet                                      |
| network_id        | 7f287247-1497-48a1-a129-026cc359c75c           |
| project_id        | bccf45eee4544264a526c4bca56fdb3c               |
| revision_number   | 2                                              |
| service_types     |                                                |
| subnetpool_id     |                                                |
| tags              |                                                |
| tenant_id         | bccf45eee4544264a526c4bca56fdb3c               |
| updated_at        | 2017-08-12T07:14:45Z                           |
+-------------------+------------------------------------------------+
(osclient)cloud@db:~/osclient$


# create a subnet with gatewy and allocation pool
(osclient)cloud@db:~/osclient$ neutron subnet-create --name LabSubnet --gateway 10.20.20.254 --allocation-pool start=10.10.20.50,end=10.10.20.100 LabNetwork 10.10.20.0/24
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new subnet:
+-------------------+-------------------------------------------------+
| Field             | Value                                           |
+-------------------+-------------------------------------------------+
| allocation_pools  | {"start": "10.10.20.50", "end": "10.10.20.100"} |
| cidr              | 10.10.20.0/24                                   |
| created_at        | 2017-08-12T07:22:34Z                            |
| description       |                                                 |
| dns_nameservers   |                                                 |
| enable_dhcp       | True                                            |
| gateway_ip        | 10.20.20.254                                    |
| host_routes       |                                                 |
| id                | 7b4acabf-07ab-4428-a9d1-686a0c0dac5b            |
| ip_version        | 4                                               |
| ipv6_address_mode |                                                 |
| ipv6_ra_mode      |                                                 |
| name              | LabSubnet                                       |
| network_id        | 7f287247-1497-48a1-a129-026cc359c75c            |
| project_id        | bccf45eee4544264a526c4bca56fdb3c                |
| revision_number   | 2                                               |
| service_types     |                                                 |
| subnetpool_id     |                                                 |
| tags              |                                                 |
| tenant_id         | bccf45eee4544264a526c4bca56fdb3c                |
| updated_at        | 2017-08-12T07:22:34Z                            |
+-------------------+-------------------------------------------------+
(osclient)cloud@db:~/osclient$
(osclient)cloud@db:~/osclient$ neutron subnet-list --fit-width
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+---------------------+---------------------+----------------------------------------+
| id                                   | name                | cidr                | allocation_pools                       |
+--------------------------------------+---------------------+---------------------+----------------------------------------+
| 3f5cb4cb-3524-48c3-8b1c-45ae37531289 | S1                  | 10.10.10.0/24       | {"start": "10.10.10.2", "end":         |
|                                      |                     |                     | "10.10.10.254"}                        |
| 7b4acabf-07ab-4428-a9d1-686a0c0dac5b | LabSubnet           | 10.10.20.0/24       | {"start": "10.10.20.50", "end":        |
|                                      |                     |                     | "10.10.20.100"}                        |
| 91c773a1-a4e2-4f14-946d-401c1f7ee627 | private-subnet      | 10.0.0.0/26         | {"start": "10.0.0.2", "end":           |
|                                      |                     |                     | "10.0.0.62"}                           |
| dea60d2b-6809-43eb-a687-d1877e04f679 | ipv6-private-subnet | fd25:cc32:b8d7::/64 | {"start": "fd25:cc32:b8d7::2", "end":  |
|                                      |                     |                     | "fd25:cc32:b8d7:0:ffff:ffff:ffff:ffff" |
|                                      |                     |                     | }                                      |
+--------------------------------------+---------------------+---------------------+----------------------------------------+
(osclient)cloud@db:~/osclient$

results matching ""

    No results matching ""