openstack-manuals/doc/common/section_cli_neutron_manage_networks.xml
Christian Berendt b2235bf3fb Unified the syntax of the XML root element (common)
Execluded all XML files in the directory doc/common/tables because
they are autogenerated.

The XML root element of Docbook XML files should match the following
format:

<ELEMENT xmlns="http://docbook.org/ns/docbook"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  version="5.0"
  xml:id="THE_XML_ID_OF_THE_ELEMENT">

Change-Id: If12091be81ec8b2e6e53bfcb4c3a883a65e24736
2014-07-09 22:23:03 +02:00

258 lines
16 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
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>The <command>subnet-create</command> command
has the following positional and optional
parameters:</para>
<itemizedlist>
<listitem>
<para>The name or ID of the network to which
the subnet belongs.</para>
<para>In this example, <literal>net1</literal>
is a positional argument that specifies
the network name.</para>
</listitem>
<listitem>
<para>The CIDR of the subnet.</para>
<para>In this example,
<literal>192.168.2.0/24</literal> is a
positional argument that specifies the
CIDR.</para>
</listitem>
<listitem>
<para>The subnet name, which is
optional.</para>
<para>In this example, <literal>--name
subnet1</literal> specifies the name
of the subnet.</para>
</listitem>
</itemizedlist>
</step>
</procedure>
</section>
<section xml:id="cli_routers">
<title>Create routers</title>
<procedure>
<step>
<para>Create a 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>
<note>
<para>When creating a port, you can specify any unallocated
IP in the subnet even if the address is not in a
pre-defined pool of allocated IP addresses (set by your
cloud provider).</para>
</note>
</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>
<note>
<para>Note that the system allocates one IP address if you
do not specify an IP address in the <command>neutron
port-create</command> command.</para></note>
</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>