使用openstack API和shell脚本检索网络id

使用openstack API和shell脚本检索网络id,openstack,openstack-nova,Openstack,Openstack Nova,我需要检索使用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

我需要检索使用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

您可以执行
中子网络列表
租户id
作为参数提供,然后通过管道将对grep的响应发送到所需网络的名称

neutron --os-tenant-id {tenant_id} net-list | grep {network_name}
你会得到这样的回答

|{network_id}{network_name}{subnets}|


我找到了一种方法,根据您的答案使用
中子子网列表| grep vpx eg subnet | awk'{print$2}'
。谢谢!