How to list nodes in ec2 west in libcloud

475 Views Asked by At

I want to list nodes in ec2 region using libcoud. How do I do that? Below gives east only.

Driver = get_driver(Provider.EC2)
conn = Driver(key, secret)
conn.list_nodes()
2

There are 2 best solutions below

0
On

You can get the relevant driver for that region:

cls = get_driver(Provider.EC2_US_WEST)
driver = cls(ACCESS_ID, SECRET_KEY)

Taken from the bottom example in this documentation page.

0
On

You can do this via the driver initialization. For example:

ec2_conn = get_driver(Provider.EC2)(aws_key, aws_secret, region='us-west-1')
instances = ec2_conn.list_nodes(ex_node_ids=[i-xxxxxx])
print instances