All of the prerequisites for supporting multiple VM providers should be in place. This has been tested with rackspace legacy, rackspace nova, and hpcloud. The scripts now use novaclient instead of libcloud. The old v1_0 code that was removed from novaclient is added here for as long as we continue to use rackspace legacy. It's slightly modified to handle some operational considerations (such as cache-busting), and to integrate with the current version of novaclient. We can remove it when it's no longer needed. Machines are now generated from snapshot images created from per-provider base images, this lets us specify, eg, oneiric and precise images from each provider. Setup scripts take the provider name as an argument (so each provider in Jenkins can have its own job for easier monitoring). The fetch script takes the base image name (eg, "oneiric") as an argument and gets the oldest matching node from any provider. Snapshot images are created from scratch each time; no more long-running template hosts. Devstack fixed network set to something that doesn't collide with hpcloud. Min_ram is now configurable per-base-image (so we can request servers with a certain amount of ram for each image (in case an image has no swap, or otherwise needs more ram)). SKIP_DEVSTACK_GATE_PROJECT added to the gate script to make testing the script itself during development easier. More robust detection of image URLs in the image update script. On a running devstack node, before running devstack, check to see if there is swap space. If not, assume we're on HPCloud and unmount /mnt and use it for swap. Change-Id: I782e1180424ce0f3c7b69a3042eccc85b2b50389
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
from novaclient import client
|
|
import accounts
|
|
import backup_schedules
|
|
import flavors
|
|
import images
|
|
import ipgroups
|
|
import servers
|
|
import zones
|
|
|
|
|
|
class Client(object):
|
|
"""
|
|
Top-level object to access the OpenStack Compute API.
|
|
|
|
Create an instance with your creds::
|
|
|
|
>>> client = Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
|
|
|
|
Then call methods on its managers::
|
|
|
|
>>> client.servers.list()
|
|
...
|
|
>>> client.flavors.list()
|
|
...
|
|
|
|
"""
|
|
|
|
def __init__(self, username, api_key, project_id, auth_url=None,
|
|
insecure=False, timeout=None, token=None, region_name=None,
|
|
endpoint_name=None, extensions=None, service_type=None,
|
|
service_name=None, endpoint_type='publicURL'):
|
|
|
|
# FIXME(comstud): Rename the api_key argument above when we
|
|
# know it's not being used as keyword argument
|
|
password = api_key
|
|
self.accounts = accounts.AccountManager(self)
|
|
self.backup_schedules = backup_schedules.BackupScheduleManager(self)
|
|
self.flavors = flavors.FlavorManager(self)
|
|
self.images = images.ImageManager(self)
|
|
self.ipgroups = ipgroups.IPGroupManager(self)
|
|
self.servers = servers.ServerManager(self)
|
|
self.zones = zones.ZoneManager(self)
|
|
#service_type is unused in v1_0
|
|
#service_name is unused in v1_0
|
|
#endpoint_name is unused in v_10
|
|
#endpoint_type was endpoint_name
|
|
|
|
# Add in any extensions...
|
|
if extensions:
|
|
for (ext_name, ext_manager_class, ext_module) in extensions:
|
|
setattr(self, ext_name, ext_manager_class(self))
|
|
|
|
_auth_url = auth_url or 'https://auth.api.rackspacecloud.com/v1.0'
|
|
|
|
self.client = client.HTTPClient(username,
|
|
password,
|
|
project_id,
|
|
_auth_url,
|
|
insecure=insecure,
|
|
timeout=timeout,
|
|
proxy_token=token,
|
|
region_name=region_name,
|
|
endpoint_type=endpoint_type)
|
|
|
|
def authenticate(self):
|
|
"""
|
|
Authenticate against the server.
|
|
|
|
Normally this is called automatically when you first access the API,
|
|
but you can call this method to force authentication right now.
|
|
|
|
Returns on success; raises :exc:`exceptions.Unauthorized` if the
|
|
credentials are wrong.
|
|
"""
|
|
self.client.authenticate()
|