Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch Openstack Instances using python-boto

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.

like image 692
Syed Habib M Avatar asked Jan 13 '14 11:01

Syed Habib M


1 Answers

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")
like image 66
andpei Avatar answered Nov 02 '22 11:11

andpei