使用 Openstack API 和 shell 脚本检索网络的 ID



我需要检索使用shell脚本和openstack API创建的网络的ID。有没有办法这样做?

neutron net-create test-net --provider:network_type vlan --provider:physical_network physnet2 --provider:segmentation_id 22  
neutron subnet-create test-net --name test-subnet --allocation-pool start=10.153.9.20,end=10.153.9.34 --gateway 10.153.8.1 10.153.8.0/22
您可以

执行neutron net-list [1] 将tenant_id作为参数,然后将对 grep 的响应通过管道传输到您想要通过名称选择的网络

neutron --os-tenant-id {tenant_id} net-list | grep {network_name}

你会得到这样的东西作为回应

|{network_id} |{network_name} |{子网} |

最新更新