Merge "Move openstack_cloud helper functions"
This commit is contained in:
commit
9c8a528917
README.rst
doc/source/user
examples/cloud
cleanup-servers.pycreate-server-dict.pycreate-server-name-or-id.pydebug-logging.pyfind-an-image.pyhttp-debug-logging.pymunch-dict-object.pynormalization.py
openstack
__init__.py
cloud
connection.pytests
functional/cloud
unit
base.py
cloud
test_caching.pytest_cluster_templates.pytest_create_server.pytest_domain_params.pytest_domains.pytest_flavors.pytest_floating_ip_common.pytest_floating_ip_pool.pytest_identity_roles.pytest_image.pytest_inventory.pytest_meta.pytest_network.pytest_object.pytest_operator.pytest_operator_noauth.pytest_project.pytest_security_groups.pytest_services.pytest_shade.pytest_stack.pytest_users.pytest_volume.pytest_volume_access.py
@ -138,14 +138,14 @@ Create a server using objects configured with the ``clouds.yaml`` file:
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import openstack
|
import openstack.cloud
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
# Initialize cloud
|
# Initialize cloud
|
||||||
# Cloud configs are read with openstack.config
|
# Cloud configs are read with openstack.config
|
||||||
cloud = openstack.openstack_cloud(cloud='mordred')
|
cloud = openstack.cloud.openstack_cloud(cloud='mordred')
|
||||||
|
|
||||||
# Upload an image to the cloud
|
# Upload an image to the cloud
|
||||||
image = cloud.create_image(
|
image = cloud.create_image(
|
||||||
|
@ -62,7 +62,7 @@ Complete Example
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
@ -314,7 +314,7 @@ Complete Example Again
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
@ -346,7 +346,7 @@ Import the library
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
Logging
|
Logging
|
||||||
=======
|
=======
|
||||||
@ -373,7 +373,7 @@ Example with Debug Logging
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.openstack_cloud(
|
||||||
@ -387,7 +387,7 @@ Example with HTTP Debug Logging
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.openstack_cloud(
|
||||||
@ -484,7 +484,7 @@ Image and Flavor by Name or ID
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
@ -531,7 +531,7 @@ Image and Flavor by Dict
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
@ -562,7 +562,7 @@ Munch Objects
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='zetta', region_name='no-osl1')
|
cloud = openstack.openstack_cloud(cloud='zetta', region_name='no-osl1')
|
||||||
@ -594,7 +594,7 @@ Cleanup Script
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
@ -616,7 +616,7 @@ Normalization
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
||||||
@ -632,7 +632,7 @@ Strict Normalized Results
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.openstack_cloud(
|
||||||
@ -649,7 +649,7 @@ How Did I Find the Image Name for the Last Example?
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
||||||
@ -670,7 +670,7 @@ Added / Modified Information
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='my-citycloud', region_name='Buf1')
|
cloud = openstack.openstack_cloud(cloud='my-citycloud', region_name='Buf1')
|
||||||
@ -712,7 +712,7 @@ User Agent Info
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.openstack_cloud(
|
||||||
@ -730,7 +730,7 @@ Uploading Large Objects
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
||||||
@ -751,7 +751,7 @@ Uploading Large Objects
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
||||||
@ -767,7 +767,7 @@ Service Conditionals
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='kiss', region_name='region1')
|
cloud = openstack.openstack_cloud(cloud='kiss', region_name='region1')
|
||||||
@ -781,7 +781,7 @@ Service Conditional Overrides
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='rax', region_name='DFW')
|
cloud = openstack.openstack_cloud(cloud='rax', region_name='DFW')
|
||||||
|
@ -15,8 +15,8 @@ To use `openstack.cloud` in a project:
|
|||||||
objects can be accessed using either dictionary or object notation
|
objects can be accessed using either dictionary or object notation
|
||||||
(e.g., ``server.id``, ``image.name`` and ``server['id']``, ``image['name']``)
|
(e.g., ``server.id``, ``image.name`` and ``server['id']``, ``image['name']``)
|
||||||
|
|
||||||
.. autoclass:: openstack.OpenStackCloud
|
.. autoclass:: openstack.cloud.OpenStackCloud
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
.. autoclass:: openstack.OperatorCloud
|
.. autoclass:: openstack.cloud.OperatorCloud
|
||||||
:members:
|
:members:
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
|
|
||||||
# Initialize and turn on debug logging
|
# Initialize and turn on debug logging
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.openstack_cloud(
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(http_debug=True)
|
openstack.enable_logging(http_debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(
|
cloud = openstack.openstack_cloud(
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging(debug=True)
|
openstack.enable_logging(debug=True)
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
cloud = openstack.openstack_cloud(cloud='ovh', region_name='SBG1')
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import openstack
|
from openstack import cloud as openstack
|
||||||
openstack.enable_logging()
|
openstack.enable_logging()
|
||||||
|
|
||||||
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
cloud = openstack.openstack_cloud(cloud='fuga', region_name='cystack')
|
||||||
|
@ -17,97 +17,7 @@ __all__ = [
|
|||||||
'enable_logging',
|
'enable_logging',
|
||||||
]
|
]
|
||||||
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
import keystoneauth1.exceptions
|
|
||||||
import requestsexceptions
|
|
||||||
|
|
||||||
from openstack._log import enable_logging # noqa
|
from openstack._log import enable_logging # noqa
|
||||||
from openstack.cloud.exc import * # noqa
|
|
||||||
# TODO(shade) These two want to be removed before we make a release
|
|
||||||
from openstack.cloud.openstackcloud import OpenStackCloud
|
|
||||||
from openstack.cloud.operatorcloud import OperatorCloud
|
|
||||||
import openstack.connection
|
import openstack.connection
|
||||||
|
|
||||||
if requestsexceptions.SubjectAltNameWarning:
|
connect = openstack.connection.Connection
|
||||||
warnings.filterwarnings(
|
|
||||||
'ignore', category=requestsexceptions.SubjectAltNameWarning)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_openstack_config(app_name=None, app_version=None):
|
|
||||||
import openstack.config
|
|
||||||
return openstack.config.OpenStackConfig(
|
|
||||||
app_name=app_name, app_version=app_version)
|
|
||||||
|
|
||||||
|
|
||||||
# TODO(shade) This wants to be remove before we make a release.
|
|
||||||
def openstack_clouds(
|
|
||||||
config=None, debug=False, cloud=None, strict=False,
|
|
||||||
app_name=None, app_version=None):
|
|
||||||
if not config:
|
|
||||||
config = _get_openstack_config(app_name, app_version)
|
|
||||||
try:
|
|
||||||
if cloud is None:
|
|
||||||
return [
|
|
||||||
OpenStackCloud(
|
|
||||||
cloud=f.name, debug=debug,
|
|
||||||
cloud_config=cloud_region,
|
|
||||||
strict=strict)
|
|
||||||
for cloud_region in config.get_all()
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
return [
|
|
||||||
OpenStackCloud(
|
|
||||||
cloud=f.name, debug=debug,
|
|
||||||
cloud_config=cloud_region,
|
|
||||||
strict=strict)
|
|
||||||
for cloud_region in config.get_all()
|
|
||||||
if cloud_region.name == cloud
|
|
||||||
]
|
|
||||||
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
|
||||||
raise OpenStackCloudException(
|
|
||||||
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
|
||||||
|
|
||||||
|
|
||||||
# TODO(shade) This wants to be removed before we make a release.
|
|
||||||
def openstack_cloud(
|
|
||||||
config=None, strict=False, app_name=None, app_version=None, **kwargs):
|
|
||||||
if not config:
|
|
||||||
config = _get_openstack_config(app_name, app_version)
|
|
||||||
try:
|
|
||||||
cloud_region = config.get_one(**kwargs)
|
|
||||||
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
|
||||||
raise OpenStackCloudException(
|
|
||||||
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
|
||||||
return OpenStackCloud(cloud_config=cloud_region, strict=strict)
|
|
||||||
|
|
||||||
|
|
||||||
# TODO(shade) This wants to be removed before we make a release.
|
|
||||||
def operator_cloud(
|
|
||||||
config=None, strict=False, app_name=None, app_version=None, **kwargs):
|
|
||||||
if not config:
|
|
||||||
config = _get_openstack_config(app_name, app_version)
|
|
||||||
try:
|
|
||||||
cloud_region = config.get_one(**kwargs)
|
|
||||||
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
|
||||||
raise OpenStackCloudException(
|
|
||||||
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
|
||||||
return OperatorCloud(cloud_config=cloud_region, strict=strict)
|
|
||||||
|
|
||||||
|
|
||||||
def connect(*args, **kwargs):
|
|
||||||
"""Create a `openstack.connection.Connection`."""
|
|
||||||
return openstack.connection.Connection(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def connect_all(config=None, app_name=None, app_version=None):
|
|
||||||
if not config:
|
|
||||||
config = _get_openstack_config(app_name, app_version)
|
|
||||||
try:
|
|
||||||
return [
|
|
||||||
openstack.connection.Connection(config=cloud_region)
|
|
||||||
for cloud_region in config.get_all()
|
|
||||||
]
|
|
||||||
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
|
||||||
raise OpenStackCloudException(
|
|
||||||
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# 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 keystoneauth1.exceptions
|
||||||
|
|
||||||
|
from openstack._log import enable_logging # noqa
|
||||||
|
from openstack.cloud.exc import * # noqa
|
||||||
|
from openstack.cloud.openstackcloud import OpenStackCloud
|
||||||
|
from openstack.cloud.operatorcloud import OperatorCloud
|
||||||
|
|
||||||
|
|
||||||
|
def _get_openstack_config(app_name=None, app_version=None):
|
||||||
|
import openstack.config
|
||||||
|
return openstack.config.OpenStackConfig(
|
||||||
|
app_name=app_name, app_version=app_version)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO(shade) This wants to be remove before we make a release.
|
||||||
|
def openstack_clouds(
|
||||||
|
config=None, debug=False, cloud=None, strict=False,
|
||||||
|
app_name=None, app_version=None):
|
||||||
|
if not config:
|
||||||
|
config = _get_openstack_config(app_name, app_version)
|
||||||
|
try:
|
||||||
|
if cloud is None:
|
||||||
|
return [
|
||||||
|
OpenStackCloud(
|
||||||
|
cloud=f.name, debug=debug,
|
||||||
|
cloud_config=cloud_region,
|
||||||
|
strict=strict)
|
||||||
|
for cloud_region in config.get_all()
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
OpenStackCloud(
|
||||||
|
cloud=f.name, debug=debug,
|
||||||
|
cloud_config=cloud_region,
|
||||||
|
strict=strict)
|
||||||
|
for cloud_region in config.get_all()
|
||||||
|
if cloud_region.name == cloud
|
||||||
|
]
|
||||||
|
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
||||||
|
raise OpenStackCloudException(
|
||||||
|
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
||||||
|
|
||||||
|
|
||||||
|
def openstack_cloud(
|
||||||
|
config=None, strict=False, app_name=None, app_version=None, **kwargs):
|
||||||
|
if not config:
|
||||||
|
config = _get_openstack_config(app_name, app_version)
|
||||||
|
try:
|
||||||
|
cloud_region = config.get_one(**kwargs)
|
||||||
|
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
||||||
|
raise OpenStackCloudException(
|
||||||
|
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
||||||
|
return OpenStackCloud(cloud_config=cloud_region, strict=strict)
|
||||||
|
|
||||||
|
|
||||||
|
def operator_cloud(
|
||||||
|
config=None, strict=False, app_name=None, app_version=None, **kwargs):
|
||||||
|
if not config:
|
||||||
|
config = _get_openstack_config(app_name, app_version)
|
||||||
|
try:
|
||||||
|
cloud_region = config.get_one(**kwargs)
|
||||||
|
except keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin as e:
|
||||||
|
raise OpenStackCloudException(
|
||||||
|
"Invalid cloud configuration: {exc}".format(exc=str(e)))
|
||||||
|
return OperatorCloud(cloud_config=cloud_region, strict=strict)
|
@ -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 openstack.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)
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
import openstack.cloud
|
|
||||||
import openstack.config
|
import openstack.config
|
||||||
|
import openstack.cloud
|
||||||
from openstack.cloud import _utils
|
from openstack.cloud import _utils
|
||||||
|
|
||||||
|
|
||||||
@ -37,17 +37,17 @@ class OpenStackInventory(object):
|
|||||||
|
|
||||||
if cloud is None:
|
if cloud is None:
|
||||||
self.clouds = [
|
self.clouds = [
|
||||||
openstack.OpenStackCloud(cloud_config=cloud_region)
|
openstack.cloud.OpenStackCloud(cloud_config=cloud_region)
|
||||||
for cloud_region in config.get_all()
|
for cloud_region in config.get_all()
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.clouds = [
|
self.clouds = [
|
||||||
openstack.OpenStackCloud(
|
openstack.cloud.OpenStackCloud(
|
||||||
cloud_config=config.get_one(cloud))
|
cloud_config=config.get_one(cloud))
|
||||||
]
|
]
|
||||||
except openstack.config.exceptions.OpenStackConfigException as e:
|
except openstack.config.exceptions.OpenStackConfigException as e:
|
||||||
raise openstack.OpenStackCloudException(e)
|
raise openstack.cloud.OpenStackCloudException(e)
|
||||||
|
|
||||||
if private:
|
if private:
|
||||||
for cloud in self.clouds:
|
for cloud in self.clouds:
|
||||||
@ -66,7 +66,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 openstack.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
|
||||||
|
@ -329,7 +329,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
cloud = shade.openstack_cloud(cloud='example')
|
cloud = openstack.cloud.openstack_cloud(cloud='example')
|
||||||
# Work normally
|
# Work normally
|
||||||
servers = cloud.list_servers()
|
servers = cloud.list_servers()
|
||||||
cloud2 = cloud.connect_as(username='different-user', password='')
|
cloud2 = cloud.connect_as(username='different-user', password='')
|
||||||
@ -408,7 +408,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
cloud = shade.openstack_cloud(cloud='example')
|
cloud = openstack.cloud.openstack_cloud(cloud='example')
|
||||||
# Work normally
|
# Work normally
|
||||||
servers = cloud.list_servers()
|
servers = cloud.list_servers()
|
||||||
cloud2 = cloud.connect_as_project('different-project')
|
cloud2 = cloud.connect_as_project('different-project')
|
||||||
|
@ -74,8 +74,11 @@ try to find it and if that fails, you would create it::
|
|||||||
network = conn.network.create_network({"name": "zuul"})
|
network = conn.network.create_network({"name": "zuul"})
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import warnings
|
||||||
|
|
||||||
import keystoneauth1.exceptions
|
import keystoneauth1.exceptions
|
||||||
import os_service_types
|
import os_service_types
|
||||||
|
import requestsexceptions
|
||||||
import six
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
|
||||||
@ -87,6 +90,10 @@ from openstack import exceptions
|
|||||||
from openstack import service_description
|
from openstack import service_description
|
||||||
from openstack import task_manager
|
from openstack import task_manager
|
||||||
|
|
||||||
|
if requestsexceptions.SubjectAltNameWarning:
|
||||||
|
warnings.filterwarnings(
|
||||||
|
'ignore', category=requestsexceptions.SubjectAltNameWarning)
|
||||||
|
|
||||||
_logger = _log.setup_logging('openstack')
|
_logger = _log.setup_logging('openstack')
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,14 +38,14 @@ class BaseFunctionalTestCase(base.TestCase):
|
|||||||
def _set_user_cloud(self, **kwargs):
|
def _set_user_cloud(self, **kwargs):
|
||||||
user_config = self.config.get_one(
|
user_config = self.config.get_one(
|
||||||
cloud=self._demo_name, **kwargs)
|
cloud=self._demo_name, **kwargs)
|
||||||
self.user_cloud = openstack.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(
|
operator_config = self.config.get_one(
|
||||||
cloud=self._op_name, **kwargs)
|
cloud=self._op_name, **kwargs)
|
||||||
self.operator_cloud = openstack.OperatorCloud(
|
self.operator_cloud = openstack.cloud.OperatorCloud(
|
||||||
cloud_config=operator_config,
|
cloud_config=operator_config,
|
||||||
log_inner_exceptions=True)
|
log_inner_exceptions=True)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ 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 openstack.OpenStackCloudException(
|
raise openstack.cloud.OpenStackCloudException(
|
||||||
'\n'.join(exception_list))
|
'\n'.join(exception_list))
|
||||||
|
|
||||||
def test_search_domains(self):
|
def test_search_domains(self):
|
||||||
|
@ -46,7 +46,7 @@ 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 openstack.OpenStackCloudException(
|
raise openstack.cloud.OpenStackCloudException(
|
||||||
'\n'.join(exception_list))
|
'\n'.join(exception_list))
|
||||||
|
|
||||||
def test_create_group(self):
|
def test_create_group(self):
|
||||||
|
@ -20,7 +20,7 @@ Functional tests for `shade` identity methods.
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from openstack import OpenStackCloudException
|
from openstack.cloud.exc import OpenStackCloudException
|
||||||
from openstack.tests.functional.cloud import base
|
from openstack.tests.functional.cloud import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ test_users
|
|||||||
Functional tests for `shade` user methods.
|
Functional tests for `shade` user methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from openstack import OpenStackCloudException
|
from openstack.cloud.exc import OpenStackCloudException
|
||||||
from openstack.tests.functional.cloud import base
|
from openstack.tests.functional.cloud import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,14 +119,14 @@ class BaseTestCase(base.TestCase):
|
|||||||
secure_files=['non-existant'])
|
secure_files=['non-existant'])
|
||||||
self.cloud_config = self.config.get_one(
|
self.cloud_config = self.config.get_one(
|
||||||
cloud=test_cloud, validate=False)
|
cloud=test_cloud, validate=False)
|
||||||
self.cloud = openstack.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 = openstack.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 = openstack.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)
|
||||||
|
|
||||||
@ -465,10 +465,10 @@ class RequestsMockTestCase(BaseTestCase):
|
|||||||
cloud=test_cloud, validate=True, **kwargs)
|
cloud=test_cloud, validate=True, **kwargs)
|
||||||
self.conn = openstack.connection.Connection(
|
self.conn = openstack.connection.Connection(
|
||||||
config=self.cloud_config)
|
config=self.cloud_config)
|
||||||
self.cloud = openstack.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 = openstack.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)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import munch
|
|||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
import openstack
|
import openstack
|
||||||
|
import openstack.cloud
|
||||||
from openstack.cloud import exc
|
from openstack.cloud import exc
|
||||||
from openstack.cloud import meta
|
from openstack.cloud import meta
|
||||||
from openstack.tests import fakes
|
from openstack.tests import fakes
|
||||||
@ -104,7 +105,7 @@ class TestMemoryCache(base.RequestsMockTestCase):
|
|||||||
return self.cloud._normalize_images([fake_image])
|
return self.cloud._normalize_images([fake_image])
|
||||||
|
|
||||||
def test_openstack_cloud(self):
|
def test_openstack_cloud(self):
|
||||||
self.assertIsInstance(self.cloud, openstack.OpenStackCloud)
|
self.assertIsInstance(self.cloud, openstack.cloud.OpenStackCloud)
|
||||||
|
|
||||||
def test_list_projects_v3(self):
|
def test_list_projects_v3(self):
|
||||||
project_one = self._get_project_data()
|
project_one = self._get_project_data()
|
||||||
@ -480,7 +481,7 @@ class TestMemoryCache(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_list_images_ignores_unsteady_status(self, mock_image_client):
|
def test_list_images_ignores_unsteady_status(self, mock_image_client):
|
||||||
steady_image = munch.Munch(id='68', name='Jagr', status='active')
|
steady_image = munch.Munch(id='68', name='Jagr', status='active')
|
||||||
for status in ('queued', 'saving', 'pending_delete'):
|
for status in ('queued', 'saving', 'pending_delete'):
|
||||||
@ -500,7 +501,7 @@ class TestMemoryCache(base.RequestsMockTestCase):
|
|||||||
self._image_dict(steady_image)],
|
self._image_dict(steady_image)],
|
||||||
self.cloud.list_images())
|
self.cloud.list_images())
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_list_images_caches_steady_status(self, mock_image_client):
|
def test_list_images_caches_steady_status(self, mock_image_client):
|
||||||
steady_image = munch.Munch(id='91', name='Federov', status='active')
|
steady_image = munch.Munch(id='91', name='Federov', status='active')
|
||||||
first_image = None
|
first_image = None
|
||||||
@ -523,7 +524,7 @@ class TestMemoryCache(base.RequestsMockTestCase):
|
|||||||
self._munch_images(first_image),
|
self._munch_images(first_image),
|
||||||
self.cloud.list_images())
|
self.cloud.list_images())
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_cache_no_cloud_name(self, mock_image_client):
|
def test_cache_no_cloud_name(self, mock_image_client):
|
||||||
|
|
||||||
self.cloud.name = None
|
self.cloud.name = None
|
||||||
@ -557,5 +558,5 @@ class TestBogusAuth(base.TestCase):
|
|||||||
|
|
||||||
def test_get_auth_bogus(self):
|
def test_get_auth_bogus(self):
|
||||||
with testtools.ExpectedException(exc.OpenStackCloudException):
|
with testtools.ExpectedException(exc.OpenStackCloudException):
|
||||||
openstack.openstack_cloud(
|
openstack.cloud.openstack_cloud(
|
||||||
cloud='_bogus_test_', config=self.config)
|
cloud='_bogus_test_', config=self.config)
|
||||||
|
@ -152,7 +152,7 @@ class TestClusterTemplates(base.RequestsMockTestCase):
|
|||||||
# match the more specific HTTPError, even though it's a subclass
|
# match the more specific HTTPError, even though it's a subclass
|
||||||
# of OpenStackCloudException.
|
# of OpenStackCloudException.
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudHTTPError):
|
openstack.cloud.OpenStackCloudHTTPError):
|
||||||
self.cloud.create_cluster_template('fake-cluster-template')
|
self.cloud.create_cluster_template('fake-cluster-template')
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ class TestCreateServer(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, "wait_for_server")
|
@mock.patch.object(openstack.cloud.OpenStackCloud, "wait_for_server")
|
||||||
def test_create_server_with_admin_pass_wait(self, mock_wait):
|
def test_create_server_with_admin_pass_wait(self, mock_wait):
|
||||||
"""
|
"""
|
||||||
Test that a server with an admin_pass passed returns the password
|
Test that a server with an admin_pass passed returns the password
|
||||||
@ -411,8 +411,8 @@ class TestCreateServer(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, "get_active_server")
|
@mock.patch.object(openstack.cloud.OpenStackCloud, "get_active_server")
|
||||||
@mock.patch.object(openstack.OpenStackCloud, "get_server")
|
@mock.patch.object(openstack.cloud.OpenStackCloud, "get_server")
|
||||||
def test_wait_for_server(self, mock_get_server, mock_get_active_server):
|
def test_wait_for_server(self, mock_get_server, mock_get_active_server):
|
||||||
"""
|
"""
|
||||||
Test that waiting for a server returns the server instance when
|
Test that waiting for a server returns the server instance when
|
||||||
@ -446,7 +446,7 @@ class TestCreateServer(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
self.assertEqual('ACTIVE', server['status'])
|
self.assertEqual('ACTIVE', server['status'])
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'wait_for_server')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'wait_for_server')
|
||||||
def test_create_server_wait(self, mock_wait):
|
def test_create_server_wait(self, mock_wait):
|
||||||
"""
|
"""
|
||||||
Test that create_server with a wait actually does the wait.
|
Test that create_server with a wait actually does the wait.
|
||||||
@ -483,7 +483,7 @@ class TestCreateServer(base.RequestsMockTestCase):
|
|||||||
)
|
)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'add_ips_to_server')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'add_ips_to_server')
|
||||||
@mock.patch('time.sleep')
|
@mock.patch('time.sleep')
|
||||||
def test_create_server_no_addresses(
|
def test_create_server_no_addresses(
|
||||||
self, mock_sleep, mock_add_ips_to_server):
|
self, mock_sleep, mock_add_ips_to_server):
|
||||||
|
@ -21,8 +21,8 @@ from openstack.tests.unit import base
|
|||||||
|
|
||||||
class TestDomainParams(base.TestCase):
|
class TestDomainParams(base.TestCase):
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_project')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_project')
|
||||||
def test_identity_params_v3(self, mock_get_project,
|
def test_identity_params_v3(self, mock_get_project,
|
||||||
mock_is_client_version):
|
mock_is_client_version):
|
||||||
mock_get_project.return_value = munch.Munch(id=1234)
|
mock_get_project.return_value = munch.Munch(id=1234)
|
||||||
@ -34,8 +34,8 @@ class TestDomainParams(base.TestCase):
|
|||||||
self.assertIn('domain_id', ret)
|
self.assertIn('domain_id', ret)
|
||||||
self.assertEqual(ret['domain_id'], '5678')
|
self.assertEqual(ret['domain_id'], '5678')
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_project')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_project')
|
||||||
def test_identity_params_v3_no_domain(
|
def test_identity_params_v3_no_domain(
|
||||||
self, mock_get_project, mock_is_client_version):
|
self, mock_get_project, mock_is_client_version):
|
||||||
mock_get_project.return_value = munch.Munch(id=1234)
|
mock_get_project.return_value = munch.Munch(id=1234)
|
||||||
@ -46,8 +46,8 @@ class TestDomainParams(base.TestCase):
|
|||||||
self.cloud._get_identity_params,
|
self.cloud._get_identity_params,
|
||||||
domain_id=None, project='bar')
|
domain_id=None, project='bar')
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_project')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_project')
|
||||||
def test_identity_params_v2(self, mock_get_project,
|
def test_identity_params_v2(self, mock_get_project,
|
||||||
mock_is_client_version):
|
mock_is_client_version):
|
||||||
mock_get_project.return_value = munch.Munch(id=1234)
|
mock_get_project.return_value = munch.Munch(id=1234)
|
||||||
@ -58,8 +58,8 @@ class TestDomainParams(base.TestCase):
|
|||||||
self.assertEqual(ret['tenant_id'], 1234)
|
self.assertEqual(ret['tenant_id'], 1234)
|
||||||
self.assertNotIn('domain', ret)
|
self.assertNotIn('domain', ret)
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_project')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_project')
|
||||||
def test_identity_params_v2_no_domain(self, mock_get_project,
|
def test_identity_params_v2_no_domain(self, mock_get_project,
|
||||||
mock_is_client_version):
|
mock_is_client_version):
|
||||||
mock_get_project.return_value = munch.Munch(id=1234)
|
mock_get_project.return_value = munch.Munch(id=1234)
|
||||||
|
@ -94,7 +94,7 @@ class TestDomains(base.RequestsMockTestCase):
|
|||||||
domain_data = self._get_domain_data(domain_name='domain_name',
|
domain_data = self._get_domain_data(domain_name='domain_name',
|
||||||
enabled=True)
|
enabled=True)
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudBadRequest,
|
openstack.cloud.OpenStackCloudBadRequest,
|
||||||
"Failed to create domain domain_name"
|
"Failed to create domain domain_name"
|
||||||
):
|
):
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
@ -149,7 +149,7 @@ class TestDomains(base.RequestsMockTestCase):
|
|||||||
validate=dict(json={'domain': {'enabled': False}})),
|
validate=dict(json={'domain': {'enabled': False}})),
|
||||||
dict(method='DELETE', uri=domain_resource_uri, status_code=404)])
|
dict(method='DELETE', uri=domain_resource_uri, status_code=404)])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudURINotFound,
|
openstack.cloud.OpenStackCloudURINotFound,
|
||||||
"Failed to delete domain %s" % domain_data.domain_id
|
"Failed to delete domain %s" % domain_data.domain_id
|
||||||
):
|
):
|
||||||
self.op_cloud.delete_domain(domain_data.domain_id)
|
self.op_cloud.delete_domain(domain_data.domain_id)
|
||||||
@ -203,7 +203,7 @@ class TestDomains(base.RequestsMockTestCase):
|
|||||||
json=domain_data.json_response,
|
json=domain_data.json_response,
|
||||||
validate=dict(json={'domain': {'enabled': False}}))])
|
validate=dict(json={'domain': {'enabled': False}}))])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudHTTPError,
|
openstack.cloud.OpenStackCloudHTTPError,
|
||||||
"Error in updating domain %s" % domain_data.domain_id
|
"Error in updating domain %s" % domain_data.domain_id
|
||||||
):
|
):
|
||||||
self.op_cloud.delete_domain(domain_data.domain_id)
|
self.op_cloud.delete_domain(domain_data.domain_id)
|
||||||
|
@ -78,7 +78,7 @@ class TestFlavors(base.RequestsMockTestCase):
|
|||||||
endpoint=fakes.COMPUTE_ENDPOINT, id=fakes.FLAVOR_ID),
|
endpoint=fakes.COMPUTE_ENDPOINT, id=fakes.FLAVOR_ID),
|
||||||
status_code=503)])
|
status_code=503)])
|
||||||
|
|
||||||
self.assertRaises(openstack.OpenStackCloudException,
|
self.assertRaises(openstack.cloud.OpenStackCloudException,
|
||||||
self.op_cloud.delete_flavor, 'vanilla')
|
self.op_cloud.delete_flavor, 'vanilla')
|
||||||
|
|
||||||
def test_list_flavors(self):
|
def test_list_flavors(self):
|
||||||
@ -153,7 +153,7 @@ class TestFlavors(base.RequestsMockTestCase):
|
|||||||
endpoint=fakes.COMPUTE_ENDPOINT),
|
endpoint=fakes.COMPUTE_ENDPOINT),
|
||||||
json={'flavors': []})])
|
json={'flavors': []})])
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.get_flavor_by_ram,
|
self.cloud.get_flavor_by_ram,
|
||||||
ram=100)
|
ram=100)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ Tests floating IP resource methods for Neutron and Nova-network.
|
|||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from openstack.cloud import meta
|
from openstack.cloud import meta
|
||||||
from openstack import OpenStackCloud
|
from openstack.cloud import OpenStackCloud
|
||||||
from openstack.tests import fakes
|
from openstack.tests import fakes
|
||||||
from openstack.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ test_floating_ip_pool
|
|||||||
Test floating IP pool resource (managed by nova)
|
Test floating IP pool resource (managed by nova)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from openstack import OpenStackCloudException
|
from openstack.cloud.exc import OpenStackCloudException
|
||||||
from openstack.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
from openstack.tests import fakes
|
from openstack.tests import fakes
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ class TestIdentityRoles(base.RequestsMockTestCase):
|
|||||||
def test_list_role_assignments_exception_v2(self):
|
def test_list_role_assignments_exception_v2(self):
|
||||||
self.use_keystone_v2()
|
self.use_keystone_v2()
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Must provide project and user for keystone v2"
|
"Must provide project and user for keystone v2"
|
||||||
):
|
):
|
||||||
self.op_cloud.list_role_assignments()
|
self.op_cloud.list_role_assignments()
|
||||||
@ -301,7 +301,7 @@ class TestIdentityRoles(base.RequestsMockTestCase):
|
|||||||
def test_list_role_assignments_exception_v2_no_project(self):
|
def test_list_role_assignments_exception_v2_no_project(self):
|
||||||
self.use_keystone_v2()
|
self.use_keystone_v2()
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Must provide project and user for keystone v2"
|
"Must provide project and user for keystone v2"
|
||||||
):
|
):
|
||||||
self.op_cloud.list_role_assignments(filters={'user': '12345'})
|
self.op_cloud.list_role_assignments(filters={'user': '12345'})
|
||||||
|
@ -588,8 +588,8 @@ class TestImage(BaseTestImage):
|
|||||||
is_public=False, **kwargs)
|
is_public=False, **kwargs)
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_v1(
|
def test_create_image_put_v1(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = False
|
mock_is_client_version.return_value = False
|
||||||
@ -626,8 +626,8 @@ class TestImage(BaseTestImage):
|
|||||||
self._munch_images(ret), self.cloud.list_images())
|
self._munch_images(ret), self.cloud.list_images())
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_v1_bad_delete(
|
def test_create_image_put_v1_bad_delete(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = False
|
mock_is_client_version.return_value = False
|
||||||
@ -665,8 +665,8 @@ class TestImage(BaseTestImage):
|
|||||||
mock_image_client.delete.assert_called_with('/images/42')
|
mock_image_client.delete.assert_called_with('/images/42')
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_update_image_no_patch(
|
def test_update_image_no_patch(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
@ -697,8 +697,8 @@ class TestImage(BaseTestImage):
|
|||||||
mock_image_client.patch.assert_not_called()
|
mock_image_client.patch.assert_not_called()
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_v2_bad_delete(
|
def test_create_image_put_v2_bad_delete(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
@ -737,8 +737,8 @@ class TestImage(BaseTestImage):
|
|||||||
mock_image_client.delete.assert_called_with('/images/42')
|
mock_image_client.delete.assert_called_with('/images/42')
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_bad_int(
|
def test_create_image_put_bad_int(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
@ -750,8 +750,8 @@ class TestImage(BaseTestImage):
|
|||||||
mock_image_client.post.assert_not_called()
|
mock_image_client.post.assert_not_called()
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_user_int(
|
def test_create_image_put_user_int(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
@ -786,8 +786,8 @@ class TestImage(BaseTestImage):
|
|||||||
self._munch_images(ret), self.cloud.list_images())
|
self._munch_images(ret), self.cloud.list_images())
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_meta_int(
|
def test_create_image_put_meta_int(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
@ -816,8 +816,8 @@ class TestImage(BaseTestImage):
|
|||||||
self._munch_images(ret), self.cloud.list_images())
|
self._munch_images(ret), self.cloud.list_images())
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_protected(
|
def test_create_image_put_protected(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
@ -855,8 +855,8 @@ class TestImage(BaseTestImage):
|
|||||||
self.assertEqual(self._munch_images(ret), self.cloud.list_images())
|
self.assertEqual(self._munch_images(ret), self.cloud.list_images())
|
||||||
|
|
||||||
# TODO(shade) Migrate this to requests-mock
|
# TODO(shade) Migrate this to requests-mock
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_is_client_version')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_is_client_version')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, '_image_client')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, '_image_client')
|
||||||
def test_create_image_put_user_prop(
|
def test_create_image_put_user_prop(
|
||||||
self, mock_image_client, mock_is_client_version):
|
self, mock_image_client, mock_is_client_version):
|
||||||
mock_is_client_version.return_value = True
|
mock_is_client_version.return_value = True
|
||||||
|
@ -26,7 +26,7 @@ class TestInventory(base.TestCase):
|
|||||||
super(TestInventory, self).setUp()
|
super(TestInventory, self).setUp()
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test__init(self, mock_cloud, mock_config):
|
def test__init(self, mock_cloud, mock_config):
|
||||||
mock_config.return_value.get_all.return_value = [{}]
|
mock_config.return_value.get_all.return_value = [{}]
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class TestInventory(base.TestCase):
|
|||||||
self.assertTrue(mock_config.return_value.get_all.called)
|
self.assertTrue(mock_config.return_value.get_all.called)
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test__init_one_cloud(self, mock_cloud, mock_config):
|
def test__init_one_cloud(self, mock_cloud, mock_config):
|
||||||
mock_config.return_value.get_one.return_value = [{}]
|
mock_config.return_value.get_one.return_value = [{}]
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TestInventory(base.TestCase):
|
|||||||
'supercloud')
|
'supercloud')
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test__raise_exception_on_no_cloud(self, mock_cloud, mock_config):
|
def test__raise_exception_on_no_cloud(self, mock_cloud, mock_config):
|
||||||
"""
|
"""
|
||||||
Test that when os-client-config can't find a named cloud, a
|
Test that when os-client-config can't find a named cloud, a
|
||||||
@ -72,7 +72,7 @@ class TestInventory(base.TestCase):
|
|||||||
'supercloud')
|
'supercloud')
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test_list_hosts(self, mock_cloud, mock_config):
|
def test_list_hosts(self, mock_cloud, mock_config):
|
||||||
mock_config.return_value.get_all.return_value = [{}]
|
mock_config.return_value.get_all.return_value = [{}]
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class TestInventory(base.TestCase):
|
|||||||
self.assertEqual([server], ret)
|
self.assertEqual([server], ret)
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test_list_hosts_no_detail(self, mock_cloud, mock_config):
|
def test_list_hosts_no_detail(self, mock_cloud, mock_config):
|
||||||
mock_config.return_value.get_all.return_value = [{}]
|
mock_config.return_value.get_all.return_value = [{}]
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class TestInventory(base.TestCase):
|
|||||||
self.assertFalse(inv.clouds[0].get_openstack_vars.called)
|
self.assertFalse(inv.clouds[0].get_openstack_vars.called)
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test_search_hosts(self, mock_cloud, mock_config):
|
def test_search_hosts(self, mock_cloud, mock_config):
|
||||||
mock_config.return_value.get_all.return_value = [{}]
|
mock_config.return_value.get_all.return_value = [{}]
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class TestInventory(base.TestCase):
|
|||||||
self.assertEqual([server], ret)
|
self.assertEqual([server], ret)
|
||||||
|
|
||||||
@mock.patch("openstack.config.loader.OpenStackConfig")
|
@mock.patch("openstack.config.loader.OpenStackConfig")
|
||||||
@mock.patch("openstack.OpenStackCloud")
|
@mock.patch("openstack.cloud.OpenStackCloud")
|
||||||
def test_get_host(self, mock_cloud, mock_config):
|
def test_get_host(self, mock_cloud, mock_config):
|
||||||
mock_config.return_value.get_all.return_value = [{}]
|
mock_config.return_value.get_all.return_value = [{}]
|
||||||
|
|
||||||
|
@ -348,10 +348,10 @@ class TestMeta(base.RequestsMockTestCase):
|
|||||||
'10.0.0.101', meta.get_server_private_ip(srv, self.cloud))
|
'10.0.0.101', meta.get_server_private_ip(srv, self.cloud))
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'has_service')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'has_service')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_volumes')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_volumes')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_image_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_image_name')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_flavor_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_flavor_name')
|
||||||
def test_get_server_private_ip_devstack(
|
def test_get_server_private_ip_devstack(
|
||||||
self,
|
self,
|
||||||
mock_get_flavor_name, mock_get_image_name,
|
mock_get_flavor_name, mock_get_image_name,
|
||||||
@ -413,9 +413,9 @@ class TestMeta(base.RequestsMockTestCase):
|
|||||||
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_volumes')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_volumes')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_image_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_image_name')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_flavor_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_flavor_name')
|
||||||
def test_get_server_private_ip_no_fip(
|
def test_get_server_private_ip_no_fip(
|
||||||
self,
|
self,
|
||||||
mock_get_flavor_name, mock_get_image_name,
|
mock_get_flavor_name, mock_get_image_name,
|
||||||
@ -463,9 +463,9 @@ class TestMeta(base.RequestsMockTestCase):
|
|||||||
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_volumes')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_volumes')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_image_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_image_name')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_flavor_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_flavor_name')
|
||||||
def test_get_server_cloud_no_fips(
|
def test_get_server_cloud_no_fips(
|
||||||
self,
|
self,
|
||||||
mock_get_flavor_name, mock_get_image_name,
|
mock_get_flavor_name, mock_get_image_name,
|
||||||
@ -511,10 +511,10 @@ class TestMeta(base.RequestsMockTestCase):
|
|||||||
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'has_service')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'has_service')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_volumes')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_volumes')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_image_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_image_name')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_flavor_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_flavor_name')
|
||||||
def test_get_server_cloud_missing_fips(
|
def test_get_server_cloud_missing_fips(
|
||||||
self,
|
self,
|
||||||
mock_get_flavor_name, mock_get_image_name,
|
mock_get_flavor_name, mock_get_image_name,
|
||||||
@ -580,9 +580,9 @@ class TestMeta(base.RequestsMockTestCase):
|
|||||||
self.assertEqual(PUBLIC_V4, srv['public_v4'])
|
self.assertEqual(PUBLIC_V4, srv['public_v4'])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_volumes')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_volumes')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_image_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_image_name')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_flavor_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_flavor_name')
|
||||||
def test_get_server_cloud_rackspace_v6(
|
def test_get_server_cloud_rackspace_v6(
|
||||||
self, mock_get_flavor_name, mock_get_image_name,
|
self, mock_get_flavor_name, mock_get_image_name,
|
||||||
mock_get_volumes):
|
mock_get_volumes):
|
||||||
@ -630,9 +630,9 @@ class TestMeta(base.RequestsMockTestCase):
|
|||||||
"2001:4800:7819:103:be76:4eff:fe05:8525", srv['interface_ip'])
|
"2001:4800:7819:103:be76:4eff:fe05:8525", srv['interface_ip'])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_volumes')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_volumes')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_image_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_image_name')
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'get_flavor_name')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'get_flavor_name')
|
||||||
def test_get_server_cloud_osic_split(
|
def test_get_server_cloud_osic_split(
|
||||||
self, mock_get_flavor_name, mock_get_image_name,
|
self, mock_get_flavor_name, mock_get_image_name,
|
||||||
mock_get_volumes):
|
mock_get_volumes):
|
||||||
|
@ -183,7 +183,7 @@ class TestNetwork(base.RequestsMockTestCase):
|
|||||||
def test_create_network_provider_wrong_type(self):
|
def test_create_network_provider_wrong_type(self):
|
||||||
provider_opts = "invalid"
|
provider_opts = "invalid"
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Parameter 'provider' must be a dict"
|
"Parameter 'provider' must be a dict"
|
||||||
):
|
):
|
||||||
self.cloud.create_network("netname", provider=provider_opts)
|
self.cloud.create_network("netname", provider=provider_opts)
|
||||||
@ -231,7 +231,7 @@ class TestNetwork(base.RequestsMockTestCase):
|
|||||||
append=['v2.0', 'networks', "%s.json" % network_id]),
|
append=['v2.0', 'networks', "%s.json" % network_id]),
|
||||||
status_code=503)
|
status_code=503)
|
||||||
])
|
])
|
||||||
self.assertRaises(openstack.OpenStackCloudException,
|
self.assertRaises(openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.delete_network, network_name)
|
self.cloud.delete_network, network_name)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class TestObject(BaseTestObject):
|
|||||||
dict(method='DELETE', uri=self.container_endpoint,
|
dict(method='DELETE', uri=self.container_endpoint,
|
||||||
status_code=409)])
|
status_code=409)])
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.delete_container, self.container)
|
self.cloud.delete_container, self.container)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class TestObject(BaseTestObject):
|
|||||||
dict(method='POST', uri=self.container_endpoint,
|
dict(method='POST', uri=self.container_endpoint,
|
||||||
status_code=409)])
|
status_code=409)])
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.update_container, self.container, dict(foo='bar'))
|
self.cloud.update_container, self.container, dict(foo='bar'))
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ class TestObject(BaseTestObject):
|
|||||||
|
|
||||||
def test_set_container_access_invalid(self):
|
def test_set_container_access_invalid(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.set_container_access, self.container, 'invalid')
|
self.cloud.set_container_access, self.container, 'invalid')
|
||||||
|
|
||||||
def test_get_container_access(self):
|
def test_get_container_access(self):
|
||||||
@ -360,7 +360,7 @@ class TestObject(BaseTestObject):
|
|||||||
status_code=416)])
|
status_code=416)])
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.get_object,
|
self.cloud.get_object,
|
||||||
self.container, self.object)
|
self.container, self.object)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import mock
|
import mock
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
import openstack
|
import openstack.cloud
|
||||||
from openstack.cloud import exc
|
from openstack.cloud import exc
|
||||||
from openstack.config import cloud_region
|
from openstack.config import cloud_region
|
||||||
from openstack.tests import fakes
|
from openstack.tests import fakes
|
||||||
@ -23,7 +23,7 @@ from openstack.tests.unit import base
|
|||||||
class TestOperatorCloud(base.RequestsMockTestCase):
|
class TestOperatorCloud(base.RequestsMockTestCase):
|
||||||
|
|
||||||
def test_operator_cloud(self):
|
def test_operator_cloud(self):
|
||||||
self.assertIsInstance(self.op_cloud, openstack.OperatorCloud)
|
self.assertIsInstance(self.op_cloud, openstack.cloud.OperatorCloud)
|
||||||
|
|
||||||
@mock.patch.object(cloud_region.CloudRegion, 'get_endpoint')
|
@mock.patch.object(cloud_region.CloudRegion, 'get_endpoint')
|
||||||
def test_get_session_endpoint_provided(self, fake_get_endpoint):
|
def test_get_session_endpoint_provided(self, fake_get_endpoint):
|
||||||
|
@ -12,7 +12,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.
|
||||||
|
|
||||||
import openstack
|
import openstack.cloud
|
||||||
from openstack.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class TestOpenStackCloudOperatorNoAuth(base.RequestsMockTestCase):
|
|||||||
# with 'v1'. As such, since we are overriding the endpoint,
|
# with 'v1'. As such, since we are overriding the endpoint,
|
||||||
# we must explicitly do the same as we move away from the
|
# we must explicitly do the same as we move away from the
|
||||||
# client library.
|
# client library.
|
||||||
self.cloud_noauth = openstack.operator_cloud(
|
self.cloud_noauth = openstack.cloud.operator_cloud(
|
||||||
auth_type='none',
|
auth_type='none',
|
||||||
baremetal_endpoint_override="https://bare-metal.example.com/v1")
|
baremetal_endpoint_override="https://bare-metal.example.com/v1")
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class TestOpenStackCloudOperatorNoAuth(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
The old way of doing this was to abuse admin_token.
|
The old way of doing this was to abuse admin_token.
|
||||||
"""
|
"""
|
||||||
self.cloud_noauth = openstack.operator_cloud(
|
self.cloud_noauth = openstack.cloud.operator_cloud(
|
||||||
auth_type='admin_token',
|
auth_type='admin_token',
|
||||||
auth=dict(
|
auth=dict(
|
||||||
endpoint='https://bare-metal.example.com/v1',
|
endpoint='https://bare-metal.example.com/v1',
|
||||||
|
@ -76,7 +76,7 @@ class TestProject(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
def test_create_project_v3_no_domain(self):
|
def test_create_project_v3_no_domain(self):
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"User or project creation requires an explicit"
|
"User or project creation requires an explicit"
|
||||||
" domain_id argument."
|
" domain_id argument."
|
||||||
):
|
):
|
||||||
@ -126,7 +126,7 @@ class TestProject(base.RequestsMockTestCase):
|
|||||||
# shade will raise an attribute error instead of the proper
|
# shade will raise an attribute error instead of the proper
|
||||||
# project not found exception.
|
# project not found exception.
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Project %s not found." % project_data.project_id
|
"Project %s not found." % project_data.project_id
|
||||||
):
|
):
|
||||||
self.op_cloud.update_project(project_data.project_id)
|
self.op_cloud.update_project(project_data.project_id)
|
||||||
|
@ -83,7 +83,7 @@ class TestSecurityGroups(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
self.cloud.secgroup_source = None
|
self.cloud.secgroup_source = None
|
||||||
self.has_neutron = False
|
self.has_neutron = False
|
||||||
self.assertRaises(openstack.OpenStackCloudUnavailableFeature,
|
self.assertRaises(openstack.cloud.OpenStackCloudUnavailableFeature,
|
||||||
self.cloud.list_security_groups)
|
self.cloud.list_security_groups)
|
||||||
|
|
||||||
def test_delete_security_group_neutron(self):
|
def test_delete_security_group_neutron(self):
|
||||||
@ -146,7 +146,7 @@ class TestSecurityGroups(base.RequestsMockTestCase):
|
|||||||
|
|
||||||
def test_delete_security_group_none(self):
|
def test_delete_security_group_none(self):
|
||||||
self.cloud.secgroup_source = None
|
self.cloud.secgroup_source = None
|
||||||
self.assertRaises(openstack.OpenStackCloudUnavailableFeature,
|
self.assertRaises(openstack.cloud.OpenStackCloudUnavailableFeature,
|
||||||
self.cloud.delete_security_group,
|
self.cloud.delete_security_group,
|
||||||
'doesNotExist')
|
'doesNotExist')
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ class TestSecurityGroups(base.RequestsMockTestCase):
|
|||||||
def test_create_security_group_none(self):
|
def test_create_security_group_none(self):
|
||||||
self.cloud.secgroup_source = None
|
self.cloud.secgroup_source = None
|
||||||
self.has_neutron = False
|
self.has_neutron = False
|
||||||
self.assertRaises(openstack.OpenStackCloudUnavailableFeature,
|
self.assertRaises(openstack.cloud.OpenStackCloudUnavailableFeature,
|
||||||
self.cloud.create_security_group,
|
self.cloud.create_security_group,
|
||||||
'', '')
|
'', '')
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ class TestSecurityGroups(base.RequestsMockTestCase):
|
|||||||
def test_create_security_group_rule_none(self):
|
def test_create_security_group_rule_none(self):
|
||||||
self.has_neutron = False
|
self.has_neutron = False
|
||||||
self.cloud.secgroup_source = None
|
self.cloud.secgroup_source = None
|
||||||
self.assertRaises(openstack.OpenStackCloudUnavailableFeature,
|
self.assertRaises(openstack.cloud.OpenStackCloudUnavailableFeature,
|
||||||
self.cloud.create_security_group_rule,
|
self.cloud.create_security_group_rule,
|
||||||
'')
|
'')
|
||||||
|
|
||||||
@ -498,7 +498,7 @@ class TestSecurityGroups(base.RequestsMockTestCase):
|
|||||||
def test_delete_security_group_rule_none(self):
|
def test_delete_security_group_rule_none(self):
|
||||||
self.has_neutron = False
|
self.has_neutron = False
|
||||||
self.cloud.secgroup_source = None
|
self.cloud.secgroup_source = None
|
||||||
self.assertRaises(openstack.OpenStackCloudUnavailableFeature,
|
self.assertRaises(openstack.cloud.OpenStackCloudUnavailableFeature,
|
||||||
self.cloud.delete_security_group_rule,
|
self.cloud.delete_security_group_rule,
|
||||||
'')
|
'')
|
||||||
|
|
||||||
@ -538,7 +538,7 @@ class TestSecurityGroups(base.RequestsMockTestCase):
|
|||||||
endpoint=fakes.COMPUTE_ENDPOINT),
|
endpoint=fakes.COMPUTE_ENDPOINT),
|
||||||
json={'security_groups': [nova_grp_dict]}),
|
json={'security_groups': [nova_grp_dict]}),
|
||||||
])
|
])
|
||||||
self.assertRaises(openstack.OpenStackCloudException,
|
self.assertRaises(openstack.cloud.OpenStackCloudException,
|
||||||
self.cloud.create_security_group_rule,
|
self.cloud.create_security_group_rule,
|
||||||
secgroup_name_or_id='nova-sec-group',
|
secgroup_name_or_id='nova-sec-group',
|
||||||
direction='egress')
|
direction='egress')
|
||||||
|
@ -19,7 +19,7 @@ test_cloud_services
|
|||||||
Tests Keystone services commands.
|
Tests Keystone services commands.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from openstack import OpenStackCloudException
|
from openstack.cloud.exc import OpenStackCloudException
|
||||||
from openstack.cloud.exc import OpenStackCloudUnavailableFeature
|
from openstack.cloud.exc import OpenStackCloudUnavailableFeature
|
||||||
from openstack.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
@ -52,9 +52,9 @@ class TestShade(base.RequestsMockTestCase):
|
|||||||
self.cloud.has_service = fake_has_service
|
self.cloud.has_service = fake_has_service
|
||||||
|
|
||||||
def test_openstack_cloud(self):
|
def test_openstack_cloud(self):
|
||||||
self.assertIsInstance(self.cloud, openstack.OpenStackCloud)
|
self.assertIsInstance(self.cloud, openstack.cloud.OpenStackCloud)
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'search_images')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'search_images')
|
||||||
def test_get_images(self, mock_search):
|
def test_get_images(self, mock_search):
|
||||||
image1 = dict(id='123', name='mickey')
|
image1 = dict(id='123', name='mickey')
|
||||||
mock_search.return_value = [image1]
|
mock_search.return_value = [image1]
|
||||||
@ -62,7 +62,7 @@ class TestShade(base.RequestsMockTestCase):
|
|||||||
self.assertIsNotNone(r)
|
self.assertIsNotNone(r)
|
||||||
self.assertDictEqual(image1, r)
|
self.assertDictEqual(image1, r)
|
||||||
|
|
||||||
@mock.patch.object(openstack.OpenStackCloud, 'search_images')
|
@mock.patch.object(openstack.cloud.OpenStackCloud, 'search_images')
|
||||||
def test_get_image_not_found(self, mock_search):
|
def test_get_image_not_found(self, mock_search):
|
||||||
mock_search.return_value = []
|
mock_search.return_value = []
|
||||||
r = self.cloud.get_image('doesNotExist')
|
r = self.cloud.get_image('doesNotExist')
|
||||||
|
@ -57,7 +57,7 @@ class TestStack(base.RequestsMockTestCase):
|
|||||||
status_code=404)
|
status_code=404)
|
||||||
])
|
])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudURINotFound):
|
openstack.cloud.OpenStackCloudURINotFound):
|
||||||
self.cloud.list_stacks()
|
self.cloud.list_stacks()
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class TestStack(base.RequestsMockTestCase):
|
|||||||
status_code=404)
|
status_code=404)
|
||||||
])
|
])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudURINotFound):
|
openstack.cloud.OpenStackCloudURINotFound):
|
||||||
self.cloud.search_stacks()
|
self.cloud.search_stacks()
|
||||||
|
|
||||||
def test_delete_stack(self):
|
def test_delete_stack(self):
|
||||||
@ -171,7 +171,7 @@ class TestStack(base.RequestsMockTestCase):
|
|||||||
reason="ouch"),
|
reason="ouch"),
|
||||||
])
|
])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudBadRequest):
|
openstack.cloud.OpenStackCloudBadRequest):
|
||||||
self.cloud.delete_stack(self.stack_id)
|
self.cloud.delete_stack(self.stack_id)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ class TestStack(base.RequestsMockTestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException):
|
openstack.cloud.OpenStackCloudException):
|
||||||
self.cloud.delete_stack(self.stack_id, wait=True)
|
self.cloud.delete_stack(self.stack_id, wait=True)
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
@ -124,7 +124,7 @@ class TestUsers(base.RequestsMockTestCase):
|
|||||||
user_data = self._get_user_data(domain_id=uuid.uuid4().hex,
|
user_data = self._get_user_data(domain_id=uuid.uuid4().hex,
|
||||||
email='test@example.com')
|
email='test@example.com')
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"User or project creation requires an explicit"
|
"User or project creation requires an explicit"
|
||||||
" domain_id argument."
|
" domain_id argument."
|
||||||
):
|
):
|
||||||
|
@ -60,7 +60,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||||||
'volumeId': vol['id']}})
|
'volumeId': vol['id']}})
|
||||||
)])
|
)])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudURINotFound,
|
openstack.cloud.OpenStackCloudURINotFound,
|
||||||
"Error attaching volume %s to server %s" % (
|
"Error attaching volume %s to server %s" % (
|
||||||
volume['id'], server['id'])
|
volume['id'], server['id'])
|
||||||
):
|
):
|
||||||
@ -126,7 +126,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||||||
json={'volumes': [errored_volume]})])
|
json={'volumes': [errored_volume]})])
|
||||||
|
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Error in attaching volume %s" % errored_volume['id']
|
"Error in attaching volume %s" % errored_volume['id']
|
||||||
):
|
):
|
||||||
self.cloud.attach_volume(server, volume)
|
self.cloud.attach_volume(server, volume)
|
||||||
@ -137,7 +137,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||||||
volume = dict(id='volume001', status='error', attachments=[])
|
volume = dict(id='volume001', status='error', attachments=[])
|
||||||
|
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Volume %s is not available. Status is '%s'" % (
|
"Volume %s is not available. Status is '%s'" % (
|
||||||
volume['id'], volume['status'])
|
volume['id'], volume['status'])
|
||||||
):
|
):
|
||||||
@ -153,7 +153,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Volume %s already attached to server %s on device %s" % (
|
"Volume %s already attached to server %s on device %s" % (
|
||||||
volume['id'], server['id'], device_id)
|
volume['id'], server['id'], device_id)
|
||||||
):
|
):
|
||||||
@ -189,7 +189,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||||||
'os-volume_attachments', volume['id']]),
|
'os-volume_attachments', volume['id']]),
|
||||||
status_code=404)])
|
status_code=404)])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudURINotFound,
|
openstack.cloud.OpenStackCloudURINotFound,
|
||||||
"Error detaching volume %s from server %s" % (
|
"Error detaching volume %s from server %s" % (
|
||||||
volume['id'], server['id'])
|
volume['id'], server['id'])
|
||||||
):
|
):
|
||||||
@ -238,7 +238,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||||||
'volumev2', 'public', append=['volumes', 'detail']),
|
'volumev2', 'public', append=['volumes', 'detail']),
|
||||||
json={'volumes': [errored_volume]})])
|
json={'volumes': [errored_volume]})])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"Error in detaching volume %s" % errored_volume['id']
|
"Error in detaching volume %s" % errored_volume['id']
|
||||||
):
|
):
|
||||||
self.cloud.detach_volume(server, volume)
|
self.cloud.detach_volume(server, volume)
|
||||||
|
@ -187,7 +187,7 @@ class TestVolumeAccess(base.RequestsMockTestCase):
|
|||||||
qs_elements=['is_public=None']),
|
qs_elements=['is_public=None']),
|
||||||
json={'volume_types': [volume_type]})])
|
json={'volume_types': [volume_type]})])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
openstack.OpenStackCloudException,
|
openstack.cloud.OpenStackCloudException,
|
||||||
"VolumeType not found: MISSING"):
|
"VolumeType not found: MISSING"):
|
||||||
self.op_cloud.add_volume_type_access(
|
self.op_cloud.add_volume_type_access(
|
||||||
"MISSING", project_001['project_id'])
|
"MISSING", project_001['project_id'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user