Merge "json name usage"
diff --git a/HACKING.rst b/HACKING.rst
index fed4130..a546f8c 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -153,10 +153,25 @@
kwarg2=dict_of_numbers)
+openstack-common
+----------------
+
+A number of modules from openstack-common are imported into the project.
+
+These modules are "incubating" in openstack-common and are kept in sync
+with the help of openstack-common's update.py script. See:
+
+ http://wiki.openstack.org/CommonLibrary#Incubation
+
+The copy of the code should never be directly modified here. Please
+always update openstack-common first and then run the script to copy
+the changes across.
+
+
OpenStack Trademark
-------------------
-OpenStack is a registered trademark of OpenStack, LLC, and uses the
+OpenStack is a registered trademark of the OpenStack Foundation, and uses the
following capitalization:
OpenStack
diff --git a/tempest/clients.py b/tempest/clients.py
index 150cf67..aa9b558 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -19,8 +19,7 @@
from tempest import config
from tempest import exceptions
-from tempest.services.boto.clients import APIClientEC2
-from tempest.services.boto.clients import ObjectClientS3
+from tempest.services import botoclients
from tempest.services.compute.json.extensions_client import \
ExtensionsClientJSON
from tempest.services.compute.json.flavors_client import FlavorsClientJSON
@@ -205,8 +204,8 @@
self.image_client = ImageClientJSON(*client_args)
self.container_client = ContainerClient(*client_args)
self.object_client = ObjectClient(*client_args)
- self.ec2api_client = APIClientEC2(*client_args)
- self.s3_client = ObjectClientS3(*client_args)
+ self.ec2api_client = botoclients.APIClientEC2(*client_args)
+ self.s3_client = botoclients.ObjectClientS3(*client_args)
self.custom_object_client = ObjectClientCustomizedHeader(*client_args)
self.custom_account_client = \
AccountClientCustomizedHeader(*client_args)
diff --git a/tempest/config.py b/tempest/config.py
index ddd1b5b..c982dee 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -19,7 +19,6 @@
import os
import sys
-from tempest.common.utils import data_utils
from tempest.common.utils.misc import singleton
from tempest.openstack.common import cfg
diff --git a/tempest/services/boto/__init__.py b/tempest/services/boto/__init__.py
deleted file mode 100644
index f744d9d..0000000
--- a/tempest/services/boto/__init__.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack, LLC
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from ConfigParser import DuplicateSectionError
-from contextlib import closing
-import re
-from types import MethodType
-
-import boto
-
-from tempest.exceptions import InvalidConfiguration
-from tempest.exceptions import NotFound
-
-
-class BotoClientBase(object):
-
- ALLOWED_METHODS = set()
-
- def __init__(self, config,
- username=None, password=None,
- auth_url=None, tenant_name=None,
- *args, **kwargs):
-
- self.connection_timeout = str(config.boto.http_socket_timeout)
- self.num_retries = str(config.boto.num_retries)
- self.build_timeout = config.boto.build_timeout
- self.ks_cred = {"username": username,
- "password": password,
- "auth_url": auth_url,
- "tenant_name": tenant_name}
-
- def _keystone_aws_get(self):
- import keystoneclient.v2_0.client
-
- keystone = keystoneclient.v2_0.client.Client(**self.ks_cred)
- ec2_cred_list = keystone.ec2.list(keystone.auth_user_id)
- ec2_cred = None
- for cred in ec2_cred_list:
- if cred.tenant_id == keystone.auth_tenant_id:
- ec2_cred = cred
- break
- else:
- ec2_cred = keystone.ec2.create(keystone.auth_user_id,
- keystone.auth_tenant_id)
- if not all((ec2_cred, ec2_cred.access, ec2_cred.secret)):
- raise NotFound("Unable to get access and secret keys")
- return ec2_cred
-
- def _config_boto_timeout(self, timeout, retries):
- try:
- boto.config.add_section("Boto")
- except DuplicateSectionError:
- pass
- boto.config.set("Boto", "http_socket_timeout", timeout)
- boto.config.set("Boto", "num_retries", retries)
-
- def __getattr__(self, name):
- """Automatically creates methods for the allowed methods set."""
- if name in self.ALLOWED_METHODS:
- def func(self, *args, **kwargs):
- with closing(self.get_connection()) as conn:
- return getattr(conn, name)(*args, **kwargs)
-
- func.__name__ = name
- setattr(self, name, MethodType(func, self, self.__class__))
- setattr(self.__class__, name,
- MethodType(func, None, self.__class__))
- return getattr(self, name)
- else:
- raise AttributeError(name)
-
- def get_connection(self):
- self._config_boto_timeout(self.connection_timeout, self.num_retries)
- if not all((self.connection_data["aws_access_key_id"],
- self.connection_data["aws_secret_access_key"])):
- if all(self.ks_cred.itervalues()):
- ec2_cred = self._keystone_aws_get()
- self.connection_data["aws_access_key_id"] = \
- ec2_cred.access
- self.connection_data["aws_secret_access_key"] = \
- ec2_cred.secret
- else:
- raise InvalidConfiguration(
- "Unable to get access and secret keys")
- return self.connect_method(**self.connection_data)
diff --git a/tempest/services/boto/clients.py b/tempest/services/botoclients.py
similarity index 63%
rename from tempest/services/boto/clients.py
rename to tempest/services/botoclients.py
index 228e826..143257a 100644
--- a/tempest/services/boto/clients.py
+++ b/tempest/services/botoclients.py
@@ -15,13 +15,90 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ConfigParser
+import contextlib
+import re
+import types
import urlparse
-import boto
-from boto.ec2.regioninfo import RegionInfo
-from boto.s3.connection import OrdinaryCallingFormat
+from tempest import exceptions
-from tempest.services.boto import BotoClientBase
+import boto
+import boto.ec2
+import boto.s3.connection
+
+
+class BotoClientBase(object):
+
+ ALLOWED_METHODS = set()
+
+ def __init__(self, config,
+ username=None, password=None,
+ auth_url=None, tenant_name=None,
+ *args, **kwargs):
+
+ self.connection_timeout = str(config.boto.http_socket_timeout)
+ self.num_retries = str(config.boto.num_retries)
+ self.build_timeout = config.boto.build_timeout
+ self.ks_cred = {"username": username,
+ "password": password,
+ "auth_url": auth_url,
+ "tenant_name": tenant_name}
+
+ def _keystone_aws_get(self):
+ import keystoneclient.v2_0.client
+
+ keystone = keystoneclient.v2_0.client.Client(**self.ks_cred)
+ ec2_cred_list = keystone.ec2.list(keystone.auth_user_id)
+ ec2_cred = None
+ for cred in ec2_cred_list:
+ if cred.tenant_id == keystone.auth_tenant_id:
+ ec2_cred = cred
+ break
+ else:
+ ec2_cred = keystone.ec2.create(keystone.auth_user_id,
+ keystone.auth_tenant_id)
+ if not all((ec2_cred, ec2_cred.access, ec2_cred.secret)):
+ raise exceptions.NotFound("Unable to get access and secret keys")
+ return ec2_cred
+
+ def _config_boto_timeout(self, timeout, retries):
+ try:
+ boto.config.add_section("Boto")
+ except ConfigParser.DuplicateSectionError:
+ pass
+ boto.config.set("Boto", "http_socket_timeout", timeout)
+ boto.config.set("Boto", "num_retries", retries)
+
+ def __getattr__(self, name):
+ """Automatically creates methods for the allowed methods set."""
+ if name in self.ALLOWED_METHODS:
+ def func(self, *args, **kwargs):
+ with contextlib.closing(self.get_connection()) as conn:
+ return getattr(conn, name)(*args, **kwargs)
+
+ func.__name__ = name
+ setattr(self, name, types.MethodType(func, self, self.__class__))
+ setattr(self.__class__, name,
+ types.MethodType(func, None, self.__class__))
+ return getattr(self, name)
+ else:
+ raise AttributeError(name)
+
+ def get_connection(self):
+ self._config_boto_timeout(self.connection_timeout, self.num_retries)
+ if not all((self.connection_data["aws_access_key_id"],
+ self.connection_data["aws_secret_access_key"])):
+ if all(self.ks_cred.itervalues()):
+ ec2_cred = self._keystone_aws_get()
+ self.connection_data["aws_access_key_id"] = \
+ ec2_cred.access
+ self.connection_data["aws_secret_access_key"] = \
+ ec2_cred.secret
+ else:
+ raise exceptions.InvalidConfiguration(
+ "Unable to get access and secret keys")
+ return self.connect_method(**self.connection_data)
class APIClientEC2(BotoClientBase):
@@ -35,8 +112,8 @@
aws_secret = config.boto.aws_secret
purl = urlparse.urlparse(config.boto.ec2_url)
- region = RegionInfo(name=config.identity.region,
- endpoint=purl.hostname)
+ region = boto.ec2.regioninfo.RegionInfo(name=config.identity.region,
+ endpoint=purl.hostname)
port = purl.port
if port is None:
if purl.scheme is not "https":
@@ -134,7 +211,8 @@
"is_secure": purl.scheme == "https",
"host": purl.hostname,
"port": port,
- "calling_format": OrdinaryCallingFormat()}
+ "calling_format": boto.s3.connection.
+ OrdinaryCallingFormat()}
ALLOWED_METHODS = set(('create_bucket', 'delete_bucket', 'generate_url',
'get_all_buckets', 'get_bucket', 'delete_key',
diff --git a/tempest/services/compute/admin/xml/quotas_client.py b/tempest/services/compute/admin/xml/quotas_client.py
index d567a9c..f416334 100644
--- a/tempest/services/compute/admin/xml/quotas_client.py
+++ b/tempest/services/compute/admin/xml/quotas_client.py
@@ -15,11 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import urllib
-
from lxml import etree
-from tempest.common.rest_client import RestClientXML
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import xml_to_json
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 2116e1e..02cf970 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -403,7 +403,7 @@
url = self.base_url + '/servers?all_tenants=1'
resp = self.requests.get(url)
- resp, body = self.post('servers', post_body, self.headers)
+ resp, body = self.get('servers', self.headers)
body = json.loads(body)
return resp, body['servers']
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index a5f6ec3..e4271d9 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -105,7 +105,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id, wait=True)
+ self.get_volume(id)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index 9bb1d11..6469761 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from lxml import etree
-
XMLNS_11 = "http://docs.openstack.org/compute/api/v1.1"
diff --git a/tempest/services/compute/xml/limits_client.py b/tempest/services/compute/xml/limits_client.py
index 473952b..d233bba 100644
--- a/tempest/services/compute/xml/limits_client.py
+++ b/tempest/services/compute/xml/limits_client.py
@@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from lxml import etree
from lxml import objectify
from tempest.common.rest_client import RestClientXML
diff --git a/tempest/services/compute/xml/quotas_client.py b/tempest/services/compute/xml/quotas_client.py
index 8978214..faa0aab 100644
--- a/tempest/services/compute/xml/quotas_client.py
+++ b/tempest/services/compute/xml/quotas_client.py
@@ -15,15 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import urllib
-
from lxml import etree
from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
class QuotasClientXML(RestClientXML):
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
index 60ef398..69b9bac 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -141,7 +141,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id, wait=True)
+ self.get_volume(id)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/identity/xml/identity_client.py b/tempest/services/identity/xml/identity_client.py
index f746fba..2431282 100644
--- a/tempest/services/identity/xml/identity_client.py
+++ b/tempest/services/identity/xml/identity_client.py
@@ -17,16 +17,13 @@
import httplib2
import json
-import logging
from lxml import etree
-from tempest.common.rest_client import RestClient
from tempest.common.rest_client import RestClientXML
from tempest import exceptions
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import Text
from tempest.services.compute.xml.common import xml_to_json
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 187e80d..ac1859a 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -18,11 +18,10 @@
from hashlib import sha1
import hmac
import httplib2
-import json
-import re
+from urlparse import urlparse
+
from tempest.common.rest_client import RestClient
from tempest import exceptions
-from urlparse import urlparse
class ObjectClient(RestClient):
@@ -41,7 +40,7 @@
def update_object(self, container, object_name, data):
"""Upload data to replace current storage object."""
- return create_object(container, object_name, data)
+ return self.create_object(container, object_name, data)
def delete_object(self, container, object_name):
"""Delete storage object."""
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 75e1a8b..ff1556f 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -125,7 +125,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id, wait=True)
+ self.get_volume(id)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index c89f66e..dc70cb7 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -85,10 +85,6 @@
body = xml_to_json(etree.fromstring(body))
return resp, body
- def _get_snapshot_status(self, snapshot_id):
- resp, body = self.get_snapshot(snapshot_id)
- return body['status']
-
#NOTE(afazekas): just for the wait function
def _get_snapshot_status(self, snapshot_id):
resp, body = self.get_snapshot(snapshot_id)
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 862ffae..5041869 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -151,7 +151,7 @@
def is_resource_deleted(self, id):
try:
- self.get_volume(id, wait=True)
+ self.get_volume(id)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/testboto.py b/tempest/testboto.py
index 1b768ef..14844b3 100644
--- a/tempest/testboto.py
+++ b/tempest/testboto.py
@@ -18,13 +18,11 @@
from contextlib import closing
import logging
import re
-import time
import boto
from boto.exception import BotoServerError
from boto.exception import EC2ResponseError
from boto.s3.bucket import Bucket
-from boto.s3.key import Key
import testresources
import testtools
@@ -33,7 +31,6 @@
from tempest.tests.boto.utils.wait import re_search_wait
from tempest.tests.boto.utils.wait import state_wait
from tempest.tests.boto.utils.wait import wait_exception
-from tempest.tests.boto.utils.wait import wait_no_exception
LOG = logging.getLogger(__name__)
@@ -379,7 +376,7 @@
snaps = volume.snapshots()
if len(snaps):
LOG.critical("%s Volume has %s snapshot(s)", volume.id,
- map(snps.id, snaps))
+ map(snaps.id, snaps))
#Note(afazekas): detaching/attching not valid EC2 status
def _volume_state():
diff --git a/tempest/tests/boto/test_ec2_instance_run.py b/tempest/tests/boto/test_ec2_instance_run.py
index 8358ef9..403ec4c 100644
--- a/tempest/tests/boto/test_ec2_instance_run.py
+++ b/tempest/tests/boto/test_ec2_instance_run.py
@@ -15,17 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-from contextlib import closing
import logging
from boto.exception import EC2ResponseError
-from boto.s3.key import Key
import testtools
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
-from tempest.exceptions import EC2RegisterImageException
from tempest.test import attr
from tempest.testboto import BotoTestCase
import tempest.tests.boto
@@ -88,8 +85,8 @@
state = state_wait(_state, "available")
if state != "available":
for _image in cls.images.itervalues():
- ec2_client.deregister_image(_image["image_id"])
- raise RegisterImageException(image_id=image["image_id"])
+ cls.ec2_client.deregister_image(_image["image_id"])
+ raise EC2RegisterImageException(image_id=image["image_id"])
@attr(type='smoke')
def test_run_stop_terminate_instance(self):
diff --git a/tempest/tests/boto/test_ec2_network.py b/tempest/tests/boto/test_ec2_network.py
index ef476a2..ef307a1 100644
--- a/tempest/tests/boto/test_ec2_network.py
+++ b/tempest/tests/boto/test_ec2_network.py
@@ -47,4 +47,4 @@
address.disassociate)
self.client.release_address(public_ip)
self.cancelResourceCleanUp(rcuk)
- assertAddressReleasedWait(address)
+ self.assertAddressReleasedWait(address)
diff --git a/tempest/tests/boto/test_ec2_security_groups.py b/tempest/tests/boto/test_ec2_security_groups.py
index 5981408..dd46a91 100644
--- a/tempest/tests/boto/test_ec2_security_groups.py
+++ b/tempest/tests/boto/test_ec2_security_groups.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
diff --git a/tempest/tests/boto/test_ec2_volumes.py b/tempest/tests/boto/test_ec2_volumes.py
index 7d3c5ab..aa2325f 100644
--- a/tempest/tests/boto/test_ec2_volumes.py
+++ b/tempest/tests/boto/test_ec2_volumes.py
@@ -16,9 +16,6 @@
# under the License.
import logging
-import time
-
-import testtools
from tempest import clients
from tempest.test import attr
diff --git a/tempest/tests/boto/test_s3_ec2_images.py b/tempest/tests/boto/test_s3_ec2_images.py
index da248e1..8913395 100644
--- a/tempest/tests/boto/test_s3_ec2_images.py
+++ b/tempest/tests/boto/test_s3_ec2_images.py
@@ -15,10 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from contextlib import closing
import os
-from boto.s3.key import Key
import testtools
from tempest import clients
diff --git a/tempest/tests/boto/test_s3_objects.py b/tempest/tests/boto/test_s3_objects.py
index e7bc4b1..8334b07 100644
--- a/tempest/tests/boto/test_s3_objects.py
+++ b/tempest/tests/boto/test_s3_objects.py
@@ -24,7 +24,6 @@
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
from tempest.testboto import BotoTestCase
-from tempest.tests import boto
@attr("S3")
diff --git a/tempest/tests/compute/admin/test_flavors.py b/tempest/tests/compute/admin/test_flavors.py
index fe977c1..9ad8745 100644
--- a/tempest/tests/compute/admin/test_flavors.py
+++ b/tempest/tests/compute/admin/test_flavors.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.common.utils.data_utils import rand_int_id
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
diff --git a/tempest/tests/compute/admin/test_quotas.py b/tempest/tests/compute/admin/test_quotas.py
index 0f46d62..a4b106b 100644
--- a/tempest/tests/compute/admin/test_quotas.py
+++ b/tempest/tests/compute/admin/test_quotas.py
@@ -20,7 +20,6 @@
import quotas_client as adm_quotas_json
from tempest.services.compute.admin.xml import quotas_client as adm_quotas_xml
from tempest.test import attr
-from tempest.tests import compute
from tempest.tests.compute import base
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index f2af1fc..594535f 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -154,7 +154,7 @@
@classmethod
def clear_isolated_creds(cls):
if not cls.isolated_creds:
- pass
+ return
admin_client = cls._get_identity_admin_client()
for user, tenant in cls.isolated_creds:
diff --git a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
index 9f0cda0..165cf79 100644
--- a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
@@ -15,9 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
-from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
diff --git a/tempest/tests/compute/floating_ips/test_list_floating_ips.py b/tempest/tests/compute/floating_ips/test_list_floating_ips.py
index e534e3c..42befd0 100644
--- a/tempest/tests/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/tests/compute/floating_ips/test_list_floating_ips.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
diff --git a/tempest/tests/compute/images/test_images.py b/tempest/tests/compute/images/test_images.py
index 446ef50..edc58e7 100644
--- a/tempest/tests/compute/images/test_images.py
+++ b/tempest/tests/compute/images/test_images.py
@@ -20,7 +20,6 @@
from tempest import clients
from tempest.common.utils.data_utils import parse_image_id
from tempest.common.utils.data_utils import rand_name
-import tempest.config
from tempest import exceptions
from tempest.test import attr
from tempest.tests import compute
diff --git a/tempest/tests/compute/images/test_images_oneserver.py b/tempest/tests/compute/images/test_images_oneserver.py
index 5cc921b..08966fd 100644
--- a/tempest/tests/compute/images/test_images_oneserver.py
+++ b/tempest/tests/compute/images/test_images_oneserver.py
@@ -20,7 +20,6 @@
from tempest import clients
from tempest.common.utils.data_utils import parse_image_id
from tempest.common.utils.data_utils import rand_name
-import tempest.config
from tempest import exceptions
from tempest.test import attr
from tempest.tests import compute
diff --git a/tempest/tests/compute/images/test_list_images.py b/tempest/tests/compute/images/test_list_images.py
index b9b57ee..0f661b7 100644
--- a/tempest/tests/compute/images/test_list_images.py
+++ b/tempest/tests/compute/images/test_list_images.py
@@ -15,9 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.utils.data_utils import parse_image_id
-from tempest.common.utils.data_utils import rand_name
-from tempest import exceptions
from tempest.test import attr
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/servers/test_disk_config.py b/tempest/tests/compute/servers/test_disk_config.py
index 3987e69..57b95f2 100644
--- a/tempest/tests/compute/servers/test_disk_config.py
+++ b/tempest/tests/compute/servers/test_disk_config.py
@@ -18,7 +18,6 @@
import testtools
from tempest.common.utils.data_utils import rand_name
-from tempest import exceptions
from tempest.test import attr
from tempest.tests import compute
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/servers/test_list_server_filters.py b/tempest/tests/compute/servers/test_list_server_filters.py
index e07a905..9b061b5 100644
--- a/tempest/tests/compute/servers/test_list_server_filters.py
+++ b/tempest/tests/compute/servers/test_list_server_filters.py
@@ -16,8 +16,6 @@
# under the License.
-import testtools
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
diff --git a/tempest/tests/compute/servers/test_list_servers_negative.py b/tempest/tests/compute/servers/test_list_servers_negative.py
index eb4ea02..f93bebf 100644
--- a/tempest/tests/compute/servers/test_list_servers_negative.py
+++ b/tempest/tests/compute/servers/test_list_servers_negative.py
@@ -15,13 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import re
-import sys
-
-import testtools
from tempest import clients
-from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.tests import compute
from tempest.tests.compute.base import BaseComputeTest
diff --git a/tempest/tests/compute/servers/test_server_metadata.py b/tempest/tests/compute/servers/test_server_metadata.py
index a214d15..ef1b956 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -197,7 +197,6 @@
def test_delete_nonexistant_server_metadata_item(self):
# Negative test: Should not be able to delete metadata item from a
# nonexistant server
- meta = {'d': 'delvalue'}
#Delete the metadata item
try:
diff --git a/tempest/tests/compute/servers/test_servers_negative.py b/tempest/tests/compute/servers/test_servers_negative.py
index 55d9581..9b528f6 100644
--- a/tempest/tests/compute/servers/test_servers_negative.py
+++ b/tempest/tests/compute/servers/test_servers_negative.py
@@ -17,8 +17,6 @@
import sys
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
@@ -275,3 +273,17 @@
self.assertRaises(exceptions.NotFound, self.client.delete_server,
sys.maxint + 1)
+
+ @attr(type='negative')
+ def test_create_with_nonexistent_security_group(self):
+ # Create a server with a nonexistent security group
+ try:
+ security_groups = [{'name': 'does_not_exist'}]
+ self.create_server_with_extras('fail',
+ self.image_ref,
+ self.flavor_ref,
+ security_groups=security_groups)
+ except exceptions.BadRequest:
+ pass
+ else:
+ self.fail('Server was created with nonexistent security group')
diff --git a/tempest/tests/compute/test_authorization.py b/tempest/tests/compute/test_authorization.py
index 8f4ad50..d826d40 100644
--- a/tempest/tests/compute/test_authorization.py
+++ b/tempest/tests/compute/test_authorization.py
@@ -243,7 +243,6 @@
# Reset the base_url...
self.alt_security_client.base_url = self.saved_base_url
if resp['status'] is not None:
- resp, _ = \
self.alt_security_client.delete_security_group(body['id'])
self.fail("Create Security Group request should not happen if"
"the tenant id does not match the current user")
@@ -283,7 +282,6 @@
# Reset the base_url...
self.alt_security_client.base_url = self.saved_base_url
if resp['status'] is not None:
- resp, _ = \
self.alt_security_client.delete_security_group_rule(
body['id'])
self.fail("Create security group rule request should not "
diff --git a/tempest/tests/compute/test_live_block_migration.py b/tempest/tests/compute/test_live_block_migration.py
index d22e6b5..6449ddc 100644
--- a/tempest/tests/compute/test_live_block_migration.py
+++ b/tempest/tests/compute/test_live_block_migration.py
@@ -20,7 +20,6 @@
import testtools
-from tempest.common.utils.linux.remote_client import RemoteClient
from tempest import config
from tempest import exceptions
from tempest.services.compute.json.hosts_client import HostsClientJSON
@@ -124,8 +123,8 @@
server_id = self._get_an_active_server()
target_host = self._get_non_existing_host_name()
- with self.assertRaises(exceptions.BadRequest) as cm:
- self._migrate_server_to(server_id, target_host)
+ self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
+ server_id, target_host)
self.assertEquals('ACTIVE', self._get_server_status(server_id))
@classmethod
diff --git a/tempest/tests/compute/volumes/test_attach_volume.py b/tempest/tests/compute/volumes/test_attach_volume.py
index edf3179..1aed833 100644
--- a/tempest/tests/compute/volumes/test_attach_volume.py
+++ b/tempest/tests/compute/volumes/test_attach_volume.py
@@ -17,7 +17,6 @@
import testtools
-from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
import tempest.config
diff --git a/tempest/tests/identity/admin/test_roles.py b/tempest/tests/identity/admin/test_roles.py
index 2779b51..3194e7d 100644
--- a/tempest/tests/identity/admin/test_roles.py
+++ b/tempest/tests/identity/admin/test_roles.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.tests.identity import base
diff --git a/tempest/tests/identity/admin/test_services.py b/tempest/tests/identity/admin/test_services.py
index 0246f8c..16b9fd8 100644
--- a/tempest/tests/identity/admin/test_services.py
+++ b/tempest/tests/identity/admin/test_services.py
@@ -18,7 +18,6 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
-from tempest.test import attr
from tempest.tests.identity import base
diff --git a/tempest/tests/identity/admin/test_tenants.py b/tempest/tests/identity/admin/test_tenants.py
index 9321b07..594afe8 100644
--- a/tempest/tests/identity/admin/test_tenants.py
+++ b/tempest/tests/identity/admin/test_tenants.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
diff --git a/tempest/tests/network/base.py b/tempest/tests/network/base.py
index 5af7e2c..8606079 100644
--- a/tempest/tests/network/base.py
+++ b/tempest/tests/network/base.py
@@ -29,8 +29,6 @@
def setUpClass(cls):
os = clients.Manager()
client = os.network_client
- config = os.config
- networks = []
enabled = True
# Validate that there is even an endpoint configured
diff --git a/tempest/tests/network/test_network_basic_ops.py b/tempest/tests/network/test_network_basic_ops.py
index d297c98..aed368e 100644
--- a/tempest/tests/network/test_network_basic_ops.py
+++ b/tempest/tests/network/test_network_basic_ops.py
@@ -184,7 +184,6 @@
def setUpClass(cls):
super(TestNetworkBasicOps, cls).setUpClass()
cls.check_preconditions()
- cfg = cls.config.network
cls.tenant_id = cls.manager._get_identity_client(
cls.config.identity.username,
cls.config.identity.password,
diff --git a/tempest/tests/object_storage/base.py b/tempest/tests/object_storage/base.py
index 376deb7..2492d8b 100644
--- a/tempest/tests/object_storage/base.py
+++ b/tempest/tests/object_storage/base.py
@@ -18,7 +18,6 @@
import testtools
from tempest import clients
-import tempest.config
from tempest import exceptions
from tempest.tests.identity.base import DataGenerator
@@ -48,6 +47,5 @@
try:
cls.account_client.list_account_containers()
except exceptions.EndpointNotFound:
- enabled = False
skip_msg = "No OpenStack Object Storage API endpoint"
raise cls.skipException(skip_msg)
diff --git a/tempest/tests/object_storage/test_container_sync.py b/tempest/tests/object_storage/test_container_sync.py
index f087aff..dad6309 100644
--- a/tempest/tests/object_storage/test_container_sync.py
+++ b/tempest/tests/object_storage/test_container_sync.py
@@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.utils.data_utils import arbitrary_string
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
from tempest.tests.object_storage import base
diff --git a/tempest/tests/volume/base.py b/tempest/tests/volume/base.py
index 6625180..c91244f 100644
--- a/tempest/tests/volume/base.py
+++ b/tempest/tests/volume/base.py
@@ -113,7 +113,7 @@
@classmethod
def clear_isolated_creds(cls):
if not cls.isolated_creds:
- pass
+ return
admin_client = cls._get_identity_admin_client()
for user, tenant in cls.isolated_creds:
diff --git a/tempest/tests/volume/test_volumes_snapshots.py b/tempest/tests/volume/test_volumes_snapshots.py
index 75ea155..3acc5f6 100644
--- a/tempest/tests/volume/test_volumes_snapshots.py
+++ b/tempest/tests/volume/test_volumes_snapshots.py
@@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common.utils.data_utils import rand_name
from tempest.tests.volume import base