Merge flavor response schema into one file

After removing v3 schemas, we have only 1 set of schemas for v2 (/v2.1)
APIs but those end up in scattered structure.

Schema files needs to be re arranged into a clean structure. Any
resource schema should be defined in single file for better readability.

This patch merge the flavor response schema into one file.

Partially implements blueprint rearrange-nova-response-schemas

Change-Id: I2f660ce072fe199b4ed4d51ac2267b871d82ef83
diff --git a/tempest/api_schema/response/compute/flavors.py b/tempest/api_schema/response/compute/flavors.py
deleted file mode 100644
index 65f2c28..0000000
--- a/tempest/api_schema/response/compute/flavors.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright 2014 NEC Corporation.  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 tempest.api_schema.response.compute import parameter_types
-
-list_flavors = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'flavors': {
-                'type': 'array',
-                'items': {
-                    'type': 'object',
-                    'properties': {
-                        'name': {'type': 'string'},
-                        'links': parameter_types.links,
-                        'id': {'type': 'string'}
-                    },
-                    'required': ['name', 'links', 'id']
-                }
-            },
-            'flavors_links': parameter_types.links
-        },
-        # NOTE(gmann): flavors_links attribute is not necessary
-        # to be present always So it is not 'required'.
-        'required': ['flavors']
-    }
-}
-
-common_flavor_info = {
-    'type': 'object',
-    'properties': {
-        'name': {'type': 'string'},
-        'links': parameter_types.links,
-        'ram': {'type': 'integer'},
-        'vcpus': {'type': 'integer'},
-        'swap': {'type': 'integer'},
-        'disk': {'type': 'integer'},
-        'id': {'type': 'string'}
-    },
-    'required': ['name', 'links', 'ram', 'vcpus',
-                 'swap', 'disk', 'id']
-}
-
-common_flavor_list_details = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'flavors': {
-                'type': 'array',
-                'items': common_flavor_info
-            }
-        },
-        'required': ['flavors']
-    }
-}
-
-common_flavor_details = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'flavor': common_flavor_info
-        },
-        'required': ['flavor']
-    }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors.py b/tempest/api_schema/response/compute/v2_1/flavors.py
index 76c4cee..725d17a 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors.py
@@ -12,52 +12,86 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import copy
-
-from tempest.api_schema.response.compute import flavors
 from tempest.api_schema.response.compute import parameter_types
 
-list_flavors_details = copy.deepcopy(flavors.common_flavor_list_details)
+list_flavors = {
+    'status_code': [200],
+    'response_body': {
+        'type': 'object',
+        'properties': {
+            'flavors': {
+                'type': 'array',
+                'items': {
+                    'type': 'object',
+                    'properties': {
+                        'name': {'type': 'string'},
+                        'links': parameter_types.links,
+                        'id': {'type': 'string'}
+                    },
+                    'required': ['name', 'links', 'id']
+                }
+            },
+            'flavors_links': parameter_types.links
+        },
+        # NOTE(gmann): flavors_links attribute is not necessary
+        # to be present always So it is not 'required'.
+        'required': ['flavors']
+    }
+}
 
-# 'swap' attributes comes as integer value but if it is empty it comes as "".
-# So defining type of as string and integer.
-list_flavors_details['response_body']['properties']['flavors']['items'][
-    'properties']['swap'] = {'type': ['string', 'integer']}
+common_flavor_info = {
+    'type': 'object',
+    'properties': {
+        'name': {'type': 'string'},
+        'links': parameter_types.links,
+        'ram': {'type': 'integer'},
+        'vcpus': {'type': 'integer'},
+        # 'swap' attributes comes as integer value but if it is empty
+        # it comes as "". So defining type of as string and integer.
+        'swap': {'type': ['integer', 'string']},
+        'disk': {'type': 'integer'},
+        'id': {'type': 'string'},
+        'OS-FLV-DISABLED:disabled': {'type': 'boolean'},
+        'os-flavor-access:is_public': {'type': 'boolean'},
+        'rxtx_factor': {'type': 'number'},
+        'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}
+    },
+    # 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and
+    # 'OS-FLV-EXT-DATA' are API extensions. So they are not 'required'.
+    'required': ['name', 'links', 'ram', 'vcpus', 'swap', 'disk', 'id']
+}
 
-# Defining 'flavors_links' attributes for V2 flavor schema
-list_flavors_details['response_body'][
-    'properties'].update({'flavors_links': parameter_types.links})
-# NOTE(gmann): flavors_links attribute is not necessary to be
-# present always So it is not 'required'.
-
-# Defining extra attributes for V2 flavor schema
-list_flavors_details['response_body']['properties']['flavors']['items'][
-    'properties'].update({'OS-FLV-DISABLED:disabled': {'type': 'boolean'},
-                          'os-flavor-access:is_public': {'type': 'boolean'},
-                          'rxtx_factor': {'type': 'number'},
-                          'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}})
-# 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and 'OS-FLV-EXT-DATA'
-# are API extensions. So they are not 'required'.
+list_flavors_details = {
+    'status_code': [200],
+    'response_body': {
+        'type': 'object',
+        'properties': {
+            'flavors': {
+                'type': 'array',
+                'items': common_flavor_info
+            },
+            # NOTE(gmann): flavors_links attribute is not necessary
+            # to be present always So it is not 'required'.
+            'flavors_links': parameter_types.links
+        },
+        'required': ['flavors']
+    }
+}
 
 unset_flavor_extra_specs = {
     'status_code': [200]
 }
 
-create_get_flavor_details = copy.deepcopy(flavors.common_flavor_details)
-
-# 'swap' attributes comes as integer value but if it is empty it comes as "".
-# So defining type of as string and integer.
-create_get_flavor_details['response_body']['properties']['flavor'][
-    'properties']['swap'] = {'type': ['string', 'integer']}
-
-# Defining extra attributes for V2 flavor schema
-create_get_flavor_details['response_body']['properties']['flavor'][
-    'properties'].update({'OS-FLV-DISABLED:disabled': {'type': 'boolean'},
-                          'os-flavor-access:is_public': {'type': 'boolean'},
-                          'rxtx_factor': {'type': 'number'},
-                          'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}})
-# 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and 'OS-FLV-EXT-DATA'
-# are API extensions. So they are not 'required'.
+create_get_flavor_details = {
+    'status_code': [200],
+    'response_body': {
+        'type': 'object',
+        'properties': {
+            'flavor': common_flavor_info
+        },
+        'required': ['flavor']
+    }
+}
 
 delete_flavor = {
     'status_code': [202]
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 25b1869..2de43cf 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -16,11 +16,10 @@
 import json
 import urllib
 
-from tempest.api_schema.response.compute import flavors as common_schema
 from tempest.api_schema.response.compute import flavors_access as schema_access
 from tempest.api_schema.response.compute import flavors_extra_specs \
     as schema_extra_specs
-from tempest.api_schema.response.compute.v2_1 import flavors as v2schema
+from tempest.api_schema.response.compute.v2_1 import flavors as schema
 from tempest.common import service_client
 
 
@@ -33,7 +32,7 @@
 
         resp, body = self.get(url)
         body = json.loads(body)
-        self.validate_response(common_schema.list_flavors, resp, body)
+        self.validate_response(schema.list_flavors, resp, body)
         return service_client.ResponseBodyList(resp, body['flavors'])
 
     def list_flavors_with_detail(self, params=None):
@@ -43,13 +42,13 @@
 
         resp, body = self.get(url)
         body = json.loads(body)
-        self.validate_response(v2schema.list_flavors_details, resp, body)
+        self.validate_response(schema.list_flavors_details, resp, body)
         return service_client.ResponseBodyList(resp, body['flavors'])
 
     def get_flavor_details(self, flavor_id):
         resp, body = self.get("flavors/%s" % str(flavor_id))
         body = json.loads(body)
-        self.validate_response(v2schema.create_get_flavor_details, resp, body)
+        self.validate_response(schema.create_get_flavor_details, resp, body)
         return service_client.ResponseBody(resp, body['flavor'])
 
     def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
@@ -73,13 +72,13 @@
         resp, body = self.post('flavors', post_body)
 
         body = json.loads(body)
-        self.validate_response(v2schema.create_get_flavor_details, resp, body)
+        self.validate_response(schema.create_get_flavor_details, resp, body)
         return service_client.ResponseBody(resp, body['flavor'])
 
     def delete_flavor(self, flavor_id):
         """Deletes the given flavor."""
         resp, body = self.delete("flavors/{0}".format(flavor_id))
-        self.validate_response(v2schema.delete_flavor, resp, body)
+        self.validate_response(schema.delete_flavor, resp, body)
         return service_client.ResponseBody(resp, body)
 
     def is_resource_deleted(self, id):
@@ -137,7 +136,7 @@
         """Unsets extra Specs from the mentioned flavor."""
         resp, body = self.delete('flavors/%s/os-extra_specs/%s' %
                                  (str(flavor_id), key))
-        self.validate_response(v2schema.unset_flavor_extra_specs, resp, body)
+        self.validate_response(schema.unset_flavor_extra_specs, resp, body)
         return service_client.ResponseBody(resp, body)
 
     def list_flavor_access(self, flavor_id):