溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Pike版Openstack虛擬機(jī)命令行指定ip地址的示例分析

發(fā)布時(shí)間:2021-11-11 17:09:08 來(lái)源:億速云 閱讀:132 作者:柒染 欄目:云計(jì)算

Pike版Openstack虛擬機(jī)命令行指定ip地址的示例分析,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

查看已有的網(wǎng)絡(luò)接口(對(duì)應(yīng)虛擬機(jī)網(wǎng)卡)

# . admin-openrc

admin權(quán)限查看能夠多看到租戶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權(quán)限創(chuàng)建一個(gè)網(wǎng)絡(luò)接口,可以指定租戶,指定ip地址,以及指定對(duì)應(yīng)的網(wǎng)絡(luò)

# . 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                                                                 |
+-----------------------+--------------------------------------------------------------------------------------+

將新創(chuàng)建的port連接到虛擬機(jī)上

# 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,則會(huì)自己創(chuàng)建一個(gè)新的

# 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正常。

關(guān)于Pike版Openstack虛擬機(jī)命令行指定ip地址的示例分析問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI