Migrate Python namespace from climateclient to blazarclient

The python-blazarclient repository has been using the climateclient
namespace.

This patch converts the climateclient namespace to the blazarclient
namespace. Additionally, some classes, methods and variables that
include 'climate' in their name are also changed to 'blazar'.

Change-Id: Ibf900f9a8a7a7bfb0b6b213545b9cbf121ce0df7
Closes-Bug: #1662735
Closes-Bug: #1311746
This commit is contained in:
Masahito Muroi 2017-02-13 18:47:22 +09:00 committed by Pierre Riteau
parent 053ccbc2f0
commit 581c1170a3
26 changed files with 165 additions and 144 deletions

View File

@ -1,12 +1,12 @@
Climate Style Commandments Blazar Style Commandments
========================== =========================
- Step 1: Read the OpenStack Style Commandments - Step 1: Read the OpenStack Style Commandments
http://docs.openstack.org/developer/hacking/ http://docs.openstack.org/developer/hacking/
- Step 2: Read on - Step 2: Read on
Climate Specific Commandments Blazar Specific Commandments
----------------------------- ----------------------------
None so far None so far

View File

@ -1,5 +1,5 @@
============== =============
Climate client Blazar client
============== =============
**Climate client** provides possibility to use *Climate* API(s). **Blazar client** provides possibility to use *Blazar* API(s).

View File

@ -18,8 +18,8 @@ import json
import requests import requests
from climateclient import exception from blazarclient import exception
from climateclient.i18n import _ from blazarclient.i18n import _
class BaseClientManager(object): class BaseClientManager(object):
@ -28,16 +28,16 @@ class BaseClientManager(object):
There are environments, nodes and jobs types of API requests. There are environments, nodes and jobs types of API requests.
Manager provides CRUD operations for them. Manager provides CRUD operations for them.
""" """
def __init__(self, climate_url, auth_token): def __init__(self, blazar_url, auth_token):
self.climate_url = climate_url self.blazar_url = blazar_url
self.auth_token = auth_token self.auth_token = auth_token
USER_AGENT = 'python-climateclient' USER_AGENT = 'python-blazarclient'
def _get(self, url, response_key): def _get(self, url, response_key):
"""Sends get request to Climate. """Sends get request to Blazar.
:param url: URL to the wanted Climate resource. :param url: URL to the wanted Blazar resource.
:type url: str :type url: str
:param response_key: Type of resource (environment, node, job). :param response_key: Type of resource (environment, node, job).
@ -50,9 +50,9 @@ class BaseClientManager(object):
return body[response_key] return body[response_key]
def _create(self, url, body, response_key): def _create(self, url, body, response_key):
"""Sends create request to Climate. """Sends create request to Blazar.
:param url: URL to the wanted Climate resource. :param url: URL to the wanted Blazar resource.
:type url: str :type url: str
:param body: Values resource to be created from. :param body: Values resource to be created from.
@ -68,17 +68,17 @@ class BaseClientManager(object):
return body[response_key] return body[response_key]
def _delete(self, url): def _delete(self, url):
"""Sends delete request to Climate. """Sends delete request to Blazar.
:param url: URL to the wanted Climate resource. :param url: URL to the wanted Blazar resource.
:type url: str :type url: str
""" """
resp, body = self.request(url, 'DELETE') resp, body = self.request(url, 'DELETE')
def _update(self, url, body, response_key=None): def _update(self, url, body, response_key=None):
"""Sends update request to Climate. """Sends update request to Blazar.
:param url: URL to the wanted Climate resource. :param url: URL to the wanted Blazar resource.
:type url: str :type url: str
:param body: Values resource to be updated from. :param body: Values resource to be updated from.
@ -117,7 +117,7 @@ class BaseClientManager(object):
kwargs['data'] = json.dumps(kwargs['body']) kwargs['data'] = json.dumps(kwargs['body'])
del kwargs['body'] del kwargs['body']
resp = requests.request(method, self.climate_url + url, **kwargs) resp = requests.request(method, self.blazar_url + url, **kwargs)
try: try:
body = json.loads(resp.text) body = json.loads(resp.text)
@ -131,6 +131,6 @@ class BaseClientManager(object):
error_message = resp.text error_message = resp.text
body = _("ERROR: {0}").format(error_message) body = _("ERROR: {0}").format(error_message)
raise exception.ClimateClientException(body, code=resp.status_code) raise exception.BlazarClientException(body, code=resp.status_code)
return resp, body return resp, body

View File

@ -15,14 +15,14 @@
from oslo_utils import importutils from oslo_utils import importutils
from climateclient import exception from blazarclient import exception
from climateclient.i18n import _ from blazarclient.i18n import _
def Client(version=1, *args, **kwargs): def Client(version=1, *args, **kwargs):
version_map = { version_map = {
'1': 'climateclient.v1.client.Client', '1': 'blazarclient.v1.client.Client',
'1a0': 'climateclient.v1.client.Client', '1a0': 'blazarclient.v1.client.Client',
} }
try: try:
client_path = version_map[str(version)] client_path = version_map[str(version)]

View File

@ -23,8 +23,8 @@ from cliff.formatters import table
from cliff import lister from cliff import lister
from cliff import show from cliff import show
from climateclient import exception from blazarclient import exception
from climateclient import utils from blazarclient import utils
class OpenStackCommand(command.Command): class OpenStackCommand(command.Command):
@ -56,18 +56,18 @@ class TableFormatter(table.TableFormatter):
stdout.write('\n') stdout.write('\n')
class ClimateCommand(OpenStackCommand): class BlazarCommand(OpenStackCommand):
"""Base Climate CLI command.""" """Base Blazar CLI command."""
api = 'reservation' api = 'reservation'
log = logging.getLogger(__name__ + '.ClimateCommand') log = logging.getLogger(__name__ + '.BlazarCommand')
values_specs = [] values_specs = []
json_indent = None json_indent = None
resource = None resource = None
allow_names = True allow_names = True
def __init__(self, app, app_args): def __init__(self, app, app_args):
super(ClimateCommand, self).__init__(app, app_args) super(BlazarCommand, self).__init__(app, app_args)
# NOTE(dbelova): This is no longer supported in cliff version 1.5.2 # NOTE(dbelova): This is no longer supported in cliff version 1.5.2
# the same moment occurred in Neutron: # the same moment occurred in Neutron:
@ -80,7 +80,7 @@ class ClimateCommand(OpenStackCommand):
return self.app.client return self.app.client
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(ClimateCommand, self).get_parser(prog_name) parser = super(BlazarCommand, self).get_parser(prog_name)
return parser return parser
def format_output_data(self, data): def format_output_data(self, data):
@ -115,7 +115,7 @@ class ClimateCommand(OpenStackCommand):
return {} return {}
class CreateCommand(ClimateCommand, show.ShowOne): class CreateCommand(BlazarCommand, show.ShowOne):
"""Create resource with passed args.""" """Create resource with passed args."""
api = 'reservation' api = 'reservation'
@ -124,9 +124,9 @@ class CreateCommand(ClimateCommand, show.ShowOne):
def get_data(self, parsed_args): def get_data(self, parsed_args):
self.log.debug('get_data(%s)' % parsed_args) self.log.debug('get_data(%s)' % parsed_args)
climate_client = self.get_client() blazar_client = self.get_client()
body = self.args2body(parsed_args) body = self.args2body(parsed_args)
resource_manager = getattr(climate_client, self.resource) resource_manager = getattr(blazar_client, self.resource)
data = resource_manager.create(**body) data = resource_manager.create(**body)
self.format_output_data(data) self.format_output_data(data)
@ -137,7 +137,7 @@ class CreateCommand(ClimateCommand, show.ShowOne):
return zip(*sorted(six.iteritems(data))) return zip(*sorted(six.iteritems(data)))
class UpdateCommand(ClimateCommand): class UpdateCommand(BlazarCommand):
"""Update resource's information.""" """Update resource's information."""
api = 'reservation' api = 'reservation'
@ -159,22 +159,22 @@ class UpdateCommand(ClimateCommand):
def run(self, parsed_args): def run(self, parsed_args):
self.log.debug('run(%s)' % parsed_args) self.log.debug('run(%s)' % parsed_args)
climate_client = self.get_client() blazar_client = self.get_client()
body = self.args2body(parsed_args) body = self.args2body(parsed_args)
if self.allow_names: if self.allow_names:
res_id = utils.find_resource_id_by_name_or_id(climate_client, res_id = utils.find_resource_id_by_name_or_id(blazar_client,
self.resource, self.resource,
parsed_args.id) parsed_args.id)
else: else:
res_id = parsed_args.id res_id = parsed_args.id
resource_manager = getattr(climate_client, self.resource) resource_manager = getattr(blazar_client, self.resource)
resource_manager.update(res_id, **body) resource_manager.update(res_id, **body)
print(self.app.stdout, 'Updated %s: %s' % (self.resource, print(self.app.stdout, 'Updated %s: %s' % (self.resource,
parsed_args.id)) parsed_args.id))
return return
class DeleteCommand(ClimateCommand): class DeleteCommand(BlazarCommand):
"""Delete a given resource.""" """Delete a given resource."""
api = 'reservation' api = 'reservation'
@ -194,10 +194,10 @@ class DeleteCommand(ClimateCommand):
def run(self, parsed_args): def run(self, parsed_args):
self.log.debug('run(%s)' % parsed_args) self.log.debug('run(%s)' % parsed_args)
climate_client = self.get_client() blazar_client = self.get_client()
resource_manager = getattr(climate_client, self.resource) resource_manager = getattr(blazar_client, self.resource)
if self.allow_names: if self.allow_names:
res_id = utils.find_resource_id_by_name_or_id(climate_client, res_id = utils.find_resource_id_by_name_or_id(blazar_client,
self.resource, self.resource,
parsed_args.id) parsed_args.id)
else: else:
@ -208,7 +208,7 @@ class DeleteCommand(ClimateCommand):
return return
class ListCommand(ClimateCommand, lister.Lister): class ListCommand(BlazarCommand, lister.Lister):
"""List resources that belong to a given tenant.""" """List resources that belong to a given tenant."""
api = 'reservation' api = 'reservation'
@ -225,7 +225,7 @@ class ListCommand(ClimateCommand, lister.Lister):
params['sort_by'] = parsed_args.sort_by params['sort_by'] = parsed_args.sort_by
else: else:
msg = 'Invalid sort option %s' % parsed_args.sort_by msg = 'Invalid sort option %s' % parsed_args.sort_by
raise exception.ClimateClientException(msg) raise exception.BlazarClientException(msg)
return params return params
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -233,10 +233,10 @@ class ListCommand(ClimateCommand, lister.Lister):
return parser return parser
def retrieve_list(self, parsed_args): def retrieve_list(self, parsed_args):
"""Retrieve a list of resources from Climate server""" """Retrieve a list of resources from Blazar server"""
climate_client = self.get_client() blazar_client = self.get_client()
body = self.args2body(parsed_args) body = self.args2body(parsed_args)
resource_manager = getattr(climate_client, self.resource) resource_manager = getattr(blazar_client, self.resource)
data = resource_manager.list(**body) data = resource_manager.list(**body)
return data return data
@ -260,7 +260,7 @@ class ListCommand(ClimateCommand, lister.Lister):
return self.setup_columns(data, parsed_args) return self.setup_columns(data, parsed_args)
class ShowCommand(ClimateCommand, show.ShowOne): class ShowCommand(BlazarCommand, show.ShowOne):
"""Show information of a given resource.""" """Show information of a given resource."""
api = 'reservation' api = 'reservation'
@ -279,16 +279,16 @@ class ShowCommand(ClimateCommand, show.ShowOne):
def get_data(self, parsed_args): def get_data(self, parsed_args):
self.log.debug('get_data(%s)' % parsed_args) self.log.debug('get_data(%s)' % parsed_args)
climate_client = self.get_client() blazar_client = self.get_client()
if self.allow_names: if self.allow_names:
res_id = utils.find_resource_id_by_name_or_id(climate_client, res_id = utils.find_resource_id_by_name_or_id(blazar_client,
self.resource, self.resource,
parsed_args.id) parsed_args.id)
else: else:
res_id = parsed_args.id res_id = parsed_args.id
resource_manager = getattr(climate_client, self.resource) resource_manager = getattr(blazar_client, self.resource)
data = resource_manager.get(res_id) data = resource_manager.get(res_id)
self.format_output_data(data) self.format_output_data(data)
return zip(*sorted(six.iteritems(data))) return zip(*sorted(six.iteritems(data)))

View File

@ -14,10 +14,10 @@
# limitations under the License. # limitations under the License.
from climateclient.i18n import _ from blazarclient.i18n import _
class ClimateClientException(Exception): class BlazarClientException(Exception):
"""Base exception class.""" """Base exception class."""
message = _("An unknown exception occurred %s.") message = _("An unknown exception occurred %s.")
code = 500 code = 500
@ -34,17 +34,17 @@ class ClimateClientException(Exception):
if not message: if not message:
message = self.message % kwargs message = self.message % kwargs
super(ClimateClientException, self).__init__(message) super(BlazarClientException, self).__init__(message)
class CommandError(ClimateClientException): class CommandError(BlazarClientException):
"""Occurs if not all authentication vital options are set.""" """Occurs if not all authentication vital options are set."""
message = _("You have to provide all options like user name or tenant " message = _("You have to provide all options like user name or tenant "
"id to make authentication possible.") "id to make authentication possible.")
code = 401 code = 401
class NotAuthorized(ClimateClientException): class NotAuthorized(BlazarClientException):
"""HTTP 401 - Not authorized. """HTTP 401 - Not authorized.
User have no enough rights to perform action. User have no enough rights to perform action.
@ -53,26 +53,26 @@ class NotAuthorized(ClimateClientException):
message = _("Not authorized request.") message = _("Not authorized request.")
class NoClimateEndpoint(ClimateClientException): class NoBlazarEndpoint(BlazarClientException):
"""Occurs if no endpoint for Climate set in the Keystone.""" """Occurs if no endpoint for Blazar set in the Keystone."""
message = _("No publicURL endpoint for Climate found. Set endpoint " message = _("No publicURL endpoint for Blazar found. Set endpoint "
"for Climate in the Keystone.") "for Blazar in the Keystone.")
code = 404 code = 404
class NoUniqueMatch(ClimateClientException): class NoUniqueMatch(BlazarClientException):
"""Occurs if there are more than one appropriate resources.""" """Occurs if there are more than one appropriate resources."""
message = _("There is no unique requested resource.") message = _("There is no unique requested resource.")
code = 409 code = 409
class UnsupportedVersion(ClimateClientException): class UnsupportedVersion(BlazarClientException):
"""Occurs if unsupported client version was requested.""" """Occurs if unsupported client version was requested."""
message = _("Unsupported client version requested.") message = _("Unsupported client version requested.")
code = 406 code = 406
class IncorrectLease(ClimateClientException): class IncorrectLease(BlazarClientException):
"""Occurs if lease parameters are incorrect.""" """Occurs if lease parameters are incorrect."""
message = _("The lease parameters are incorrect.") message = _("The lease parameters are incorrect.")
code = 409 code = 409

View File

@ -21,7 +21,7 @@ See http://docs.openstack.org/developer/oslo.i18n/usage.html .
import oslo_i18n import oslo_i18n
_translators = oslo_i18n.TranslatorFactory(domain='climateclient') _translators = oslo_i18n.TranslatorFactory(domain='blazarclient')
# The primary translation function using the well-known name "_" # The primary translation function using the well-known name "_"
_ = _translators.primary _ = _translators.primary

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
""" """
Command-line interface to the Climate APIs Command-line interface to the Blazar APIs
""" """
from __future__ import print_function from __future__ import print_function
@ -29,12 +29,12 @@ from keystoneclient import client as keystone_client
from keystoneclient import exceptions as keystone_exceptions from keystoneclient import exceptions as keystone_exceptions
from oslo_utils import encodeutils from oslo_utils import encodeutils
from climateclient import client as climate_client from blazarclient import client as blazar_client
from climateclient import exception from blazarclient import exception
from climateclient import utils from blazarclient import utils
from climateclient.v1.shell_commands import hosts from blazarclient.v1.shell_commands import hosts
from climateclient.v1.shell_commands import leases from blazarclient.v1.shell_commands import leases
from climateclient import version as base_version from blazarclient import version as base_version
COMMANDS_V1 = { COMMANDS_V1 = {
'lease-list': leases.ListLeases, 'lease-list': leases.ListLeases,
@ -106,17 +106,17 @@ class HelpAction(argparse.Action):
sys.exit(0) sys.exit(0)
class ClimateShell(app.App): class BlazarShell(app.App):
"""Manager class for the Climate CLI.""" """Manager class for the Blazar CLI."""
CONSOLE_MESSAGE_FORMAT = '%(message)s' CONSOLE_MESSAGE_FORMAT = '%(message)s'
DEBUG_MESSAGE_FORMAT = '%(levelname)s: %(name)s %(message)s' DEBUG_MESSAGE_FORMAT = '%(levelname)s: %(name)s %(message)s'
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def __init__(self): def __init__(self):
super(ClimateShell, self).__init__( super(BlazarShell, self).__init__(
description=__doc__.strip(), description=__doc__.strip(),
version=VERSION, version=VERSION,
command_manager=commandmanager.CommandManager('climate.cli'), ) command_manager=commandmanager.CommandManager('blazar.cli'), )
self.commands = COMMANDS self.commands = COMMANDS
def build_option_parser(self, description, version, argparse_kwargs=None): def build_option_parser(self, description, version, argparse_kwargs=None):
@ -247,8 +247,8 @@ class ClimateShell(app.App):
parser.add_argument( parser.add_argument(
'--insecure', '--insecure',
action='store_true', action='store_true',
default=env('CLIMATECLIENT_INSECURE', default=False), default=env('BLAZARCLIENT_INSECURE', default=False),
help="Explicitly allow climateclient to perform \"insecure\" " help="Explicitly allow blazarclient to perform \"insecure\" "
"SSL (https) requests. The server's certificate will " "SSL (https) requests. The server's certificate will "
"not be verified against any certificate authorities. " "not be verified against any certificate authorities. "
"This option should be used with caution.") "This option should be used with caution.")
@ -412,18 +412,18 @@ class ClimateShell(app.App):
if auth: if auth:
try: try:
climate_url = keystone.service_catalog.url_for( blazar_url = keystone.service_catalog.url_for(
service_type='reservation' service_type='reservation'
) )
except keystone_exceptions.EndpointNotFound: except keystone_exceptions.EndpointNotFound:
raise exception.NoClimateEndpoint() raise exception.NoBlazarEndpoint()
else: else:
raise exception.NotAuthorized("User %s is not authorized." % raise exception.NotAuthorized("User %s is not authorized." %
self.options.os_username) self.options.os_username)
client = climate_client.Client(self.options.os_reservation_api_version, client = blazar_client.Client(self.options.os_reservation_api_version,
climate_url=climate_url, blazar_url=blazar_url,
auth_token=keystone.auth_token) auth_token=keystone.auth_token)
self.client = client self.client = client
return return
@ -434,7 +434,7 @@ class ClimateShell(app.App):
* validate authentication info * validate authentication info
""" """
super(ClimateShell, self).initialize_app(argv) super(BlazarShell, self).initialize_app(argv)
cmd_name = None cmd_name = None
if argv: if argv:
@ -473,8 +473,8 @@ class ClimateShell(app.App):
def main(argv=sys.argv[1:]): def main(argv=sys.argv[1:]):
try: try:
return ClimateShell().run(map(encodeutils.safe_decode, argv)) return BlazarShell().run(map(encodeutils.safe_decode, argv))
except exception.ClimateClientException: except exception.BlazarClientException:
return 1 return 1
except Exception as e: except Exception as e:
print(unicode(e)) print(unicode(e))

View File

@ -16,9 +16,9 @@
import requests import requests
from climateclient import base from blazarclient import base
from climateclient import exception from blazarclient import exception
from climateclient import tests from blazarclient import tests
class BaseClientManagerTestCase(tests.TestCase): class BaseClientManagerTestCase(tests.TestCase):
@ -87,7 +87,7 @@ class BaseClientManagerTestCase(tests.TestCase):
kwargs = {"body": {"key": "value"}} kwargs = {"body": {"key": "value"}}
self.assertRaises(exception.ClimateClientException, self.assertRaises(exception.BlazarClientException,
self.manager.request, self.manager.request,
self.url, "POST", **kwargs) self.url, "POST", **kwargs)
@ -97,6 +97,6 @@ class BaseClientManagerTestCase(tests.TestCase):
kwargs = {"body": "key"} kwargs = {"body": "key"}
self.assertRaises(exception.ClimateClientException, self.assertRaises(exception.BlazarClientException,
self.manager.request, self.manager.request,
self.url, "POST", **kwargs) self.url, "POST", **kwargs)

View File

@ -15,9 +15,9 @@
from oslo_utils import importutils from oslo_utils import importutils
from climateclient import client from blazarclient import client
from climateclient import exception from blazarclient import exception
from climateclient import tests from blazarclient import tests
class BaseClientTestCase(tests.TestCase): class BaseClientTestCase(tests.TestCase):
@ -32,12 +32,12 @@ class BaseClientTestCase(tests.TestCase):
def test_with_v1(self): def test_with_v1(self):
self.client.Client() self.client.Client()
self.import_obj.assert_called_once_with( self.import_obj.assert_called_once_with(
'climateclient.v1.client.Client') 'blazarclient.v1.client.Client')
def test_with_v1a0(self): def test_with_v1a0(self):
self.client.Client(version='1a0') self.client.Client(version='1a0')
self.import_obj.assert_called_once_with( self.import_obj.assert_called_once_with(
'climateclient.v1.client.Client') 'blazarclient.v1.client.Client')
def test_with_wrong_vers(self): def test_with_wrong_vers(self):
self.assertRaises(exception.UnsupportedVersion, self.assertRaises(exception.UnsupportedVersion,

View File

@ -16,8 +16,8 @@
import mock import mock
import testtools import testtools
from climateclient import command from blazarclient import command
from climateclient import tests from blazarclient import tests
class OpenstackCommandTestCase(tests.TestCase): class OpenstackCommandTestCase(tests.TestCase):
@ -48,15 +48,15 @@ class TableFormatterTestCase(tests.TestCase):
pass pass
class ClimateCommandTestCase(tests.TestCase): class BlazarCommandTestCase(tests.TestCase):
def setUp(self): def setUp(self):
super(ClimateCommandTestCase, self).setUp() super(BlazarCommandTestCase, self).setUp()
self.app = mock.MagicMock() self.app = mock.MagicMock()
self.parser = self.patch(command.OpenStackCommand, 'get_parser') self.parser = self.patch(command.OpenStackCommand, 'get_parser')
self.command = command.ClimateCommand(self.app, []) self.command = command.BlazarCommand(self.app, [])
def test_get_client(self): def test_get_client(self):
client = self.command.get_client() client = self.command.get_client()

View File

@ -23,10 +23,10 @@ import fixtures
import testtools import testtools
#note(n.s.): you may need it later #note(n.s.): you may need it later
#from climateclient import client as climate_client #from blazarclient import client as blazar_client
#from climateclient import exception #from blazarclient import exception
from climateclient import shell from blazarclient import shell
from climateclient import tests from blazarclient import tests
FAKE_ENV = {'OS_USERNAME': 'username', FAKE_ENV = {'OS_USERNAME': 'username',
'OS_PASSWORD': 'password', 'OS_PASSWORD': 'password',
@ -34,17 +34,17 @@ FAKE_ENV = {'OS_USERNAME': 'username',
'OS_AUTH_URL': 'http://no.where'} 'OS_AUTH_URL': 'http://no.where'}
class ClimateShellTestCase(tests.TestCase): class BlazarShellTestCase(tests.TestCase):
def make_env(self, exclude=None, fake_env=FAKE_ENV): def make_env(self, exclude=None, fake_env=FAKE_ENV):
env = dict((k, v) for k, v in fake_env.items() if k != exclude) env = dict((k, v) for k, v in fake_env.items() if k != exclude)
self.useFixture(fixtures.MonkeyPatch('os.environ', env)) self.useFixture(fixtures.MonkeyPatch('os.environ', env))
def setUp(self): def setUp(self):
super(ClimateShellTestCase, self).setUp() super(BlazarShellTestCase, self).setUp()
#Create shell for non-specific tests #Create shell for non-specific tests
self.climate_shell = shell.ClimateShell() self.blazar_shell = shell.BlazarShell()
def shell(self, argstr, exitcodes=(0,)): def shell(self, argstr, exitcodes=(0,)):
orig = sys.stdout orig = sys.stdout
@ -52,7 +52,7 @@ class ClimateShellTestCase(tests.TestCase):
try: try:
sys.stdout = six.StringIO() sys.stdout = six.StringIO()
sys.stderr = six.StringIO() sys.stderr = six.StringIO()
_shell = shell.ClimateShell() _shell = shell.BlazarShell()
_shell.initialize_app(argstr.split()) _shell.initialize_app(argstr.split())
except SystemExit: except SystemExit:
exc_type, exc_value, exc_traceback = sys.exc_info() exc_type, exc_value, exc_traceback = sys.exc_info()
@ -86,7 +86,7 @@ class ClimateShellTestCase(tests.TestCase):
@testtools.skip('lol') @testtools.skip('lol')
def test_authenticate_user(self): def test_authenticate_user(self):
obj = shell.ClimateShell() obj = shell.BlazarShell()
obj.initialize_app('list-leases') obj.initialize_app('list-leases')
obj.options.os_token = 'aaaa-bbbb-cccc' obj.options.os_token = 'aaaa-bbbb-cccc'
obj.options.os_cacert = 'cert' obj.options.os_cacert = 'cert'

View File

@ -19,8 +19,8 @@ import os
import re import re
import six import six
from climateclient import exception from blazarclient import exception
from climateclient.i18n import _ from blazarclient.i18n import _
HEX_ELEM = '[0-9A-Fa-f]' HEX_ELEM = '[0-9A-Fa-f]'
UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}', UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}',
@ -114,8 +114,8 @@ def find_resource_id_by_name_or_id(client, resource, name_or_id):
for resource in resources: for resource in resources:
if resource['id'] == name_or_id: if resource['id'] == name_or_id:
return name_or_id return name_or_id
raise exception.ClimateClientException('No resource found with ID %s' % raise exception.BlazarClientException('No resource found with ID %s' %
name_or_id) name_or_id)
return _find_resource_id_by_name(client, resource, name_or_id) return _find_resource_id_by_name(client, resource, name_or_id)
@ -137,8 +137,8 @@ def _find_resource_id_by_name(client, resource, name):
return named_resources[0] return named_resources[0]
else: else:
message = "Unable to find resource with name '%s'" % name message = "Unable to find resource with name '%s'" % name
raise exception.ClimateClientException(message=message, raise exception.BlazarClientException(message=message,
status_code=404) status_code=404)
def from_elapsed_time_to_seconds(elapsed_time, pos_sign=True): def from_elapsed_time_to_seconds(elapsed_time, pos_sign=True):
@ -150,8 +150,8 @@ def from_elapsed_time_to_seconds(elapsed_time, pos_sign=True):
""" """
is_elapsed_time = re.match(ELAPSED_TIME_REGEX, elapsed_time) is_elapsed_time = re.match(ELAPSED_TIME_REGEX, elapsed_time)
if is_elapsed_time is None: if is_elapsed_time is None:
raise exception.ClimateClientException(_("Invalid time " raise exception.BlazarClientException(_("Invalid time "
"format for option.")) "format for option."))
elapsed_time_value = int(is_elapsed_time.group(1)) elapsed_time_value = int(is_elapsed_time.group(1))
elapsed_time_option = is_elapsed_time.group(2) elapsed_time_option = is_elapsed_time.group(2)
seconds = { seconds = {

View File

@ -14,12 +14,12 @@
# limitations under the License. # limitations under the License.
from climateclient.v1 import hosts from blazarclient.v1 import hosts
from climateclient.v1 import leases from blazarclient.v1 import leases
class Client(object): class Client(object):
"""Top level object to communicate with Climate. """Top level object to communicate with Blazar.
Contains managers to control requests that should be passed to each type of Contains managers to control requests that should be passed to each type of
resources - leases, events, etc. resources - leases, events, etc.
@ -31,11 +31,11 @@ class Client(object):
... ...
""" """
def __init__(self, climate_url, auth_token): def __init__(self, blazar_url, auth_token):
self.climate_url = climate_url self.blazar_url = blazar_url
self.auth_token = auth_token self.auth_token = auth_token
self.lease = leases.LeaseClientManager(self.climate_url, self.lease = leases.LeaseClientManager(self.blazar_url,
self.auth_token) self.auth_token)
self.host = hosts.ComputeHostClientManager(self.climate_url, self.host = hosts.ComputeHostClientManager(self.blazar_url,
self.auth_token) self.auth_token)

View File

@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from climateclient import base from blazarclient import base
from climateclient.i18n import _ from blazarclient.i18n import _
class ComputeHostClientManager(base.BaseClientManager): class ComputeHostClientManager(base.BaseClientManager):

View File

@ -15,9 +15,9 @@
from oslo_utils import timeutils from oslo_utils import timeutils
from climateclient import base from blazarclient import base
from climateclient.i18n import _ from blazarclient.i18n import _
from climateclient import utils from blazarclient import utils
class LeaseClientManager(base.BaseClientManager): class LeaseClientManager(base.BaseClientManager):

View File

@ -15,7 +15,7 @@
import logging import logging
from climateclient import command from blazarclient import command
class ListHosts(command.ListCommand): class ListHosts(command.ListCommand):

View File

@ -18,8 +18,8 @@ import datetime
import logging import logging
import re import re
from climateclient import command from blazarclient import command
from climateclient import exception from blazarclient import exception
class ListLeases(command.ListCommand): class ListLeases(command.ListCommand):
@ -162,7 +162,7 @@ class CreateLease(command.CreateCommand):
if not phys_res_info['min'] and not phys_res_info['max']: if not phys_res_info['min'] and not phys_res_info['max']:
raise exception.IncorrectLease(err_msg) raise exception.IncorrectLease(err_msg)
# NOTE(sbauza): The resource type should be conf-driven mapped with # NOTE(sbauza): The resource type should be conf-driven mapped with
# climate.conf file but that's potentially on another # blazar.conf file but that's potentially on another
# host # host
phys_res_info['resource_type'] = 'physical:host' phys_res_info['resource_type'] = 'physical:host'
physical_reservations.append(phys_res_info) physical_reservations.append(phys_res_info)

View File

@ -16,4 +16,4 @@
import pbr.version import pbr.version
__version__ = pbr.version.VersionInfo('python-climateclient').version_string() __version__ = pbr.version.VersionInfo('python-blazarclient').version_string()

View File

@ -0,0 +1,20 @@
# Copyright (c) 2017 NTT Inc.
#
# 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.
import os
__path__ = [
os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
'blazarclient')]

View File

@ -1,5 +1,5 @@
[metadata] [metadata]
name = python-climateclient name = python-blazarclient
summary = Client for OpenStack Reservation Service summary = Client for OpenStack Reservation Service
description-file = README.rst description-file = README.rst
license = Apache Software License license = Apache Software License
@ -16,18 +16,19 @@ classifiers =
Operating System :: POSIX :: Linux Operating System :: POSIX :: Linux
author = OpenStack author = OpenStack
author_email = openstack-dev@lists.openstack.org author_email = openstack-dev@lists.openstack.org
home-page = https://launchpad.net/climate home-page = https://launchpad.net/blazar
[global] [global]
setup-hooks = pbr.hooks.setup_hook setup-hooks = pbr.hooks.setup_hook
[files] [files]
packages = packages =
climateclient blazarclient
[entry_points] [entry_points]
console_scripts = console_scripts =
climate = climateclient.shell:main climate = blazarclient.shell:main
blazar = blazarclient.shell:main
[build_sphinx] [build_sphinx]
all_files = 1 all_files = 1

View File

@ -8,8 +8,8 @@ deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
BRANCH_NAME=master BRANCH_NAME=master
CLIENT_NAME=python-climateclient CLIENT_NAME=python-blazarclient
DISCOVER_DIRECTORY=climateclient/tests DISCOVER_DIRECTORY=blazarclient/tests
commands = commands =
python setup.py testr --slowest --testr-args="{posargs}" python setup.py testr --slowest --testr-args="{posargs}"
@ -24,7 +24,7 @@ ignore = E265,H405
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg
[hacking] [hacking]
import_exceptions = climateclient.i18n import_exceptions = blazarclient.i18n
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}