Rename from reddwarf to trove.

Implements Blueprint reddwarf-trove-rename

Change-Id: Ib2d694c7466887ca297bea4250eca17cdc06b7bf
This commit is contained in:
Michael Basnight 2013-06-17 23:34:27 -07:00
parent bc90b3e088
commit 9916c8f273
44 changed files with 193 additions and 195 deletions

View File

@ -2,7 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} -m subunit.run discover . $LISTOPT $IDOPTION ${PYTHON:-python} -m subunit.run discover -t ./ ./troveclient/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE test_id_option=--load-list $IDFILE
test_list_option=--list test_list_option=--list

View File

@ -1,9 +1,9 @@
Python bindings to the Reddwarf API Python bindings to the Trove API
================================================== ==================================================
This is a client for the Reddwarf API. There's a Python API (the This is a client for the Trove API. There's a Python API (the
``reddwarfclient`` module), and a command-line script (``reddwarf``). Each ``troveclient`` module), and a command-line script (``trove``). Each
implements 100% (or less ;) ) of the Reddwarf API. implements 100% (or less ;) ) of the Trove API.
Command-line API Command-line API
---------------- ----------------
@ -13,7 +13,7 @@ tenant, and appropriate auth url.
.. code-block:: bash .. code-block:: bash
$ reddwarf-cli --username=jsmith --apikey=abcdefg --tenant=12345 --auth_url=http://reddwarf_auth:35357/v2.0/tokens auth login $ trove-cli --username=jsmith --apikey=abcdefg --tenant=12345 --auth_url=http://trove_auth:35357/v2.0/tokens auth login
At this point you will be authenticated and given a token, which is stored At this point you will be authenticated and given a token, which is stored
at ~/.apitoken. From there you can make other calls to the CLI. at ~/.apitoken. From there you can make other calls to the CLI.

View File

@ -1,31 +0,0 @@
# Copyright (c) 2011 OpenStack, LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from reddwarfclient.accounts import Accounts
from reddwarfclient.databases import Databases
from reddwarfclient.flavors import Flavors
from reddwarfclient.instances import Instances
from reddwarfclient.hosts import Hosts
from reddwarfclient.management import Management
from reddwarfclient.management import RootHistory
from reddwarfclient.root import Root
from reddwarfclient.storage import StorageInfo
from reddwarfclient.users import Users
from reddwarfclient.versions import Versions
from reddwarfclient.diagnostics import DiagnosticsInterrogator
from reddwarfclient.diagnostics import HwInfoInterrogator
from reddwarfclient.client import Dbaas
from reddwarfclient.client import ReddwarfHTTPClient

View File

@ -9,9 +9,9 @@ me=${0##*/}
function print_usage() { function print_usage() {
cat >&2 <<EOS cat >&2 <<EOS
Run tests against a local instance of reddwarf Run tests against a local instance of trove
Usage: $me reddwarf_path [logfile] Usage: $me trove_path [logfile]
EOS EOS
} }
@ -28,25 +28,25 @@ if [ $# -lt 1 ]; then
exit 5 exit 5
fi fi
reddwarf_path=$1 trove_path=$1
reddwarf_pid_file="`pwd`.pid" trove_pid_file="`pwd`.pid"
function start_server() { function start_server() {
server_log=`pwd`/rdserver.txt server_log=`pwd`/rdserver.txt
set +e set +e
rm $server_log rm $server_log
set -e set -e
pushd $reddwarf_path pushd $trove_path
bin/start_server.sh --pid-file=$reddwarf_pid_file \ bin/start_server.sh --pid-file=$trove_pid_file \
--override-logfile=$server_log --override-logfile=$server_log
popd popd
} }
function stop_server() { function stop_server() {
if [ -f $reddwarf_pid_file ]; if [ -f $trove_pid_file ];
then then
pushd $reddwarf_path pushd $trove_path
bin/stop_server.sh $reddwarf_pid_file bin/stop_server.sh $trove_pid_file
popd popd
else else
echo "The pid file did not exist, so not stopping server." echo "The pid file did not exist, so not stopping server."

View File

@ -19,12 +19,12 @@ classifier =
[entry_points] [entry_points]
console_scripts = console_scripts =
reddwarf-cli = reddwarfclient.cli:main trove-cli = troveclient.cli:main
reddwarf-mgmt-cli = reddwarfclient.mcli:main trove-mgmt-cli = troveclient.mcli:main
[files] [files]
packages = packages =
reddwarfclient troveclient
[global] [global]
setup-hooks = setup-hooks =

View File

@ -8,7 +8,5 @@ discover
sphinx>=1.1.2 sphinx>=1.1.2
testrepository>=0.0.13 testrepository>=0.0.13
testtools>=0.9.29 testtools>=0.9.29
# This used to be but openstack/requirements is set to [below].
# If this breaks we 1) fix tests to use [below] or
# 2) petition to use mock>=1.0.1
mock>=0.8.0 mock>=0.8.0

31
troveclient/__init__.py Normal file
View File

@ -0,0 +1,31 @@
# Copyright (c) 2011 OpenStack, LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from troveclient.accounts import Accounts
from troveclient.databases import Databases
from troveclient.flavors import Flavors
from troveclient.instances import Instances
from troveclient.hosts import Hosts
from troveclient.management import Management
from troveclient.management import RootHistory
from troveclient.root import Root
from troveclient.storage import StorageInfo
from troveclient.users import Users
from troveclient.versions import Versions
from troveclient.diagnostics import DiagnosticsInterrogator
from troveclient.diagnostics import HwInfoInterrogator
from troveclient.client import Dbaas
from troveclient.client import TroveHTTPClient

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
class Account(base.Resource): class Account(base.Resource):

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import exceptions from troveclient import exceptions
def get_authenticator_cls(cls_or_name): def get_authenticator_cls(cls_or_name):
@ -228,7 +228,7 @@ class ServiceCatalog(object):
def _url_for(self, attr=None, filter_value=None, def _url_for(self, attr=None, filter_value=None,
endpoint_type='publicURL'): endpoint_type='publicURL'):
""" """
Fetch the public URL from the Reddwarf service for a particular Fetch the public URL from the Trove service for a particular
endpoint attribute. If none given, return the first. endpoint attribute. If none given, return the first.
""" """
matching_endpoints = [] matching_endpoints = []

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
import exceptions import exceptions

View File

@ -22,8 +22,8 @@ Base utilities to build API operation managers and objects on top of.
import contextlib import contextlib
import hashlib import hashlib
import os import os
from reddwarfclient import exceptions from troveclient import exceptions
from reddwarfclient import utils from troveclient import utils
# Python 2.4 compat # Python 2.4 compat
@ -93,7 +93,7 @@ class Manager(utils.HookableMixin):
often enough to keep the cache reasonably up-to-date. often enough to keep the cache reasonably up-to-date.
""" """
base_dir = utils.env('REDDWARFCLIENT_ID_CACHE_DIR', base_dir = utils.env('REDDWARFCLIENT_ID_CACHE_DIR',
default="~/.reddwarfclient") default="~/.troveclient")
# NOTE(sirp): Keep separate UUID caches for each username + endpoint # NOTE(sirp): Keep separate UUID caches for each username + endpoint
# pair # pair

View File

@ -15,7 +15,7 @@
# under the License. # under the License.
""" """
Reddwarf Command line tool Trove Command line tool
""" """
#TODO(tim.simpson): optparse is deprecated. Replace with argparse. #TODO(tim.simpson): optparse is deprecated. Replace with argparse.
@ -24,17 +24,17 @@ import os
import sys import sys
# If ../reddwarf/__init__.py exists, add ../ to Python search path, so that # If ../trove/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python... # it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir, os.pardir,
os.pardir)) os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'reddwarfclient', if os.path.exists(os.path.join(possible_topdir, 'troveclient',
'__init__.py')): '__init__.py')):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
from reddwarfclient import common from troveclient import common
class InstanceCommands(common.AuthedCommandsBase): class InstanceCommands(common.AuthedCommandsBase):

View File

@ -30,8 +30,8 @@ if not hasattr(urlparse, 'parse_qsl'):
import cgi import cgi
urlparse.parse_qsl = cgi.parse_qsl urlparse.parse_qsl = cgi.parse_qsl
from reddwarfclient import auth from troveclient import auth
from reddwarfclient import exceptions from troveclient import exceptions
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -52,9 +52,9 @@ if 'REDDWARFCLIENT_DEBUG' in os.environ and os.environ['REDDWARFCLIENT_DEBUG']:
log_to_streamhandler() log_to_streamhandler()
class ReddwarfHTTPClient(httplib2.Http): class TroveHTTPClient(httplib2.Http):
USER_AGENT = 'python-reddwarfclient' USER_AGENT = 'python-troveclient'
def __init__(self, user, password, tenant, auth_url, service_name, def __init__(self, user, password, tenant, auth_url, service_name,
service_url=None, service_url=None,
@ -64,7 +64,7 @@ class ReddwarfHTTPClient(httplib2.Http):
endpoint_type='publicURL', service_type=None, endpoint_type='publicURL', service_type=None,
timings=False): timings=False):
super(ReddwarfHTTPClient, self).__init__(timeout=timeout) super(TroveHTTPClient, self).__init__(timeout=timeout)
self.username = user self.username = user
self.password = password self.password = password
@ -130,7 +130,7 @@ class ReddwarfHTTPClient(httplib2.Http):
_logger.debug("RESP:%s %s\n", resp, body) _logger.debug("RESP:%s %s\n", resp, body)
def pretty_log(self, args, kwargs, resp, body): def pretty_log(self, args, kwargs, resp, body):
from reddwarfclient import common from troveclient import common
if not _logger.isEnabledFor(logging.DEBUG): if not _logger.isEnabledFor(logging.DEBUG):
return return
@ -170,7 +170,7 @@ class ReddwarfHTTPClient(httplib2.Http):
kwargs['headers']['User-Agent'] = self.USER_AGENT kwargs['headers']['User-Agent'] = self.USER_AGENT
self.morph_request(kwargs) self.morph_request(kwargs)
resp, body = super(ReddwarfHTTPClient, self).request(*args, **kwargs) resp, body = super(TroveHTTPClient, self).request(*args, **kwargs)
# Save this in case anyone wants it. # Save this in case anyone wants it.
self.last_response = (resp, body) self.last_response = (resp, body)
@ -297,26 +297,26 @@ class Dbaas(object):
""" """
def __init__(self, username, api_key, tenant=None, auth_url=None, def __init__(self, username, api_key, tenant=None, auth_url=None,
service_type='database', service_name='reddwarf', service_type='database', service_name='trove',
service_url=None, insecure=False, auth_strategy='keystone', service_url=None, insecure=False, auth_strategy='keystone',
region_name=None, client_cls=ReddwarfHTTPClient): region_name=None, client_cls=TroveHTTPClient):
from reddwarfclient.versions import Versions from troveclient.versions import Versions
from reddwarfclient.databases import Databases from troveclient.databases import Databases
from reddwarfclient.flavors import Flavors from troveclient.flavors import Flavors
from reddwarfclient.instances import Instances from troveclient.instances import Instances
from reddwarfclient.limits import Limits from troveclient.limits import Limits
from reddwarfclient.users import Users from troveclient.users import Users
from reddwarfclient.root import Root from troveclient.root import Root
from reddwarfclient.hosts import Hosts from troveclient.hosts import Hosts
from reddwarfclient.quota import Quotas from troveclient.quota import Quotas
from reddwarfclient.backups import Backups from troveclient.backups import Backups
from reddwarfclient.security_groups import SecurityGroups from troveclient.security_groups import SecurityGroups
from reddwarfclient.security_groups import SecurityGroupRules from troveclient.security_groups import SecurityGroupRules
from reddwarfclient.storage import StorageInfo from troveclient.storage import StorageInfo
from reddwarfclient.management import Management from troveclient.management import Management
from reddwarfclient.accounts import Accounts from troveclient.accounts import Accounts
from reddwarfclient.diagnostics import DiagnosticsInterrogator from troveclient.diagnostics import DiagnosticsInterrogator
from reddwarfclient.diagnostics import HwInfoInterrogator from troveclient.diagnostics import HwInfoInterrogator
self.client = client_cls(username, api_key, tenant, auth_url, self.client = client_cls(username, api_key, tenant, auth_url,
service_type=service_type, service_type=service_type,

View File

@ -19,9 +19,9 @@ import os
import pickle import pickle
import sys import sys
from reddwarfclient import client from troveclient import client
from reddwarfclient.xml import ReddwarfXmlClient from troveclient.xml import TroveXmlClient
from reddwarfclient import exceptions from troveclient import exceptions
from urllib import quote from urllib import quote
@ -92,7 +92,7 @@ class CliOptions(object):
'auth_url': None, 'auth_url': None,
'auth_type': 'keystone', 'auth_type': 'keystone',
'service_type': 'database', 'service_type': 'database',
'service_name': 'reddwarf', 'service_name': 'trove',
'region': 'RegionOne', 'region': 'RegionOne',
'service_url': None, 'service_url': None,
'insecure': False, 'insecure': False,
@ -204,9 +204,9 @@ class CommandsBase(object):
"""Creates the all important client object.""" """Creates the all important client object."""
try: try:
if self.xml: if self.xml:
client_cls = ReddwarfXmlClient client_cls = TroveXmlClient
else: else:
client_cls = client.ReddwarfHTTPClient client_cls = client.TroveHTTPClient
if self.verbose: if self.verbose:
client.log_to_streamhandler(sys.stdout) client.log_to_streamhandler(sys.stdout)
client.RDC_PP = True client.RDC_PP = True

View File

@ -1,7 +1,7 @@
from reddwarfclient import base from troveclient import base
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
from reddwarfclient.common import limit_url from troveclient.common import limit_url
from reddwarfclient.common import Paginated from troveclient.common import Paginated
import exceptions import exceptions
import urlparse import urlparse

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
import exceptions import exceptions

View File

@ -14,11 +14,11 @@
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
import exceptions import exceptions
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
class Flavor(base.Resource): class Flavor(base.Resource):

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
class Host(base.Resource): class Host(base.Resource):

View File

@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
import exceptions import exceptions
import urlparse import urlparse
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
from reddwarfclient.common import limit_url from troveclient.common import limit_url
from reddwarfclient.common import Paginated from troveclient.common import Paginated
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD' REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
import exceptions import exceptions

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
import urlparse import urlparse
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
from reddwarfclient.common import limit_url from troveclient.common import limit_url
from reddwarfclient.common import Paginated from troveclient.common import Paginated
from reddwarfclient.instances import Instance from troveclient.instances import Instance
class RootHistory(base.Resource): class RootHistory(base.Resource):

View File

@ -15,7 +15,7 @@
# under the License. # under the License.
""" """
Reddwarf Management Command line tool Trove Management Command line tool
""" """
import json import json
@ -24,17 +24,17 @@ import os
import sys import sys
# If ../reddwarf/__init__.py exists, add ../ to Python search path, so that # If ../trove/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python... # it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir, os.pardir,
os.pardir)) os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'reddwarfclient', if os.path.exists(os.path.join(possible_topdir, 'troveclient',
'__init__.py')): '__init__.py')):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
from reddwarfclient import common from troveclient import common
oparser = None oparser = None

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
class Quotas(base.ManagerWithFind): class Quotas(base.ManagerWithFind):

View File

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
from reddwarfclient import users from troveclient import users
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
import exceptions import exceptions

View File

@ -14,13 +14,13 @@
# under the License. # under the License.
# #
from reddwarfclient import base from troveclient import base
import exceptions import exceptions
import urlparse import urlparse
from reddwarfclient.common import limit_url from troveclient.common import limit_url
from reddwarfclient.common import Paginated from troveclient.common import Paginated
class SecurityGroup(base.Resource): class SecurityGroup(base.Resource):

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
class Device(base.Resource): class Device(base.Resource):

View File

View File

@ -1,8 +1,8 @@
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import accounts from troveclient import accounts
from reddwarfclient import base from troveclient import base
""" """
Unit tests for accounts.py Unit tests for accounts.py

View File

@ -1,10 +1,10 @@
import contextlib import contextlib
from testtools import TestCase from testtools import TestCase
from reddwarfclient import auth from troveclient import auth
from mock import Mock from mock import Mock
from reddwarfclient import exceptions from troveclient import exceptions
""" """
Unit tests for the classes and functions in auth.py. Unit tests for the classes and functions in auth.py.
@ -129,8 +129,8 @@ class KeyStoneV2AuthenticatorTest(TestCase):
self.assertEqual(url, r) self.assertEqual(url, r)
def test__v2_auth(self): def test__v2_auth(self):
username = "reddwarf_user" username = "trove_user"
password = "reddwarf_password" password = "trove_password"
tenant = "tenant" tenant = "tenant"
cls_type = auth.KeyStoneV2Authenticator cls_type = auth.KeyStoneV2Authenticator
authObj = auth.KeyStoneV2Authenticator(url=None, type=cls_type, authObj = auth.KeyStoneV2Authenticator(url=None, type=cls_type,
@ -159,8 +159,8 @@ class Auth1_1Test(TestCase):
check_url_none(self, auth.Auth1_1) check_url_none(self, auth.Auth1_1)
# url is not none # url is not none
username = "reddwarf_user" username = "trove_user"
password = "reddwarf_password" password = "trove_password"
url = "test_url" url = "test_url"
authObj = auth.Auth1_1(url=url, authObj = auth.Auth1_1(url=url,
type=auth.Auth1_1, type=auth.Auth1_1,
@ -204,8 +204,8 @@ class RaxAuthenticatorTest(TestCase):
self.assertEqual(url, r) self.assertEqual(url, r)
def test__rax_auth(self): def test__rax_auth(self):
username = "reddwarf_user" username = "trove_user"
password = "reddwarf_password" password = "trove_password"
tenant = "tenant" tenant = "tenant"
authObj = auth.RaxAuthenticator(url=None, authObj = auth.RaxAuthenticator(url=None,
type=auth.RaxAuthenticator, type=auth.RaxAuthenticator,
@ -359,12 +359,12 @@ class ServiceCatalogTest(TestCase):
self.assertEqual(self.test_url, r_url) self.assertEqual(self.test_url, r_url)
def case_ambiguous_endpoint(self, scObj): def case_ambiguous_endpoint(self, scObj):
scObj.service_type = "reddwarf" scObj.service_type = "trove"
scObj.service_name = "test_service_name" scObj.service_name = "test_service_name"
def side_effect_func_service(key): def side_effect_func_service(key):
if key == "type": if key == "type":
return "reddwarf" return "trove"
elif key == "name": elif key == "name":
return "test_service_name" return "test_service_name"
return None return None

View File

@ -4,9 +4,9 @@ import os
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import base from troveclient import base
from reddwarfclient import exceptions from troveclient import exceptions
from reddwarfclient import utils from troveclient import utils
""" """
Unit tests for base.py Unit tests for base.py

View File

@ -7,9 +7,9 @@ import time
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import client from troveclient import client
from reddwarfclient import exceptions from troveclient import exceptions
from reddwarfclient import utils from troveclient import utils
""" """
Unit tests for client.py Unit tests for client.py
@ -23,13 +23,13 @@ class ClientTest(TestCase):
self.assertTrue(client._logger.level == logging.DEBUG) self.assertTrue(client._logger.level == logging.DEBUG)
class ReddwarfHTTPClientTest(TestCase): class TroveHTTPClientTest(TestCase):
def setUp(self): def setUp(self):
super(ReddwarfHTTPClientTest, self).setUp() super(TroveHTTPClientTest, self).setUp()
self.orig__init = client.ReddwarfHTTPClient.__init__ self.orig__init = client.TroveHTTPClient.__init__
client.ReddwarfHTTPClient.__init__ = Mock(return_value=None) client.TroveHTTPClient.__init__ = Mock(return_value=None)
self.hc = client.ReddwarfHTTPClient() self.hc = client.TroveHTTPClient()
self.hc.auth_token = "test-auth-token" self.hc.auth_token = "test-auth-token"
self.hc.service_url = "test-service-url/" self.hc.service_url = "test-service-url/"
self.hc.tenant = "test-tenant" self.hc.tenant = "test-tenant"
@ -43,8 +43,8 @@ class ReddwarfHTTPClientTest(TestCase):
self.orig_htttp_request = httplib2.Http.request self.orig_htttp_request = httplib2.Http.request
def tearDown(self): def tearDown(self):
super(ReddwarfHTTPClientTest, self).tearDown() super(TroveHTTPClientTest, self).tearDown()
client.ReddwarfHTTPClient.__init__ = self.orig__init client.TroveHTTPClient.__init__ = self.orig__init
client._logger = self.orig_client__logger client._logger = self.orig_client__logger
time.time = self.orig_time time.time = self.orig_time
httplib2.Http.request = self.orig_htttp_request httplib2.Http.request = self.orig_htttp_request
@ -53,7 +53,7 @@ class ReddwarfHTTPClientTest(TestCase):
self.__debug_lines.append(s) self.__debug_lines.append(s)
def test___init__(self): def test___init__(self):
client.ReddwarfHTTPClient.__init__ = self.orig__init client.TroveHTTPClient.__init__ = self.orig__init
user = "test-user" user = "test-user"
password = "test-password" password = "test-password"
@ -62,15 +62,15 @@ class ReddwarfHTTPClientTest(TestCase):
service_name = None service_name = None
# when there is no auth_strategy provided # when there is no auth_strategy provided
self.assertRaises(ValueError, client.ReddwarfHTTPClient, user, self.assertRaises(ValueError, client.TroveHTTPClient, user,
password, tenant, auth_url, service_name) password, tenant, auth_url, service_name)
hc = client.ReddwarfHTTPClient(user, password, tenant, auth_url, hc = client.TroveHTTPClient(user, password, tenant, auth_url,
service_name, auth_strategy="fake") service_name, auth_strategy="fake")
self.assertEqual("http://test-auth-url", hc.auth_url) self.assertEqual("http://test-auth-url", hc.auth_url)
# auth_url is none # auth_url is none
hc = client.ReddwarfHTTPClient(user, password, tenant, None, hc = client.TroveHTTPClient(user, password, tenant, None,
service_name, auth_strategy="fake") service_name, auth_strategy="fake")
self.assertEqual(None, hc.auth_url) self.assertEqual(None, hc.auth_url)
@ -157,7 +157,7 @@ class ReddwarfHTTPClientTest(TestCase):
status_list = [400, 401, 403, 404, 408, 409, 413, 500, 501] status_list = [400, 401, 403, 404, 408, 409, 413, 500, 501]
for status in status_list: for status in status_list:
resp.status = status resp.status = status
self.assertRaises(ValueError, self.hc.request) self.assertRaises(Exception, self.hc.request)
exception = exceptions.ResponseFormatError exception = exceptions.ResponseFormatError
self.hc.morph_response_body = Mock(side_effect=exception) self.hc.morph_response_body = Mock(side_effect=exception)
@ -171,7 +171,7 @@ class ReddwarfHTTPClientTest(TestCase):
status_list = [400, 401, 403, 404, 408, 409, 413, 500, 501] status_list = [400, 401, 403, 404, 408, 409, 413, 500, 501]
for status in status_list: for status in status_list:
resp.status = status resp.status = status
self.assertRaises(ValueError, self.assertRaises(Exception,
self.hc.raise_error_from_status, resp, Mock()) self.hc.raise_error_from_status, resp, Mock())
def test_morph_request(self): def test_morph_request(self):
@ -293,16 +293,16 @@ class DbaasTest(TestCase):
def setUp(self): def setUp(self):
super(DbaasTest, self).setUp() super(DbaasTest, self).setUp()
self.orig__init = client.ReddwarfHTTPClient.__init__ self.orig__init = client.TroveHTTPClient.__init__
client.ReddwarfHTTPClient.__init__ = Mock(return_value=None) client.TroveHTTPClient.__init__ = Mock(return_value=None)
self.dbaas = client.Dbaas("user", "api-key") self.dbaas = client.Dbaas("user", "api-key")
def tearDown(self): def tearDown(self):
super(DbaasTest, self).tearDown() super(DbaasTest, self).tearDown()
client.ReddwarfHTTPClient.__init__ = self.orig__init client.TroveHTTPClient.__init__ = self.orig__init
def test___init__(self): def test___init__(self):
client.ReddwarfHTTPClient.__init__ = Mock(return_value=None) client.TroveHTTPClient.__init__ = Mock(return_value=None)
self.assertNotEqual(None, self.dbaas.mgmt) self.assertNotEqual(None, self.dbaas.mgmt)
def test_set_management_url(self): def test_set_management_url(self):

View File

@ -6,8 +6,8 @@ import collections
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import common from troveclient import common
from reddwarfclient import client from troveclient import client
""" """
unit tests for common.py unit tests for common.py
@ -41,7 +41,7 @@ class CommonTest(TestCase):
for s in status: for s in status:
resp = Mock() resp = Mock()
resp.status = s resp.status = s
self.assertRaises(ValueError, self.assertRaises(Exception,
common.check_for_exceptions, resp, "body") common.check_for_exceptions, resp, "body")
# a no-exception case # a no-exception case
@ -82,7 +82,7 @@ class CliOptionsTest(TestCase):
self.assertEqual(None, co.auth_url) self.assertEqual(None, co.auth_url)
self.assertEqual('keystone', co.auth_type) self.assertEqual('keystone', co.auth_type)
self.assertEqual('database', co.service_type) self.assertEqual('database', co.service_type)
self.assertEqual('reddwarf', co.service_name) self.assertEqual('trove', co.service_name)
self.assertEqual('RegionOne', co.region) self.assertEqual('RegionOne', co.region)
self.assertEqual(None, co.service_url) self.assertEqual(None, co.service_url)
self.assertFalse(co.insecure) self.assertFalse(co.insecure)

View File

@ -1,8 +1,8 @@
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import instances from troveclient import instances
from reddwarfclient import base from troveclient import base
""" """
Unit tests for instances.py Unit tests for instances.py
@ -118,7 +118,7 @@ class InstancesTest(TestCase):
self.instances.api.client.delete = Mock(return_value=(resp, body)) self.instances.api.client.delete = Mock(return_value=(resp, body))
self.instances.delete('instance1') self.instances.delete('instance1')
resp.status = 500 resp.status = 500
self.assertRaises(ValueError, self.instances.delete, 'instance1') self.assertRaises(Exception, self.instances.delete, 'instance1')
def test__action(self): def test__action(self):
body = Mock() body = Mock()

View File

@ -1,6 +1,6 @@
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import limits from troveclient import limits
class LimitsTest(TestCase): class LimitsTest(TestCase):

View File

@ -1,8 +1,8 @@
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import management from troveclient import management
from reddwarfclient import base from troveclient import base
""" """
Unit tests for management.py Unit tests for management.py
@ -96,7 +96,7 @@ class ManagementTest(TestCase):
self.management._action(1, 'body') self.management._action(1, 'body')
self.assertEqual(1, self.management.api.client.post.call_count) self.assertEqual(1, self.management.api.client.post.call_count)
resp.status = 400 resp.status = 400
self.assertRaises(ValueError, self.management._action, 1, 'body') self.assertRaises(Exception, self.management._action, 1, 'body')
self.assertEqual(2, self.management.api.client.post.call_count) self.assertEqual(2, self.management.api.client.post.call_count)
def _mock_action(self): def _mock_action(self):

View File

@ -1,8 +1,8 @@
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import security_groups from troveclient import security_groups
from reddwarfclient import base from troveclient import base
""" """
Unit tests for security_groups.py Unit tests for security_groups.py
@ -98,5 +98,5 @@ class SecGroupRuleTest(TestCase):
Mock(return_value=(resp, body)) Mock(return_value=(resp, body))
self.security_group_rules.delete(self.id) self.security_group_rules.delete(self.id)
resp.status = 500 resp.status = 500
self.assertRaises(ValueError, self.security_group_rules.delete, self.assertRaises(Exception, self.security_group_rules.delete,
self.id) self.id)

View File

@ -1,8 +1,8 @@
from testtools import TestCase from testtools import TestCase
from mock import Mock from mock import Mock
from reddwarfclient import users from troveclient import users
from reddwarfclient import base from troveclient import base
""" """
Unit tests for users.py Unit tests for users.py

View File

@ -1,7 +1,7 @@
import os import os
from testtools import TestCase from testtools import TestCase
from reddwarfclient import utils from troveclient import utils
from reddwarfclient import versions from troveclient import versions
class UtilsTest(TestCase): class UtilsTest(TestCase):

View File

@ -1,6 +1,6 @@
from testtools import TestCase from testtools import TestCase
from lxml import etree from lxml import etree
from reddwarfclient import xml from troveclient import xml
class XmlTest(TestCase): class XmlTest(TestCase):
@ -205,10 +205,10 @@ class XmlTest(TestCase):
test_list = xml.modify_response_types(test_list["a_list"], TYPE_MAP) test_list = xml.modify_response_types(test_list["a_list"], TYPE_MAP)
self.assertEqual([{'Int': 5}, {'Str': 'A'}], test_list) self.assertEqual([{'Int': 5}, {'Str': 'A'}], test_list)
def test_reddwarfxmlclient(self): def test_trovexmlclient(self):
from reddwarfclient import exceptions from troveclient import exceptions
client = xml.ReddwarfXmlClient("user", "password", "tenant", client = xml.TroveXmlClient("user", "password", "tenant",
"auth_url", "service_name", "auth_url", "service_name",
auth_strategy="fake") auth_strategy="fake")
request = {'headers': {}} request = {'headers': {}}

View File

@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
from reddwarfclient import databases from troveclient import databases
from reddwarfclient.common import check_for_exceptions from troveclient.common import check_for_exceptions
from reddwarfclient.common import limit_url from troveclient.common import limit_url
from reddwarfclient.common import Paginated from troveclient.common import Paginated
from reddwarfclient.common import quote_user_host from troveclient.common import quote_user_host
import exceptions import exceptions
import urlparse import urlparse

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from reddwarfclient import base from troveclient import base
class Version(base.Resource): class Version(base.Resource):

View File

@ -2,8 +2,8 @@ from lxml import etree
import json import json
from numbers import Number from numbers import Number
from reddwarfclient import exceptions from troveclient import exceptions
from reddwarfclient.client import ReddwarfHTTPClient from troveclient.client import TroveHTTPClient
XML_NS = {None: "http://docs.openstack.org/database/api/v1.0"} XML_NS = {None: "http://docs.openstack.org/database/api/v1.0"}
@ -262,7 +262,7 @@ def modify_response_types(value, type_translator):
for element in value] for element in value]
class ReddwarfXmlClient(ReddwarfHTTPClient): class TroveXmlClient(TroveHTTPClient):
@classmethod @classmethod
def morph_request(self, kwargs): def morph_request(self, kwargs):