Sync with oslo_incubator

This patch resync openstack common modules from oslo_incubator. The most
significant changes include the migration to namespace oslo_foo and the
deletion of uuidutils.py (moved to oslo_utils now).

Change-Id: I133f15c99b4dd9efaede357a06b4e4e0246a5fbb
This commit is contained in:
tengqm 2015-03-23 20:25:49 +08:00
parent d4dab8c875
commit 0146483fab
8 changed files with 92 additions and 72 deletions

View File

@ -16,25 +16,30 @@ See http://docs.openstack.org/developer/oslo.i18n/usage.html
"""
import oslo.i18n
try:
import oslo_i18n
# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
# application name when this module is synced into the separate
# repository. It is OK to have more than one translation function
# using the same domain, since there will still only be one message
# catalog.
_translators = oslo_i18n.TranslatorFactory(domain='heatclient')
# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
# application name when this module is synced into the separate
# repository. It is OK to have more than one translation function
# using the same domain, since there will still only be one message
# catalog.
_translators = oslo.i18n.TranslatorFactory(domain='heatclient')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
except ImportError:
# NOTE(dims): Support for cases where a project wants to use
# code from oslo-incubator, but is not ready to be internationalized
# (like tempest)
_ = _LI = _LW = _LE = _LC = lambda x: x

View File

@ -17,6 +17,19 @@
# E0202: An attribute inherited from %s hide this method
# pylint: disable=E0202
########################################################################
#
# THIS MODULE IS DEPRECATED
#
# Please refer to
# https://etherpad.openstack.org/p/kilo-oslo-library-proposals for
# the discussion leading to this deprecation.
#
# We recommend checking out the python-openstacksdk project
# (https://launchpad.net/python-openstacksdk) instead.
#
########################################################################
import abc
import argparse
import os

View File

@ -20,13 +20,27 @@
Base utilities to build API operation managers and objects on top of.
"""
########################################################################
#
# THIS MODULE IS DEPRECATED
#
# Please refer to
# https://etherpad.openstack.org/p/kilo-oslo-library-proposals for
# the discussion leading to this deprecation.
#
# We recommend checking out the python-openstacksdk project
# (https://launchpad.net/python-openstacksdk) instead.
#
########################################################################
# E1102: %s is not callable
# pylint: disable=E1102
import abc
import copy
from oslo.utils import strutils
from oslo_utils import strutils
import six
from six.moves.urllib import parse

View File

@ -34,8 +34,8 @@ try:
except ImportError:
import json
from oslo.utils import encodeutils
from oslo.utils import importutils
from oslo_utils import encodeutils
from oslo_utils import importutils
import requests
from heatclient.openstack.common._i18n import _
@ -118,7 +118,7 @@ class HTTPClient(object):
return
string_parts = [
"curl -i",
"curl -g -i",
"-X '%s'" % method,
"'%s'" % url,
]

View File

@ -21,6 +21,19 @@ wrong the tests might raise AssertionError. I've indicated in comments the
places where actual behavior differs from the spec.
"""
########################################################################
#
# THIS MODULE IS DEPRECATED
#
# Please refer to
# https://etherpad.openstack.org/p/kilo-oslo-library-proposals for
# the discussion leading to this deprecation.
#
# We recommend checking out the python-openstacksdk project
# (https://launchpad.net/python-openstacksdk) instead.
#
########################################################################
# W0102: Dangerous default value %s as argument
# pylint: disable=W0102
@ -30,7 +43,6 @@ import requests
import six
from six.moves.urllib import parse
from heatclient.openstack.common._i18n import _
from heatclient.openstack.common.apiclient import client
@ -42,7 +54,7 @@ def assert_has_keys(dct, required=None, optional=None):
assert k in dct
except AssertionError:
extra_keys = set(dct.keys()).difference(set(required + optional))
raise AssertionError(_("found unexpected keys: %s") %
raise AssertionError("found unexpected keys: %s" %
list(extra_keys))
@ -92,9 +104,9 @@ class FakeHTTPClient(client.HTTPClient):
expected = (method, url)
called = self.callstack[pos][0:2]
assert self.callstack, \
_("Expected %s %s but no calls were made.") % expected
"Expected %s %s but no calls were made." % expected
assert expected == called, _('Expected %s %s; got %s %s') % \
assert expected == called, 'Expected %s %s; got %s %s' % \
(expected + called)
if body is not None:
@ -108,7 +120,7 @@ class FakeHTTPClient(client.HTTPClient):
expected = (method, url)
assert self.callstack, \
_("Expected %s %s but no calls were made.") % expected
"Expected %s %s but no calls were made." % expected
found = False
entry = None
@ -117,7 +129,7 @@ class FakeHTTPClient(client.HTTPClient):
found = True
break
assert found, _('Expected %s %s; got %s') % \
assert found, 'Expected %s %s; got %s' % \
(method, url, self.callstack)
if body is not None:
assert entry[3] == body, "%s != %s" % (entry[3], body)
@ -159,8 +171,8 @@ class FakeHTTPClient(client.HTTPClient):
callback = "%s_%s" % (method.lower(), munged_url)
if not hasattr(self, callback):
raise AssertionError(_('Called unknown API method: %s %s, '
'expected fakes method name: %s') %
raise AssertionError('Called unknown API method: %s %s, '
'expected fakes method name: %s' %
(method, url, callback))
resp = getattr(self, callback)(**kwargs)

View File

@ -11,12 +11,25 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import encodeutils
########################################################################
#
# THIS MODULE IS DEPRECATED
#
# Please refer to
# https://etherpad.openstack.org/p/kilo-oslo-library-proposals for
# the discussion leading to this deprecation.
#
# We recommend checking out the python-openstacksdk project
# (https://launchpad.net/python-openstacksdk) instead.
#
########################################################################
from oslo_utils import encodeutils
from oslo_utils import uuidutils
import six
from heatclient.openstack.common._i18n import _
from heatclient.openstack.common.apiclient import exceptions
from heatclient.openstack.common import uuidutils
def find_resource(manager, name_or_id, **find_args):

View File

@ -24,8 +24,8 @@ import os
import sys
import textwrap
from oslo.utils import encodeutils
from oslo.utils import strutils
from oslo_utils import encodeutils
from oslo_utils import strutils
import prettytable
import six
from six import moves

View File

@ -1,37 +0,0 @@
# Copyright (c) 2012 Intel Corporation.
# 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.
"""
UUID related utilities and helper functions.
"""
import uuid
def generate_uuid():
return str(uuid.uuid4())
def is_uuid_like(val):
"""Returns validation of a value as a UUID.
For our purposes, a UUID is a canonical form string:
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
"""
try:
return str(uuid.UUID(val)) == val
except (TypeError, ValueError, AttributeError):
return False