我尝试使用带有以下 api 调用的 nova python 客户端生成一个 cirros 实例,
server = nova.servers.create(name = "cirros_vm",
image = image.id,
flavor = flavor.id )
我收到以下错误:
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)
这是因为我的租户中有多个网络。帮助文档显示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.
但我无法弄清楚如何将网络 ID 传递给这个 API。当我将网络 ID 作为有序列表提供时,
server = nova.servers.create(name = "api_cir_test",
image = image.id,
flavor = flavor.id,
nics=[ network1.id, network2.id])
我收到以下错误:
AttributeError: 'unicode' object has no attribute 'get'
以下是使用的变量的详细信息:
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")