python openstack vpc互通_使用python-博托启动OpenStack的实例

I am trying to launch instances on opensatck setup with multiple networks configured using python-boto.

But I got following error,

EC2ResponseError: EC2ResponseError: 400 Bad Request

NetworkAmbiguousMultiple possible networks found, use a Network ID to be more specific.req-28b5a4e8-3838-4111-95db-337c5048716d

My code is like here,

from boto import ec2

ostack = ec2.connection.EC2Connection(

ec2_access_key, ec2_secret_key, is_secure=False, port=8773, region='nova',

path='/services/Cloud'

)

ostack.run_instances('ami-xxxxx', key_name='BotoTest')

The above is working fine for single network configured to openstack.

Note: run_instances doesn't have keyword argument for network-id.

Where I made a mistake or how to fix it? or is it bug in python-boto?

Advance in Thanks.

解决方案

I believe that this isn't a bug of boto, which was built to communicate with the AWS-API. While most of the EC2-AWS functionality work well with the EC2-OpenStack API, some features are not implemented and are answered with a HTTP-Error 500 or 400.

AWS use the VPC (Virtual Private Cloud) as Network and an Availability Zone as Subnet. Both have a default setting, which is taken if there is no further specification when creating a new instance. But in OpenStack I can't see a possibility to mark a Network and a Subnet as default.

In my attempts, neither private_ip_address nor subnet_id works to specify a network/subnet at run_instances() if there are more than one at OpenStack.

Edit: if you only have one network/subnet, the following code works fine with boto at trystack.org:

import boto

conn = boto.connect_ec2_endpoint("http://8.21.28.222:8773/services/Cloud",aws_access_key_id='...',aws_secret_access_key='...')

new_instance = conn.run_instances("ami-00000020", key_name="trystack", security_groups=["default"], instance_type="m1.small")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值