Neeke

伪全栈攻城狮

OpenStack Quantum 租户 网络 子网 路由配置

最近在开发与OpenStack相关的一个产品,程序在安装的时候需要对当前网络环境进行一些配置,但是不能让用户在WEB上面去配置,而是通过shell脚本自动配置,捣鼓了好长时间终于搞定了。

1.创建租户

keystone tenant-create --name test_tenant
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |                                  |
|   enabled   |               True               |
|      id     | 6cfa815662fb401789dc7dc75b5ba1e8 |
|     name    |           test_tenant            |
+-------------+----------------------------------+

2.使新的租户被admin可见

keystone user-list
+----------------------------------+---------+---------+-------+
|                id                |   name  | enabled | email |
+----------------------------------+---------+---------+-------+
| 38436513c8f0441780c75fcc198710b0 |  admin  |   True  |       |
| ff89ee3e0cad48269367782c52c2cc2b |  cinder |   True  |       |
| 87046c5379304082974a2f98309a3dba |   ec2   |   True  |       |
| d596c959fe1e4a229708e567a7adb70d |  glance |   True  |       |
| f9292edbe5434737a2293dd5f8dd9e27 |   nova  |   True  |       |
| 4ded12f274634eb0a06564d9b0967f86 | quantum |   True  |       |
| e1300cc43e4c4d7cacef112cd5269375 |  swift  |   True  |       |
+----------------------------------+---------+---------+-------+
keystone role-list
+----------------------------------+----------+
|                id                |   name   |
+----------------------------------+----------+
| 100d061b5298490b843cc10d5dd80ba5 |  Member  |
| 9fe2ff9ee4384b1894a90878d3e92bab | _member_ |
| 7a1d979082b84aeaa39b20fe95b77648 |  admin   |
+----------------------------------+----------+
keystone user-role-add --tenant_id 6cfa815662fb401789dc7dc75b5ba1e8 --user-id 38436513c8f0441780c75fcc198710b0 --role-id 7a1d979082b84aeaa39b20fe95b77648

3.创建network

quantum net-create --tenant-id 6cfa815662fb401789dc7dc75b5ba1e8 net_test_tenant
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 1385ae9c-b29d-4e22-9669-8fd5c794821d |
| name                      | net_test_tenant                      |
| provider:network_type     | gre                                  |
| provider:physical_network |                                      |
| provider:segmentation_id  | 5                                    |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | 6cfa815662fb401789dc7dc75b5ba1e8     |
+---------------------------+--------------------------------------+

4.创建subnet

quantum subnet-create --tenant-id 6cfa815662fb401789dc7dc75b5ba1e8 net_test_tenant --name sub_net_test_tenant 172.0.0.0/24
Created a new subnet:
+------------------+----------------------------------------------+
| Field            | Value                                        |
+------------------+----------------------------------------------+
| allocation_pools | {"start": "172.0.0.2", "end": "172.0.0.254"} |
| cidr             | 172.0.0.0/24                                 |
| dns_nameservers  |                                              |
| enable_dhcp      | True                                         |
| gateway_ip       | 172.0.0.1                                    |
| host_routes      |                                              |
| id               | f7d59dec-44ac-4454-a1b4-bf88e1f6680a         |
| ip_version       | 4                                            |
| name             | sub_net_test_tenant                          |
| network_id       | 1385ae9c-b29d-4e22-9669-8fd5c794821d         |
| tenant_id        | 6cfa815662fb401789dc7dc75b5ba1e8             |
+------------------+----------------------------------------------+

5.创建路由

quantum router-create --tenant-id 6cfa815662fb401789dc7dc75b5ba1e8 test_router
Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| external_gateway_info |                                      |
| id                    | ede346db-c8c6-429e-8726-eaccf7fd62d4 |
| name                  | test_router                          |
| status                | ACTIVE                               |
| tenant_id             | 6cfa815662fb401789dc7dc75b5ba1e8     |
+-----------------------+--------------------------------------+

6.绑定路由到外网

quantum router-gateway-set ede346db-c8c6-429e-8726-eaccf7fd62d4 ext_net
Set gateway for router ede346db-c8c6-429e-8726-eaccf7fd62d4

7.绑定路由到子网

quantum router-interface-add ede346db-c8c6-429e-8726-eaccf7fd62d4 f7d59dec-44ac-4454-a1b4-bf88e1f6680a
Added interface to router ede346db-c8c6-429e-8726-eaccf7fd62d4

需要注意的是,这些配置在删除时必须从后往前删,不然的话删除起来很麻烦!

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«   2016年11月   »
123456
78910111213
14151617181920
21222324252627
282930
网站分类
搜索
最新留言
文章归档
友情链接

Powered By Z-BlogPHP 1.5.1 Zero

Copyright Your WebSite.Some Rights Reserved.