diff --git a/examples/connect.py b/examples/connect.py index d9c52c893..1864053a6 100644 --- a/examples/connect.py +++ b/examples/connect.py @@ -20,17 +20,19 @@ import argparse import os import openstack -from openstack import config as occ +from openstack.config import loader from openstack import utils import sys utils.enable_logging(True, stream=sys.stdout) -#: Defines the OpenStack Client Config (OCC) cloud key in your OCC config -#: file, typically in $HOME/.config/openstack/clouds.yaml. That configuration +#: Defines the OpenStack Config loud key in your config file, +#: typically in $HOME/.config/openstack/clouds.yaml. That configuration #: will determine where the examples will be run and what resource defaults #: will be used to run the examples. TEST_CLOUD = os.getenv('OS_TEST_CLOUD', 'devstack-admin') +config = loader.OpenStackConfig() +cloud = openstack.connect(cloud=TEST_CLOUD) class Opts(object): @@ -42,13 +44,7 @@ class Opts(object): def _get_resource_value(resource_key, default): - try: - return cloud.config['example'][resource_key] - except KeyError: - return default - -config = occ.OpenStackConfig() -cloud = openstack.connect(cloud=TEST_CLOUD) + return config.get_extra_config('example').get(resource_key, default) SERVER_NAME = 'openstacksdk-example' IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') @@ -70,7 +66,7 @@ def create_connection_from_config(): def create_connection_from_args(): parser = argparse.ArgumentParser() - config = occ.OpenStackConfig() + config = loader.OpenStackConfig() config.register_argparse_arguments(parser, sys.argv[1:]) args = parser.parse_args() return openstack.connect(config=config.get_one(argparse=args)) diff --git a/openstack/tests/examples/__init__.py b/openstack/tests/functional/examples/__init__.py similarity index 100% rename from openstack/tests/examples/__init__.py rename to openstack/tests/functional/examples/__init__.py diff --git a/openstack/tests/examples/test_compute.py b/openstack/tests/functional/examples/test_compute.py similarity index 94% rename from openstack/tests/examples/test_compute.py rename to openstack/tests/functional/examples/test_compute.py index 127960898..188c77495 100644 --- a/openstack/tests/examples/test_compute.py +++ b/openstack/tests/functional/examples/test_compute.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack.tests.unit import base +from openstack.tests.functional import base from examples.compute import create from examples.compute import delete @@ -21,7 +21,7 @@ from examples.network import find as network_find from examples.network import list as network_list -class TestCompute(base.TestCase): +class TestCompute(base.BaseFunctionalTest): """Test the compute examples The purpose of these tests is to ensure the examples run without erring diff --git a/openstack/tests/examples/test_identity.py b/openstack/tests/functional/examples/test_identity.py similarity index 93% rename from openstack/tests/examples/test_identity.py rename to openstack/tests/functional/examples/test_identity.py index 0255f1103..8db8bd7ea 100644 --- a/openstack/tests/examples/test_identity.py +++ b/openstack/tests/functional/examples/test_identity.py @@ -10,13 +10,13 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack.tests.unit import base +from openstack.tests.functional import base from examples import connect from examples.identity import list as identity_list -class TestIdentity(base.TestCase): +class TestIdentity(base.BaseFunctionalTest): """Test the identity examples The purpose of these tests is to ensure the examples run without erring diff --git a/openstack/tests/examples/test_image.py b/openstack/tests/functional/examples/test_image.py similarity index 92% rename from openstack/tests/examples/test_image.py rename to openstack/tests/functional/examples/test_image.py index b1e421da8..117b9db3f 100644 --- a/openstack/tests/examples/test_image.py +++ b/openstack/tests/functional/examples/test_image.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack.tests.unit import base +from openstack.tests.functional import base from examples import connect from examples.image import create as image_create @@ -18,7 +18,7 @@ from examples.image import delete as image_delete from examples.image import list as image_list -class TestImage(base.TestCase): +class TestImage(base.BaseFunctionalTest): """Test the image examples The purpose of these tests is to ensure the examples run without erring diff --git a/openstack/tests/examples/test_network.py b/openstack/tests/functional/examples/test_network.py similarity index 94% rename from openstack/tests/examples/test_network.py rename to openstack/tests/functional/examples/test_network.py index 349d1f726..ef99eedae 100644 --- a/openstack/tests/examples/test_network.py +++ b/openstack/tests/functional/examples/test_network.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack.tests.unit import base +from openstack.tests.functional import base from examples import connect from examples.network import create as network_create @@ -19,7 +19,7 @@ from examples.network import find as network_find from examples.network import list as network_list -class TestNetwork(base.TestCase): +class TestNetwork(base.BaseFunctionalTest): """Test the network examples The purpose of these tests is to ensure the examples run without erring