创建网络
提供者为external,类型为flat,网络名称为public,:
root@controller:~# neutron net-create --shared --provider:physical_network external --provider:network_type flat public
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | 75c074be-1905-495d-9c2a-413761e0f67b |
| mtu | 0 |
| name | public |
| provider:network_type | flat |
| provider:physical_network | external |
| provider:segmentation_id | |
| router:external | False |
| shared | True |
| status | ACTIVE |
| subnets | |
| tenant_id | 89254dc0494c4f15936f0f762ff050eb |
+---------------------------+--------------------------------------+
root@controller:~# neutron net-list
+--------------------------------------+--------+---------+
| id | name | subnets |
+--------------------------------------+--------+---------+
| 75c074be-1905-495d-9c2a-413761e0f67b | public | |
+--------------------------------------+--------+---------+
创建子网
子网名称:public-subnet
子网范围:192.168.10.10,192.168.10.100
root@controller:~# neutron subnet-create --name public-subnet --allocation-pool start=192.168.10.10,end=192.168.10.100 --dns-nameserver 114.114.114.114 --gateway 192.168.10.1 public 192.168.10.0/24
Created a new subnet:
+-------------------+-----------------------------------------------------+
| Field | Value |
+-------------------+-----------------------------------------------------+
| allocation_pools | {"start": "192.168.10.10", "end": "192.168.10.100"} |
| cidr | 192.168.10.0/24 |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | 192.168.10.1 |
| host_routes | |
| id | 6ad951d8-8000-44e1-adc1-89506d9a8433 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | public-subnet |
| network_id | 75c074be-1905-495d-9c2a-413761e0f67b |
| subnetpool_id | |
| tenant_id | 89254dc0494c4f15936f0f762ff050eb |
+-------------------+-----------------------------------------------------+
root@controller:~# neutron subnet-list
+--------------------------------------+---------------+-----------------+-----------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+---------------+-----------------+-----------------------------------------------------+
| 6ad951d8-8000-44e1-adc1-89506d9a8433 | public-subnet | 192.168.10.0/24 | {"start": "192.168.10.10", "end": "192.168.10.100"} |
+--------------------------------------+---------------+-----------------+-----------------------------------------------------+
子网创建好后,network节点会创建一个虚拟网桥:
root@network:~# brctl show
bridge name bridge id STP enabled interfaces
brq75c074be-19 8000.000c29db9568 no eth1
tapb11ba192-6d
创建虚拟机
先要新建一把key:
root@controller:~# nova keypair-add mykey
root@controller:~# nova keypair-list
+-------+-------------------------------------------------+
| Name | Fingerprint |
+-------+-------------------------------------------------+
| mykey | 45:c1:71:78:e5:8c:c4:08:d1:af:a3:69:e6:66:96:c5 |
+-------+-------------------------------------------------+
启动虚拟机:
root@controller:~# nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=75c074be-1905-495d-9c2a-413761e0f67b --security-group default --key-name mykey demo1
获取虚拟机vnc:
root@controller:~# nova get-vnc-console demo1 novnc