OpenStack更换实例ip的方法

经过查询OpenStack官方文档发现如下:

https://docs.openstack.org/python-openstackclient/pike/cli/command-objects/port.html#cmdoption-port-set-no-fixed-ip

--no-fixed-ip
Clear existing information of fixed IP addresses. Specify both --fixed-ip and --no-fixed-ip to overwrite the current fixed IP addresses.
# 大致意思就是--fixed-ip 和 --no-fixed-ip两个选项同时使用就可以实现覆盖IP,也就达到了我们需要更换IP的目的
[lookback@LookdeMacBook-Pro ~/OpenStack]# openstack server list --name 网络测试
+--------------------------------------+----------+--------+---------------------------------------------------------------+---------------------------------------+---------------+
| ID                                   | Name     | Status | Networks                                                      | Image                                 | Flavor        |
+--------------------------------------+----------+--------+---------------------------------------------------------------+---------------------------------------+---------------+
| e92226be-b9ae-40bd-8f02-ade2eb9141b4 | 网络测试 | ACTIVE | NET-A=172.30.4.11; NET-B=172.25.200.204; NET-C=172.20.200.204 | CentOS-7.7.1908-x86_64-Cloud-20200207 | DT-L-1c1g40gD |
+--------------------------------------+----------+--------+---------------------------------------------------------------+---------------------------------------+---------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]# openstack port list --fixed-ip ip-address=172.25.200.204
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| ID                                   | Name | MAC Address       | Fixed IP Addresses                                                            | Status |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| 8d7f1824-3e1c-41fe-9a8e-f848f4070434 |      | fa:16:3e:c0:4e:8d | ip_address='172.25.200.204', subnet_id='e0531da2-b031-4e0a-9303-33f10d9c3aec' | ACTIVE |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
[lookback@LookdeMacBook-Pro ~/OpenStack]# openstack port set --no-fixed-ip --fixed-ip ip-address=172.25.200.210 8d7f1824-3e1c-41fe-9a8e-f848f4070434
[lookback@LookdeMacBook-Pro ~/OpenStack]# 
[lookback@LookdeMacBook-Pro ~/OpenStack]# 
[lookback@LookdeMacBook-Pro ~/OpenStack]# openstack server list --name 网络测试
+--------------------------------------+----------+--------+---------------------------------------------------------------+---------------------------------------+---------------+
| ID                                   | Name     | Status | Networks                                                      | Image                                 | Flavor        |
+--------------------------------------+----------+--------+---------------------------------------------------------------+---------------------------------------+---------------+
| e92226be-b9ae-40bd-8f02-ade2eb9141b4 | 网络测试 | ACTIVE | NET-A=172.30.4.11; NET-B=172.25.200.210; NET-C=172.20.200.204 | CentOS-7.7.1908-x86_64-Cloud-20200207 | DT-L-1c1g40gD |
+--------------------------------------+----------+--------+---------------------------------------------------------------+---------------------------------------+---------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]#

一键更换

[lookback@LookdeMacBook-Pro ~/OpenStack]# Original_IP=172.25.200.204 && New_IP=72.25.200.210 && \
openstack port set --no-fixed-ip --fixed-ip ip-address=$New_IP $(openstack port list --fixed-ip ip-address=$Original_IP -c ID -f value)
[lookback@LookdeMacBook-Pro ~/OpenStack]# 

OpenStack更换实例ip的方法

lookback
  • 本文由 发表于 2020年3月17日06:18:05
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: