添加 Openstack neutron 端口的脚本或 Playbook 将多个 IP 添加到实例
Script or Playbook to ADD Openstack neutron port add multiple IPs to an instance
向 openstack VM 添加多个 ips,无论是现有的还是新的 VM,就像我收到向实例添加 200 多个 ips 的请求一样可怕。我如何编写脚本或剧本?
起始IP从192.168.0.50到192.168.0.150
我如何在此处手动添加多个 ips
$ source Project_admin
$ openstack network list | grep Test12
| ID | Name | Subnet | ID |
| kshd332sjkh-kjhj-sdsds-sdsdsds |Test12 | (192.168.0.0/24) | derere43e-erere-drerer-erererer |
$ openstack port list | grep 192.168.0.49 # (it show the First NIC port information and Port ID of an Single VM its a primary NIC)
这里我的第一个网卡端口id是3k3j43434-skdjk-erere-2323
#openstck port set --fixed-ip subnet=**derere43e-erere-drerer-erererer**,ip-address=192.168.0.50 --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.51 --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.52 --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.53 **3k3j43434-skdjk-erere-2323** **(myfirst-nic-port-id of 192.168.0.49)**
我如何使用 script/python 或使用 os_port 的剧本执行此操作。有什么方法可以实现这些对我的轮班任务更有帮助
你在OS什么?如果您有 shell 之类的 Bash 供您使用,这将适用于您的特定示例:
for octet in {50..150};do
openstack port set --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.$octet
done
向 openstack VM 添加多个 ips,无论是现有的还是新的 VM,就像我收到向实例添加 200 多个 ips 的请求一样可怕。我如何编写脚本或剧本?
起始IP从192.168.0.50到192.168.0.150
我如何在此处手动添加多个 ips
$ source Project_admin
$ openstack network list | grep Test12
| ID | Name | Subnet | ID |
| kshd332sjkh-kjhj-sdsds-sdsdsds |Test12 | (192.168.0.0/24) | derere43e-erere-drerer-erererer |
$ openstack port list | grep 192.168.0.49 # (it show the First NIC port information and Port ID of an Single VM its a primary NIC)
这里我的第一个网卡端口id是3k3j43434-skdjk-erere-2323
#openstck port set --fixed-ip subnet=**derere43e-erere-drerer-erererer**,ip-address=192.168.0.50 --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.51 --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.52 --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.53 **3k3j43434-skdjk-erere-2323** **(myfirst-nic-port-id of 192.168.0.49)**
我如何使用 script/python 或使用 os_port 的剧本执行此操作。有什么方法可以实现这些对我的轮班任务更有帮助
你在OS什么?如果您有 shell 之类的 Bash 供您使用,这将适用于您的特定示例:
for octet in {50..150};do
openstack port set --fixed-ip subnet-derere43e-erere-drerer-erererer,ip-address=192.168.0.$octet
done