Launch Openstack Instances using python-boto
Asked Answered
K

2

6

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 <?xml version="1.0"?> <Response><Errors><Error><Code>NetworkAmbiguous</Code><Message>Multiple possible networks found, use a Network ID to be more specific.</Message></Error></Errors><RequestID>req-28b5a4e8-3838-4111-95db-337c5048716d</RequestID></Response>

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.

Kochi answered 13/1, 2014 at 11:49 Comment(2)
Same issue with right_aws ruby library ec2.launch_instances... as you say it is an api issueHylo
yet check with latest version of openstack. Will update you once I have done my checking.Kochi
N
2

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")
Nahama answered 14/1, 2014 at 10:56 Comment(4)
Yeah, you were right. But I trying to override it. Update this question will soon :-)Kochi
Can you check hereKochi
I found that the OpenStack EC2 API does not filter for vpc/subnet/network IDs at run_instancesNahama
It should be enable for icehouse only.Kochi
W
0

Have you tried? :

from boto import ec2
ostack = ec2.connection.EC2Connection(
   ec2_access_key, ec2_secret_key, is_secure=False, port=8773, region='nova',
   path='/services/Cloud', debug=1
)

then

ostack.run_instances('ami-xxxxx',  subnet_id='your network id', key_name='BotoTest')

Amazon uses this for VPC networks? Are you running a VPC?

Waver answered 14/1, 2014 at 5:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.