nova命令列給虛機配置ip
1.首先,載入source源,即配置環境變數:source admin.rc
2.檢視虛機列表:nova list
這裡以asd為例(以下省略),找到他的id:7b8125b9-1b7c-4566-8dc5-d8aa0e00fb00
3. 關閉虛機:
(neutron-server)[[email protected] /]$ nova stop asd
Request to stop server asd has been accepted.
可以看到asd的狀態已經關閉。
說明:nova stop/start 。。
4. 檢視ip資訊
(neutron-server)[
或者執行命令:(neutron-server)[[email protected] /]$ neutron net-list
找到你想附加的ip的id,以fly-net id=bd0e166f-ecb4-4650-a715-32e7ca1fbecf 為例
5. ip附加(attach)命令:
(neutron-server)[[email protected] /]$ nova interface-attach --net-id bd0e166f-ecb4-4650-a715-32e7ca1fbecf
另附:
Nova interface-detach server_id port-id 這一步會解除連線,而且會刪除該port
此時,可以看到,虛機asd NetWork欄已經有了ip,說明配置成功!
6. 重啟虛機asd即可:(neutron-server)[[email protected] /]$ nova start asd
Request to start server asd has been accepted.
附錄:
(neutron-server)[[email protected] /]$ nova help | grep interface
Command-line interface to the OpenStack Nova API.
interface-attach Attach a network interface to a server.
interface-detach Detach a network interface from a server.
interface-list List interfaces attached to a server.
baremetal-interface-add Add a network interface to a baremetal node.
baremetal-interface-list List network interfaces associated with a
baremetal-interface-remove Remove a network interface from a baremetal
interfaces.