renamed to novaclient and fixed flavor tests
This commit is contained in:
parent
8611fc2598
commit
bd18c7e429
1
LICENSE
1
LICENSE
|
@ -1,5 +1,6 @@
|
||||||
Copyright (c) 2009 Jacob Kaplan-Moss - initial codebase (< v2.1)
|
Copyright (c) 2009 Jacob Kaplan-Moss - initial codebase (< v2.1)
|
||||||
Copyright (c) 2011 Rackspace - OpenStack extensions (>= v2.1)
|
Copyright (c) 2011 Rackspace - OpenStack extensions (>= v2.1)
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
|
|
16
README.rst
16
README.rst
|
@ -2,12 +2,12 @@ Python bindings to the OpenStack Nova API
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
This is a client for the OpenStack Nova API. There's a Python API (the
|
This is a client for the OpenStack Nova API. There's a Python API (the
|
||||||
``novatools`` module), and a command-line script (``nova``). Each
|
``novaclient`` module), and a command-line script (``nova``). Each
|
||||||
implements 100% of the OpenStack Nova API.
|
implements 100% of the OpenStack Nova API.
|
||||||
|
|
||||||
[PENDING] `Full documentation is available`__.
|
[PENDING] `Full documentation is available`__.
|
||||||
|
|
||||||
__ http://packages.python.org/python-novatools/
|
__ http://packages.python.org/python-novaclient/
|
||||||
|
|
||||||
You'll also probably want to read `Rackspace's API guide`__ (PDF) -- the first
|
You'll also probably want to read `Rackspace's API guide`__ (PDF) -- the first
|
||||||
bit, at least -- to get an idea of the concepts. Rackspace is doing the cloud
|
bit, at least -- to get an idea of the concepts. Rackspace is doing the cloud
|
||||||
|
@ -18,11 +18,11 @@ __ http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf
|
||||||
|
|
||||||
Development takes place on GitHub__. Bug reports and patches may be filed there.
|
Development takes place on GitHub__. Bug reports and patches may be filed there.
|
||||||
|
|
||||||
__ https://github.com/rackspace/python-novatools
|
__ https://github.com/rackspace/python-client
|
||||||
|
|
||||||
This code a fork of `Jacobian's python-cloudservers`__ If you need API support
|
This code a fork of `Jacobian's python-cloudservers`__ If you need API support
|
||||||
for the Rackspace API soley or the BSD license, you should use that repository.
|
for the Rackspace API soley or the BSD license, you should use that repository.
|
||||||
python-novatools is licensed under the Apache License like the rest of OpenStack.
|
python-client is licensed under the Apache License like the rest of OpenStack.
|
||||||
|
|
||||||
__ http://github.com/jacobian/python-cloudservers
|
__ http://github.com/jacobian/python-cloudservers
|
||||||
|
|
||||||
|
@ -104,12 +104,12 @@ Python API
|
||||||
|
|
||||||
[PENDING] There's also a `complete Python API`__.
|
[PENDING] There's also a `complete Python API`__.
|
||||||
|
|
||||||
__ http://packages.python.org/python-novatools/
|
__ http://packages.python.org/python-novaclient/
|
||||||
|
|
||||||
By way of a quick-start::
|
By way of a quick-start::
|
||||||
|
|
||||||
>>> import novatools
|
>>> import novaclient
|
||||||
>>> nt = novatools.OpenStack(USERNAME, API_KEY [, AUTH_URL])
|
>>> nt = novaclient.OpenStack(USERNAME, API_KEY [, AUTH_URL])
|
||||||
>>> nt.flavors.list()
|
>>> nt.flavors.list()
|
||||||
[...]
|
[...]
|
||||||
>>> nt.servers.list()
|
>>> nt.servers.list()
|
||||||
|
@ -127,4 +127,4 @@ By way of a quick-start::
|
||||||
What's new?
|
What's new?
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
[PENDING] See `the release notes <http://packages.python.org/python-novatools/releases.html>`_.
|
[PENDING] See `the release notes <http://packages.python.org/python-novaclient/releases.html>`_.
|
||||||
|
|
|
@ -61,9 +61,9 @@ qthelp:
|
||||||
@echo
|
@echo
|
||||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-novatools.qhcp"
|
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-novaclient.qhcp"
|
||||||
@echo "To view the help file:"
|
@echo "To view the help file:"
|
||||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-novatools.qhc"
|
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-novaclient.qhc"
|
||||||
|
|
||||||
latex:
|
latex:
|
||||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
The :mod:`novatools` Python API
|
The :mod:`novaclient` Python API
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
.. module:: novatools
|
.. module:: novaclient
|
||||||
:synopsis: A client for the OpenStack Nova API.
|
:synopsis: A client for the OpenStack Nova API.
|
||||||
|
|
||||||
.. currentmodule:: novatools
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
First create an instance of :class:`OpenStack` with your credentials::
|
First create an instance of :class:`OpenStack` with your credentials::
|
||||||
|
|
||||||
>>> from novatools import OpenStack
|
>>> from novaclient import OpenStack
|
||||||
>>> nova = OpenStack(USERNAME, API_KEY, AUTH_URL)
|
>>> nova = OpenStack(USERNAME, API_KEY, AUTH_URL)
|
||||||
|
|
||||||
Then call methods on the :class:`OpenStack` object:
|
Then call methods on the :class:`OpenStack` object:
|
||||||
|
|
12
docs/conf.py
12
docs/conf.py
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# python-novatools documentation build configuration file, created by
|
# python-novaclient documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Sun Dec 6 14:19:25 2009.
|
# sphinx-quickstart on Sun Dec 6 14:19:25 2009.
|
||||||
#
|
#
|
||||||
# This file is execfile()d with the current directory set to its containing dir.
|
# This file is execfile()d with the current directory set to its containing dir.
|
||||||
|
@ -37,7 +37,7 @@ source_suffix = '.rst'
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'python-novatools'
|
project = u'python-novaclient'
|
||||||
copyright = u'Rackspace, based on work by Jacob Kaplan-Moss'
|
copyright = u'Rackspace, based on work by Jacob Kaplan-Moss'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
|
@ -45,9 +45,9 @@ copyright = u'Rackspace, based on work by Jacob Kaplan-Moss'
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '2.2'
|
version = '2.3'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '2.2'
|
release = '2.3'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -158,7 +158,7 @@ html_static_path = ['_static']
|
||||||
#html_file_suffix = ''
|
#html_file_suffix = ''
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'python-novatoolsdoc'
|
htmlhelp_basename = 'python-novaclientdoc'
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output --------------------------------------------------
|
# -- Options for LaTeX output --------------------------------------------------
|
||||||
|
@ -172,7 +172,7 @@ htmlhelp_basename = 'python-novatoolsdoc'
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index', 'python-novatools.tex', u'python-novatools Documentation',
|
('index', 'python-novaclient.tex', u'python-novaclient Documentation',
|
||||||
u'Rackspace - based on work by Jacob Kaplan-Moss', 'manual'),
|
u'Rackspace - based on work by Jacob Kaplan-Moss', 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ Python bindings to the OpenStack Nova API
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
This is a client for OpenStack Nova API. There's :doc:`a Python 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
|
<api>` (the :mod:`novaclient` module), and a :doc:`command-line script
|
||||||
<shell>` (installed as :program:`nova`). Each implements the entire
|
<shell>` (installed as :program:`nova`). Each implements the entire
|
||||||
OpenStack Nova API.
|
OpenStack Nova API.
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ Contributing
|
||||||
|
|
||||||
Development takes place `on GitHub`__; please file bugs/pull requests there.
|
Development takes place `on GitHub`__; please file bugs/pull requests there.
|
||||||
|
|
||||||
__ https://github.com/rackspace/python-novatools
|
__ https://github.com/rackspace/python-novaclient
|
||||||
|
|
||||||
Run tests with ``python setup.py test``.
|
Run tests with ``python setup.py test``.
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
Backup schedules
|
Backup schedules
|
||||||
================
|
================
|
||||||
|
|
||||||
.. currentmodule:: cloudservers
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
Rackspace allows scheduling of weekly and/or daily backups for virtual
|
Rackspace allows scheduling of weekly and/or daily backups for virtual
|
||||||
servers. You can access these backup schedules either off the API object as
|
servers. You can access these backup schedules either off the API object as
|
||||||
:attr:`CloudServers.backup_schedules`, or directly off a particular
|
:attr:`OpenStack.backup_schedules`, or directly off a particular
|
||||||
:class:`Server` instance as :attr:`Server.backup_schedule`.
|
:class:`Server` instance as :attr:`Server.backup_schedule`.
|
||||||
|
|
||||||
Classes
|
Classes
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
Exceptions
|
Exceptions
|
||||||
==========
|
==========
|
||||||
|
|
||||||
.. currentmodule:: cloudservers
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
Exceptions
|
Exceptions
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Exceptions that the API might throw:
|
Exceptions that the API might throw:
|
||||||
|
|
||||||
.. automodule:: cloudservers
|
.. automodule:: novaclient
|
||||||
:members: CloudServersException, BadRequest, Unauthorized, Forbidden,
|
:members: OpenStackException, BadRequest, Unauthorized, Forbidden,
|
||||||
NotFound, OverLimit
|
NotFound, OverLimit
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ From Rackspace's API documentation:
|
||||||
Classes
|
Classes
|
||||||
-------
|
-------
|
||||||
|
|
||||||
.. currentmodule:: cloudservers
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
.. autoclass:: FlavorManager
|
.. autoclass:: FlavorManager
|
||||||
:members: get, list, find, findall
|
:members: get, list, find, findall
|
||||||
|
@ -32,4 +32,4 @@ Classes
|
||||||
|
|
||||||
.. attribute:: disk
|
.. attribute:: disk
|
||||||
|
|
||||||
The amount of disk space this flavor has, in MB
|
The amount of disk space this flavor has, in MB
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Images
|
Images
|
||||||
======
|
======
|
||||||
|
|
||||||
.. currentmodule:: cloudservers
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
An "image" is a snapshot from which you can create new server instances.
|
An "image" is a snapshot from which you can create new server instances.
|
||||||
|
|
||||||
|
@ -51,4 +51,4 @@ Classes
|
||||||
.. attribute:: serverId
|
.. attribute:: serverId
|
||||||
|
|
||||||
If this image was created from a :class:`Server` then this attribute
|
If this image was created from a :class:`Server` then this attribute
|
||||||
will be set to the ID of the server whence this image came.
|
will be set to the ID of the server whence this image came.
|
||||||
|
|
|
@ -25,7 +25,7 @@ From the Rackspace API guide:
|
||||||
Classes
|
Classes
|
||||||
-------
|
-------
|
||||||
|
|
||||||
.. currentmodule:: cloudservers
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
.. autoclass:: IPGroupManager
|
.. autoclass:: IPGroupManager
|
||||||
:members: get, list, find, findall, create, delete
|
:members: get, list, find, findall, create, delete
|
||||||
|
@ -43,4 +43,4 @@ Classes
|
||||||
|
|
||||||
.. attribute:: servers
|
.. attribute:: servers
|
||||||
|
|
||||||
A list of server IDs in this group.
|
A list of server IDs in this group.
|
||||||
|
|
|
@ -6,7 +6,7 @@ A virtual machine instance.
|
||||||
Classes
|
Classes
|
||||||
-------
|
-------
|
||||||
|
|
||||||
.. currentmodule:: cloudservers
|
.. currentmodule:: novaclient
|
||||||
|
|
||||||
.. autoclass:: ServerManager
|
.. autoclass:: ServerManager
|
||||||
:members: get, list, find, findall, create, update, delete, share_ip,
|
:members: get, list, find, findall, create, update, delete, share_ip,
|
||||||
|
@ -70,4 +70,4 @@ Constants
|
||||||
Reboot types:
|
Reboot types:
|
||||||
|
|
||||||
.. data:: REBOOT_SOFT
|
.. data:: REBOOT_SOFT
|
||||||
.. data:: REBOOT_HARD
|
.. data:: REBOOT_HARD
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
Release notes
|
Release notes
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
2.3 (March 2, 2011)
|
||||||
|
=================
|
||||||
|
|
||||||
|
* package renamed to python-novaclient. Module to novaclient
|
||||||
|
|
||||||
|
|
||||||
2.2 (March 1, 2011)
|
2.2 (March 1, 2011)
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,15 @@ two environment variables:
|
||||||
|
|
||||||
Your API key.
|
Your API key.
|
||||||
|
|
||||||
|
.. envvar:: NOVA_URL
|
||||||
|
|
||||||
|
The OpenStack API server URL.
|
||||||
|
|
||||||
For example, in Bash you'd use::
|
For example, in Bash you'd use::
|
||||||
|
|
||||||
export NOVA_USERNAME=yourname
|
export NOVA_USERNAME=yourname
|
||||||
export NOVA_API_KEY=yadayadayada
|
export NOVA_API_KEY=yadayadayada
|
||||||
|
export NOVA_URL=http://...
|
||||||
|
|
||||||
From there, all shell commands take the form::
|
From there, all shell commands take the form::
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
novatools module.
|
novaclient module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '2.2'
|
__version__ = '2.3'
|
||||||
|
|
||||||
from novatools.backup_schedules import (
|
from novaclient.backup_schedules import (
|
||||||
BackupSchedule, BackupScheduleManager,
|
BackupSchedule, BackupScheduleManager,
|
||||||
BACKUP_WEEKLY_DISABLED, BACKUP_WEEKLY_SUNDAY, BACKUP_WEEKLY_MONDAY,
|
BACKUP_WEEKLY_DISABLED, BACKUP_WEEKLY_SUNDAY, BACKUP_WEEKLY_MONDAY,
|
||||||
BACKUP_WEEKLY_TUESDAY, BACKUP_WEEKLY_WEDNESDAY,
|
BACKUP_WEEKLY_TUESDAY, BACKUP_WEEKLY_WEDNESDAY,
|
||||||
|
@ -33,15 +33,15 @@ from novatools.backup_schedules import (
|
||||||
BACKUP_DAILY_H_1400_1600, BACKUP_DAILY_H_1600_1800,
|
BACKUP_DAILY_H_1400_1600, BACKUP_DAILY_H_1600_1800,
|
||||||
BACKUP_DAILY_H_1800_2000, BACKUP_DAILY_H_2000_2200,
|
BACKUP_DAILY_H_1800_2000, BACKUP_DAILY_H_2000_2200,
|
||||||
BACKUP_DAILY_H_2200_0000)
|
BACKUP_DAILY_H_2200_0000)
|
||||||
from novatools.client import OpenStackClient
|
from novaclient.client import OpenStackClient
|
||||||
from novatools.exceptions import (OpenStackException, BadRequest,
|
from novaclient.exceptions import (OpenStackException, BadRequest,
|
||||||
Unauthorized, Forbidden, NotFound, OverLimit)
|
Unauthorized, Forbidden, NotFound, OverLimit)
|
||||||
from novatools.flavors import FlavorManager, Flavor
|
from novaclient.flavors import FlavorManager, Flavor
|
||||||
from novatools.images import ImageManager, Image
|
from novaclient.images import ImageManager, Image
|
||||||
from novatools.ipgroups import IPGroupManager, IPGroup
|
from novaclient.ipgroups import IPGroupManager, IPGroup
|
||||||
from novatools.servers import (ServerManager, Server, REBOOT_HARD,
|
from novaclient.servers import (ServerManager, Server, REBOOT_HARD,
|
||||||
REBOOT_SOFT)
|
REBOOT_SOFT)
|
||||||
from novatools.zones import Zone, ZoneManager
|
from novaclient.zones import Zone, ZoneManager
|
||||||
|
|
||||||
|
|
||||||
class OpenStack(object):
|
class OpenStack(object):
|
||||||
|
@ -79,7 +79,7 @@ class OpenStack(object):
|
||||||
Normally this is called automatically when you first access the API,
|
Normally this is called automatically when you first access the API,
|
||||||
but you can call this method to force authentication right now.
|
but you can call this method to force authentication right now.
|
||||||
|
|
||||||
Returns on success; raises :exc:`novatools.Unauthorized` if the
|
Returns on success; raises :exc:`novaclient.Unauthorized` if the
|
||||||
credentials are wrong.
|
credentials are wrong.
|
||||||
"""
|
"""
|
||||||
self.client.authenticate()
|
self.client.authenticate()
|
|
@ -2,7 +2,7 @@
|
||||||
Backup Schedule interface.
|
Backup Schedule interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from novatools import base
|
from novaclient import base
|
||||||
|
|
||||||
BACKUP_WEEKLY_DISABLED = 'DISABLED'
|
BACKUP_WEEKLY_DISABLED = 'DISABLED'
|
||||||
BACKUP_WEEKLY_SUNDAY = 'SUNDAY'
|
BACKUP_WEEKLY_SUNDAY = 'SUNDAY'
|
|
@ -2,7 +2,7 @@
|
||||||
Base utilities to build API operation managers and objects on top of.
|
Base utilities to build API operation managers and objects on top of.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from novatools.exceptions import NotFound
|
from novaclient.exceptions import NotFound
|
||||||
|
|
||||||
# Python 2.4 compat
|
# Python 2.4 compat
|
||||||
try:
|
try:
|
|
@ -16,13 +16,13 @@ if not hasattr(urlparse, 'parse_qsl'):
|
||||||
import cgi
|
import cgi
|
||||||
urlparse.parse_qsl = cgi.parse_qsl
|
urlparse.parse_qsl = cgi.parse_qsl
|
||||||
|
|
||||||
import novatools
|
import novaclient
|
||||||
from novatools import exceptions
|
from novaclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
class OpenStackClient(httplib2.Http):
|
class OpenStackClient(httplib2.Http):
|
||||||
|
|
||||||
USER_AGENT = 'python-novatools/%s' % novatools.__version__
|
USER_AGENT = 'python-novaclient/%s' % novaclient.__version__
|
||||||
|
|
||||||
def __init__(self, user, apikey, auth_url):
|
def __init__(self, user, apikey, auth_url):
|
||||||
super(OpenStackClient, self).__init__()
|
super(OpenStackClient, self).__init__()
|
|
@ -3,7 +3,7 @@ Flavor interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from novatools import base
|
from novaclient import base
|
||||||
|
|
||||||
|
|
||||||
class Flavor(base.Resource):
|
class Flavor(base.Resource):
|
|
@ -2,7 +2,7 @@
|
||||||
Image interface.
|
Image interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from novatools import base
|
from novaclient import base
|
||||||
|
|
||||||
|
|
||||||
class Image(base.Resource):
|
class Image(base.Resource):
|
|
@ -2,7 +2,7 @@
|
||||||
IP Group interface.
|
IP Group interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from novatools import base
|
from novaclient import base
|
||||||
|
|
||||||
|
|
||||||
class IPGroup(base.Resource):
|
class IPGroup(base.Resource):
|
|
@ -19,7 +19,7 @@
|
||||||
Server interface.
|
Server interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from novatools import base
|
from novaclient import base
|
||||||
|
|
||||||
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'
|
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'
|
||||||
|
|
|
@ -20,7 +20,7 @@ Command-line interface to the OpenStack Nova API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import novatools
|
import novaclient
|
||||||
import getpass
|
import getpass
|
||||||
import httplib2
|
import httplib2
|
||||||
import os
|
import os
|
||||||
|
@ -29,11 +29,11 @@ import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
# Choices for flags.
|
# Choices for flags.
|
||||||
DAY_CHOICES = [getattr(novatools, i).lower()
|
DAY_CHOICES = [getattr(novaclient, i).lower()
|
||||||
for i in dir(novatools)
|
for i in dir(novaclient)
|
||||||
if i.startswith('BACKUP_WEEKLY_')]
|
if i.startswith('BACKUP_WEEKLY_')]
|
||||||
HOUR_CHOICES = [getattr(novatools, i).lower()
|
HOUR_CHOICES = [getattr(novaclient, i).lower()
|
||||||
for i in dir(novatools)
|
for i in dir(novaclient)
|
||||||
if i.startswith('BACKUP_DAILY_')]
|
if i.startswith('BACKUP_DAILY_')]
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ def env(e):
|
||||||
class OpenStackShell(object):
|
class OpenStackShell(object):
|
||||||
|
|
||||||
# Hook for the test suite to inject a fake server.
|
# Hook for the test suite to inject a fake server.
|
||||||
_api_class = novatools.OpenStack
|
_api_class = novaclient.OpenStack
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.parser = argparse.ArgumentParser(
|
self.parser = argparse.ArgumentParser(
|
||||||
|
@ -155,7 +155,7 @@ class OpenStackShell(object):
|
||||||
self.cs = self._api_class(user, apikey, url)
|
self.cs = self._api_class(user, apikey, url)
|
||||||
try:
|
try:
|
||||||
self.cs.authenticate()
|
self.cs.authenticate()
|
||||||
except novatools.Unauthorized:
|
except novaclient.Unauthorized:
|
||||||
raise CommandError("Invalid OpenStack Nova credentials.")
|
raise CommandError("Invalid OpenStack Nova credentials.")
|
||||||
|
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
@ -198,10 +198,10 @@ class OpenStackShell(object):
|
||||||
# If we have some flags, update the backup
|
# If we have some flags, update the backup
|
||||||
backup = {}
|
backup = {}
|
||||||
if args.daily:
|
if args.daily:
|
||||||
backup['daily'] = getattr(novatools, 'BACKUP_DAILY_%s' %
|
backup['daily'] = getattr(novaclient, 'BACKUP_DAILY_%s' %
|
||||||
args.daily.upper())
|
args.daily.upper())
|
||||||
if args.weekly:
|
if args.weekly:
|
||||||
backup['weekly'] = getattr(novatools, 'BACKUP_WEEKLY_%s' %
|
backup['weekly'] = getattr(novaclient, 'BACKUP_WEEKLY_%s' %
|
||||||
args.weekly.upper())
|
args.weekly.upper())
|
||||||
if args.enabled is not None:
|
if args.enabled is not None:
|
||||||
backup['enabled'] = args.enabled
|
backup['enabled'] = args.enabled
|
||||||
|
@ -221,17 +221,17 @@ class OpenStackShell(object):
|
||||||
@arg('--flavor',
|
@arg('--flavor',
|
||||||
default=None,
|
default=None,
|
||||||
metavar='<flavor>',
|
metavar='<flavor>',
|
||||||
help="Flavor ID (see 'novatools flavors'). "\
|
help="Flavor ID (see 'novaclient flavors'). "\
|
||||||
"Defaults to 256MB RAM instance.")
|
"Defaults to 256MB RAM instance.")
|
||||||
@arg('--image',
|
@arg('--image',
|
||||||
default=None,
|
default=None,
|
||||||
metavar='<image>',
|
metavar='<image>',
|
||||||
help="Image ID (see 'novatools images'). "\
|
help="Image ID (see 'novaclient images'). "\
|
||||||
"Defaults to Ubuntu 10.04 LTS.")
|
"Defaults to Ubuntu 10.04 LTS.")
|
||||||
@arg('--ipgroup',
|
@arg('--ipgroup',
|
||||||
default=None,
|
default=None,
|
||||||
metavar='<group>',
|
metavar='<group>',
|
||||||
help="IP group name or ID (see 'novatools ipgroup-list').")
|
help="IP group name or ID (see 'novaclient ipgroup-list').")
|
||||||
@arg('--meta',
|
@arg('--meta',
|
||||||
metavar="<key=value>",
|
metavar="<key=value>",
|
||||||
action='append',
|
action='append',
|
||||||
|
@ -394,8 +394,8 @@ class OpenStackShell(object):
|
||||||
@arg('--hard',
|
@arg('--hard',
|
||||||
dest='reboot_type',
|
dest='reboot_type',
|
||||||
action='store_const',
|
action='store_const',
|
||||||
const=novatools.REBOOT_HARD,
|
const=novaclient.REBOOT_HARD,
|
||||||
default=novatools.REBOOT_SOFT,
|
default=novaclient.REBOOT_SOFT,
|
||||||
help='Perform a hard reboot (instead of a soft one).')
|
help='Perform a hard reboot (instead of a soft one).')
|
||||||
@arg('server', metavar='<server>', help='Name or ID of server.')
|
@arg('server', metavar='<server>', help='Name or ID of server.')
|
||||||
def do_reboot(self, args):
|
def do_reboot(self, args):
|
||||||
|
@ -572,7 +572,7 @@ class OpenStackShell(object):
|
||||||
"""Get a flavor by name, ID, or RAM size."""
|
"""Get a flavor by name, ID, or RAM size."""
|
||||||
try:
|
try:
|
||||||
return self._find_resource(self.cs.flavors, flavor)
|
return self._find_resource(self.cs.flavors, flavor)
|
||||||
except novatools.NotFound:
|
except novaclient.NotFound:
|
||||||
return self.cs.flavors.find(ram=flavor)
|
return self.cs.flavors.find(ram=flavor)
|
||||||
|
|
||||||
def _find_resource(self, manager, name_or_id):
|
def _find_resource(self, manager, name_or_id):
|
||||||
|
@ -582,7 +582,7 @@ class OpenStackShell(object):
|
||||||
return manager.get(int(name_or_id))
|
return manager.get(int(name_or_id))
|
||||||
else:
|
else:
|
||||||
return manager.find(name=name_or_id)
|
return manager.find(name=name_or_id)
|
||||||
except novatools.NotFound:
|
except novaclient.NotFound:
|
||||||
raise CommandError("No %s with a name or ID of '%s' exists." %
|
raise CommandError("No %s with a name or ID of '%s' exists." %
|
||||||
(manager.resource_class.__name__.lower(), name_or_id))
|
(manager.resource_class.__name__.lower(), name_or_id))
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
Zone interface.
|
Zone interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from novatools import base
|
from novaclient import base
|
||||||
|
|
||||||
|
|
||||||
class Zone(base.Resource):
|
class Zone(base.Resource):
|
|
@ -1,6 +1,6 @@
|
||||||
[nosetests]
|
[nosetests]
|
||||||
with-coverage = true
|
with-coverage = true
|
||||||
cover-package = novatools
|
cover-package = novaclient
|
||||||
cover-html = true
|
cover-html = true
|
||||||
cover-erase = true
|
cover-erase = true
|
||||||
cover-inclusive = true
|
cover-inclusive = true
|
||||||
|
|
8
setup.py
8
setup.py
|
@ -10,11 +10,11 @@ if sys.version_info < (2,6):
|
||||||
requirements.append('simplejson')
|
requirements.append('simplejson')
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = "python-novatools",
|
name = "python-novaclient",
|
||||||
version = "2.2",
|
version = "2.3",
|
||||||
description = "Client library for OpenStack Nova API",
|
description = "Client library for OpenStack Nova API",
|
||||||
long_description = read('README.rst'),
|
long_description = read('README.rst'),
|
||||||
url = 'https://github.com/rackspace/python-novatools',
|
url = 'https://github.com/rackspace/python-novaclient',
|
||||||
license = 'Apache',
|
license = 'Apache',
|
||||||
author = 'Rackspace, based on work by Jacob Kaplan-Moss',
|
author = 'Rackspace, based on work by Jacob Kaplan-Moss',
|
||||||
author_email = 'github@racklabs.com',
|
author_email = 'github@racklabs.com',
|
||||||
|
@ -34,6 +34,6 @@ setup(
|
||||||
test_suite = "nose.collector",
|
test_suite = "nose.collector",
|
||||||
|
|
||||||
entry_points = {
|
entry_points = {
|
||||||
'console_scripts': ['nova = novatools.shell:main']
|
'console_scripts': ['nova = novaclient.shell:main']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,8 +10,8 @@ import httplib2
|
||||||
import urlparse
|
import urlparse
|
||||||
import urllib
|
import urllib
|
||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
from novatools import OpenStack
|
from novaclient import OpenStack
|
||||||
from novatools.client import OpenStackClient
|
from novaclient.client import OpenStackClient
|
||||||
from utils import fail, assert_in, assert_not_in, assert_has_keys
|
from utils import fail, assert_in, assert_not_in, assert_has_keys
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +38,29 @@ class FakeServer(OpenStack):
|
||||||
|
|
||||||
self.client.callstack = []
|
self.client.callstack = []
|
||||||
|
|
||||||
|
def assert_called_anytime(self, method, url, body=None):
|
||||||
|
"""
|
||||||
|
Assert than an API method was called anytime in the test.
|
||||||
|
"""
|
||||||
|
expected = (method, url)
|
||||||
|
|
||||||
|
assert self.client.callstack, \
|
||||||
|
"Expected %s %s but no calls were made." % expected
|
||||||
|
|
||||||
|
found = False
|
||||||
|
for entry in self.client.callstack:
|
||||||
|
called = entry[0:2]
|
||||||
|
if expected == entry[0:2]:
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
assert found, 'Expected %s %s; got %s' % \
|
||||||
|
(expected, self.client.callstack)
|
||||||
|
if body is not None:
|
||||||
|
assert_equal(entry[2], body)
|
||||||
|
|
||||||
|
self.client.callstack = []
|
||||||
|
|
||||||
def authenticate(self):
|
def authenticate(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import mock
|
import mock
|
||||||
import novatools
|
import novaclient
|
||||||
import httplib2
|
import httplib2
|
||||||
from nose.tools import assert_raises, assert_equal
|
from nose.tools import assert_raises, assert_equal
|
||||||
|
|
||||||
|
|
||||||
def test_authenticate_success():
|
def test_authenticate_success():
|
||||||
cs = novatools.OpenStack("username", "apikey")
|
cs = novaclient.OpenStack("username", "apikey")
|
||||||
auth_response = httplib2.Response({
|
auth_response = httplib2.Response({
|
||||||
'status': 204,
|
'status': 204,
|
||||||
'x-server-management-url':
|
'x-server-management-url':
|
||||||
|
@ -31,19 +31,19 @@ def test_authenticate_success():
|
||||||
|
|
||||||
|
|
||||||
def test_authenticate_failure():
|
def test_authenticate_failure():
|
||||||
cs = novatools.OpenStack("username", "apikey")
|
cs = novaclient.OpenStack("username", "apikey")
|
||||||
auth_response = httplib2.Response({'status': 401})
|
auth_response = httplib2.Response({'status': 401})
|
||||||
mock_request = mock.Mock(return_value=(auth_response, None))
|
mock_request = mock.Mock(return_value=(auth_response, None))
|
||||||
|
|
||||||
@mock.patch.object(httplib2.Http, "request", mock_request)
|
@mock.patch.object(httplib2.Http, "request", mock_request)
|
||||||
def test_auth_call():
|
def test_auth_call():
|
||||||
assert_raises(novatools.Unauthorized, cs.client.authenticate)
|
assert_raises(novaclient.Unauthorized, cs.client.authenticate)
|
||||||
|
|
||||||
test_auth_call()
|
test_auth_call()
|
||||||
|
|
||||||
|
|
||||||
def test_auth_automatic():
|
def test_auth_automatic():
|
||||||
client = novatools.OpenStack("username", "apikey").client
|
client = novaclient.OpenStack("username", "apikey").client
|
||||||
client.management_url = ''
|
client.management_url = ''
|
||||||
mock_request = mock.Mock(return_value=(None, None))
|
mock_request = mock.Mock(return_value=(None, None))
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ def test_auth_automatic():
|
||||||
|
|
||||||
|
|
||||||
def test_auth_manual():
|
def test_auth_manual():
|
||||||
cs = novatools.OpenStack("username", "apikey")
|
cs = novaclient.OpenStack("username", "apikey")
|
||||||
|
|
||||||
@mock.patch.object(cs.client, 'authenticate')
|
@mock.patch.object(cs.client, 'authenticate')
|
||||||
def test_auth_call(m):
|
def test_auth_call(m):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
from novatools.backup_schedules import *
|
from novaclient.backup_schedules import *
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_isinstance
|
from utils import assert_isinstance
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import novatools.base
|
import novaclient.base
|
||||||
from novatools import Flavor
|
from novaclient import Flavor
|
||||||
from novatools.exceptions import NotFound
|
from novaclient.exceptions import NotFound
|
||||||
from novatools.base import Resource
|
from novaclient.base import Resource
|
||||||
from nose.tools import assert_equal, assert_not_equal, assert_raises
|
from nose.tools import assert_equal, assert_not_equal, assert_raises
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@ def test_resource_repr():
|
||||||
|
|
||||||
|
|
||||||
def test_getid():
|
def test_getid():
|
||||||
assert_equal(novatools.base.getid(4), 4)
|
assert_equal(novaclient.base.getid(4), 4)
|
||||||
|
|
||||||
class O(object):
|
class O(object):
|
||||||
id = 4
|
id = 4
|
||||||
assert_equal(novatools.base.getid(O), 4)
|
assert_equal(novaclient.base.getid(O), 4)
|
||||||
|
|
||||||
|
|
||||||
def test_resource_lazy_getattr():
|
def test_resource_lazy_getattr():
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import mock
|
import mock
|
||||||
import httplib2
|
import httplib2
|
||||||
from novatools.client import OpenStackClient
|
from novaclient.client import OpenStackClient
|
||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
|
|
||||||
fake_response = httplib2.Response({"status": 200})
|
fake_response = httplib2.Response({"status": 200})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from novatools import Flavor, NotFound
|
from novaclient import Flavor, NotFound
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_isinstance
|
from utils import assert_isinstance
|
||||||
from nose.tools import assert_raises, assert_equal
|
from nose.tools import assert_raises, assert_equal
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from novatools import Image
|
from novaclient import Image
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_isinstance
|
from utils import assert_isinstance
|
||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from novatools import IPGroup
|
from novaclient import IPGroup
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_isinstance
|
from utils import assert_isinstance
|
||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
|
|
|
@ -2,7 +2,7 @@ import StringIO
|
||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_isinstance
|
from utils import assert_isinstance
|
||||||
from novatools import Server
|
from novaclient import Server
|
||||||
|
|
||||||
cs = FakeServer()
|
cs = FakeServer()
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import mock
|
import mock
|
||||||
import httplib2
|
import httplib2
|
||||||
from nose.tools import assert_raises, assert_equal
|
from nose.tools import assert_raises, assert_equal
|
||||||
from novatools.shell import OpenStackShell, CommandError
|
from novaclient.shell import OpenStackShell, CommandError
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_in
|
from utils import assert_in
|
||||||
|
|
||||||
|
@ -18,10 +18,12 @@ def setup():
|
||||||
|
|
||||||
# Make a fake shell object, a helping wrapper to call it, and a quick way
|
# Make a fake shell object, a helping wrapper to call it, and a quick way
|
||||||
# of asserting that certain API calls were made.
|
# of asserting that certain API calls were made.
|
||||||
global shell, _shell, assert_called
|
global shell, _shell, assert_called, assert_called_anytime
|
||||||
_shell = OpenStackShell()
|
_shell = OpenStackShell()
|
||||||
_shell._api_class = FakeServer
|
_shell._api_class = FakeServer
|
||||||
assert_called = lambda m, u, b=None: _shell.cs.assert_called(m, u, b)
|
assert_called = lambda m, u, b=None: _shell.cs.assert_called(m, u, b)
|
||||||
|
assert_called_anytime = lambda m, u, b=None: \
|
||||||
|
_shell.cs.assert_called_anytime(m, u, b)
|
||||||
shell = lambda cmd: _shell.main(cmd.split())
|
shell = lambda cmd: _shell.main(cmd.split())
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +177,7 @@ def test_boot_ipgroup_name():
|
||||||
|
|
||||||
def test_flavor_list():
|
def test_flavor_list():
|
||||||
shell('flavor-list')
|
shell('flavor-list')
|
||||||
assert_called('GET', '/flavors/detail')
|
assert_called_anytime('GET', '/flavors/detail')
|
||||||
|
|
||||||
|
|
||||||
def test_image_list():
|
def test_image_list():
|
||||||
|
|
|
@ -2,7 +2,7 @@ import StringIO
|
||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
from fakeserver import FakeServer
|
from fakeserver import FakeServer
|
||||||
from utils import assert_isinstance
|
from utils import assert_isinstance
|
||||||
from novatools import Zone
|
from novaclient import Zone
|
||||||
|
|
||||||
os = FakeServer()
|
os = FakeServer()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue