Created
June 6, 2016 11:38
-
-
Save tonybaloney/cf2c39f699e34760d9c0d1c5c3f92f44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use libcloud 1.0.0-rc2 | |
from libcloud.compute.types import Provider | |
from libcloud.compute.providers import get_driver | |
from libcloud.common.dimensiondata import API_ENDPOINTS | |
# instantiate driver connection - 1 instance per region | |
cls = get_driver(Provider.DIMENSIONDATA) | |
# list regions | |
for (region, value) in API_ENDPOINTS.items(): | |
print('%s region - %s - at %s' % (region, value['name'], value['host'])) | |
# connect to a region - use the key | |
driver = cls('my username', 'my password', region='dd-na') | |
# We don't have detached volumes | |
# list locations within region | |
locations = driver.list_locations() | |
# List servers.. (is already paged) | |
servers = driver.list_nodes() | |
# list servers paged , returns generator function | |
all_servers = [servers for servers in driver.ex_list_nodes_paginated()] | |
# you can filter those servers by location, network, etc etc | |
servers_in_network = driver.list_nodes(location=locations[0]) | |
# get a list of network domains (like a VRF) | |
domains = driver.ex_list_network_domains() # location kwarg optional | |
# get a list of VLANS. | |
vlans = driver.ex_list_vlans() # location and network_domain kwarg optional if filtering needed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment