您好,登錄后才能下訂單哦!
Pike版Openstack虛擬機命令行指定ip地址的示例分析,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
查看已有的網絡接口(對應虛擬機網卡)
# . admin-openrc
admin權限查看能夠多看到租戶id tenant_id
# neutron port-list neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. +--------------------------------------+------+----------------------------------+-------------------+--------------------------------------------------------------------------------------+ | id | name | tenant_id | mac_address | fixed_ips | +--------------------------------------+------+----------------------------------+-------------------+--------------------------------------------------------------------------------------+ | 00401677-543c-4834-9f30-d25e179e88a0 | | 9c658f84358140378e637f0b27c7ca57 | fa:16:3e:e0:d1:c2 | {"subnet_id": "c26fc89c-44ce-492b-aa88-befe9bae942c", "ip_address": "172.16.40.134"} | | e6480311-3226-49fc-8964-a15237d6ff14 | | 9c658f84358140378e637f0b27c7ca57 | fa:16:3e:67:01:eb | {"subnet_id": "c26fc89c-44ce-492b-aa88-befe9bae942c", "ip_address": "172.16.40.108"} | +--------------------------------------+------+----------------------------------+-------------------+--------------------------------------------------------------------------------------+
普通租戶是看不到租戶id的
# . tbg-openrc # neutron port-list neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. +--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+ | 00401677-543c-4834-9f30-d25e179e88a0 | | fa:16:3e:e0:d1:c2 | {"subnet_id": "c26fc89c-44ce-492b-aa88-befe9bae942c", "ip_address": "172.16.40.134"} | | e6480311-3226-49fc-8964-a15237d6ff14 | | fa:16:3e:67:01:eb | {"subnet_id": "c26fc89c-44ce-492b-aa88-befe9bae942c", "ip_address": "172.16.40.108"} | +--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
使用admin權限創建一個網絡接口,可以指定租戶,指定ip地址,以及指定對應的網絡
# . admin-openrc # neutron port-create --tenant-id 9c658f84358140378e637f0b27c7ca57 --fixed-ip ip_address='172.16.40.104' provider neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. Created a new port: +-----------------------+--------------------------------------------------------------------------------------+ | Field | Value | +-----------------------+--------------------------------------------------------------------------------------+ | admin_state_up | True | | allowed_address_pairs | | | binding:host_id | | | binding:profile | {} | | binding:vif_details | {} | | binding:vif_type | unbound | | binding:vnic_type | normal | | created_at | 2018-02-27T07:42:08Z | | description | | | device_id | | | device_owner | | | extra_dhcp_opts | | | fixed_ips | {"subnet_id": "c26fc89c-44ce-492b-aa88-befe9bae942c", "ip_address": "172.16.40.104"} | | id | 5e993bfd-219b-4e0e-9173-721e072e7342 | | mac_address | fa:16:3e:d8:40:0a | | name | | | network_id | c35672ab-6d14-4fd6-99a5-5b912ae1070a | | port_security_enabled | True | | project_id | 9c658f84358140378e637f0b27c7ca57 | | revision_number | 3 | | security_groups | e437d647-4c0e-42c4-bc40-f15d15364748 | | status | DOWN | | tags | | | tenant_id | 9c658f84358140378e637f0b27c7ca57 | | updated_at | 2018-02-27T07:42:08Z | +-----------------------+--------------------------------------------------------------------------------------+
將新創建的port連接到虛擬機上
# nova list +--------------------------------------+------------+---------+------------+-------------+------------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+------------+---------+------------+-------------+------------------------+ | eddcb46e-eac5-4403-83a8-1f0d8ac34439 | hadoop-4 | ACTIVE | - | Running | provider=172.16.40.134 | | 06a43249-9258-409e-b791-541396771a9d | zxq-3 | ACTIVE | - | Running | provider=172.16.40.108 | +--------------------------------------+------------+---------+------------+-------------+------------------------+
添加連接,如果不指定port-id,則會自己創建一個新的
# nova interface-attach --port-id 5e993bfd-219b-4e0e-9173-721e072e7342 eddcb46e-eac5-4403-83a8-1f0d8ac34439 # nova interface-list eddcb46e-eac5-4403-83a8-1f0d8ac34439 +------------+--------------------------------------+--------------------------------------+---------------+-------------------+ | Port State | Port ID | Net ID | IP addresses | MAC Addr | +------------+--------------------------------------+--------------------------------------+---------------+-------------------+ | BUILD | 00401677-543c-4834-9f30-d25e179e88a0 | c35672ab-6d14-4fd6-99a5-5b912ae1070a | 172.16.40.134 | fa:16:3e:e0:d1:c2 | | BUILD | 5e993bfd-219b-4e0e-9173-721e072e7342 | c35672ab-6d14-4fd6-99a5-5b912ae1070a | 172.16.40.104 | fa:16:3e:d8:40:0a | +------------+--------------------------------------+--------------------------------------+---------------+-------------------+
分離接口
# nova interface-detach eddcb46e-eac5-4403-83a8-1f0d8ac34439 00401677-543c-4834-9f30-d25e179e88a0 # ping 172.16.40.104 PING 172.16.40.104 (172.16.40.104) 56(84) bytes of data. 64 bytes from 172.16.40.104: icmp_seq=1 ttl=64 time=3.11 ms
可以ping通,添加指定ip正常。
關于Pike版Openstack虛擬機命令行指定ip地址的示例分析問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。