玩转OpenStack网络Neutron(1)--热身
转载自:http://blog.csdn.net/yanheven1/article/details/44788581#0-tsina-1-32631-397232819ff9a47a7b7e80a40613cfe1OpenStack 网络介绍随着计算资源从物理机到虚拟机的迁移,相应地,虚拟机的网络也从以前的物理网络迁移到虚拟网络.而在OpenStack这个开源的云计算项目中,负责
转载自:http://blog.csdn.net/yanheven1/article/details/44788581#0-tsina-1-32631-397232819ff9a47a7b7e80a40613cfe1
OpenStack 网络介绍
随着计算资源从物理机到虚拟机的迁移,相应地,虚拟机的网络也从以前的物理网络迁移到虚拟网络.而在OpenStack这个开源的云计算项目中,负责网络虚拟化的是Neutron(曾用名:Quantum)和Nova-Network, 后者之前是作为Nova的一个服务来看待,而Neutron则是一个完整的子项目,当然,提供的功能也更多,支持更多的网络插件.本系列文章,将主要学习研究Neutron,学习不同插件的配置使用,不同网络类型的使用.由于侧重点为网络的配置使用,所以本文章假定读者已经拥有一个最小的两节点的OpenStack集群(布署可参考官方文档,或者陈沙克的博文:http://www.chenshake.com/install-openstack-openstack-juno-version/).安装如下:
- 控制节点:
keystone, glance, nova, neutron - 计算节点:
nova-compute, neutron agent
在Neutron里面,有几个基本概念,其实跟物理网络一样.
- 网络Network:三层网络, 可以包含多个子网.
- 子网Subnet:三层网络, 每个子网有自己的网络号(CIDR).
- 接口Port:虚拟网络中的接口, 类比物理网络设备上的网线接口.
- 路由器Router: 类比物理网络中的路由器,用于不同三层网络之前通信.
通过 Horizon 创建网络
用有效的用户名密码登陆控制台, 找到”Network”,然后点击此栏目下面的”Networks”处,弹出网络信息页,显示当前项目的网络信息,然后通过点击”Create Network”来创建网络:
随后, 填写网络名称, 然后可以直接不填子网信息, 直接下一步, 创建网络即可.
通过 Horizon 创建子网
在网络信息页,找到刚才创建的网络,点击进去:
填写子网名称, 子网的网络CIDR, 网关不指定, 默认会帮你指定为网络的第一个可用IP, 此时是192.1168.1.1, 不禁用网关:
通过 Horizon 查看网络信息
通过进入网络信息页面,可以看到当前项目的所有网络,点击某个网络进去,可以看到这个网络的信息, 这个网络所包含的子网的信息, 以及这个网络里面创建的接口的信息.
点击某个子网或者某个接口,可以进去查看它的详细信息,比如点击子网”yan-in”
通过 Horizon 创建关联某个网络的实例
在”Compute”栏目,打开里面的”Instances”, 点击”Launch Instance”按钮, 即打开的创建实例(虚拟机)的工作流了
填写主机名,选择配置,镜像等
选择主机使用的网络,点击刚才我们创建的网络”yan-test”, 点击后它自动从下的”Available networks”面移动到上面的”Selected Networks”处
忽略其他标签的设置,点击”Launch”, 即可创建使用这个网络的实例了.
若干秒后,可以看到成功创建的实例:
还可以点击实例名称”yan-test”进入查看实例详情:
通过 命令行 创建网络
首先,创建一个网络:
<code class="hljs asciidoc has-numbering" style="display: block; padding: 0px; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background-image: initial; background-attachment: initial; background-color: transparent; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="color: inherit;">$ </span><span style="color:#ff0000;">neutron net-create yan-net-test01</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-header" style="color: inherit; box-sizing: border-box;">Created a new network: +---------------------------+--------------------------------------+</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-header" style="color: inherit; box-sizing: border-box;">| Field | Value | +---------------------------+--------------------------------------+</span><span style="color:rgba(0, 0, 0, 0);"> | admin</span><span class="hljs-emphasis" style="color: inherit; box-sizing: border-box;">_state_</span><span style="color:rgba(0, 0, 0, 0);">up | True | | id | c20a2764-1c1a-4091-ac2a-bb82f7f1d20d | | name | yan-net-test01 | | provider:physical</span><span class="hljs-emphasis" style="color: inherit; box-sizing: border-box;">_network | | | shared | False | | status | ACTIVE | | subnets | | | tenant_</span><span style="color:rgba(0, 0, 0, 0);">id | 0d896fe854f64e90915ce599aa1e1c0b | </span><span class="hljs-code" style="color: inherit; box-sizing: border-box;">+---------------------------+</span><span style="color:rgba(0, 0, 0, 0);">--------------------------------------+</span></code><ul class="pre-numbering" style="color: rgb(51, 51, 51); box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li></ul>
可以通过命令查看刚才创建的网络详细信息:
<code class="hljs asciidoc has-numbering" style="display: block; padding: 0px; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background-image: initial; background-attachment: initial; background-color: transparent; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span class="hljs-header" style="box-sizing: border-box;"><span style="color:rgba(0, 0, 0, 0);">$ </span><span style="color:#ff0000;">neutron net-show yan-net-test01</span><span style="color:rgba(0, 0, 0, 0);"> +---------------------------+--------------------------------------+</span></span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-header" style="color: inherit; box-sizing: border-box;">| Field | Value | +---------------------------+--------------------------------------+</span><span style="color:rgba(0, 0, 0, 0);"> | admin</span><span class="hljs-emphasis" style="color: inherit; box-sizing: border-box;">_state_</span><span style="color:rgba(0, 0, 0, 0);">up | True | | id | c20a2764-1c1a-4091-ac2a-bb82f7f1d20d | | name | yan-net-test01 | | provider:physical</span><span class="hljs-emphasis" style="color: inherit; box-sizing: border-box;">_network | | | router:external | False | | shared | False | | status | ACTIVE | | subnets | | | tenant_</span><span style="color:rgba(0, 0, 0, 0);">id | 0d896fe854f64e90915ce599aa1e1c0b | </span><span class="hljs-code" style="color: inherit; box-sizing: border-box;">+---------------------------+</span><span style="color:rgba(0, 0, 0, 0);">--------------------------------------+</span></code><ul class="pre-numbering" style="color: rgb(51, 51, 51); box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li></ul>
更多命令可以通过help出来查看:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron help <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">|</span> grep <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">" net-"</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-create</span> Create a network for a given tenant<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-delete</span> Delete a given network<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-external</span><span class="hljs-attribute" style="box-sizing: border-box;">-list</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">List</span> external networks that belong <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> a given tenant<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-connect</span> Add an internal network interface <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> a router<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-create</span> Create a network gateway<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-delete</span> Delete a given network gateway<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-disconnect</span> Remove a network from a network gateway<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-list</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">List</span> network gateways for a given tenant<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-show</span> Show information of a given network gateway<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-attribute" style="box-sizing: border-box;">-update</span> Update the name for a network gateway<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-list</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">List</span> networks that belong <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> a given tenant<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-list</span><span class="hljs-attribute" style="box-sizing: border-box;">-on</span><span class="hljs-attribute" style="box-sizing: border-box;">-dhcp</span><span class="hljs-attribute" style="box-sizing: border-box;">-agent</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">List</span> the networks <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">on</span> a DHCP agent<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-show</span> Show information of a given network<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span> net<span class="hljs-attribute" style="box-sizing: border-box;">-update</span> Update network<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'s information. </span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li></ul>
某个具体命令的用法,也可以通过help来查看使用方法,可以查看命令需要哪些参数,以及它的功能. 比如刚才我们用的show命令:
<code class="hljs sql has-numbering" style="display: block; padding: 0px; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background-image: initial; background-attachment: initial; background-color: transparent; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="color: inherit;">$ neutron </span><span style="color:#ff0000;">help</span><span style="color:rgba(0, 0, 0, 0);"> </span>net-<span class="hljs-operator" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box;">show</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">usage</span><span style="color:rgba(0, 0, 0, 0);">: neutron net-</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">show</span><span style="color:rgba(0, 0, 0, 0);"> [-h] [-f {shell,</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">table</span><span style="color:rgba(0, 0, 0, 0);">,</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">value</span><span style="color:rgba(0, 0, 0, 0);">}] [-c </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">COLUMN</span><span style="color:rgba(0, 0, 0, 0);">] [--</span><span class="hljs-aggregate" style="color: inherit; box-sizing: border-box;">max</span><span style="color:rgba(0, 0, 0, 0);">-width <</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">integer</span><span style="color:rgba(0, 0, 0, 0);">>] [--prefix PREFIX] [--request-format {json,xml}] [-D] [-F FIELD] NETWORK </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Show</span><span style="color:rgba(0, 0, 0, 0);"> information </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">of</span><span style="color:rgba(0, 0, 0, 0);"> a given network. positional arguments: NETWORK ID </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">or</span><span style="color:rgba(0, 0, 0, 0);"> name </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">of</span><span style="color:rgba(0, 0, 0, 0);"> network </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span><span style="color:rgba(0, 0, 0, 0);"> look up. optional arguments: -h, --help </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">show</span><span style="color:rgba(0, 0, 0, 0);"> this help message </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">and</span><span style="color:rgba(0, 0, 0, 0);"> exit --request-format {json,xml} The XML </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">or</span><span style="color:rgba(0, 0, 0, 0);"> JSON request format. -D, --</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">show</span><span style="color:rgba(0, 0, 0, 0);">-details </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Show</span><span style="color:rgba(0, 0, 0, 0);"> detailed information. -F FIELD, --field FIELD Specify the field(s) </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span><span style="color:rgba(0, 0, 0, 0);"> be returned </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">by</span><span style="color:rgba(0, 0, 0, 0);"> server. You can repeat this </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">option</span><span style="color:rgba(0, 0, 0, 0);">. </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">output</span><span style="color:rgba(0, 0, 0, 0);"> formatters: </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">output</span><span style="color:rgba(0, 0, 0, 0);"> formatter options -f {shell,</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">table</span><span style="color:rgba(0, 0, 0, 0);">,</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">value</span><span style="color:rgba(0, 0, 0, 0);">}, --format {shell,</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">table</span><span style="color:rgba(0, 0, 0, 0);">,</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">value</span><span style="color:rgba(0, 0, 0, 0);">} the </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">output</span><span style="color:rgba(0, 0, 0, 0);"> format, defaults </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">table</span><span style="color:rgba(0, 0, 0, 0);"> -c </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">COLUMN</span><span style="color:rgba(0, 0, 0, 0);">, --</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">column</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">COLUMN</span><span style="color:rgba(0, 0, 0, 0);"> specify the </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">column</span><span style="color:rgba(0, 0, 0, 0);">(s) </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span><span style="color:rgba(0, 0, 0, 0);"> include, can be repeated </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">table</span><span style="color:rgba(0, 0, 0, 0);"> formatter: --</span><span class="hljs-aggregate" style="color: inherit; box-sizing: border-box;">max</span><span style="color:rgba(0, 0, 0, 0);">-width <</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">integer</span><span style="color:rgba(0, 0, 0, 0);">> Maximum display width, </span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span><span style="color:rgba(0, 0, 0, 0);"> disable shell formatter: a format a UNIX shell can parse (variable=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"value"</span><span style="color:rgba(0, 0, 0, 0);">) --prefix PREFIX </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">add</span><span style="color:rgba(0, 0, 0, 0);"> a prefix </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span><span style="color:rgba(0, 0, 0, 0);"> </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">all</span><span style="color:rgba(0, 0, 0, 0);"> variable </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">names</span><span style="color:rgba(0, 0, 0, 0);"> </span></span></code><ul class="pre-numbering" style="color: rgb(51, 51, 51); box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li><li style="box-sizing: border-box; padding: 0px 5px;">27</li><li style="box-sizing: border-box; padding: 0px 5px;">28</li><li style="box-sizing: border-box; padding: 0px 5px;">29</li><li style="box-sizing: border-box; padding: 0px 5px;">30</li><li style="box-sizing: border-box; padding: 0px 5px;">31</li><li style="box-sizing: border-box; padding: 0px 5px;">32</li><li style="box-sizing: border-box; padding: 0px 5px;">33</li><li style="box-sizing: border-box; padding: 0px 5px;">34</li><li style="box-sizing: border-box; padding: 0px 5px;">35</li><li style="box-sizing: border-box; padding: 0px 5px;">36</li><li style="box-sizing: border-box; padding: 0px 5px;">37</li></ul>
看到可以改变输出的格式,比如让输出为shell格式:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron net<span class="hljs-attribute" style="box-sizing: border-box;">-show</span> yan<span class="hljs-attribute" style="box-sizing: border-box;">-net</span><span class="hljs-attribute" style="box-sizing: border-box;">-test01</span> <span class="hljs-attribute" style="box-sizing: border-box;">-f</span> shell admin_state_up<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"True"</span> id<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"c20a2764-1c1a-4091-ac2a-bb82f7f1d20d"</span> name<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"yan-net-test01"</span> provider:physical_network<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">""</span> router:external<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"False"</span> shared<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"False"</span> status<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"ACTIVE"</span> subnets<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">""</span> tenant_id<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"0d896fe854f64e90915ce599aa1e1c0b"</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li></ul>
通过 命令行 创建子网
查看子网,有哪些相关命令:
<code class="hljs sql has-numbering" style="display: block; padding: 0px; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background-image: initial; background-attachment: initial; background-color: transparent; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="color: inherit;">$ </span><span style="color:#ff0000;">neutron help | grep subnet</span><span style="color:rgba(0, 0, 0, 0);"> subnet-</span><span class="hljs-operator" style="color: inherit; box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">create</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Create</span> a subnet <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> a given tenant. subnet-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">delete</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Delete</span> a given subnet. subnet-list List subnets that belong <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> a given tenant. subnet-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">show</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Show</span> information <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">of</span> a given subnet. subnet-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">update</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Update</span> subnet<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'s information. </span></span></code><ul class="pre-numbering" style="color: rgb(51, 51, 51); box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li></ul>
创建子网,就跟在horizon页面创建类似,指定网络,以及子网的CIDR等这些具体信息:
<code class="hljs asciidoc has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron subnet-create yan-net-test01 --name yan-test01-subnet --gateway 192.168.1.1 192.168.1.0/24 <span class="hljs-header" style="box-sizing: border-box;">Created a new subnet: +------------------+--------------------------------------------------+</span> <span class="hljs-header" style="box-sizing: border-box;">| Field | Value | +------------------+--------------------------------------------------+</span> | allocation<span class="hljs-emphasis" style="box-sizing: border-box;">_pools | {"start": "192.168.1.2", "end": "192.168.1.254"} | | cidr | 192.168.1.0/24 | | dns_</span>nameservers | | | enable<span class="hljs-emphasis" style="box-sizing: border-box;">_dhcp | True | | gateway_</span>ip | 192.168.1.1 | | host<span class="hljs-emphasis" style="box-sizing: border-box;">_routes | | | id | ee2c7da4-083b-4510-9fef-21a58dc47b3d | | ip_</span>version | 4 | | name | yan-test01-subnet | | network<span class="hljs-emphasis" style="box-sizing: border-box;">_id | c20a2764-1c1a-4091-ac2a-bb82f7f1d20d | | tenant_</span>id | 0d896fe854f64e90915ce599aa1e1c0b | <span class="hljs-code" style="box-sizing: border-box;">+------------------+</span>--------------------------------------------------+ </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li></ul>
通过 命令行 创建Port
查看port都有哪些相关命令:
<code class="hljs vhdl has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron help | grep <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>- <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>-create Create a <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> a given tenant. <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>-delete Delete a given <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>. <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>-list List ports that belong <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> a given tenant. <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>-show Show information <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">of</span> a given <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>. <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>-update Update <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span><span class="hljs-attribute" style="box-sizing: border-box;">'s</span> information. router-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">port</span>-list List ports that belong <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> a given tenant, <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">with</span> specified router. </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li></ul>
创建port:
<code class="hljs asciidoc has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron port-create yan-net-test01 <span class="hljs-header" style="box-sizing: border-box;">Created a new port: +-----------------------+------------------------------------------------------------------------------------+</span> <span class="hljs-header" style="box-sizing: border-box;">| Field | Value | +-----------------------+------------------------------------------------------------------------------------+</span> | admin<span class="hljs-emphasis" style="box-sizing: border-box;">_state_</span>up | True | | allowed<span class="hljs-emphasis" style="box-sizing: border-box;">_address_</span>pairs | | | binding:host<span class="hljs-emphasis" style="box-sizing: border-box;">_id | | | binding:profile | {} | | binding:vif_</span>details | {} | | binding:vif<span class="hljs-emphasis" style="box-sizing: border-box;">_type | unbound | | binding:vnic_</span>type | normal | | device<span class="hljs-emphasis" style="box-sizing: border-box;">_id | | | device_</span>owner | | | fixed<span class="hljs-emphasis" style="box-sizing: border-box;">_ips | {"subnet_</span>id": "ee2c7da4-083b-4510-9fef-21a58dc47b3d", "ip<span class="hljs-emphasis" style="box-sizing: border-box;">_address": "192.168.1.2"} | | id | c1e9efdb-aa67-4a77-b80c-dd4321b39f1c | | mac_</span>address | fa:16:3e:1a:f8:5b | | name | | | network<span class="hljs-emphasis" style="box-sizing: border-box;">_id | c20a2764-1c1a-4091-ac2a-bb82f7f1d20d | | security_</span>groups | 5e179e17-f641-429b-a876-1361e9b4792a | | status | DOWN | <span class="hljs-header" style="box-sizing: border-box;">| tenant_id | 0d896fe854f64e90915ce599aa1e1c0b | +-----------------------+------------------------------------------------------------------------------------+</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li></ul>
其实创建接口,我们还可以指定很多信息,比如接口的名称,接口的IP地址, 绑定的安全组信息等, 详细可以help一下:
<code class="hljs livecodeserver has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron help port-<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">create</span> usage: neutron port-<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">create</span> [-h] [-f {<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">shell</span>,table,<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">value</span>}] [-c COLUMN] [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--max-width <integer>] [--prefix PREFIX]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--request-format {json,xml}]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--tenant-id TENANT_ID] [--name NAME]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--device-id DEVICE_ID]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--device-owner DEVICE_OWNER] [--admin-state-down]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--mac-address MAC_ADDRESS]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--security-group SECURITY_GROUP | --no-security-groups]</span> [<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--extra-dhcp-opt EXTRA_DHCP_OPTS]</span> NETWORK Create <span class="hljs-operator" style="box-sizing: border-box;">a</span> port <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> <span class="hljs-operator" style="box-sizing: border-box;">a</span> given tenant. positional arguments: NETWORK Network ID <span class="hljs-operator" style="box-sizing: border-box;">or</span> name this port belongs <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">to</span>. optional arguments: -h, <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--help show this help message and exit</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--request-format {json,xml}</span> The XML <span class="hljs-operator" style="box-sizing: border-box;">or</span> JSON request <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">format</span>. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--tenant-id TENANT_ID</span> The owner tenant ID. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--name NAME Name of this port.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR</span> Desired IP <span class="hljs-operator" style="box-sizing: border-box;">and</span>/<span class="hljs-operator" style="box-sizing: border-box;">or</span> subnet <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> this port: subnet_id=<name_or_id>,ip_address=<ip>. You can <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">repeat</span> this option. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--device-id DEVICE_ID</span> Device ID <span class="hljs-operator" style="box-sizing: border-box;">of</span> this port. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--device-owner DEVICE_OWNER</span> Device owner <span class="hljs-operator" style="box-sizing: border-box;">of</span> this port. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--admin-state-down Set admin state up to false.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--mac-address MAC_ADDRESS</span> MAC address <span class="hljs-operator" style="box-sizing: border-box;">of</span> this port. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--security-group SECURITY_GROUP</span> Security group associated <span class="hljs-operator" style="box-sizing: border-box;">with</span> <span class="hljs-operator" style="box-sizing: border-box;">the</span> port. You can <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">repeat</span> this option. <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--no-security-groups Associate no security groups with the port.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--extra-dhcp-opt EXTRA_DHCP_OPTS</span> Extra dhcp options <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">to</span> be assigned <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">to</span> this port: opt_na me=<dhcp_option_name>,opt_value=<<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">value</span>>,ip_version={<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>}. You can <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">repeat</span> this option. output formatters: output formatter options -f {<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">shell</span>,table,<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">value</span>}, <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--format {shell,table,value}</span> <span class="hljs-operator" style="box-sizing: border-box;">the</span> output <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">format</span>, defaults <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">to</span> table -c COLUMN, <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--column COLUMN</span> specify <span class="hljs-operator" style="box-sizing: border-box;">the</span> column(s) <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">to</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">include</span>, can be repeated table formatter: <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--max-width <integer></span> Maximum display width, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">to</span> disable <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">shell</span> formatter: <span class="hljs-operator" style="box-sizing: border-box;">a</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">format</span> <span class="hljs-operator" style="box-sizing: border-box;">a</span> UNIX <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">shell</span> can parse (<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">variable</span>=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"value"</span>) <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">--prefix PREFIX add a prefix to all variable names</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li><li style="box-sizing: border-box; padding: 0px 5px;">27</li><li style="box-sizing: border-box; padding: 0px 5px;">28</li><li style="box-sizing: border-box; padding: 0px 5px;">29</li><li style="box-sizing: border-box; padding: 0px 5px;">30</li><li style="box-sizing: border-box; padding: 0px 5px;">31</li><li style="box-sizing: border-box; padding: 0px 5px;">32</li><li style="box-sizing: border-box; padding: 0px 5px;">33</li><li style="box-sizing: border-box; padding: 0px 5px;">34</li><li style="box-sizing: border-box; padding: 0px 5px;">35</li><li style="box-sizing: border-box; padding: 0px 5px;">36</li><li style="box-sizing: border-box; padding: 0px 5px;">37</li><li style="box-sizing: border-box; padding: 0px 5px;">38</li><li style="box-sizing: border-box; padding: 0px 5px;">39</li><li style="box-sizing: border-box; padding: 0px 5px;">40</li><li style="box-sizing: border-box; padding: 0px 5px;">41</li><li style="box-sizing: border-box; padding: 0px 5px;">42</li><li style="box-sizing: border-box; padding: 0px 5px;">43</li><li style="box-sizing: border-box; padding: 0px 5px;">44</li><li style="box-sizing: border-box; padding: 0px 5px;">45</li><li style="box-sizing: border-box; padding: 0px 5px;">46</li><li style="box-sizing: border-box; padding: 0px 5px;">47</li><li style="box-sizing: border-box; padding: 0px 5px;">48</li><li style="box-sizing: border-box; padding: 0px 5px;">49</li><li style="box-sizing: border-box; padding: 0px 5px;">50</li><li style="box-sizing: border-box; padding: 0px 5px;">51</li><li style="box-sizing: border-box; padding: 0px 5px;">52</li><li style="box-sizing: border-box; padding: 0px 5px;">53</li><li style="box-sizing: border-box; padding: 0px 5px;">54</li><li style="box-sizing: border-box; padding: 0px 5px;">55</li><li style="box-sizing: border-box; padding: 0px 5px;">56</li><li style="box-sizing: border-box; padding: 0px 5px;">57</li><li style="box-sizing: border-box; padding: 0px 5px;">58</li><li style="box-sizing: border-box; padding: 0px 5px;">59</li><li style="box-sizing: border-box; padding: 0px 5px;">60</li><li style="box-sizing: border-box; padding: 0px 5px;">61</li></ul>
通过 命令行 创建指定Port的实例
首先要确定创建实例的配置大小,镜像,然后指定使用刚才创建的接口Port来创建实例:
<code class="hljs 1c has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ nova boot yan-instance01 --flavor m1.small --image Ubuntu-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14.04</span>-Server-amd64 --nic port-id=c1e9efdb-aa67-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>a77-b80c-dd4321b39f1c +--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| Property | Value |</span> +--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-DCF:diskConfig | MANUAL |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-EXT-AZ:availability_zone | nova |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-EXT-STS:power_state | 0 |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-EXT-STS:task_state | - |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-EXT-STS:vm_state | building |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-SRV-USG:launched_at | - |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| OS-SRV-USG:terminated_at | - |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| accessIPv4 | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| accessIPv6 | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| config_drive | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| created | 2015-04-11T08:44:30Z |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| default_ephemeral_device | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| default_swap_device | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| flavor | m1.small (2) |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| hostId | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| id | 01a2a55e-f1d4-4b4b-a81d-e6aaf8ee4693 |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| image | Ubuntu-14.04-Server-amd64 (7991bbbd-ab70-4b66-93fe-5813aac5c6c5) |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| key_name | - |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| metadata | {} |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| name | yan-instance01 |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| os-extended-volumes:volumes_attached | [] |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| progress | 0 |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| root_device_name | |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| security_groups | default |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| status | BUILD |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| tenant_id | 0d896fe854f64e90915ce599aa1e1c0b |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| updated | 2015-04-11T08:44:30Z |</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">| user_id | dd446a6b042c4ecab7175dc07f91fef2 |</span> +--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li><li style="box-sizing: border-box; padding: 0px 5px;">27</li><li style="box-sizing: border-box; padding: 0px 5px;">28</li><li style="box-sizing: border-box; padding: 0px 5px;">29</li><li style="box-sizing: border-box; padding: 0px 5px;">30</li><li style="box-sizing: border-box; padding: 0px 5px;">31</li><li style="box-sizing: border-box; padding: 0px 5px;">32</li><li style="box-sizing: border-box; padding: 0px 5px;">33</li><li style="box-sizing: border-box; padding: 0px 5px;">34</li><li style="box-sizing: border-box; padding: 0px 5px;">35</li></ul>
当然,创建实例时,关于网络的选择,除了可以指定port外,你还可以指定创建实例的IP地址,如果只指定网络,其实OPENSTACK的创建流程,也会先帮你创建这个网络的一个port,只不过这个步骤没暴露出来而已.
扩展网络地址范围
之前创建网络时只创建了一个子网,而子网的网络号(CIDR)信息是不能修改的.这里我们想要增加这个网络的地址范围,就只能在这个网络下创建多个子网,而且创建的子网不能有地址重叠,否则会报错,创建失败.
创建流程与创建第一个子网时一样.
当然,扩展网络地址范围还有种情况,就是我们创建子网时指定的地址池”Allocation Pools”,则可以通过命令行下子网修改命令来进行这个地址池的扩展,但无论怎样,地址范围都限定在创建时指定的CIDR范围里.
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ neutron help subnet<span class="hljs-attribute" style="box-sizing: border-box;">-updateusage</span>: neutron subnet<span class="hljs-attribute" style="box-sizing: border-box;">-update</span> <span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-attribute" style="box-sizing: border-box;">-h</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>request<span class="hljs-attribute" style="box-sizing: border-box;">-format</span> {json,<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">xml</span>}<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>name NAME<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>gateway GATEWAY_IP<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>no<span class="hljs-attribute" style="box-sizing: border-box;">-gateway</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>allocation<span class="hljs-attribute" style="box-sizing: border-box;">-pool</span> start<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span>IP_ADDR,end<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span>IP_ADDR<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>host<span class="hljs-attribute" style="box-sizing: border-box;">-route</span> destination<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span>CIDR,nexthop<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span>IP_ADDR<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>dns<span class="hljs-attribute" style="box-sizing: border-box;">-nameserver</span> DNS_NAMESERVER<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>disable<span class="hljs-attribute" style="box-sizing: border-box;">-dhcp</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> </span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>enable<span class="hljs-attribute" style="box-sizing: border-box;">-dhcp</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> SUBNET</span></code>
- 2304
- 0
- 0
- 0
扫一扫分享内容
- 分享
顶部
所有评论(0)