Merge "Verify flavor extra specs attributes of Nova APIs"

This commit is contained in:
Jenkins
2014-04-24 00:22:27 +00:00
committed by Gerrit Code Review
5 changed files with 78 additions and 4 deletions

View File

@@ -0,0 +1,39 @@
# 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.
flavor_extra_specs = {
'status_code': [200],
'response_body': {
'type': 'object',
'properties': {
'extra_specs': {
'type': 'object',
'patternProperties': {
'^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
}
}
},
'required': ['extra_specs']
}
}
flavor_extra_specs_key = {
'status_code': [200],
'response_body': {
'type': 'object',
'patternProperties': {
'^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
}
}
}

View File

@@ -31,3 +31,7 @@ list_flavors_details['response_body']['properties']['flavors']['items'][
'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'.
unset_flavor_extra_specs = {
'status_code': [200]
}

View File

@@ -15,6 +15,7 @@
import copy
from tempest.api_schema.compute import flavors
from tempest.api_schema.compute import flavors_extra_specs
list_flavors_details = copy.deepcopy(flavors.common_flavor_list_details)
@@ -31,3 +32,10 @@ list_flavors_details['response_body']['properties']['flavors']['items'][
# So they are not 'required'.
list_flavors_details['response_body']['properties']['flavors']['items'][
'required'].extend(['disabled', 'ephemeral'])
set_flavor_extra_specs = copy.deepcopy(flavors_extra_specs.flavor_extra_specs)
set_flavor_extra_specs['status_code'] = [201]
unset_flavor_extra_specs = {
'status_code': [204]
}

View File

@@ -18,6 +18,8 @@ import urllib
from tempest.api_schema.compute import flavors as common_schema
from tempest.api_schema.compute import flavors_access as schema_access
from tempest.api_schema.compute import flavors_extra_specs \
as schema_extra_specs
from tempest.api_schema.compute.v2 import flavors as v2schema
from tempest.common import rest_client
from tempest import config
@@ -99,12 +101,16 @@ class FlavorsClientJSON(rest_client.RestClient):
resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
post_body)
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs,
resp, body)
return resp, body['extra_specs']
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs,
resp, body)
return resp, body['extra_specs']
def get_flavor_extra_spec_with_key(self, flavor_id, key):
@@ -112,6 +118,8 @@ class FlavorsClientJSON(rest_client.RestClient):
resp, body = self.get('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
key))
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs_key,
resp, body)
return resp, body
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
@@ -119,12 +127,16 @@ class FlavorsClientJSON(rest_client.RestClient):
resp, body = self.put('flavors/%s/os-extra_specs/%s' %
(flavor_id, key), json.dumps(kwargs))
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs_key,
resp, body)
return resp, body
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets extra Specs from the mentioned flavor."""
return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
key))
resp, body = self.delete('flavors/%s/os-extra_specs/%s' %
(str(flavor_id), key))
self.validate_response(v2schema.unset_flavor_extra_specs, resp, body)
return resp, body
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""

View File

@@ -18,6 +18,8 @@ import urllib
from tempest.api_schema.compute import flavors as common_schema
from tempest.api_schema.compute import flavors_access as schema_access
from tempest.api_schema.compute import flavors_extra_specs \
as schema_extra_specs
from tempest.api_schema.compute.v3 import flavors as v3schema
from tempest.common import rest_client
from tempest import config
@@ -99,12 +101,15 @@ class FlavorsV3ClientJSON(rest_client.RestClient):
resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
post_body)
body = json.loads(body)
self.validate_response(v3schema.set_flavor_extra_specs, resp, body)
return resp, body['extra_specs']
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
resp, body = self.get('flavors/%s/flavor-extra-specs' % flavor_id)
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs,
resp, body)
return resp, body['extra_specs']
def get_flavor_extra_spec_with_key(self, flavor_id, key):
@@ -112,6 +117,8 @@ class FlavorsV3ClientJSON(rest_client.RestClient):
resp, body = self.get('flavors/%s/flavor-extra-specs/%s' %
(str(flavor_id), key))
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs_key,
resp, body)
return resp, body
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
@@ -119,12 +126,16 @@ class FlavorsV3ClientJSON(rest_client.RestClient):
resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
(flavor_id, key), json.dumps(kwargs))
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs_key,
resp, body)
return resp, body
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets extra Specs from the mentioned flavor."""
return self.delete('flavors/%s/flavor-extra-specs/%s' %
(str(flavor_id), key))
resp, body = self.delete('flavors/%s/flavor-extra-specs/%s' %
(str(flavor_id), key))
self.validate_response(v3schema.unset_flavor_extra_specs, resp, body)
return resp, body
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""