[英]Openstack NovaClient : Error while launching an instance using servers.create()
I tried to spawn a cirros instance using nova python client with below api call, 我尝试使用nova python客户端在api调用下生成一个cirros实例,
server = nova.servers.create(name = "cirros_vm",
image = image.id,
flavor = flavor.id )
I am getting the following error: 我收到以下错误:
novaclient.exceptions.BadRequest: Multiple possible networks
found, use a Network ID to be more specific. (HTTP 400)
(Request-ID: req-c3aba1d2-23e9-4751-badc-60142286232e)
This is because I an having multiple networks inside my tenant.The help documentation shows that the optional nics
argument should be used. 这是因为我在租户中有多个网络。帮助文档显示应该使用可选的
nics
参数。
:param nics: (optional extension) an ordered list of nics to be
added to this server, with information about
connected networks, fixed ips, port etc.
But I am not able to figure out how to pass network ids to this api. 但我无法弄清楚如何将网络ID传递给此api。 When I give network ids as an ordered list,
当我将网络ID作为有序列表时,
server = nova.servers.create(name = "api_cir_test",
image = image.id,
flavor = flavor.id,
nics=[ network1.id, network2.id])
I am getting the following error: 我收到以下错误:
AttributeError: 'unicode' object has no attribute 'get'
Below are the details of variables used: 以下是使用的变量的详细信息:
nova is an object of Client in module novaclient.v1_1.client
image = nova.images.find(name="cirros")
flavor =nova.flavors.find(name="m1.small")
network =nova.networks.find(label="test_net")
The nics
argument requires the same information you would supply on the nova boot
command line...which means it accepts things other than network ids (you can pass in explicit neutron port IDs, for example, or you can provide information about fixed ip addresses). nics
参数需要您在nova boot
命令行中提供的相同信息...这意味着它接受除网络ID之外的其他内容(例如,您可以传入明确的中子端口ID,或者您可以提供有关固定IP地址的信息)。 The nics
argument needs an ordered list of dictionaries , such as: nics
参数需要一个有序的字典列表,例如:
server = nova.servers.create(name = "api_cir_test",
image = image.id,
flavor = flavor.id,
nics=[{'net-id': network1.id},
{'net-id': network2.id}])
That should successfully create your server. 这应该成功创建您的服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.