Renamed all CloudServers to OpenStack and python-cloudservers to python-novatools
This commit is contained in:
parent
7e2c002b2a
commit
4e2f2e21d3
@ -61,9 +61,9 @@ qthelp:
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-cloudservers.qhcp"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-novatools.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-cloudservers.qhc"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-novatools.qhc"
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
|
28
docs/api.rst
28
docs/api.rst
@ -1,22 +1,22 @@
|
||||
The :mod:`cloudservers` Python API
|
||||
The :mod:`novatools` Python API
|
||||
==================================
|
||||
|
||||
.. module:: cloudservers
|
||||
:synopsis: A client for the Rackspace Cloud Servers API.
|
||||
.. module:: novatools
|
||||
:synopsis: A client for the OpenStack Nova API.
|
||||
|
||||
.. currentmodule:: cloudservers
|
||||
.. currentmodule:: novatools
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
First create an instance of :class:`CloudServers` with your credentials::
|
||||
First create an instance of :class:`OpenStack` with your credentials::
|
||||
|
||||
>>> from cloudservers import CloudServers
|
||||
>>> cloudservers = CloudServers(USERNAME, API_KEY)
|
||||
>>> from novatools import OpenStack
|
||||
>>> nova = OpenStack(USERNAME, API_KEY, AUTH_URL)
|
||||
|
||||
Then call methods on the :class:`CloudServers` object:
|
||||
Then call methods on the :class:`OpenStack` object:
|
||||
|
||||
.. class:: CloudServers
|
||||
.. class:: OpenStack
|
||||
|
||||
.. attribute:: backup_schedules
|
||||
|
||||
@ -43,10 +43,10 @@ Then call methods on the :class:`CloudServers` object:
|
||||
|
||||
For example::
|
||||
|
||||
>>> cloudservers.servers.list()
|
||||
>>> nova.servers.list()
|
||||
[<Server: buildslave-ubuntu-9.10>]
|
||||
|
||||
>>> cloudservers.flavors.list()
|
||||
>>> nova.flavors.list()
|
||||
[<Flavor: 256 server>,
|
||||
<Flavor: 512 server>,
|
||||
<Flavor: 1GB server>,
|
||||
@ -55,8 +55,8 @@ For example::
|
||||
<Flavor: 8GB server>,
|
||||
<Flavor: 15.5GB server>]
|
||||
|
||||
>>> fl = cloudservers.flavors.find(ram=512)
|
||||
>>> cloudservers.servers.create("my-server", flavor=fl)
|
||||
>>> fl = nova.flavors.find(ram=512)
|
||||
>>> nova.servers.create("my-server", flavor=fl)
|
||||
<Server: my-server>
|
||||
|
||||
For more information, see the reference:
|
||||
@ -64,4 +64,4 @@ For more information, see the reference:
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
ref/index
|
||||
ref/index
|
||||
|
16
docs/conf.py
16
docs/conf.py
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python-cloudservers documentation build configuration file, created by
|
||||
# python-novatools documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sun Dec 6 14:19:25 2009.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
@ -37,17 +37,17 @@ source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'python-cloudservers'
|
||||
copyright = u'Jacob Kaplan-Moss'
|
||||
project = u'python-novatools'
|
||||
copyright = u'Rackspace, with inital work done by Jacob Kaplan-Moss'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '1.2'
|
||||
version = '2.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.2'
|
||||
release = '2.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
@ -158,7 +158,7 @@ html_static_path = ['_static']
|
||||
#html_file_suffix = ''
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'python-cloudserversdoc'
|
||||
htmlhelp_basename = 'python-novatoolsdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
@ -172,8 +172,8 @@ htmlhelp_basename = 'python-cloudserversdoc'
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'python-cloudservers.tex', u'python-cloudservers Documentation',
|
||||
u'Jacob Kaplan-Moss', 'manual'),
|
||||
('index', 'python-novatools.tex', u'python-novatools Documentation',
|
||||
u'Rackspace with initial work by Jacob Kaplan-Moss', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -1,18 +1,12 @@
|
||||
Python bindings to the Rackspace Cloud Servers API
|
||||
Python bindings to the OpenStack Nova API
|
||||
==================================================
|
||||
|
||||
This is a client for Rackspace's Cloud Servers API. There's :doc:`a Python API
|
||||
<api>` (the :mod:`cloudservers` module), and a :doc:`command-line script
|
||||
<shell>` (installed as :program:`cloudservers`). Each implements the entire
|
||||
Rackspace Cloud Servers API.
|
||||
This is a client for OpenStack Nova API. There's :doc:`a Python API
|
||||
<api>` (the :mod:`novatools` module), and a :doc:`command-line script
|
||||
<shell>` (installed as :program:`novatools`). Each implements the entire
|
||||
OpenStack Nova API.
|
||||
|
||||
You'll need a `Rackspace Cloud`__ account, and you'll need to make sure to sign
|
||||
up for both Cloud Servers *and* Cloud Files -- Rackspace won't let you get an
|
||||
API key unless you've got a Cloud Files account, too. Once you've got an
|
||||
account, you'll find your API key in the management console under "Your
|
||||
Account".
|
||||
|
||||
__ http://rackspacecloud.com/
|
||||
You'll need an `OpenStack Nova` account, which you can get by using `nova-manage`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
@ -38,7 +32,7 @@ Contributing
|
||||
|
||||
Development takes place `on GitHub`__; please file bugs/pull requests there.
|
||||
|
||||
__ http://github.com/jacobian/python-cloudservers
|
||||
__ https://github.com/rackspace/python-novatools
|
||||
|
||||
Run tests with ``python setup.py test``.
|
||||
|
||||
|
@ -2,6 +2,17 @@
|
||||
Release notes
|
||||
=============
|
||||
|
||||
2.0 (Feb 7, 2011)
|
||||
=================
|
||||
|
||||
* Forked from https://github.com/jacobian/python-cloudservers
|
||||
|
||||
* Rebranded to python-novatools
|
||||
|
||||
* Auth URL support
|
||||
|
||||
* New OpenStack specific commands added (pause, suspend, etc)
|
||||
|
||||
1.2 (August 15, 2010)
|
||||
=====================
|
||||
|
||||
@ -22,4 +33,4 @@ Release notes
|
||||
with an SSH public key at boot time. This is just a shortcut for ``--files``,
|
||||
but it's a useful shortcut.
|
||||
|
||||
* Changed the default server image to Ubuntu 10.04 LTS.
|
||||
* Changed the default server image to Ubuntu 10.04 LTS.
|
||||
|
@ -1,40 +1,37 @@
|
||||
The :program:`cloudservers` shell utility
|
||||
The :program:`novatools` shell utility
|
||||
=========================================
|
||||
|
||||
.. program:: cloudservers
|
||||
.. program:: novatools
|
||||
.. highlight:: bash
|
||||
|
||||
The :program:`cloudservers` shell utility interacts with Rackspace Cloud servers
|
||||
from the command line. It supports the entirety of the Cloud Servers API,
|
||||
including some commands not available from the Rackspace web console.
|
||||
The :program:`novatools` shell utility interacts with OpenStack Nova API
|
||||
from the command line. It supports the entirety of the OpenStack Nova API.
|
||||
|
||||
First, you'll need a Rackspace Cloud Servers account and an API key. At the time
|
||||
of this writing getting an API key is non-obvious: you need to sign up for
|
||||
*both* Cloud Servers *and* Cloud Files; only then can you grab an API key from
|
||||
the Rackspace web console.
|
||||
First, you'll need an OpenStack Nova account and an API key. You get this
|
||||
by using the `nova-manage` command in OpenStack Nova.
|
||||
|
||||
You'll need to provide :program:`cloudservers` with your Rackspace username and
|
||||
You'll need to provide :program:`novatools` with your OpenStack username and
|
||||
API key. You can do this with the :option:`--username` and :option:`--apikey`
|
||||
options, but it's easier to just set them as environment variables by setting
|
||||
two environment variables:
|
||||
|
||||
.. envvar:: CLOUD_SERVERS_USERNAME
|
||||
.. envvar:: NOVA_TOOLS_USERNAME
|
||||
|
||||
Your Rackspace Cloud username.
|
||||
Your OpenStack Nova username.
|
||||
|
||||
.. envvar:: CLOUD_SERVERS_API_KEY
|
||||
.. envvar:: NOVA_TOOLS_API_KEY
|
||||
|
||||
Your API key.
|
||||
|
||||
For example, in Bash you'd use::
|
||||
|
||||
export CLOUD_SERVERS_USERNAME=yourname
|
||||
export CLOUD_SERVERS_API_KEY=yadayadayada
|
||||
export NOVA_TOOLS_USERNAME=yourname
|
||||
export NOVA_TOOLS_API_KEY=yadayadayada
|
||||
|
||||
From there, all shell commands take the form::
|
||||
|
||||
cloudservers <command> [arguments...]
|
||||
novatools <command> [arguments...]
|
||||
|
||||
Run :program:`cloudservers help` to get a full list of all possible commands,
|
||||
and run :program:`cloudservers help <command>` to get detailed help for that
|
||||
command.
|
||||
Run :program:`novatools help` to get a full list of all possible commands,
|
||||
and run :program:`novatools help <command>` to get detailed help for that
|
||||
command.
|
||||
|
@ -1,6 +1,6 @@
|
||||
__version__ = '1.2'
|
||||
__version__ = '2.0'
|
||||
|
||||
from cloudservers.backup_schedules import (
|
||||
from novatools.backup_schedules import (
|
||||
BackupSchedule, BackupScheduleManager,
|
||||
BACKUP_WEEKLY_DISABLED, BACKUP_WEEKLY_SUNDAY, BACKUP_WEEKLY_MONDAY,
|
||||
BACKUP_WEEKLY_TUESDAY, BACKUP_WEEKLY_WEDNESDAY,
|
||||
@ -12,29 +12,29 @@ from cloudservers.backup_schedules import (
|
||||
BACKUP_DAILY_H_1400_1600, BACKUP_DAILY_H_1600_1800,
|
||||
BACKUP_DAILY_H_1800_2000, BACKUP_DAILY_H_2000_2200,
|
||||
BACKUP_DAILY_H_2200_0000)
|
||||
from cloudservers.client import CloudServersClient
|
||||
from cloudservers.exceptions import (CloudServersException, BadRequest,
|
||||
from novatools.client import OpenStackClient
|
||||
from novatools.exceptions import (OpenStackException, BadRequest,
|
||||
Unauthorized, Forbidden, NotFound, OverLimit)
|
||||
from cloudservers.flavors import FlavorManager, Flavor
|
||||
from cloudservers.images import ImageManager, Image
|
||||
from cloudservers.ipgroups import IPGroupManager, IPGroup
|
||||
from cloudservers.servers import (ServerManager, Server, REBOOT_HARD,
|
||||
from novatools.flavors import FlavorManager, Flavor
|
||||
from novatools.images import ImageManager, Image
|
||||
from novatools.ipgroups import IPGroupManager, IPGroup
|
||||
from novatools.servers import (ServerManager, Server, REBOOT_HARD,
|
||||
REBOOT_SOFT)
|
||||
|
||||
|
||||
class CloudServers(object):
|
||||
class OpenStack(object):
|
||||
"""
|
||||
Top-level object to access the Rackspace Cloud Servers API.
|
||||
Top-level object to access the OpenStack Nova API.
|
||||
|
||||
Create an instance with your creds::
|
||||
|
||||
>>> cs = CloudServers(USERNAME, API_KEY [, AUTH_URL])
|
||||
>>> os = OpenStack(USERNAME, API_KEY, AUTH_URL)
|
||||
|
||||
Then call methods on its managers::
|
||||
|
||||
>>> cs.servers.list()
|
||||
>>> os.servers.list()
|
||||
...
|
||||
>>> cs.flavors.list()
|
||||
>>> os.flavors.list()
|
||||
...
|
||||
|
||||
&c.
|
||||
@ -43,7 +43,7 @@ class CloudServers(object):
|
||||
def __init__(self, username, apikey,
|
||||
auth_url='https://auth.api.rackspacecloud.com/v1.0'):
|
||||
self.backup_schedules = BackupScheduleManager(self)
|
||||
self.client = CloudServersClient(username, apikey, auth_url)
|
||||
self.client = OpenStackClient(username, apikey, auth_url)
|
||||
self.flavors = FlavorManager(self)
|
||||
self.images = ImageManager(self)
|
||||
self.ipgroups = IPGroupManager(self)
|
||||
@ -56,7 +56,7 @@ class CloudServers(object):
|
||||
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:`cloudservers.Unauthorized` if the
|
||||
Returns on success; raises :exc:`novatools.Unauthorized` if the
|
||||
credentials are wrong.
|
||||
"""
|
||||
self.client.authenticate()
|
||||
|
@ -1,4 +1,4 @@
|
||||
from cloudservers import base
|
||||
from novatools import base
|
||||
|
||||
BACKUP_WEEKLY_DISABLED = 'DISABLED'
|
||||
BACKUP_WEEKLY_SUNDAY = 'SUNDAY'
|
||||
|
@ -2,7 +2,7 @@
|
||||
Base utilities to build API operation managers and objects on top of.
|
||||
"""
|
||||
|
||||
from cloudservers.exceptions import NotFound
|
||||
from novatools.exceptions import NotFound
|
||||
|
||||
# Python 2.4 compat
|
||||
try:
|
||||
|
@ -12,16 +12,16 @@ if not hasattr(urlparse, 'parse_qsl'):
|
||||
import cgi
|
||||
urlparse.parse_qsl = cgi.parse_qsl
|
||||
|
||||
import cloudservers
|
||||
from cloudservers import exceptions
|
||||
import novatools
|
||||
from novatools import exceptions
|
||||
|
||||
|
||||
class CloudServersClient(httplib2.Http):
|
||||
class OpenStackClient(httplib2.Http):
|
||||
|
||||
USER_AGENT = 'python-cloudservers/%s' % cloudservers.__version__
|
||||
USER_AGENT = 'python-novatools/%s' % novatools.__version__
|
||||
|
||||
def __init__(self, user, apikey, auth_url):
|
||||
super(CloudServersClient, self).__init__()
|
||||
super(OpenStackClient, self).__init__()
|
||||
self.user = user
|
||||
self.apikey = apikey
|
||||
self.auth_url = auth_url
|
||||
@ -41,7 +41,7 @@ class CloudServersClient(httplib2.Http):
|
||||
|
||||
# print "-------------"
|
||||
# print "ARGS:", args
|
||||
resp, body = super(CloudServersClient, self).request(*args, **kwargs)
|
||||
resp, body = super(OpenStackClient, self).request(*args, **kwargs)
|
||||
# print "RESPONSE", resp
|
||||
# print "BODY", body
|
||||
if body:
|
||||
@ -101,7 +101,7 @@ class CloudServersClient(httplib2.Http):
|
||||
"""
|
||||
Munge GET URLs to always return uncached content.
|
||||
|
||||
The Cloud Servers API caches data *very* agressively and doesn't
|
||||
The OpenStack Nova API caches data *very* agressively and doesn't
|
||||
respect cache headers. To avoid stale data, then, we append a little
|
||||
bit of nonsense onto GET parameters; this appears to force the data not
|
||||
to be cached.
|
||||
|
@ -1,4 +1,4 @@
|
||||
class CloudServersException(Exception):
|
||||
class OpenStackException(Exception):
|
||||
"""
|
||||
The base exception class for all exceptions this library raises.
|
||||
"""
|
||||
@ -11,7 +11,7 @@ class CloudServersException(Exception):
|
||||
return "%s (HTTP %s)" % (self.message, self.code)
|
||||
|
||||
|
||||
class BadRequest(CloudServersException):
|
||||
class BadRequest(OpenStackException):
|
||||
"""
|
||||
HTTP 400 - Bad request: you sent some malformed data.
|
||||
"""
|
||||
@ -19,7 +19,7 @@ class BadRequest(CloudServersException):
|
||||
message = "Bad request"
|
||||
|
||||
|
||||
class Unauthorized(CloudServersException):
|
||||
class Unauthorized(OpenStackException):
|
||||
"""
|
||||
HTTP 401 - Unauthorized: bad credentials.
|
||||
"""
|
||||
@ -27,7 +27,7 @@ class Unauthorized(CloudServersException):
|
||||
message = "Unauthorized"
|
||||
|
||||
|
||||
class Forbidden(CloudServersException):
|
||||
class Forbidden(OpenStackException):
|
||||
"""
|
||||
HTTP 403 - Forbidden: your credentials don't give you access to this
|
||||
resource.
|
||||
@ -36,7 +36,7 @@ class Forbidden(CloudServersException):
|
||||
message = "Forbidden"
|
||||
|
||||
|
||||
class NotFound(CloudServersException):
|
||||
class NotFound(OpenStackException):
|
||||
"""
|
||||
HTTP 404 - Not found
|
||||
"""
|
||||
@ -44,7 +44,7 @@ class NotFound(CloudServersException):
|
||||
message = "Not found"
|
||||
|
||||
|
||||
class OverLimit(CloudServersException):
|
||||
class OverLimit(OpenStackException):
|
||||
"""
|
||||
HTTP 413 - Over limit: you're over the API limits for this time period.
|
||||
"""
|
||||
@ -53,7 +53,7 @@ class OverLimit(CloudServersException):
|
||||
|
||||
|
||||
# NotImplemented is a python keyword.
|
||||
class HTTPNotImplemented(CloudServersException):
|
||||
class HTTPNotImplemented(OpenStackException):
|
||||
"""
|
||||
HTTP 501 - Not Implemented: the server does not support this operation.
|
||||
"""
|
||||
@ -64,7 +64,7 @@ class HTTPNotImplemented(CloudServersException):
|
||||
# In Python 2.4 Exception is old-style and thus doesn't have a __subclasses__()
|
||||
# so we can do this:
|
||||
# _code_map = dict((c.http_status, c)
|
||||
# for c in CloudServersException.__subclasses__())
|
||||
# for c in OpenStackException.__subclasses__())
|
||||
#
|
||||
# Instead, we have to hardcode it:
|
||||
_code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
|
||||
@ -73,7 +73,7 @@ _code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
|
||||
|
||||
def from_response(response, body):
|
||||
"""
|
||||
Return an instance of a CloudServersException or subclass
|
||||
Return an instance of an OpenStackException or subclass
|
||||
based on an httplib2 response.
|
||||
|
||||
Usage::
|
||||
@ -82,7 +82,7 @@ def from_response(response, body):
|
||||
if resp.status != 200:
|
||||
raise exception_from_response(resp, body)
|
||||
"""
|
||||
cls = _code_map.get(response.status, CloudServersException)
|
||||
cls = _code_map.get(response.status, OpenStackException)
|
||||
if body:
|
||||
message = "n/a"
|
||||
details = "n/a"
|
||||
|
@ -1,4 +1,4 @@
|
||||
from cloudservers import base
|
||||
from novatools import base
|
||||
|
||||
|
||||
class Flavor(base.Resource):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from cloudservers import base
|
||||
from novatools import base
|
||||
|
||||
|
||||
class Image(base.Resource):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from cloudservers import base
|
||||
from novatools import base
|
||||
|
||||
|
||||
class IPGroup(base.Resource):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from cloudservers import base
|
||||
from novatools import base
|
||||
|
||||
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
"""
|
||||
Command-line interface to the Cloud Servers API.
|
||||
Command-line interface to the OpenStack Nova API.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import cloudservers
|
||||
import novatools
|
||||
import getpass
|
||||
import httplib2
|
||||
import os
|
||||
@ -12,11 +12,11 @@ import sys
|
||||
import textwrap
|
||||
|
||||
# Choices for flags.
|
||||
DAY_CHOICES = [getattr(cloudservers, i).lower()
|
||||
for i in dir(cloudservers)
|
||||
DAY_CHOICES = [getattr(novatools, i).lower()
|
||||
for i in dir(novatools)
|
||||
if i.startswith('BACKUP_WEEKLY_')]
|
||||
HOUR_CHOICES = [getattr(cloudservers, i).lower()
|
||||
for i in dir(cloudservers)
|
||||
HOUR_CHOICES = [getattr(novatools, i).lower()
|
||||
for i in dir(novatools)
|
||||
if i.startswith('BACKUP_DAILY_')]
|
||||
|
||||
|
||||
@ -45,19 +45,19 @@ def env(e):
|
||||
return os.environ.get(e, '')
|
||||
|
||||
|
||||
class CloudserversShell(object):
|
||||
class OpenStackShell(object):
|
||||
|
||||
# Hook for the test suite to inject a fake server.
|
||||
_api_class = cloudservers.CloudServers
|
||||
_api_class = novatools.OpenStack
|
||||
|
||||
def __init__(self):
|
||||
self.parser = argparse.ArgumentParser(
|
||||
prog='cloudservers',
|
||||
prog='novatools',
|
||||
description=__doc__.strip(),
|
||||
epilog='See "cloudservers help COMMAND" '\
|
||||
epilog='See "novatools help COMMAND" '\
|
||||
'for help on a specific command.',
|
||||
add_help=False,
|
||||
formatter_class=CloudserversHelpFormatter,
|
||||
formatter_class=OpenStackHelpFormatter,
|
||||
)
|
||||
|
||||
# Global arguments
|
||||
@ -72,19 +72,19 @@ class CloudserversShell(object):
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
self.parser.add_argument('--username',
|
||||
default=env('CLOUD_SERVERS_USERNAME'),
|
||||
help='Defaults to env[CLOUD_SERVERS_USERNAME].')
|
||||
default=env('NOVA_TOOLS_USERNAME'),
|
||||
help='Defaults to env[NOVA_TOOLS_USERNAME].')
|
||||
|
||||
self.parser.add_argument('--apikey',
|
||||
default=env('CLOUD_SERVERS_API_KEY'),
|
||||
help='Defaults to env[CLOUD_SERVERS_API_KEY].')
|
||||
default=env('NOVA_TOOLS_API_KEY'),
|
||||
help='Defaults to env[NOVA_TOOLS_API_KEY].')
|
||||
|
||||
auth_url = env('CLOUD_SERVERS_URL')
|
||||
auth_url = env('NOVA_TOOLS_URL')
|
||||
if auth_url == '':
|
||||
auth_url = 'https://auth.api.rackspacecloud.com/v1.0'
|
||||
self.parser.add_argument('--url',
|
||||
default=auth_url,
|
||||
help='Defaults to env[CLOUD_SERVERS_URL].')
|
||||
help='Defaults to env[NOVA_TOOLS_URL].')
|
||||
|
||||
# Subcommands
|
||||
subparsers = self.parser.add_subparsers(metavar='<subcommand>')
|
||||
@ -130,16 +130,16 @@ class CloudserversShell(object):
|
||||
user, apikey, url = args.username, args.apikey, args.url
|
||||
if not user:
|
||||
raise CommandError("You must provide a username, either via "
|
||||
"--username or via env[CLOUD_SERVERS_USERNAME]")
|
||||
"--username or via env[NOVA_TOOLS_USERNAME]")
|
||||
if not apikey:
|
||||
raise CommandError("You must provide an API key, either via "
|
||||
"--apikey or via env[CLOUD_SERVERS_API_KEY]")
|
||||
"--apikey or via env[NOVA_TOOLS_API_KEY]")
|
||||
|
||||
self.cs = self._api_class(user, apikey, url)
|
||||
try:
|
||||
self.cs.authenticate()
|
||||
except cloudservers.Unauthorized:
|
||||
raise CommandError("Invalid Cloud Servers credentials.")
|
||||
raise CommandError("Invalid OpenStack Nova credentials.")
|
||||
|
||||
args.func(args)
|
||||
|
||||
@ -204,17 +204,17 @@ class CloudserversShell(object):
|
||||
@arg('--flavor',
|
||||
default=None,
|
||||
metavar='<flavor>',
|
||||
help="Flavor ID (see 'cloudservers flavors'). "\
|
||||
help="Flavor ID (see 'novatools flavors'). "\
|
||||
"Defaults to 256MB RAM instance.")
|
||||
@arg('--image',
|
||||
default=None,
|
||||
metavar='<image>',
|
||||
help="Image ID (see 'cloudservers images'). "\
|
||||
help="Image ID (see 'novatools images'). "\
|
||||
"Defaults to Ubuntu 10.04 LTS.")
|
||||
@arg('--ipgroup',
|
||||
default=None,
|
||||
metavar='<group>',
|
||||
help="IP group name or ID (see 'cloudservers ipgroup-list').")
|
||||
help="IP group name or ID (see 'novatools ipgroup-list').")
|
||||
@arg('--meta',
|
||||
metavar="<key=value>",
|
||||
action='append',
|
||||
@ -524,11 +524,11 @@ class CloudserversShell(object):
|
||||
|
||||
|
||||
# I'm picky about my shell help.
|
||||
class CloudserversHelpFormatter(argparse.HelpFormatter):
|
||||
class OpenStackHelpFormatter(argparse.HelpFormatter):
|
||||
def start_section(self, heading):
|
||||
# Title-case the headings
|
||||
heading = '%s%s' % (heading[0].upper(), heading[1:])
|
||||
super(CloudserversHelpFormatter, self).start_section(heading)
|
||||
super(OpenStackHelpFormatter, self).start_section(heading)
|
||||
|
||||
|
||||
# Helpers
|
||||
@ -557,7 +557,7 @@ def print_dict(d):
|
||||
|
||||
def main():
|
||||
try:
|
||||
CloudserversShell().main(sys.argv[1:])
|
||||
OpenStackShell().main(sys.argv[1:])
|
||||
except CommandError, e:
|
||||
print >> sys.stderr, e
|
||||
sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user