diff --git a/.testr.conf b/.testr.conf index 8f0b5973..d45a93ae 100644 --- a/.testr.conf +++ b/.testr.conf @@ -2,7 +2,7 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ 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_list_option=--list diff --git a/README.rst b/README.rst index 929143b0..2be9bfbb 100644 --- a/README.rst +++ b/README.rst @@ -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 -``reddwarfclient`` module), and a command-line script (``reddwarf``). Each -implements 100% (or less ;) ) of the Reddwarf API. +This is a client for the Trove API. There's a Python API (the +``troveclient`` module), and a command-line script (``trove``). Each +implements 100% (or less ;) ) of the Trove API. Command-line API ---------------- @@ -13,7 +13,7 @@ tenant, and appropriate auth url. .. 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 ~/.apitoken. From there you can make other calls to the CLI. diff --git a/reddwarfclient/__init__.py b/reddwarfclient/__init__.py deleted file mode 100644 index 0383828b..00000000 --- a/reddwarfclient/__init__.py +++ /dev/null @@ -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 diff --git a/run_local.sh b/run_local.sh index f4497bcb..d496a686 100755 --- a/run_local.sh +++ b/run_local.sh @@ -9,9 +9,9 @@ me=${0##*/} function print_usage() { cat >&2 <=1.1.2 testrepository>=0.0.13 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 + diff --git a/troveclient/__init__.py b/troveclient/__init__.py new file mode 100644 index 00000000..e3506af5 --- /dev/null +++ b/troveclient/__init__.py @@ -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 diff --git a/reddwarfclient/accounts.py b/troveclient/accounts.py similarity index 95% rename from reddwarfclient/accounts.py rename to troveclient/accounts.py index 43e91358..5f60fa7e 100644 --- a/reddwarfclient/accounts.py +++ b/troveclient/accounts.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base -from reddwarfclient.common import check_for_exceptions +from troveclient import base +from troveclient.common import check_for_exceptions class Account(base.Resource): diff --git a/reddwarfclient/auth.py b/troveclient/auth.py similarity index 98% rename from reddwarfclient/auth.py rename to troveclient/auth.py index 4494447d..909d45b8 100644 --- a/reddwarfclient/auth.py +++ b/troveclient/auth.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import exceptions +from troveclient import exceptions def get_authenticator_cls(cls_or_name): @@ -228,7 +228,7 @@ class ServiceCatalog(object): def _url_for(self, attr=None, filter_value=None, 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. """ matching_endpoints = [] diff --git a/reddwarfclient/backups.py b/troveclient/backups.py similarity index 98% rename from reddwarfclient/backups.py rename to troveclient/backups.py index c78b8408..036f0277 100644 --- a/reddwarfclient/backups.py +++ b/troveclient/backups.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base import exceptions diff --git a/reddwarfclient/base.py b/troveclient/base.py similarity index 98% rename from reddwarfclient/base.py rename to troveclient/base.py index 6660ff4a..01cd19dc 100644 --- a/reddwarfclient/base.py +++ b/troveclient/base.py @@ -22,8 +22,8 @@ Base utilities to build API operation managers and objects on top of. import contextlib import hashlib import os -from reddwarfclient import exceptions -from reddwarfclient import utils +from troveclient import exceptions +from troveclient import utils # Python 2.4 compat @@ -93,7 +93,7 @@ class Manager(utils.HookableMixin): often enough to keep the cache reasonably up-to-date. """ base_dir = utils.env('REDDWARFCLIENT_ID_CACHE_DIR', - default="~/.reddwarfclient") + default="~/.troveclient") # NOTE(sirp): Keep separate UUID caches for each username + endpoint # pair diff --git a/reddwarfclient/cli.py b/troveclient/cli.py similarity index 98% rename from reddwarfclient/cli.py rename to troveclient/cli.py index f83de6d0..487a45cd 100644 --- a/reddwarfclient/cli.py +++ b/troveclient/cli.py @@ -15,7 +15,7 @@ # under the License. """ -Reddwarf Command line tool +Trove Command line tool """ #TODO(tim.simpson): optparse is deprecated. Replace with argparse. @@ -24,17 +24,17 @@ import os 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... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), 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')): sys.path.insert(0, possible_topdir) -from reddwarfclient import common +from troveclient import common class InstanceCommands(common.AuthedCommandsBase): diff --git a/reddwarfclient/client.py b/troveclient/client.py similarity index 89% rename from reddwarfclient/client.py rename to troveclient/client.py index f602afb4..1409448c 100644 --- a/reddwarfclient/client.py +++ b/troveclient/client.py @@ -30,8 +30,8 @@ if not hasattr(urlparse, 'parse_qsl'): import cgi urlparse.parse_qsl = cgi.parse_qsl -from reddwarfclient import auth -from reddwarfclient import exceptions +from troveclient import auth +from troveclient import exceptions _logger = logging.getLogger(__name__) @@ -52,9 +52,9 @@ if 'REDDWARFCLIENT_DEBUG' in os.environ and os.environ['REDDWARFCLIENT_DEBUG']: 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, service_url=None, @@ -64,7 +64,7 @@ class ReddwarfHTTPClient(httplib2.Http): endpoint_type='publicURL', service_type=None, timings=False): - super(ReddwarfHTTPClient, self).__init__(timeout=timeout) + super(TroveHTTPClient, self).__init__(timeout=timeout) self.username = user self.password = password @@ -130,7 +130,7 @@ class ReddwarfHTTPClient(httplib2.Http): _logger.debug("RESP:%s %s\n", resp, body) def pretty_log(self, args, kwargs, resp, body): - from reddwarfclient import common + from troveclient import common if not _logger.isEnabledFor(logging.DEBUG): return @@ -170,7 +170,7 @@ class ReddwarfHTTPClient(httplib2.Http): kwargs['headers']['User-Agent'] = self.USER_AGENT 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. self.last_response = (resp, body) @@ -297,26 +297,26 @@ class Dbaas(object): """ 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', - region_name=None, client_cls=ReddwarfHTTPClient): - from reddwarfclient.versions import Versions - from reddwarfclient.databases import Databases - from reddwarfclient.flavors import Flavors - from reddwarfclient.instances import Instances - from reddwarfclient.limits import Limits - from reddwarfclient.users import Users - from reddwarfclient.root import Root - from reddwarfclient.hosts import Hosts - from reddwarfclient.quota import Quotas - from reddwarfclient.backups import Backups - from reddwarfclient.security_groups import SecurityGroups - from reddwarfclient.security_groups import SecurityGroupRules - from reddwarfclient.storage import StorageInfo - from reddwarfclient.management import Management - from reddwarfclient.accounts import Accounts - from reddwarfclient.diagnostics import DiagnosticsInterrogator - from reddwarfclient.diagnostics import HwInfoInterrogator + region_name=None, client_cls=TroveHTTPClient): + from troveclient.versions import Versions + from troveclient.databases import Databases + from troveclient.flavors import Flavors + from troveclient.instances import Instances + from troveclient.limits import Limits + from troveclient.users import Users + from troveclient.root import Root + from troveclient.hosts import Hosts + from troveclient.quota import Quotas + from troveclient.backups import Backups + from troveclient.security_groups import SecurityGroups + from troveclient.security_groups import SecurityGroupRules + from troveclient.storage import StorageInfo + from troveclient.management import Management + from troveclient.accounts import Accounts + from troveclient.diagnostics import DiagnosticsInterrogator + from troveclient.diagnostics import HwInfoInterrogator self.client = client_cls(username, api_key, tenant, auth_url, service_type=service_type, diff --git a/reddwarfclient/common.py b/troveclient/common.py similarity index 98% rename from reddwarfclient/common.py rename to troveclient/common.py index 9c66c497..d10fb221 100644 --- a/reddwarfclient/common.py +++ b/troveclient/common.py @@ -19,9 +19,9 @@ import os import pickle import sys -from reddwarfclient import client -from reddwarfclient.xml import ReddwarfXmlClient -from reddwarfclient import exceptions +from troveclient import client +from troveclient.xml import TroveXmlClient +from troveclient import exceptions from urllib import quote @@ -92,7 +92,7 @@ class CliOptions(object): 'auth_url': None, 'auth_type': 'keystone', 'service_type': 'database', - 'service_name': 'reddwarf', + 'service_name': 'trove', 'region': 'RegionOne', 'service_url': None, 'insecure': False, @@ -204,9 +204,9 @@ class CommandsBase(object): """Creates the all important client object.""" try: if self.xml: - client_cls = ReddwarfXmlClient + client_cls = TroveXmlClient else: - client_cls = client.ReddwarfHTTPClient + client_cls = client.TroveHTTPClient if self.verbose: client.log_to_streamhandler(sys.stdout) client.RDC_PP = True diff --git a/reddwarfclient/databases.py b/troveclient/databases.py similarity index 93% rename from reddwarfclient/databases.py rename to troveclient/databases.py index d7f31e1a..09157d34 100644 --- a/reddwarfclient/databases.py +++ b/troveclient/databases.py @@ -1,7 +1,7 @@ -from reddwarfclient import base -from reddwarfclient.common import check_for_exceptions -from reddwarfclient.common import limit_url -from reddwarfclient.common import Paginated +from troveclient import base +from troveclient.common import check_for_exceptions +from troveclient.common import limit_url +from troveclient.common import Paginated import exceptions import urlparse diff --git a/reddwarfclient/diagnostics.py b/troveclient/diagnostics.py similarity index 98% rename from reddwarfclient/diagnostics.py rename to troveclient/diagnostics.py index 06da06c0..311a7c95 100644 --- a/reddwarfclient/diagnostics.py +++ b/troveclient/diagnostics.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base import exceptions diff --git a/reddwarfclient/exceptions.py b/troveclient/exceptions.py similarity index 100% rename from reddwarfclient/exceptions.py rename to troveclient/exceptions.py diff --git a/reddwarfclient/flavors.py b/troveclient/flavors.py similarity index 95% rename from reddwarfclient/flavors.py rename to troveclient/flavors.py index ba01a5f9..02fef331 100644 --- a/reddwarfclient/flavors.py +++ b/troveclient/flavors.py @@ -14,11 +14,11 @@ # under the License. -from reddwarfclient import base +from troveclient import base import exceptions -from reddwarfclient.common import check_for_exceptions +from troveclient.common import check_for_exceptions class Flavor(base.Resource): diff --git a/reddwarfclient/hosts.py b/troveclient/hosts.py similarity index 96% rename from reddwarfclient/hosts.py rename to troveclient/hosts.py index fb03d379..3e7ecc25 100644 --- a/reddwarfclient/hosts.py +++ b/troveclient/hosts.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # 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): diff --git a/reddwarfclient/instances.py b/troveclient/instances.py similarity index 96% rename from reddwarfclient/instances.py rename to troveclient/instances.py index 66b091ce..16e8a6b2 100644 --- a/reddwarfclient/instances.py +++ b/troveclient/instances.py @@ -13,14 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base import exceptions import urlparse -from reddwarfclient.common import check_for_exceptions -from reddwarfclient.common import limit_url -from reddwarfclient.common import Paginated +from troveclient.common import check_for_exceptions +from troveclient.common import limit_url +from troveclient.common import Paginated REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD' diff --git a/reddwarfclient/limits.py b/troveclient/limits.py similarity index 97% rename from reddwarfclient/limits.py rename to troveclient/limits.py index f2b8703a..96d2fcaa 100644 --- a/reddwarfclient/limits.py +++ b/troveclient/limits.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base import exceptions diff --git a/reddwarfclient/management.py b/troveclient/management.py similarity index 95% rename from reddwarfclient/management.py rename to troveclient/management.py index 931c0d59..1e17f92e 100644 --- a/reddwarfclient/management.py +++ b/troveclient/management.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base import urlparse -from reddwarfclient.common import check_for_exceptions -from reddwarfclient.common import limit_url -from reddwarfclient.common import Paginated -from reddwarfclient.instances import Instance +from troveclient.common import check_for_exceptions +from troveclient.common import limit_url +from troveclient.common import Paginated +from troveclient.instances import Instance class RootHistory(base.Resource): diff --git a/reddwarfclient/mcli.py b/troveclient/mcli.py similarity index 96% rename from reddwarfclient/mcli.py rename to troveclient/mcli.py index 62371cca..87179c16 100644 --- a/reddwarfclient/mcli.py +++ b/troveclient/mcli.py @@ -15,7 +15,7 @@ # under the License. """ -Reddwarf Management Command line tool +Trove Management Command line tool """ import json @@ -24,17 +24,17 @@ import os 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... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), 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')): sys.path.insert(0, possible_topdir) -from reddwarfclient import common +from troveclient import common oparser = None diff --git a/reddwarfclient/quota.py b/troveclient/quota.py similarity index 95% rename from reddwarfclient/quota.py rename to troveclient/quota.py index e5a8f749..aca7ef89 100644 --- a/reddwarfclient/quota.py +++ b/troveclient/quota.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base -from reddwarfclient.common import check_for_exceptions +from troveclient import base +from troveclient.common import check_for_exceptions class Quotas(base.ManagerWithFind): diff --git a/reddwarfclient/root.py b/troveclient/root.py similarity index 92% rename from reddwarfclient/root.py rename to troveclient/root.py index 33b0da70..e9768afb 100644 --- a/reddwarfclient/root.py +++ b/troveclient/root.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base -from reddwarfclient import users -from reddwarfclient.common import check_for_exceptions +from troveclient import users +from troveclient.common import check_for_exceptions import exceptions diff --git a/reddwarfclient/security_groups.py b/troveclient/security_groups.py similarity index 96% rename from reddwarfclient/security_groups.py rename to troveclient/security_groups.py index d26cc862..caece795 100644 --- a/reddwarfclient/security_groups.py +++ b/troveclient/security_groups.py @@ -14,13 +14,13 @@ # under the License. # -from reddwarfclient import base +from troveclient import base import exceptions import urlparse -from reddwarfclient.common import limit_url -from reddwarfclient.common import Paginated +from troveclient.common import limit_url +from troveclient.common import Paginated class SecurityGroup(base.Resource): diff --git a/reddwarfclient/storage.py b/troveclient/storage.py similarity index 97% rename from reddwarfclient/storage.py rename to troveclient/storage.py index 653096ef..67d332bd 100644 --- a/reddwarfclient/storage.py +++ b/troveclient/storage.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base class Device(base.Resource): diff --git a/troveclient/tests/__init__.py b/troveclient/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/reddwarfclient/tests/test_accounts.py b/troveclient/tests/test_accounts.py similarity index 97% rename from reddwarfclient/tests/test_accounts.py rename to troveclient/tests/test_accounts.py index ec76f134..e2716faa 100644 --- a/reddwarfclient/tests/test_accounts.py +++ b/troveclient/tests/test_accounts.py @@ -1,8 +1,8 @@ from testtools import TestCase from mock import Mock -from reddwarfclient import accounts -from reddwarfclient import base +from troveclient import accounts +from troveclient import base """ Unit tests for accounts.py diff --git a/reddwarfclient/tests/test_auth.py b/troveclient/tests/test_auth.py similarity index 97% rename from reddwarfclient/tests/test_auth.py rename to troveclient/tests/test_auth.py index f1c4b59d..28cecb9c 100644 --- a/reddwarfclient/tests/test_auth.py +++ b/troveclient/tests/test_auth.py @@ -1,10 +1,10 @@ import contextlib from testtools import TestCase -from reddwarfclient import auth +from troveclient import auth from mock import Mock -from reddwarfclient import exceptions +from troveclient import exceptions """ Unit tests for the classes and functions in auth.py. @@ -129,8 +129,8 @@ class KeyStoneV2AuthenticatorTest(TestCase): self.assertEqual(url, r) def test__v2_auth(self): - username = "reddwarf_user" - password = "reddwarf_password" + username = "trove_user" + password = "trove_password" tenant = "tenant" cls_type = auth.KeyStoneV2Authenticator authObj = auth.KeyStoneV2Authenticator(url=None, type=cls_type, @@ -159,8 +159,8 @@ class Auth1_1Test(TestCase): check_url_none(self, auth.Auth1_1) # url is not none - username = "reddwarf_user" - password = "reddwarf_password" + username = "trove_user" + password = "trove_password" url = "test_url" authObj = auth.Auth1_1(url=url, type=auth.Auth1_1, @@ -204,8 +204,8 @@ class RaxAuthenticatorTest(TestCase): self.assertEqual(url, r) def test__rax_auth(self): - username = "reddwarf_user" - password = "reddwarf_password" + username = "trove_user" + password = "trove_password" tenant = "tenant" authObj = auth.RaxAuthenticator(url=None, type=auth.RaxAuthenticator, @@ -359,12 +359,12 @@ class ServiceCatalogTest(TestCase): self.assertEqual(self.test_url, r_url) def case_ambiguous_endpoint(self, scObj): - scObj.service_type = "reddwarf" + scObj.service_type = "trove" scObj.service_name = "test_service_name" def side_effect_func_service(key): if key == "type": - return "reddwarf" + return "trove" elif key == "name": return "test_service_name" return None diff --git a/reddwarfclient/tests/test_base.py b/troveclient/tests/test_base.py similarity index 99% rename from reddwarfclient/tests/test_base.py rename to troveclient/tests/test_base.py index 5cbd590f..ac7318b0 100644 --- a/reddwarfclient/tests/test_base.py +++ b/troveclient/tests/test_base.py @@ -4,9 +4,9 @@ import os from testtools import TestCase from mock import Mock -from reddwarfclient import base -from reddwarfclient import exceptions -from reddwarfclient import utils +from troveclient import base +from troveclient import exceptions +from troveclient import utils """ Unit tests for base.py diff --git a/reddwarfclient/tests/test_client.py b/troveclient/tests/test_client.py similarity index 91% rename from reddwarfclient/tests/test_client.py rename to troveclient/tests/test_client.py index d52331ff..263316b3 100644 --- a/reddwarfclient/tests/test_client.py +++ b/troveclient/tests/test_client.py @@ -7,9 +7,9 @@ import time from testtools import TestCase from mock import Mock -from reddwarfclient import client -from reddwarfclient import exceptions -from reddwarfclient import utils +from troveclient import client +from troveclient import exceptions +from troveclient import utils """ Unit tests for client.py @@ -23,13 +23,13 @@ class ClientTest(TestCase): self.assertTrue(client._logger.level == logging.DEBUG) -class ReddwarfHTTPClientTest(TestCase): +class TroveHTTPClientTest(TestCase): def setUp(self): - super(ReddwarfHTTPClientTest, self).setUp() - self.orig__init = client.ReddwarfHTTPClient.__init__ - client.ReddwarfHTTPClient.__init__ = Mock(return_value=None) - self.hc = client.ReddwarfHTTPClient() + super(TroveHTTPClientTest, self).setUp() + self.orig__init = client.TroveHTTPClient.__init__ + client.TroveHTTPClient.__init__ = Mock(return_value=None) + self.hc = client.TroveHTTPClient() self.hc.auth_token = "test-auth-token" self.hc.service_url = "test-service-url/" self.hc.tenant = "test-tenant" @@ -43,8 +43,8 @@ class ReddwarfHTTPClientTest(TestCase): self.orig_htttp_request = httplib2.Http.request def tearDown(self): - super(ReddwarfHTTPClientTest, self).tearDown() - client.ReddwarfHTTPClient.__init__ = self.orig__init + super(TroveHTTPClientTest, self).tearDown() + client.TroveHTTPClient.__init__ = self.orig__init client._logger = self.orig_client__logger time.time = self.orig_time httplib2.Http.request = self.orig_htttp_request @@ -53,7 +53,7 @@ class ReddwarfHTTPClientTest(TestCase): self.__debug_lines.append(s) def test___init__(self): - client.ReddwarfHTTPClient.__init__ = self.orig__init + client.TroveHTTPClient.__init__ = self.orig__init user = "test-user" password = "test-password" @@ -62,15 +62,15 @@ class ReddwarfHTTPClientTest(TestCase): service_name = None # 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) - hc = client.ReddwarfHTTPClient(user, password, tenant, auth_url, + hc = client.TroveHTTPClient(user, password, tenant, auth_url, service_name, auth_strategy="fake") self.assertEqual("http://test-auth-url", hc.auth_url) # auth_url is none - hc = client.ReddwarfHTTPClient(user, password, tenant, None, + hc = client.TroveHTTPClient(user, password, tenant, None, service_name, auth_strategy="fake") self.assertEqual(None, hc.auth_url) @@ -157,7 +157,7 @@ class ReddwarfHTTPClientTest(TestCase): status_list = [400, 401, 403, 404, 408, 409, 413, 500, 501] for status in status_list: resp.status = status - self.assertRaises(ValueError, self.hc.request) + self.assertRaises(Exception, self.hc.request) exception = exceptions.ResponseFormatError 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] for status in status_list: resp.status = status - self.assertRaises(ValueError, + self.assertRaises(Exception, self.hc.raise_error_from_status, resp, Mock()) def test_morph_request(self): @@ -293,16 +293,16 @@ class DbaasTest(TestCase): def setUp(self): super(DbaasTest, self).setUp() - self.orig__init = client.ReddwarfHTTPClient.__init__ - client.ReddwarfHTTPClient.__init__ = Mock(return_value=None) + self.orig__init = client.TroveHTTPClient.__init__ + client.TroveHTTPClient.__init__ = Mock(return_value=None) self.dbaas = client.Dbaas("user", "api-key") def tearDown(self): super(DbaasTest, self).tearDown() - client.ReddwarfHTTPClient.__init__ = self.orig__init + client.TroveHTTPClient.__init__ = self.orig__init def test___init__(self): - client.ReddwarfHTTPClient.__init__ = Mock(return_value=None) + client.TroveHTTPClient.__init__ = Mock(return_value=None) self.assertNotEqual(None, self.dbaas.mgmt) def test_set_management_url(self): diff --git a/reddwarfclient/tests/test_common.py b/troveclient/tests/test_common.py similarity index 98% rename from reddwarfclient/tests/test_common.py rename to troveclient/tests/test_common.py index b038a051..e1b488a1 100644 --- a/reddwarfclient/tests/test_common.py +++ b/troveclient/tests/test_common.py @@ -6,8 +6,8 @@ import collections from testtools import TestCase from mock import Mock -from reddwarfclient import common -from reddwarfclient import client +from troveclient import common +from troveclient import client """ unit tests for common.py @@ -41,7 +41,7 @@ class CommonTest(TestCase): for s in status: resp = Mock() resp.status = s - self.assertRaises(ValueError, + self.assertRaises(Exception, common.check_for_exceptions, resp, "body") # a no-exception case @@ -82,7 +82,7 @@ class CliOptionsTest(TestCase): self.assertEqual(None, co.auth_url) self.assertEqual('keystone', co.auth_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(None, co.service_url) self.assertFalse(co.insecure) diff --git a/reddwarfclient/tests/test_instances.py b/troveclient/tests/test_instances.py similarity index 97% rename from reddwarfclient/tests/test_instances.py rename to troveclient/tests/test_instances.py index 2131d269..05e40195 100644 --- a/reddwarfclient/tests/test_instances.py +++ b/troveclient/tests/test_instances.py @@ -1,8 +1,8 @@ from testtools import TestCase from mock import Mock -from reddwarfclient import instances -from reddwarfclient import base +from troveclient import instances +from troveclient import base """ Unit tests for instances.py @@ -118,7 +118,7 @@ class InstancesTest(TestCase): self.instances.api.client.delete = Mock(return_value=(resp, body)) self.instances.delete('instance1') resp.status = 500 - self.assertRaises(ValueError, self.instances.delete, 'instance1') + self.assertRaises(Exception, self.instances.delete, 'instance1') def test__action(self): body = Mock() diff --git a/reddwarfclient/tests/test_limits.py b/troveclient/tests/test_limits.py similarity index 98% rename from reddwarfclient/tests/test_limits.py rename to troveclient/tests/test_limits.py index fda182cb..d40b646b 100644 --- a/reddwarfclient/tests/test_limits.py +++ b/troveclient/tests/test_limits.py @@ -1,6 +1,6 @@ from testtools import TestCase from mock import Mock -from reddwarfclient import limits +from troveclient import limits class LimitsTest(TestCase): diff --git a/reddwarfclient/tests/test_management.py b/troveclient/tests/test_management.py similarity index 97% rename from reddwarfclient/tests/test_management.py rename to troveclient/tests/test_management.py index 810961ac..c04e2164 100644 --- a/reddwarfclient/tests/test_management.py +++ b/troveclient/tests/test_management.py @@ -1,8 +1,8 @@ from testtools import TestCase from mock import Mock -from reddwarfclient import management -from reddwarfclient import base +from troveclient import management +from troveclient import base """ Unit tests for management.py @@ -96,7 +96,7 @@ class ManagementTest(TestCase): self.management._action(1, 'body') self.assertEqual(1, self.management.api.client.post.call_count) 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) def _mock_action(self): diff --git a/reddwarfclient/tests/test_secgroups.py b/troveclient/tests/test_secgroups.py similarity index 96% rename from reddwarfclient/tests/test_secgroups.py rename to troveclient/tests/test_secgroups.py index 25b4de81..779d01ea 100644 --- a/reddwarfclient/tests/test_secgroups.py +++ b/troveclient/tests/test_secgroups.py @@ -1,8 +1,8 @@ from testtools import TestCase from mock import Mock -from reddwarfclient import security_groups -from reddwarfclient import base +from troveclient import security_groups +from troveclient import base """ Unit tests for security_groups.py @@ -98,5 +98,5 @@ class SecGroupRuleTest(TestCase): Mock(return_value=(resp, body)) self.security_group_rules.delete(self.id) resp.status = 500 - self.assertRaises(ValueError, self.security_group_rules.delete, + self.assertRaises(Exception, self.security_group_rules.delete, self.id) diff --git a/reddwarfclient/tests/test_users.py b/troveclient/tests/test_users.py similarity index 98% rename from reddwarfclient/tests/test_users.py rename to troveclient/tests/test_users.py index 80be05fa..0fc32f68 100644 --- a/reddwarfclient/tests/test_users.py +++ b/troveclient/tests/test_users.py @@ -1,8 +1,8 @@ from testtools import TestCase from mock import Mock -from reddwarfclient import users -from reddwarfclient import base +from troveclient import users +from troveclient import base """ Unit tests for users.py diff --git a/reddwarfclient/tests/test_utils.py b/troveclient/tests/test_utils.py similarity index 94% rename from reddwarfclient/tests/test_utils.py rename to troveclient/tests/test_utils.py index c3a000da..12ee9d0c 100644 --- a/reddwarfclient/tests/test_utils.py +++ b/troveclient/tests/test_utils.py @@ -1,7 +1,7 @@ import os from testtools import TestCase -from reddwarfclient import utils -from reddwarfclient import versions +from troveclient import utils +from troveclient import versions class UtilsTest(TestCase): diff --git a/reddwarfclient/tests/test_xml.py b/troveclient/tests/test_xml.py similarity index 98% rename from reddwarfclient/tests/test_xml.py rename to troveclient/tests/test_xml.py index cda382be..96490ce2 100644 --- a/reddwarfclient/tests/test_xml.py +++ b/troveclient/tests/test_xml.py @@ -1,6 +1,6 @@ from testtools import TestCase from lxml import etree -from reddwarfclient import xml +from troveclient import xml class XmlTest(TestCase): @@ -205,10 +205,10 @@ class XmlTest(TestCase): test_list = xml.modify_response_types(test_list["a_list"], TYPE_MAP) self.assertEqual([{'Int': 5}, {'Str': 'A'}], test_list) - def test_reddwarfxmlclient(self): - from reddwarfclient import exceptions + def test_trovexmlclient(self): + from troveclient import exceptions - client = xml.ReddwarfXmlClient("user", "password", "tenant", + client = xml.TroveXmlClient("user", "password", "tenant", "auth_url", "service_name", auth_strategy="fake") request = {'headers': {}} diff --git a/reddwarfclient/users.py b/troveclient/users.py similarity index 94% rename from reddwarfclient/users.py rename to troveclient/users.py index 344252c1..acf99ca7 100644 --- a/reddwarfclient/users.py +++ b/troveclient/users.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base -from reddwarfclient import databases -from reddwarfclient.common import check_for_exceptions -from reddwarfclient.common import limit_url -from reddwarfclient.common import Paginated -from reddwarfclient.common import quote_user_host +from troveclient import base +from troveclient import databases +from troveclient.common import check_for_exceptions +from troveclient.common import limit_url +from troveclient.common import Paginated +from troveclient.common import quote_user_host import exceptions import urlparse diff --git a/reddwarfclient/utils.py b/troveclient/utils.py similarity index 100% rename from reddwarfclient/utils.py rename to troveclient/utils.py diff --git a/reddwarfclient/versions.py b/troveclient/versions.py similarity index 97% rename from reddwarfclient/versions.py rename to troveclient/versions.py index f7b52c45..4813a375 100644 --- a/reddwarfclient/versions.py +++ b/troveclient/versions.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from reddwarfclient import base +from troveclient import base class Version(base.Resource): diff --git a/reddwarfclient/xml.py b/troveclient/xml.py similarity index 98% rename from reddwarfclient/xml.py rename to troveclient/xml.py index fe94f196..d4a74513 100644 --- a/reddwarfclient/xml.py +++ b/troveclient/xml.py @@ -2,8 +2,8 @@ from lxml import etree import json from numbers import Number -from reddwarfclient import exceptions -from reddwarfclient.client import ReddwarfHTTPClient +from troveclient import exceptions +from troveclient.client import TroveHTTPClient 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] -class ReddwarfXmlClient(ReddwarfHTTPClient): +class TroveXmlClient(TroveHTTPClient): @classmethod def morph_request(self, kwargs):