Merge "Add skip for api tests"
diff --git a/.zuul.yaml b/.zuul.yaml
index 51c01d3..d60cc74 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -7,6 +7,7 @@
       jobs:
         - barbican-tempest-plugin-simple-crypto
         - barbican-tempest-plugin-simple-crypto-secure-rbac
+        - barbican-tempest-plugin-simple-crypto-zed
         - barbican-tempest-plugin-simple-crypto-yoga
         - barbican-tempest-plugin-simple-crypto-xena
         - barbican-tempest-plugin-simple-crypto-wallaby
@@ -57,8 +58,22 @@
         - barbican-tempest-plugin
 
 - job:
+    name: barbican-tempest-plugin-simple-crypto-zed
+    parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-focal
+    override-checkout: stable/zed
+    vars:
+      devstack_local_conf:
+        test-config:
+          $TEMPEST_CONFIG:
+            key_manager:
+              min_microversion: '1.0'
+              max_microversion: '1.1'
+
+- job:
     name: barbican-tempest-plugin-simple-crypto-yoga
     parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-focal
     override-checkout: stable/yoga
     vars: &microversion_v1_0
       devstack_local_conf:
@@ -71,30 +86,35 @@
 - job:
     name: barbican-tempest-plugin-simple-crypto-xena
     parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-focal
     override-checkout: stable/xena
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-wallaby
     parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-focal
     override-checkout: stable/wallaby
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-victoria
     parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-focal
     override-checkout: stable/victoria
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-ussuri
     parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-bionic
     override-checkout: stable/ussuri
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-train
     parent: barbican-tempest-plugin-simple-crypto
+    nodeset: openstack-single-node-bionic
     override-checkout: stable/train
     vars: *microversion_v1_0
 
@@ -118,18 +138,21 @@
 - job:
     name: barbican-tempest-plugin-simple-crypto-secure-rbac-yoga
     parent: barbican-tempest-plugin-simple-crypto-secure-rbac
+    nodeset: openstack-single-node-focal
     override-checkout: stable/yoga
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-secure-rbac-xena
     parent: barbican-tempest-plugin-simple-crypto-secure-rbac
+    nodeset: openstack-single-node-focal
     override-checkout: stable/xena
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-secure-rbac-wallaby
     parent: barbican-tempest-plugin-simple-crypto-secure-rbac
+    nodeset: openstack-single-node-focal
     override-checkout: stable/wallaby
     vars: *microversion_v1_0
 
@@ -143,36 +166,42 @@
 - job:
     name: barbican-tempest-plugin-simple-crypto-ipv6-only-yoga
     parent: barbican-tempest-plugin-simple-crypto-ipv6-only
+    nodeset: openstack-single-node-focal
     override-checkout: stable/yoga
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-ipv6-only-xena
     parent: barbican-tempest-plugin-simple-crypto-ipv6-only
+    nodeset: openstack-single-node-focal
     override-checkout: stable/xena
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-ipv6-only-wallaby
     parent: barbican-tempest-plugin-simple-crypto-ipv6-only
+    nodeset: openstack-single-node-focal
     override-checkout: stable/wallaby
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-ipv6-only-victoria
     parent: barbican-tempest-plugin-simple-crypto-ipv6-only
+    nodeset: openstack-single-node-focal
     override-checkout: stable/victoria
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-ipv6-only-ussuri
     parent: barbican-tempest-plugin-simple-crypto-ipv6-only
+    nodeset: openstack-single-node-bionic
     override-checkout: stable/ussuri
     vars: *microversion_v1_0
 
 - job:
     name: barbican-tempest-plugin-simple-crypto-ipv6-only-train
     parent: barbican-tempest-plugin-simple-crypto-ipv6-only
+    nodeset: openstack-single-node-bionic
     override-checkout: stable/train
     vars: *microversion_v1_0
 
diff --git a/barbican_tempest_plugin/tests/scenario/manager.py b/barbican_tempest_plugin/tests/scenario/manager.py
index 04418f0..b7f8914 100644
--- a/barbican_tempest_plugin/tests/scenario/manager.py
+++ b/barbican_tempest_plugin/tests/scenario/manager.py
@@ -19,9 +19,7 @@
 from tempest.common import image as common_image
 from tempest.common import waiters
 from tempest import config
-from tempest import exceptions
 from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
 from tempest.lib import exceptions as lib_exc
 from tempest.scenario import manager
 
@@ -34,48 +32,6 @@
 # check_*_connectivity methods to validate instances are up and accessible
 class ScenarioTest(manager.NetworkScenarioTest):
     """Base class for scenario tests. Uses tempest own clients. """
-
-    credentials = ['primary']
-
-    @classmethod
-    def setup_clients(cls):
-        super(ScenarioTest, cls).setup_clients()
-        # Clients (in alphabetical order)
-        cls.flavors_client = cls.os_primary.flavors_client
-        cls.compute_floating_ips_client = (
-            cls.os_primary.compute_floating_ips_client)
-        if CONF.service_available.glance:
-            # Check if glance v1 is available to determine which client to use.
-            if CONF.image_feature_enabled.api_v1:
-                cls.image_client = cls.os_primary.image_client
-            elif CONF.image_feature_enabled.api_v2:
-                cls.image_client = cls.os_primary.image_client_v2
-            else:
-                raise lib_exc.InvalidConfiguration(
-                    'Either api_v1 or api_v2 must be True in '
-                    '[image-feature-enabled].')
-        # Compute image client
-        cls.compute_images_client = cls.os_primary.compute_images_client
-        cls.keypairs_client = cls.os_primary.keypairs_client
-        # Nova security groups client
-        cls.compute_security_groups_client = (
-            cls.os_primary.compute_security_groups_client)
-        cls.compute_security_group_rules_client = (
-            cls.os_primary.compute_security_group_rules_client)
-        cls.servers_client = cls.os_primary.servers_client
-        # Neutron network client
-        cls.networks_client = cls.os_primary.networks_client
-        cls.ports_client = cls.os_primary.ports_client
-        cls.routers_client = cls.os_primary.routers_client
-        cls.subnets_client = cls.os_primary.subnets_client
-        cls.floating_ips_client = cls.os_primary.floating_ips_client
-        cls.security_groups_client = cls.os_primary.security_groups_client
-        cls.security_group_rules_client = (
-            cls.os_primary.security_group_rules_client)
-
-        cls.volumes_client = cls.os_primary.volumes_client_latest
-        cls.snapshots_client = cls.os_primary.snapshots_client_latest
-
     # ## Test functions library
     #
     # The create_[resource] functions only return body and discard the
@@ -130,183 +86,3 @@
                                  str(failed_stores))
 
         return image['id']
-
-    def create_floating_ip(self, thing, pool_name=None):
-        """Create a floating IP and associates to a server on Nova"""
-
-        if not pool_name:
-            pool_name = CONF.network.floating_network_name
-        floating_ip = (self.compute_floating_ips_client.
-                       create_floating_ip(pool=pool_name)['floating_ip'])
-        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
-                        self.compute_floating_ips_client.delete_floating_ip,
-                        floating_ip['id'])
-        self.compute_floating_ips_client.associate_floating_ip_to_server(
-            floating_ip['ip'], thing['id'])
-        return floating_ip
-
-    def nova_volume_attach(self, server, volume_to_attach):
-        volume = self.servers_client.attach_volume(
-            server['id'], volumeId=volume_to_attach['id'], device='/dev/%s'
-            % CONF.compute.volume_device_name)['volumeAttachment']
-        self.assertEqual(volume_to_attach['id'], volume['id'])
-        waiters.wait_for_volume_resource_status(self.volumes_client,
-                                                volume['id'], 'in-use')
-
-        self.addCleanup(self.nova_volume_detach, server, volume)
-        # Return the updated volume after the attachment
-        return self.volumes_client.show_volume(volume['id'])['volume']
-
-    def nova_volume_detach(self, server, volume):
-        self.servers_client.detach_volume(server['id'], volume['id'])
-        waiters.wait_for_volume_resource_status(self.volumes_client,
-                                                volume['id'], 'available')
-
-        volume = self.volumes_client.show_volume(volume['id'])['volume']
-        self.assertEqual('available', volume['status'])
-
-    def get_server_ip(self, server):
-        """Get the server fixed or floating IP.
-
-        Based on the configuration we're in, return a correct ip
-        address for validating that a guest is up.
-        """
-        if CONF.validation.connect_method == 'floating':
-            # The tests calling this method don't have a floating IP
-            # and can't make use of the validation resources. So the
-            # method is creating the floating IP there.
-            return self.create_floating_ip(server)['ip']
-        elif CONF.validation.connect_method == 'fixed':
-            # Determine the network name to look for based on config or creds
-            # provider network resources.
-            if CONF.validation.network_for_ssh:
-                addresses = server['addresses'][
-                    CONF.validation.network_for_ssh]
-            else:
-                creds_provider = self._get_credentials_provider()
-                net_creds = creds_provider.get_primary_creds()
-                network = getattr(net_creds, 'network', None)
-                addresses = (server['addresses'][network['name']]
-                             if network else [])
-            for address in addresses:
-                ip_version_for_ssh = CONF.validation.ip_version_for_ssh
-                if (address['version'] == ip_version_for_ssh and
-                        address['OS-EXT-IPS:type'] == 'fixed'):
-                    return address['addr']
-            raise exceptions.ServerUnreachable(server_id=server['id'])
-        else:
-            raise lib_exc.InvalidConfiguration()
-
-    def _default_security_group(self, client=None, tenant_id=None):
-        """Get default secgroup for given tenant_id.
-
-        :returns: default secgroup for given tenant
-        """
-        if client is None:
-            client = self.security_groups_client
-        if not tenant_id:
-            tenant_id = client.tenant_id
-        sgs = [
-            sg for sg in list(client.list_security_groups().values())[0]
-            if sg['tenant_id'] == tenant_id and sg['name'] == 'default'
-        ]
-        msg = "No default security group for tenant %s." % (tenant_id)
-        self.assertGreater(len(sgs), 0, msg)
-        return sgs[0]
-
-    def _create_security_group(self):
-        # Create security group
-        sg_name = data_utils.rand_name(self.__class__.__name__)
-        sg_desc = sg_name + " description"
-        secgroup = self.compute_security_groups_client.create_security_group(
-            name=sg_name, description=sg_desc)['security_group']
-        self.assertEqual(secgroup['name'], sg_name)
-        self.assertEqual(secgroup['description'], sg_desc)
-        self.addCleanup(
-            test_utils.call_and_ignore_notfound_exc,
-            self.compute_security_groups_client.delete_security_group,
-            secgroup['id'])
-
-        # Add rules to the security group
-        self._create_loginable_secgroup_rule(secgroup['id'])
-
-        return secgroup
-
-    def _create_loginable_secgroup_rule(self, secgroup_id=None):
-        _client = self.compute_security_groups_client
-        _client_rules = self.compute_security_group_rules_client
-        if secgroup_id is None:
-            sgs = _client.list_security_groups()['security_groups']
-            for sg in sgs:
-                if sg['name'] == 'default':
-                    secgroup_id = sg['id']
-
-        # These rules are intended to permit inbound ssh and icmp
-        # traffic from all sources, so no group_id is provided.
-        # Setting a group_id would only permit traffic from ports
-        # belonging to the same security group.
-        rulesets = [
-            {
-                # ssh
-                'ip_protocol': 'tcp',
-                'from_port': 22,
-                'to_port': 22,
-                'cidr': '0.0.0.0/0',
-            },
-            {
-                # ping
-                'ip_protocol': 'icmp',
-                'from_port': -1,
-                'to_port': -1,
-                'cidr': '0.0.0.0/0',
-            }
-        ]
-        rules = list()
-        for ruleset in rulesets:
-            sg_rule = _client_rules.create_security_group_rule(
-                parent_group_id=secgroup_id, **ruleset)['security_group_rule']
-            rules.append(sg_rule)
-        return rules
-
-    def _create_security_group_rule(self, secgroup=None,
-                                    sec_group_rules_client=None,
-                                    tenant_id=None,
-                                    security_groups_client=None, **kwargs):
-        """Create a rule from a dictionary of rule parameters.
-
-        Create a rule in a secgroup. if secgroup not defined will search for
-        default secgroup in tenant_id.
-
-        :param secgroup: the security group.
-        :param tenant_id: if secgroup not passed -- the tenant in which to
-            search for default secgroup
-        :param kwargs: a dictionary containing rule parameters:
-            for example, to allow incoming ssh:
-            rule = {
-                    direction: 'ingress'
-                    protocol:'tcp',
-                    port_range_min: 22,
-                    port_range_max: 22
-                    }
-        """
-        if sec_group_rules_client is None:
-            sec_group_rules_client = self.security_group_rules_client
-        if security_groups_client is None:
-            security_groups_client = self.security_groups_client
-        if not tenant_id:
-            tenant_id = security_groups_client.tenant_id
-        if secgroup is None:
-            secgroup = self._default_security_group(
-                client=security_groups_client, tenant_id=tenant_id)
-
-        ruleset = dict(security_group_id=secgroup['id'],
-                       tenant_id=secgroup['tenant_id'])
-        ruleset.update(kwargs)
-
-        sg_rule = sec_group_rules_client.create_security_group_rule(**ruleset)
-        sg_rule = sg_rule['security_group_rule']
-
-        self.assertEqual(secgroup['tenant_id'], sg_rule['tenant_id'])
-        self.assertEqual(secgroup['id'], sg_rule['security_group_id'])
-
-        return sg_rule
diff --git a/barbican_tempest_plugin/tests/scenario/test_ephemeral_disk_encryption.py b/barbican_tempest_plugin/tests/scenario/test_ephemeral_disk_encryption.py
index 0b81649..71e6a0a 100644
--- a/barbican_tempest_plugin/tests/scenario/test_ephemeral_disk_encryption.py
+++ b/barbican_tempest_plugin/tests/scenario/test_ephemeral_disk_encryption.py
@@ -63,7 +63,7 @@
         client_test_path = '/tmp/ephemeral_disk_encryption_test'
         img_uuid = self.sign_and_upload_image()
         keypair = self.create_keypair()
-        security_group = self._create_security_group()
+        security_group = self.create_security_group()
         instance = self.create_server(
             name='signed_img_server',
             image_id=img_uuid,
diff --git a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
index 9d27866..7613fa7 100644
--- a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
+++ b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
@@ -15,6 +15,7 @@
 import testtools
 
 from oslo_log import log as logging
+
 from tempest.common import utils
 from tempest import config
 from tempest.lib.common import api_version_utils
@@ -97,7 +98,7 @@
         img_uuid = self.sign_and_upload_image()
         LOG.info("Creating keypair and security group")
         keypair = self.create_keypair()
-        security_group = self._create_security_group()
+        security_group = self.create_security_group()
         server = self.create_server(
             name='signed_img_server',
             image_id=img_uuid,
@@ -118,11 +119,13 @@
                       'PLAIN encryptor provider is not supported on rbd')
     @decorators.idempotent_id('cbc752ed-b716-4727-910f-956ccf965723')
     @utils.services('compute', 'volume', 'image')
+    @testtools.skipIf(CONF.volume.storage_protocol == 'ceph',
+                      'Skip because ceph does not support Provider plain')
     def test_encrypted_cinder_volumes_cryptsetup(self):
         img_uuid = self.sign_and_upload_image()
         LOG.info("Creating keypair and security group")
         keypair = self.create_keypair()
-        security_group = self._create_security_group()
+        security_group = self.create_security_group()
         server = self.create_server(
             name='signed_img_server',
             image_id=img_uuid,
diff --git a/setup.cfg b/setup.cfg
index a8d2496..110ab8e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -5,7 +5,7 @@
 author = OpenStack
 author_email = openstack-dev@lists.openstack.org
 url = http://www.openstack.org/
-python_requires = >=3.6
+python_requires = >=3.8
 classifier =
     Environment :: OpenStack
     Intended Audience :: Information Technology
@@ -14,8 +14,6 @@
     Operating System :: POSIX :: Linux
     Programming Language :: Python
     Programming Language :: Python :: 3
-    Programming Language :: Python :: 3.6
-    Programming Language :: Python :: 3.7
     Programming Language :: Python :: 3.8
     Programming Language :: Python :: 3.9