Merge "Handle volume API version enablement"
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index f358d7f..754104e 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -36,7 +36,7 @@
     def setup_credentials(cls):
         super(BaseVolumeQuotasAdminTestJSON, cls).setup_credentials()
         cls.demo_tenant_id = cls.os_primary.credentials.tenant_id
-        cls.alt_client = cls.os_alt.volumes_client
+        cls.alt_client = cls.os_alt.volumes_client_latest
 
     @classmethod
     def setup_clients(cls):
diff --git a/tempest/api/volume/admin/test_volume_type_access.py b/tempest/api/volume/admin/test_volume_type_access.py
index 297ab6e..e93bcb5 100644
--- a/tempest/api/volume/admin/test_volume_type_access.py
+++ b/tempest/api/volume/admin/test_volume_type_access.py
@@ -30,7 +30,7 @@
     @classmethod
     def setup_clients(cls):
         super(VolumeTypesAccessTest, cls).setup_clients()
-        cls.alt_client = cls.os_alt.volumes_client
+        cls.alt_client = cls.os_alt.volumes_client_latest
 
     @decorators.idempotent_id('d4dd0027-835f-4554-a6e5-50903fb79184')
     def test_volume_type_access_add(self):
diff --git a/tempest/clients.py b/tempest/clients.py
index 93323bd..6bbc65c 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -226,49 +226,63 @@
 
     def _set_volume_clients(self):
 
-        self.volume_qos_client = self.volume_v1.QosSpecsClient()
-        self.volume_qos_v2_client = self.volume_v2.QosSpecsClient()
-        self.volume_services_client = self.volume_v1.ServicesClient()
-        self.volume_services_v2_client = self.volume_v2.ServicesClient()
-        self.backups_client = self.volume_v1.BackupsClient()
-        self.backups_v2_client = self.volume_v2.BackupsClient()
-        self.backups_v3_client = self.volume_v3.BackupsClient()
-        self.encryption_types_client = self.volume_v1.EncryptionTypesClient()
-        self.encryption_types_v2_client = \
-            self.volume_v2.EncryptionTypesClient()
-        self.snapshot_manage_v2_client = self.volume_v2.SnapshotManageClient()
-        self.snapshots_client = self.volume_v1.SnapshotsClient()
-        self.snapshots_v2_client = self.volume_v2.SnapshotsClient()
-        self.volume_manage_v2_client = self.volume_v2.VolumeManageClient()
-        self.volumes_client = self.volume_v1.VolumesClient()
-        self.volumes_v2_client = self.volume_v2.VolumesClient()
-        self.volumes_v3_client = self.volume_v3.VolumesClient()
-        self.volume_v3_messages_client = self.volume_v3.MessagesClient()
-        self.volume_v3_versions_client = self.volume_v3.VersionsClient()
-        self.volume_types_client = self.volume_v1.TypesClient()
-        self.volume_types_v2_client = self.volume_v2.TypesClient()
-        self.volume_hosts_client = self.volume_v1.HostsClient()
-        self.volume_hosts_v2_client = self.volume_v2.HostsClient()
-        self.volume_quotas_client = self.volume_v1.QuotasClient()
-        self.volume_quotas_v2_client = self.volume_v2.QuotasClient()
-        self.volume_quota_classes_v2_client = \
-            self.volume_v2.QuotaClassesClient()
-        self.volumes_extension_client = self.volume_v1.ExtensionsClient()
-        self.volumes_v2_extension_client = self.volume_v2.ExtensionsClient()
-        self.groups_v3_client = self.volume_v3.GroupsClient()
-        self.group_types_v3_client = self.volume_v3.GroupTypesClient()
-        self.volume_availability_zone_client = \
-            self.volume_v1.AvailabilityZoneClient()
-        self.volume_v2_availability_zone_client = \
-            self.volume_v2.AvailabilityZoneClient()
-        self.volume_limits_client = self.volume_v1.LimitsClient()
-        self.volume_v2_limits_client = self.volume_v2.LimitsClient()
-        self.volume_capabilities_v2_client = \
-            self.volume_v2.CapabilitiesClient()
-        self.volume_scheduler_stats_v2_client = \
-            self.volume_v2.SchedulerStatsClient()
-        self.volume_transfers_v2_client = \
-            self.volume_v2.TransfersClient()
+        if CONF.volume_feature_enabled.api_v1:
+            self.backups_client = self.volume_v1.BackupsClient()
+            self.encryption_types_client = \
+                self.volume_v1.EncryptionTypesClient()
+            self.snapshots_client = self.volume_v1.SnapshotsClient()
+            self.volume_availability_zone_client = \
+                self.volume_v1.AvailabilityZoneClient()
+            self.volume_hosts_client = self.volume_v1.HostsClient()
+            self.volume_limits_client = self.volume_v1.LimitsClient()
+            self.volume_qos_client = self.volume_v1.QosSpecsClient()
+            self.volume_quotas_client = self.volume_v1.QuotasClient()
+            self.volume_services_client = self.volume_v1.ServicesClient()
+            self.volume_types_client = self.volume_v1.TypesClient()
+            self.volumes_client = self.volume_v1.VolumesClient()
+            self.volumes_extension_client = self.volume_v1.ExtensionsClient()
+
+        if CONF.volume_feature_enabled.api_v2:
+            self.backups_v2_client = self.volume_v2.BackupsClient()
+            self.encryption_types_v2_client = \
+                self.volume_v2.EncryptionTypesClient()
+            self.snapshot_manage_v2_client = \
+                self.volume_v2.SnapshotManageClient()
+            self.snapshots_v2_client = self.volume_v2.SnapshotsClient()
+            self.volume_capabilities_v2_client = \
+                self.volume_v2.CapabilitiesClient()
+            self.volume_manage_v2_client = self.volume_v2.VolumeManageClient()
+            self.volume_qos_v2_client = self.volume_v2.QosSpecsClient()
+            self.volume_services_v2_client = self.volume_v2.ServicesClient()
+            self.volume_types_v2_client = self.volume_v2.TypesClient()
+            self.volume_hosts_v2_client = self.volume_v2.HostsClient()
+            self.volume_quotas_v2_client = self.volume_v2.QuotasClient()
+            self.volume_quota_classes_v2_client = \
+                self.volume_v2.QuotaClassesClient()
+            self.volume_scheduler_stats_v2_client = \
+                self.volume_v2.SchedulerStatsClient()
+            self.volume_transfers_v2_client = \
+                self.volume_v2.TransfersClient()
+            self.volume_v2_availability_zone_client = \
+                self.volume_v2.AvailabilityZoneClient()
+            self.volume_v2_limits_client = self.volume_v2.LimitsClient()
+            self.volumes_v2_client = self.volume_v2.VolumesClient()
+            self.volumes_v2_extension_client = \
+                self.volume_v2.ExtensionsClient()
+
+            # Set default client for users that don't need explicit version
+            self.volumes_client_latest = self.volumes_v2_client
+
+        if CONF.volume_feature_enabled.api_v3:
+            self.backups_v3_client = self.volume_v3.BackupsClient()
+            self.group_types_v3_client = self.volume_v3.GroupTypesClient()
+            self.groups_v3_client = self.volume_v3.GroupsClient()
+            self.volume_v3_messages_client = self.volume_v3.MessagesClient()
+            self.volume_v3_versions_client = self.volume_v3.VersionsClient()
+            self.volumes_v3_client = self.volume_v3.VolumesClient()
+
+            # Set default client for users that don't need explicit version
+            self.volumes_client_latest = self.volumes_v3_client
 
     def _set_object_storage_clients(self):
         # NOTE(andreaf) Load configuration from config. Once object storage
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 0972a3c..2f4d120 100644
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -95,7 +95,7 @@
     client_dict = {
         'nova': os.servers_client,
         'keystone': os.identity_client,
-        'cinder': os.volumes_client,
+        'cinder': os.volumes_client_latest,
     }
     if service != 'keystone' and service != 'cinder':
         # Since keystone and cinder may be listening on a path,