openstack-manuals/doc/common/section_cli_neutron_manage_networks.xml
Deepti Navale 94fc3a9cce Included CLI procedure for creating a router
Updated the 'Create and manage networks' section in the CLI chapter of End User
guide to include procedure for creating a router.
Closes-Bug: #1280925

Change-Id: I5061681804c3188583e22a1283378e494f2f8980
2014-02-24 10:35:06 +10:00

233 lines
15 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml" version="5.0"
xml:id="neutron_client_sample_commands">
<title>Create and manage networks</title>
<para>Before you run commands, set the following environment
variables:</para>
<programlisting language="bash">export OS_USERNAME=admin
export OS_PASSWORD=password
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://localhost:5000/v2.0</programlisting>
<section xml:id="cli_networks">
<title>Create networks</title>
<procedure>
<step>
<para>List the extensions of the system:</para>
<screen><prompt>$</prompt> <userinput>neutron ext-list -c alias -c name</userinput></screen>
<screen><computeroutput>+-----------------+--------------------------+
| alias | name |
+-----------------+--------------------------+
| agent_scheduler | Agent Schedulers |
| binding | Port Binding |
| quotas | Quota management support |
| agent | agent |
| provider | Provider Network |
| router | Neutron L3 Router |
| lbaas | LoadBalancing service |
| extraroute | Neutron Extra Route |
+-----------------+--------------------------+</computeroutput></screen>
</step>
<step>
<para>Create a network:</para>
<screen><prompt>$</prompt> <userinput>neutron net-create net1</userinput></screen>
<screen><computeroutput>Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | 2d627131-c841-4e3a-ace6-f2dd75773b6d |
| name | net1 |
| provider:network_type | vlan |
| provider:physical_network | physnet1 |
| provider:segmentation_id | 1001 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 3671f46ec35e4bbca6ef92ab7975e463 |
+---------------------------+--------------------------------------+</computeroutput></screen>
<note>
<para>Some fields of the created network are
invisible to non-admin users.</para>
</note>
</step>
<step>
<para>Create a network with specified provider network
type:</para>
<screen><prompt>$</prompt> <userinput>neutron net-create net2 --provider:network-type local</userinput></screen>
<screen><computeroutput>Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | 524e26ea-fad4-4bb0-b504-1ad0dc770e7a |
| name | net2 |
| provider:network_type | local |
| provider:physical_network | |
| provider:segmentation_id | |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 3671f46ec35e4bbca6ef92ab7975e463 |
+---------------------------+--------------------------------------+</computeroutput></screen>
<para>Just as shown previously, the unknown option
<literal>--provider:network-type</literal> is
used to create a <literal>local</literal> provider
network.</para>
</step>
</procedure>
</section>
<section xml:id="cli_subnets">
<title>Create subnets</title>
<procedure>
<step>
<para>Create a subnet:</para>
<screen><prompt>$</prompt> <userinput>neutron subnet-create net1 192.168.2.0/24 --name subnet1</userinput></screen>
<screen><computeroutput>Created a new subnet:
+------------------+--------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------+
| allocation_pools | {"start": "192.168.2.2", "end": "192.168.2.254"} |
| cidr | 192.168.2.0/24 |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 192.168.2.1 |
| host_routes | |
| id | 15a09f6c-87a5-4d14-b2cf-03d97cd4b456 |
| ip_version | 4 |
| name | subnet1 |
| network_id | 2d627131-c841-4e3a-ace6-f2dd75773b6d |
| tenant_id | 3671f46ec35e4bbca6ef92ab7975e463 |
+------------------+--------------------------------------------------+</computeroutput></screen>
<para>In the previous command, <literal>net1</literal>
is the network name,
<literal>192.168.2.0/24</literal> is the
subnet's CIDR. They are positional arguments.
<literal>--name subnet1</literal> is an
unknown option, which specifies the subnet's
name.</para>
</step>
</procedure>
</section>
<section xml:id="cli_routers">
<title>Create routers</title>
<procedure>
<step>
<para>Create a new router:</para>
<screen><prompt>$</prompt> <userinput>neutron router-create <replaceable>router1</replaceable></userinput></screen>
<screen><computeroutput>Created a new router:
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| admin_state_up | True |
| external_gateway_info | |
| id | 6e1f11ed-014b-4c16-8664-f4f615a3137a |
| name | router1 |
| status | ACTIVE |
| tenant_id | 7b5970fbe7724bf9b74c245e66b92abf |
+-----------------------+--------------------------------------+</computeroutput></screen>
<para>Take note of the unique router identifier returned, this
will be required in subsequent steps.</para>
</step>
<step>
<para>Link the router to the external provider network:</para>
<screen><prompt>$</prompt> <userinput>neutron router-gateway-set <replaceable>ROUTER</replaceable> <replaceable>NETWORK</replaceable></userinput></screen>
<para>Replace <replaceable>ROUTER</replaceable> with the unique
identifier of the router, replace <replaceable>NETWORK</replaceable>
with the unique identifier of the external provider network.</para>
</step>
<step>
<para>Link the router to the subnet:</para>
<screen><prompt>$</prompt> <userinput>neutron router-interface-add <replaceable>ROUTER</replaceable> <replaceable>SUBNET</replaceable></userinput></screen>
<para>Replace <replaceable>ROUTER</replaceable> with the unique
identifier of the router, replace <replaceable>SUBNET</replaceable>
with the unique identifier of the subnet.</para>
</step>
</procedure>
</section>
<section xml:id="cli_ports">
<title>Create ports</title>
<procedure>
<step>
<para>Create a port with specified IP address:</para>
<screen><prompt>$</prompt> <userinput>neutron port-create net1 --fixed-ip ip_address=192.168.2.40</userinput></screen>
<screen><computeroutput>Created a new port:
+----------------------+-------------------------------------------------------------------------------------+
| Field | Value |
+----------------------+-------------------------------------------------------------------------------------+
| admin_state_up | True |
| binding:capabilities | {"port_filter": false} |
| binding:vif_type | ovs |
| device_id | |
| device_owner | |
| fixed_ips | {"subnet_id": "15a09f6c-87a5-4d14-b2cf-03d97cd4b456", "ip_address": "192.168.2.40"} |
| id | f7a08fe4-e79e-4b67-bbb8-a5002455a493 |
| mac_address | fa:16:3e:97:e0:fc |
| name | |
| network_id | 2d627131-c841-4e3a-ace6-f2dd75773b6d |
| status | DOWN |
| tenant_id | 3671f46ec35e4bbca6ef92ab7975e463 |
+----------------------+-------------------------------------------------------------------------------------+</computeroutput></screen>
<para>In the previous command, <literal>net1</literal>
is the network name, which is a positional
argument. <literal>--fixed-ip
ip_address=192.168.2.40</literal> is an
option, which specifies the port's fixed IP
address we wanted.</para>
</step>
<step>
<para>Create a port without specified IP
address:</para>
<screen><prompt>$</prompt> <userinput>neutron port-create net1</userinput></screen>
<screen><computeroutput>Created a new port:
+----------------------+------------------------------------------------------------------------------------+
| Field| Value |
+----------------------+------------------------------------------------------------------------------------+
| admin_state_up | True |
| binding:capabilities | {"port_filter": false} |
| binding:vif_type | ovs |
| device_id | |
| device_owner | |
| fixed_ips | {"subnet_id": "15a09f6c-87a5-4d14-b2cf-03d97cd4b456", "ip_address": "192.168.2.2"} |
| id | baf13412-2641-4183-9533-de8f5b91444c |
| mac_address | fa:16:3e:f6:ec:c7 |
| name | |
| network_id | 2d627131-c841-4e3a-ace6-f2dd75773b6d |
| status | DOWN |
| tenant_id | 3671f46ec35e4bbca6ef92ab7975e463 |
+----------------------+------------------------------------------------------------------------------------+</computeroutput></screen>
<para>We can see that the system will allocate one IP
address if we do not specify the IP address in
command line.</para>
</step>
<step>
<para>Query ports with specified fixed IP
addresses:</para>
<screen><prompt>$</prompt> <userinput>neutron port-list --fixed-ips ip_address=192.168.2.2 ip_address=192.168.2.40</userinput></screen>
<screen><computeroutput>+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| baf13412-2641-4183-9533-de8f5b91444c | | fa:16:3e:f6:ec:c7 | {"subnet_id": "15a09f6c-87a5-4d14-b2cf-03d97cd4b456", "ip_address": "192.168.2.2"} |
| f7a08fe4-e79e-4b67-bbb8-a5002455a493 | | fa:16:3e:97:e0:fc | {"subnet_id": "15a09f6c-87a5-4d14-b2cf-03d97cd4b456", "ip_address": "192.168.2.40"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+ </computeroutput></screen>
<para><literal>--fixed-ips ip_address=192.168.2.2
ip_address=192.168.2.40</literal> is one
unknown option.</para>
<para><emphasis role="bold">How to find unknown
options?</emphasis> The unknown options can be
easily found by watching the output of
<literal>create_xxx</literal> or
<literal>show_xxx</literal> command. For
example, in the port creation command, we see the
fixed_ips fields, which can be used as an unknown
option.</para>
</step>
</procedure>
</section>
</section>