http://boto.s3.amazonaws.com/ref/ec2.html#module-boto.ec2.connection
I would basically do:
conn = boto.ec2.connect_to_region(
region_name = 'REGION_NAME',
aws_access_key_id = 'ACCESS_KEY',
aws_secret_access_key = 'SECRET_ACCESS_KEY',
)
ip_to_inst_map = {
'51.x.x.x' : 'i-xxxxxx',
'51.x.x.y' : 'i-yyyyyy',
'51.x.x.z' : 'i-zzzzzz',
}
for a in conn.get_all_addresses():
inst_id = ip_to_inst_map.get(a.public_ip)
if inst_id and a.instance_id != inst_id:
success = a.associate(inst_id)
if not success:
print "Failed to associate ip %s to inst %s" % (a.public_ip,
inst_id)
Although it appears you can just call:
conn.associate_address(instance_id, public_ip)
and if the address is already associated with that instance I'd expect
it to do nothing...
m
> --
> You received this message because you are subscribed to the Google Groups "boto-users" group.
> To post to this group, send email to boto-...@googlegroups.com.
> To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.
>
--
Matt Billenstein
ma...@vazor.com
http://www.vazor.com/