Move shade and os-client-config python content

Make shade be openstack.cloud and os-client-config be openstack.config.

Change-Id: I1d28be82a72cc1a30d6be306257fc1f0736ed604
This commit is contained in:
Monty Taylor 2017-10-04 12:39:43 -05:00
parent a3cd1f0faf
commit 65293358a0
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
248 changed files with 750 additions and 964 deletions
examples
openstack/cloud
__init__.py_adapter.py
_heat
_log.py_normalize.py_tasks.py_utils.py
cmd
exc.pyinventory.pymeta.pyopenstackcloud.pyoperatorcloud.pytask_manager.py
tests

@ -19,8 +19,7 @@ For a full guide see TODO(etoews):link to docs on developer.openstack.org
import argparse import argparse
import os import os
import os_client_config from openstack import config as occ
from openstack import connection from openstack import connection
from openstack import profile from openstack import profile
from openstack import utils from openstack import utils
@ -49,8 +48,8 @@ def _get_resource_value(resource_key, default):
except KeyError: except KeyError:
return default return default
occ = os_client_config.OpenStackConfig() config = occ.OpenStackConfig()
cloud = occ.get_one_cloud(TEST_CLOUD) cloud = config.get_one_cloud(TEST_CLOUD)
SERVER_NAME = 'openstacksdk-example' SERVER_NAME = 'openstacksdk-example'
IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk')
@ -68,14 +67,14 @@ EXAMPLE_IMAGE_NAME = 'openstacksdk-example-public-image'
def create_connection_from_config(): def create_connection_from_config():
opts = Opts(cloud_name=TEST_CLOUD) opts = Opts(cloud_name=TEST_CLOUD)
occ = os_client_config.OpenStackConfig() config = occ.OpenStackConfig()
cloud = occ.get_one_cloud(opts.cloud) cloud = config.get_one_cloud(opts.cloud)
return connection.from_config(cloud_config=cloud, options=opts) return connection.from_config(cloud_config=cloud, options=opts)
def create_connection_from_args(): def create_connection_from_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
config = os_client_config.OpenStackConfig() config = occ.OpenStackConfig()
config.register_argparse_arguments(parser, sys.argv[1:]) config.register_argparse_arguments(parser, sys.argv[1:])
args = parser.parse_args() args = parser.parse_args()
return connection.from_config(options=args) return connection.from_config(options=args)

@ -16,16 +16,16 @@ import logging
import warnings import warnings
import keystoneauth1.exceptions import keystoneauth1.exceptions
import os_client_config
import pbr.version import pbr.version
import requestsexceptions import requestsexceptions
from shade.exc import * # noqa import openstack.config as os_client_config
from shade.openstackcloud import OpenStackCloud from openstack.cloud.exc import * # noqa
from shade.operatorcloud import OperatorCloud from openstack.cloud.openstackcloud import OpenStackCloud
from shade import _log from openstack.cloud.operatorcloud import OperatorCloud
from openstack.cloud import _log
__version__ = pbr.version.VersionInfo('shade').version_string() __version__ = pbr.version.VersionInfo('openstack').version_string()
if requestsexceptions.SubjectAltNameWarning: if requestsexceptions.SubjectAltNameWarning:
warnings.filterwarnings( warnings.filterwarnings(
@ -54,16 +54,13 @@ def simple_logging(debug=False, http_debug=False):
log.addHandler(logging.StreamHandler()) log.addHandler(logging.StreamHandler())
log.setLevel(log_level) log.setLevel(log_level)
# We only want extra shade HTTP tracing in http debug mode # We only want extra shade HTTP tracing in http debug mode
log = _log.setup_logging('shade.http') log = _log.setup_logging('openstack.cloud.http')
log.setLevel(log_level) log.setLevel(log_level)
else: else:
# We only want extra shade HTTP tracing in http debug mode # We only want extra shade HTTP tracing in http debug mode
log = _log.setup_logging('shade.http') log = _log.setup_logging('openstack.cloud.http')
log.setLevel(logging.WARNING) log.setLevel(logging.WARNING)
# Simple case - we only care about request id log during debug log = _log.setup_logging('openstack.cloud')
log = _log.setup_logging('shade.request_ids')
log.setLevel(log_level)
log = _log.setup_logging('shade')
log.addHandler(logging.StreamHandler()) log.addHandler(logging.StreamHandler())
log.setLevel(log_level) log.setLevel(log_level)
# Suppress warning about keystoneauth loggers # Suppress warning about keystoneauth loggers

@ -18,9 +18,9 @@ import functools
from keystoneauth1 import adapter from keystoneauth1 import adapter
from six.moves import urllib from six.moves import urllib
from shade import _log from openstack.cloud import _log
from shade import exc from openstack.cloud import exc
from shade import task_manager from openstack.cloud import task_manager
def extract_name(url): def extract_name(url):
@ -81,13 +81,15 @@ def extract_name(url):
return [part for part in name_parts if part] return [part for part in name_parts if part]
# TODO(shade) This adapter should go away in favor of the work merging
# adapter with openstack.proxy.
class ShadeAdapter(adapter.Adapter): class ShadeAdapter(adapter.Adapter):
def __init__(self, shade_logger, manager, *args, **kwargs): def __init__(self, shade_logger, manager, *args, **kwargs):
super(ShadeAdapter, self).__init__(*args, **kwargs) super(ShadeAdapter, self).__init__(*args, **kwargs)
self.shade_logger = shade_logger self.shade_logger = shade_logger
self.manager = manager self.manager = manager
self.request_log = _log.setup_logging('shade.request_ids') self.request_log = _log.setup_logging('openstack.cloud.request_ids')
def _log_request_id(self, response, obj=None): def _log_request_id(self, response, obj=None):
# Log the request id and object id in a specific logger. This way # Log the request id and object id in a specific logger. This way

@ -12,7 +12,7 @@
import yaml import yaml
from shade._heat import template_format from openstack.cloud._heat import template_format
SECTIONS = ( SECTIONS = (

@ -15,7 +15,7 @@
import collections import collections
import time import time
from shade import meta from openstack.cloud import meta
def get_events(cloud, stack_id, event_args, marker=None, limit=None): def get_events(cloud, stack_id, event_args, marker=None, limit=None):

@ -18,10 +18,10 @@ import six
from six.moves.urllib import parse from six.moves.urllib import parse
from six.moves.urllib import request from six.moves.urllib import request
from shade._heat import environment_format from openstack.cloud._heat import environment_format
from shade._heat import template_format from openstack.cloud._heat import template_format
from shade._heat import utils from openstack.cloud._heat import utils
from shade import exc from openstack.cloud import exc
def get_template_contents(template_file=None, template_url=None, def get_template_contents(template_file=None, template_url=None,

@ -20,7 +20,7 @@ from six.moves.urllib import error
from six.moves.urllib import parse from six.moves.urllib import parse
from six.moves.urllib import request from six.moves.urllib import request
from shade import exc from openstack.cloud import exc
def base_url_for_url(url): def base_url_for_url(url):

@ -12,6 +12,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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.
# TODO(shade) The normalize functions here should get merged in to
# the sdk resource objects.
import datetime import datetime
import munch import munch
import six import six

@ -14,7 +14,7 @@
# 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 shade import task_manager from openstack.cloud import task_manager
class MachineCreate(task_manager.Task): class MachineCreate(task_manager.Task):

@ -27,9 +27,9 @@ import uuid
from decorator import decorator from decorator import decorator
from shade import _log from openstack.cloud import _log
from shade import exc from openstack.cloud import exc
from shade import meta from openstack.cloud import meta
_decorated_methods = [] _decorated_methods = []
@ -48,7 +48,7 @@ def _iterate_timeout(timeout, message, wait=2):
with <message>. with <message>.
""" """
log = _log.setup_logging('shade.iterate_timeout') log = _log.setup_logging('openstack.cloud.iterate_timeout')
try: try:
# None as a wait winds up flowing well in the per-resource cache # None as a wait winds up flowing well in the per-resource cache
@ -128,10 +128,10 @@ def _filter_list(data, name_or_id, filters):
OR OR
A string containing a jmespath expression for further filtering. A string containing a jmespath expression for further filtering.
""" """
# The logger is shade.fmmatch to allow a user/operator to configure logging # The logger is openstack.cloud.fmmatch to allow a user/operator to
# not to communicate about fnmatch misses (they shouldn't be too spammy, # configure logging not to communicate about fnmatch misses
# but one never knows) # (they shouldn't be too spammy, but one never knows)
log = _log.setup_logging('shade.fnmatch') log = _log.setup_logging('openstack.cloud.fnmatch')
if name_or_id: if name_or_id:
# name_or_id might already be unicode # name_or_id might already be unicode
name_or_id = _make_unicode(name_or_id) name_or_id = _make_unicode(name_or_id)

@ -18,8 +18,8 @@ import json
import sys import sys
import yaml import yaml
import shade import openstack.cloud
import shade.inventory import openstack.cloud.inventory
def output_format_dict(data, use_yaml): def output_format_dict(data, use_yaml):
@ -51,8 +51,8 @@ def parse_args():
def main(): def main():
args = parse_args() args = parse_args()
try: try:
shade.simple_logging(debug=args.debug) openstack.cloud.simple_logging(debug=args.debug)
inventory = shade.inventory.OpenStackInventory( inventory = openstack.cloud.inventory.OpenStackInventory(
refresh=args.refresh, private=args.private, refresh=args.refresh, private=args.private,
cloud=args.cloud) cloud=args.cloud)
if args.list: if args.list:
@ -60,7 +60,7 @@ def main():
elif args.host: elif args.host:
output = inventory.get_host(args.host) output = inventory.get_host(args.host)
print(output_format_dict(output, args.yaml)) print(output_format_dict(output, args.yaml))
except shade.OpenStackCloudException as e: except openstack.cloud.OpenStackCloudException as e:
sys.stderr.write(e.message + '\n') sys.stderr.write(e.message + '\n')
sys.exit(1) sys.exit(1)
sys.exit(0) sys.exit(0)

@ -17,7 +17,7 @@ import sys
import munch import munch
from requests import exceptions as _rex from requests import exceptions as _rex
from shade import _log from openstack.cloud import _log
class OpenStackCloudException(Exception): class OpenStackCloudException(Exception):
@ -37,7 +37,7 @@ class OpenStackCloudException(Exception):
def log_error(self, logger=None): def log_error(self, logger=None):
if not logger: if not logger:
logger = _log.setup_logging('shade.exc') logger = _log.setup_logging('openstack.cloud.exc')
if self.inner_exception and self.inner_exception[1]: if self.inner_exception and self.inner_exception[1]:
logger.error(self.orig_message, exc_info=self.inner_exception) logger.error(self.orig_message, exc_info=self.inner_exception)
@ -102,7 +102,7 @@ def _log_response_extras(response):
# Sometimes we get weird HTML errors. This is usually from load balancers # Sometimes we get weird HTML errors. This is usually from load balancers
# or other things. Log them to a special logger so that they can be # or other things. Log them to a special logger so that they can be
# toggled indepdently - and at debug level so that a person logging # toggled indepdently - and at debug level so that a person logging
# shade.* only gets them at debug. # openstack.cloud.* only gets them at debug.
if response.headers.get('content-type') != 'text/html': if response.headers.get('content-type') != 'text/html':
return return
try: try:
@ -110,7 +110,7 @@ def _log_response_extras(response):
return return
except Exception: except Exception:
return return
logger = _log.setup_logging('shade.http') logger = _log.setup_logging('openstack.cloud.http')
if response.reason: if response.reason:
logger.debug( logger.debug(
"Non-standard error '{reason}' returned from {url}:".format( "Non-standard error '{reason}' returned from {url}:".format(

@ -14,10 +14,10 @@
import functools import functools
import os_client_config import openstack.config as os_client_config
import shade import openstack.cloud
from shade import _utils from openstack.cloud import _utils
class OpenStackInventory(object): class OpenStackInventory(object):
@ -38,17 +38,17 @@ class OpenStackInventory(object):
if cloud is None: if cloud is None:
self.clouds = [ self.clouds = [
shade.OpenStackCloud(cloud_config=cloud_config) openstack.cloud.OpenStackCloud(cloud_config=cloud_config)
for cloud_config in config.get_all_clouds() for cloud_config in config.get_all_clouds()
] ]
else: else:
try: try:
self.clouds = [ self.clouds = [
shade.OpenStackCloud( openstack.cloud.OpenStackCloud(
cloud_config=config.get_one_cloud(cloud)) cloud_config=config.get_one_cloud(cloud))
] ]
except os_client_config.exceptions.OpenStackConfigException as e: except os_client_config.exceptions.OpenStackConfigException as e:
raise shade.OpenStackCloudException(e) raise openstack.cloud.OpenStackCloudException(e)
if private: if private:
for cloud in self.clouds: for cloud in self.clouds:
@ -67,7 +67,7 @@ class OpenStackInventory(object):
# Cycle on servers # Cycle on servers
for server in cloud.list_servers(detailed=expand): for server in cloud.list_servers(detailed=expand):
hostvars.append(server) hostvars.append(server)
except shade.OpenStackCloudException: except openstack.cloud.OpenStackCloudException:
# Don't fail on one particular cloud as others may work # Don't fail on one particular cloud as others may work
if fail_on_cloud_config: if fail_on_cloud_config:
raise raise

@ -18,8 +18,8 @@ import ipaddress
import six import six
import socket import socket
from shade import _log from openstack.cloud import _log
from shade import exc from openstack.cloud import exc
NON_CALLABLES = (six.string_types, bool, dict, int, float, list, type(None)) NON_CALLABLES = (six.string_types, bool, dict, int, float, list, type(None))
@ -490,7 +490,7 @@ def _log_request_id(obj, request_id):
if request_id: if request_id:
# Log the request id and object id in a specific logger. This way # Log the request id and object id in a specific logger. This way
# someone can turn it on if they're interested in this kind of tracing. # someone can turn it on if they're interested in this kind of tracing.
log = _log.setup_logging('shade.request_ids') log = _log.setup_logging('openstack.cloud.request_ids')
obj_id = None obj_id = None
if isinstance(obj, dict): if isinstance(obj, dict):
obj_id = obj.get('id', obj.get('uuid')) obj_id = obj.get('id', obj.get('uuid'))

@ -20,8 +20,8 @@ import jsonpatch
import keystoneauth1.session import keystoneauth1.session
import operator import operator
import os import os
import os_client_config import openstack.config
import os_client_config.defaults import openstack.config.defaults
import six import six
import threading import threading
import time import time
@ -34,23 +34,28 @@ from six.moves import urllib
import keystoneauth1.exceptions import keystoneauth1.exceptions
import shade import openstack.cloud
from shade.exc import * # noqa from openstack.cloud.exc import * # noqa
from shade import _adapter from openstack.cloud import _adapter
from shade._heat import event_utils from openstack.cloud._heat import event_utils
from shade._heat import template_utils from openstack.cloud._heat import template_utils
from shade import _log from openstack.cloud import _log
from shade import _legacy_clients from openstack.cloud import _normalize
from shade import _normalize from openstack.cloud import meta
from shade import meta from openstack.cloud import task_manager
from shade import task_manager from openstack.cloud import _utils
from shade import _utils
OBJECT_MD5_KEY = 'x-object-meta-x-shade-md5' # TODO(shade) shade keys were x-object-meta-x-shade-md5 - we need to add those
OBJECT_SHA256_KEY = 'x-object-meta-x-shade-sha256' # to freshness checks so that a shade->sdk transition doens't
IMAGE_MD5_KEY = 'owner_specified.shade.md5' # result in a re-upload
IMAGE_SHA256_KEY = 'owner_specified.shade.sha256' OBJECT_MD5_KEY = 'x-object-meta-x-openstack-md5'
IMAGE_OBJECT_KEY = 'owner_specified.shade.object' OBJECT_SHA256_KEY = 'x-object-meta-x-openstack-sha256'
# TODO(shade) shade keys were owner_specified.shade.md5 - we need to add those
# to freshness checks so that a shade->sdk transition doens't
# result in a re-upload
IMAGE_MD5_KEY = 'owner_specified.openstack.md5'
IMAGE_SHA256_KEY = 'owner_specified.openstack.sha256'
IMAGE_OBJECT_KEY = 'owner_specified.openstack.object'
# Rackspace returns this for intermittent import errors # Rackspace returns this for intermittent import errors
IMAGE_ERROR_396 = "Image cannot be imported. Error code: '396'" IMAGE_ERROR_396 = "Image cannot be imported. Error code: '396'"
DEFAULT_OBJECT_SEGMENT_SIZE = 1073741824 # 1GB DEFAULT_OBJECT_SEGMENT_SIZE = 1073741824 # 1GB
@ -93,9 +98,7 @@ def _no_pending_stacks(stacks):
return True return True
class OpenStackCloud( class OpenStackCloud(_normalize.Normalizer):
_normalize.Normalizer,
_legacy_clients.LegacyClientFactoryMixin):
"""Represent a connection to an OpenStack Cloud. """Represent a connection to an OpenStack Cloud.
OpenStackCloud is the entry point for all cloud operations, regardless OpenStackCloud is the entry point for all cloud operations, regardless
@ -119,7 +122,7 @@ class OpenStackCloud(
emitted to the error log. This flag emitted to the error log. This flag
will enable that behavior. will enable that behavior.
:param bool strict: Only return documented attributes for each resource :param bool strict: Only return documented attributes for each resource
as per the shade Data Model contract. (Default False) as per the Data Model contract. (Default False)
:param app_name: Name of the application to be appended to the user-agent :param app_name: Name of the application to be appended to the user-agent
string. Optional, defaults to None. string. Optional, defaults to None.
:param app_version: Version of the application to be appended to the :param app_version: Version of the application to be appended to the
@ -143,10 +146,10 @@ class OpenStackCloud(
if log_inner_exceptions: if log_inner_exceptions:
OpenStackCloudException.log_inner_exceptions = True OpenStackCloudException.log_inner_exceptions = True
self.log = _log.setup_logging('shade') self.log = _log.setup_logging('openstack.cloud')
if not cloud_config: if not cloud_config:
config = os_client_config.OpenStackConfig( config = openstack.config.OpenStackConfig(
app_name=app_name, app_version=app_version) app_name=app_name, app_version=app_version)
cloud_config = config.get_one_cloud(**kwargs) cloud_config = config.get_one_cloud(**kwargs)
@ -161,8 +164,8 @@ class OpenStackCloud(
self.secgroup_source = cloud_config.config['secgroup_source'] self.secgroup_source = cloud_config.config['secgroup_source']
self.force_ipv4 = cloud_config.force_ipv4 self.force_ipv4 = cloud_config.force_ipv4
self.strict_mode = strict self.strict_mode = strict
# TODO(mordred) When os-client-config adds a "get_client_settings()" # TODO(shade) The openstack.cloud default for get_flavor_extra_specs
# method to CloudConfig - remove this. # should be changed and this should be removed completely
self._extra_config = cloud_config._openstack_config.get_extra_config( self._extra_config = cloud_config._openstack_config.get_extra_config(
'shade', { 'shade', {
'get_flavor_extra_specs': True, 'get_flavor_extra_specs': True,
@ -296,7 +299,6 @@ class OpenStackCloud(
self._keystone_session = None self._keystone_session = None
self._legacy_clients = {}
self._raw_clients = {} self._raw_clients = {}
self._local_ipv6 = ( self._local_ipv6 = (
@ -368,11 +370,17 @@ class OpenStackCloud(
config_major = self._get_major_version_id(config_version) config_major = self._get_major_version_id(config_version)
max_major = self._get_major_version_id(max_version) max_major = self._get_major_version_id(max_version)
min_major = self._get_major_version_id(min_version) min_major = self._get_major_version_id(min_version)
# NOTE(mordred) The shade logic for versions is slightly different # TODO(shade) This should be replaced with use of Connection. However,
# than the ksa Adapter constructor logic. shade knows the versions # we need to find a sane way to deal with this additional
# it knows, and uses them when it detects them. However, if a user # logic - or we need to give up on it. If we give up on it,
# requests a version, and it's not found, and a different one shade # we need to make sure we can still support it in the shade
# does know about it found, that's a warning in shade. # compat layer.
# NOTE(mordred) This logic for versions is slightly different
# than the ksa Adapter constructor logic. openstack.cloud knows the
# versions it knows, and uses them when it detects them. However, if
# a user requests a version, and it's not found, and a different one
# openstack.cloud does know about is found, that's a warning in
# openstack.cloud.
if config_version: if config_version:
if min_major and config_major < min_major: if min_major and config_major < min_major:
raise OpenStackCloudException( raise OpenStackCloudException(
@ -384,7 +392,8 @@ class OpenStackCloud(
elif max_major and config_major > max_major: elif max_major and config_major > max_major:
raise OpenStackCloudException( raise OpenStackCloudException(
"Version {config_version} requested for {service_type}" "Version {config_version} requested for {service_type}"
" but shade understands a maximum of {max_version}".format( " but openstack.cloud understands a maximum of"
" {max_version}".format(
config_version=config_version, config_version=config_version,
service_type=service_type, service_type=service_type,
max_version=max_version)) max_version=max_version))
@ -441,6 +450,8 @@ class OpenStackCloud(
warnings.warn(warning_msg) warnings.warn(warning_msg)
return adapter return adapter
# TODO(shade) This should be replaced with using openstack Connection
# object.
def _get_raw_client( def _get_raw_client(
self, service_type, api_version=None, endpoint_override=None): self, service_type, api_version=None, endpoint_override=None):
return _adapter.ShadeAdapter( return _adapter.ShadeAdapter(
@ -588,7 +599,7 @@ class OpenStackCloud(
self._keystone_session = self.cloud_config.get_session() self._keystone_session = self.cloud_config.get_session()
if hasattr(self._keystone_session, 'additional_user_agent'): if hasattr(self._keystone_session, 'additional_user_agent'):
self._keystone_session.additional_user_agent.append( self._keystone_session.additional_user_agent.append(
('shade', shade.__version__)) ('shade', openstack.cloud.__version__))
except Exception as e: except Exception as e:
raise OpenStackCloudException( raise OpenStackCloudException(
"Error authenticating to keystone: %s " % str(e)) "Error authenticating to keystone: %s " % str(e))
@ -1825,7 +1836,7 @@ class OpenStackCloud(
:param get_extra: Whether or not to fetch extra specs for each flavor. :param get_extra: Whether or not to fetch extra specs for each flavor.
Defaults to True. Default behavior value can be Defaults to True. Default behavior value can be
overridden in clouds.yaml by setting overridden in clouds.yaml by setting
shade.get_extra_specs to False. openstack.cloud.get_extra_specs to False.
:returns: A list of flavor ``munch.Munch``. :returns: A list of flavor ``munch.Munch``.
""" """

@ -17,10 +17,10 @@ import munch
from ironicclient import exceptions as ironic_exceptions from ironicclient import exceptions as ironic_exceptions
from shade.exc import * # noqa from openstack.cloud.exc import * # noqa
from shade import openstackcloud from openstack.cloud import openstackcloud
from shade import _tasks from openstack.cloud import _tasks
from shade import _utils from openstack.cloud import _utils
class OperatorCloud(openstackcloud.OpenStackCloud): class OperatorCloud(openstackcloud.OpenStackCloud):

@ -25,9 +25,9 @@ import keystoneauth1.exceptions
import simplejson import simplejson
import six import six
from shade import _log from openstack.cloud import _log
from shade import exc from openstack.cloud import exc
from shade import meta from openstack.cloud import meta
def _is_listlike(obj): def _is_listlike(obj):
@ -226,7 +226,7 @@ def generate_task_class(method, name, result_filter_cb):
class TaskManager(object): class TaskManager(object):
log = _log.setup_logging('shade.task_manager') log = _log.setup_logging('openstack.cloud.task_manager')
def __init__( def __init__(
self, client, name, result_filter_cb=None, workers=5, **kwargs): self, client, name, result_filter_cb=None, workers=5, **kwargs):

@ -21,8 +21,8 @@ import datetime
import json import json
import uuid import uuid
from shade._heat import template_format from openstack.cloud._heat import template_format
from shade import meta from openstack.cloud import meta
PROJECT_ID = '1c36b64c840a42cd9e9b931a369337f0' PROJECT_ID = '1c36b64c840a42cd9e9b931a369337f0'
FLAVOR_ID = u'0c1d9008-f546-4608-9e8f-f8bdaec8dddd' FLAVOR_ID = u'0c1d9008-f546-4608-9e8f-f8bdaec8dddd'
@ -235,9 +235,9 @@ def make_fake_image(
u'name': u'fake_image', u'name': u'fake_image',
u'checksum': u'ee36e35a297980dee1b514de9803ec6d', u'checksum': u'ee36e35a297980dee1b514de9803ec6d',
u'created_at': u'2016-02-10T05:03:11Z', u'created_at': u'2016-02-10T05:03:11Z',
u'owner_specified.shade.md5': NO_MD5, u'owner_specified.openstack.cloud.md5': NO_MD5,
u'owner_specified.shade.sha256': NO_SHA256, u'owner_specified.openstack.cloud.sha256': NO_SHA256,
u'owner_specified.shade.object': 'images/fake_image', u'owner_specified.openstack.cloud.object': 'images/fake_image',
u'protected': False} u'protected': False}

@ -12,10 +12,10 @@
import os import os
import os_client_config as occ import openstack.config as occ
import shade import openstack.cloud
from shade.tests import base from openstack.cloud.tests import base
class BaseFunctionalTestCase(base.TestCase): class BaseFunctionalTestCase(base.TestCase):
@ -36,14 +36,14 @@ class BaseFunctionalTestCase(base.TestCase):
def _set_user_cloud(self, **kwargs): def _set_user_cloud(self, **kwargs):
user_config = self.config.get_one_cloud( user_config = self.config.get_one_cloud(
cloud=self._demo_name, **kwargs) cloud=self._demo_name, **kwargs)
self.user_cloud = shade.OpenStackCloud( self.user_cloud = openstack.cloud.OpenStackCloud(
cloud_config=user_config, cloud_config=user_config,
log_inner_exceptions=True) log_inner_exceptions=True)
def _set_operator_cloud(self, **kwargs): def _set_operator_cloud(self, **kwargs):
operator_config = self.config.get_one_cloud( operator_config = self.config.get_one_cloud(
cloud=self._op_name, **kwargs) cloud=self._op_name, **kwargs)
self.operator_cloud = shade.OperatorCloud( self.operator_cloud = openstack.cloud.OperatorCloud(
cloud_config=operator_config, cloud_config=operator_config,
log_inner_exceptions=True) log_inner_exceptions=True)

@ -17,7 +17,7 @@ test_aggregate
Functional tests for `shade` aggregate resource. Functional tests for `shade` aggregate resource.
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestAggregate(base.BaseFunctionalTestCase): class TestAggregate(base.BaseFunctionalTestCase):

@ -19,7 +19,7 @@ Funself.ctional tests for `shade` cluster_template methods.
from testtools import content from testtools import content
from shade.tests.functional import base from openstack.cloud.tests.functional import base
import os import os
import subprocess import subprocess
@ -56,7 +56,7 @@ class TestClusterTemplate(base.BaseFunctionalTestCase):
'%s/id_rsa_shade' % ssh_directory]) '%s/id_rsa_shade' % ssh_directory])
# add keypair to nova # add keypair to nova
with open('%s/id_rsa_shade.pub' % ssh_directory) as f: with open('%s/id_rsa_openstack.cloud.pub' % ssh_directory) as f:
key_content = f.read() key_content = f.read()
self.user_cloud.create_keypair('testkey', key_content) self.user_cloud.create_keypair('testkey', key_content)
@ -110,4 +110,4 @@ class TestClusterTemplate(base.BaseFunctionalTestCase):
# delete keypair # delete keypair
self.user_cloud.delete_keypair('testkey') self.user_cloud.delete_keypair('testkey')
os.unlink('/tmp/.ssh/id_rsa_shade') os.unlink('/tmp/.ssh/id_rsa_shade')
os.unlink('/tmp/.ssh/id_rsa_shade.pub') os.unlink('/tmp/.ssh/id_rsa_openstack.cloud.pub')

@ -20,10 +20,10 @@ Functional tests for `shade` compute methods.
from fixtures import TimeoutException from fixtures import TimeoutException
import six import six
from shade import exc from openstack.cloud import exc
from shade.tests.functional import base from openstack.cloud.tests.functional import base
from shade.tests.functional.util import pick_flavor from openstack.cloud.tests.functional.util import pick_flavor
from shade import _utils from openstack.cloud import _utils
class TestCompute(base.BaseFunctionalTestCase): class TestCompute(base.BaseFunctionalTestCase):

@ -24,7 +24,7 @@ import os
from testscenarios import load_tests_apply_scenarios as load_tests # noqa from testscenarios import load_tests_apply_scenarios as load_tests # noqa
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestDevstack(base.BaseFunctionalTestCase): class TestDevstack(base.BaseFunctionalTestCase):

@ -19,8 +19,8 @@ test_domain
Functional tests for `shade` keystone domain resource. Functional tests for `shade` keystone domain resource.
""" """
import shade import openstack.cloud
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestDomain(base.BaseFunctionalTestCase): class TestDomain(base.BaseFunctionalTestCase):
@ -46,7 +46,8 @@ class TestDomain(base.BaseFunctionalTestCase):
if exception_list: if exception_list:
# Raise an error: we must make users aware that something went # Raise an error: we must make users aware that something went
# wrong # wrong
raise shade.OpenStackCloudException('\n'.join(exception_list)) raise openstack.cloud.OpenStackCloudException(
'\n'.join(exception_list))
def test_search_domains(self): def test_search_domains(self):
domain_name = self.domain_prefix + '_search' domain_name = self.domain_prefix + '_search'

@ -24,9 +24,9 @@ Functional tests for `shade` endpoint resource.
import string import string
import random import random
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.exc import OpenStackCloudUnavailableFeature from openstack.cloud.exc import OpenStackCloudUnavailableFeature
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestEndpoints(base.KeystoneBaseFunctionalTestCase): class TestEndpoints(base.KeystoneBaseFunctionalTestCase):

@ -21,8 +21,8 @@ test_flavor
Functional tests for `shade` flavor resource. Functional tests for `shade` flavor resource.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestFlavor(base.BaseFunctionalTestCase): class TestFlavor(base.BaseFunctionalTestCase):

@ -23,11 +23,11 @@ import pprint
from testtools import content from testtools import content
from shade import _utils from openstack.cloud import _utils
from shade import meta from openstack.cloud import meta
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
from shade.tests.functional.util import pick_flavor from openstack.cloud.tests.functional.util import pick_flavor
class TestFloatingIP(base.BaseFunctionalTestCase): class TestFloatingIP(base.BaseFunctionalTestCase):

@ -19,7 +19,7 @@ test_floating_ip_pool
Functional tests for floating IP pool resource (managed by nova) Functional tests for floating IP pool resource (managed by nova)
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
# When using nova-network, floating IP pools are created with nova-manage # When using nova-network, floating IP pools are created with nova-manage

@ -19,8 +19,8 @@ test_groups
Functional tests for `shade` keystone group resource. Functional tests for `shade` keystone group resource.
""" """
import shade import openstack.cloud
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestGroup(base.BaseFunctionalTestCase): class TestGroup(base.BaseFunctionalTestCase):
@ -46,7 +46,8 @@ class TestGroup(base.BaseFunctionalTestCase):
if exception_list: if exception_list:
# Raise an error: we must make users aware that something went # Raise an error: we must make users aware that something went
# wrong # wrong
raise shade.OpenStackCloudException('\n'.join(exception_list)) raise openstack.cloud.OpenStackCloudException(
'\n'.join(exception_list))
def test_create_group(self): def test_create_group(self):
group_name = self.group_prefix + '_create' group_name = self.group_prefix + '_create'

@ -20,8 +20,8 @@ Functional tests for `shade` identity methods.
import random import random
import string import string
from shade import OpenStackCloudException from openstack.cloud import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestIdentity(base.KeystoneBaseFunctionalTestCase): class TestIdentity(base.KeystoneBaseFunctionalTestCase):

@ -21,7 +21,7 @@ import filecmp
import os import os
import tempfile import tempfile
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestImage(base.BaseFunctionalTestCase): class TestImage(base.BaseFunctionalTestCase):

@ -19,10 +19,10 @@ test_inventory
Functional tests for `shade` inventory methods. Functional tests for `shade` inventory methods.
""" """
from shade import inventory from openstack.cloud import inventory
from shade.tests.functional import base from openstack.cloud.tests.functional import base
from shade.tests.functional.util import pick_flavor from openstack.cloud.tests.functional.util import pick_flavor
class TestInventory(base.BaseFunctionalTestCase): class TestInventory(base.BaseFunctionalTestCase):

@ -16,8 +16,8 @@ test_keypairs
Functional tests for `shade` keypairs methods Functional tests for `shade` keypairs methods
""" """
from shade.tests import fakes from openstack.cloud.tests import fakes
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestKeypairs(base.BaseFunctionalTestCase): class TestKeypairs(base.BaseFunctionalTestCase):

@ -16,7 +16,7 @@ test_limits
Functional tests for `shade` limits method Functional tests for `shade` limits method
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestUsage(base.BaseFunctionalTestCase): class TestUsage(base.BaseFunctionalTestCase):

@ -17,7 +17,7 @@ test_magnum_services
Functional tests for `shade` services method. Functional tests for `shade` services method.
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestMagnumServices(base.BaseFunctionalTestCase): class TestMagnumServices(base.BaseFunctionalTestCase):

@ -17,8 +17,8 @@ test_network
Functional tests for `shade` network methods. Functional tests for `shade` network methods.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestNetwork(base.BaseFunctionalTestCase): class TestNetwork(base.BaseFunctionalTestCase):

@ -23,8 +23,8 @@ import tempfile
from testtools import content from testtools import content
from shade import exc from openstack.cloud import exc
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestObject(base.BaseFunctionalTestCase): class TestObject(base.BaseFunctionalTestCase):

@ -24,8 +24,8 @@ Functional tests for `shade` port resource.
import string import string
import random import random
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestPort(base.BaseFunctionalTestCase): class TestPort(base.BaseFunctionalTestCase):

@ -21,8 +21,8 @@ test_project
Functional tests for `shade` project resource. Functional tests for `shade` project resource.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestProject(base.KeystoneBaseFunctionalTestCase): class TestProject(base.KeystoneBaseFunctionalTestCase):

@ -18,8 +18,8 @@ test_qos_bandwidth_limit_rule
Functional tests for `shade`QoS bandwidth limit methods. Functional tests for `shade`QoS bandwidth limit methods.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestQosBandwidthLimitRule(base.BaseFunctionalTestCase): class TestQosBandwidthLimitRule(base.BaseFunctionalTestCase):

@ -18,8 +18,8 @@ test_qos_dscp_marking_rule
Functional tests for `shade`QoS DSCP marking rule methods. Functional tests for `shade`QoS DSCP marking rule methods.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestQosDscpMarkingRule(base.BaseFunctionalTestCase): class TestQosDscpMarkingRule(base.BaseFunctionalTestCase):

@ -18,8 +18,8 @@ test_qos_minumum_bandwidth_rule
Functional tests for `shade`QoS minimum bandwidth methods. Functional tests for `shade`QoS minimum bandwidth methods.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestQosMinimumBandwidthRule(base.BaseFunctionalTestCase): class TestQosMinimumBandwidthRule(base.BaseFunctionalTestCase):

@ -18,8 +18,8 @@ test_qos_policy
Functional tests for `shade`QoS policies methods. Functional tests for `shade`QoS policies methods.
""" """
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestQosPolicy(base.BaseFunctionalTestCase): class TestQosPolicy(base.BaseFunctionalTestCase):

@ -17,7 +17,7 @@ test_quotas
Functional tests for `shade` quotas methods. Functional tests for `shade` quotas methods.
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestComputeQuotas(base.BaseFunctionalTestCase): class TestComputeQuotas(base.BaseFunctionalTestCase):

@ -15,8 +15,8 @@
# limitations under the License. # limitations under the License.
from shade import exc from openstack.cloud import exc
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestRangeSearch(base.BaseFunctionalTestCase): class TestRangeSearch(base.BaseFunctionalTestCase):

@ -19,7 +19,7 @@ Functional tests for `shade` recordset methods.
from testtools import content from testtools import content
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestRecordset(base.BaseFunctionalTestCase): class TestRecordset(base.BaseFunctionalTestCase):

@ -19,8 +19,8 @@ Functional tests for `shade` router methods.
import ipaddress import ipaddress
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
EXPECTED_TOPLEVEL_FIELDS = ( EXPECTED_TOPLEVEL_FIELDS = (

@ -17,7 +17,7 @@ test_security_groups
Functional tests for `shade` security_groups resource. Functional tests for `shade` security_groups resource.
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestSecurityGroups(base.BaseFunctionalTestCase): class TestSecurityGroups(base.BaseFunctionalTestCase):

@ -17,7 +17,7 @@ test_server_group
Functional tests for `shade` server_group resource. Functional tests for `shade` server_group resource.
""" """
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestServerGroup(base.BaseFunctionalTestCase): class TestServerGroup(base.BaseFunctionalTestCase):

@ -24,9 +24,9 @@ Functional tests for `shade` service resource.
import string import string
import random import random
from shade.exc import OpenStackCloudException from openstack.cloud.exc import OpenStackCloudException
from shade.exc import OpenStackCloudUnavailableFeature from openstack.cloud.exc import OpenStackCloudUnavailableFeature
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestServices(base.KeystoneBaseFunctionalTestCase): class TestServices(base.KeystoneBaseFunctionalTestCase):

@ -19,9 +19,9 @@ Functional tests for `shade` stack methods.
import tempfile import tempfile
from shade import exc from openstack.cloud import exc
from shade.tests import fakes from openstack.cloud.tests import fakes
from shade.tests.functional import base from openstack.cloud.tests.functional import base
simple_template = '''heat_template_version: 2014-10-16 simple_template = '''heat_template_version: 2014-10-16
parameters: parameters:

@ -20,7 +20,7 @@ Functional tests for `shade` usage method
""" """
import datetime import datetime
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestUsage(base.BaseFunctionalTestCase): class TestUsage(base.BaseFunctionalTestCase):

@ -17,9 +17,9 @@ test_users
Functional tests for `shade` user methods. Functional tests for `shade` user methods.
""" """
from shade import operator_cloud from openstack.cloud import operator_cloud
from shade import OpenStackCloudException from openstack.cloud import OpenStackCloudException
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestUsers(base.KeystoneBaseFunctionalTestCase): class TestUsers(base.KeystoneBaseFunctionalTestCase):

@ -20,9 +20,9 @@ Functional tests for `shade` block storage methods.
from fixtures import TimeoutException from fixtures import TimeoutException
from testtools import content from testtools import content
from shade import _utils from openstack.cloud import _utils
from shade import exc from openstack.cloud import exc
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestVolume(base.BaseFunctionalTestCase): class TestVolume(base.BaseFunctionalTestCase):

@ -9,7 +9,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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 shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestVolume(base.BaseFunctionalTestCase): class TestVolume(base.BaseFunctionalTestCase):

@ -19,8 +19,8 @@ test_volume
Functional tests for `shade` block storage methods. Functional tests for `shade` block storage methods.
""" """
import testtools import testtools
from shade import exc from openstack.cloud import exc
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestVolumeType(base.BaseFunctionalTestCase): class TestVolumeType(base.BaseFunctionalTestCase):

@ -19,7 +19,7 @@ Functional tests for `shade` zone methods.
from testtools import content from testtools import content
from shade.tests.functional import base from openstack.cloud.tests.functional import base
class TestZone(base.BaseFunctionalTestCase): class TestZone(base.BaseFunctionalTestCase):

@ -20,14 +20,14 @@ import uuid
import fixtures import fixtures
import mock import mock
import os import os
import os_client_config as occ import openstack.config as occ
from requests import structures from requests import structures
from requests_mock.contrib import fixture as rm_fixture from requests_mock.contrib import fixture as rm_fixture
from six.moves import urllib from six.moves import urllib
import tempfile import tempfile
import shade.openstackcloud import openstack.cloud.openstackcloud
from shade.tests import base from openstack.cloud.tests import base
_ProjectData = collections.namedtuple( _ProjectData = collections.namedtuple(
@ -125,14 +125,14 @@ class BaseTestCase(base.TestCase):
secure_files=['non-existant']) secure_files=['non-existant'])
self.cloud_config = self.config.get_one_cloud( self.cloud_config = self.config.get_one_cloud(
cloud=test_cloud, validate=False) cloud=test_cloud, validate=False)
self.cloud = shade.OpenStackCloud( self.cloud = openstack.cloud.OpenStackCloud(
cloud_config=self.cloud_config, cloud_config=self.cloud_config,
log_inner_exceptions=True) log_inner_exceptions=True)
self.strict_cloud = shade.OpenStackCloud( self.strict_cloud = openstack.cloud.OpenStackCloud(
cloud_config=self.cloud_config, cloud_config=self.cloud_config,
log_inner_exceptions=True, log_inner_exceptions=True,
strict=True) strict=True)
self.op_cloud = shade.OperatorCloud( self.op_cloud = openstack.cloud.OperatorCloud(
cloud_config=self.cloud_config, cloud_config=self.cloud_config,
log_inner_exceptions=True) log_inner_exceptions=True)
@ -161,7 +161,8 @@ class RequestsMockTestCase(BaseTestCase):
# assert_calls (and calling assert_calls every test case that uses # assert_calls (and calling assert_calls every test case that uses
# it on cleanup). Subclassing here could be 100% eliminated in the # it on cleanup). Subclassing here could be 100% eliminated in the
# future allowing any class to simply # future allowing any class to simply
# self.useFixture(shade.RequestsMockFixture) and get all the benefits. # self.useFixture(openstack.cloud.RequestsMockFixture) and get all
# the benefits.
# NOTE(notmorgan): use an ordered dict here to ensure we preserve the # NOTE(notmorgan): use an ordered dict here to ensure we preserve the
# order in which items are added to the uri_registry. This makes # order in which items are added to the uri_registry. This makes
@ -446,10 +447,10 @@ class RequestsMockTestCase(BaseTestCase):
test_cloud = os.environ.get('SHADE_OS_CLOUD', cloud_name) test_cloud = os.environ.get('SHADE_OS_CLOUD', cloud_name)
self.cloud_config = self.config.get_one_cloud( self.cloud_config = self.config.get_one_cloud(
cloud=test_cloud, validate=True, **kwargs) cloud=test_cloud, validate=True, **kwargs)
self.cloud = shade.OpenStackCloud( self.cloud = openstack.cloud.OpenStackCloud(
cloud_config=self.cloud_config, cloud_config=self.cloud_config,
log_inner_exceptions=True) log_inner_exceptions=True)
self.op_cloud = shade.OperatorCloud( self.op_cloud = openstack.cloud.OperatorCloud(
cloud_config=self.cloud_config, cloud_config=self.cloud_config,
log_inner_exceptions=True) log_inner_exceptions=True)

Some files were not shown because too many files have changed in this diff Show More