Make Volume conditionally required attribute in Instance Create Schema

volume attribute may be removed in cases where volume support is off

Fixes: bug 1200029

Change-Id: Ic956e3d16cfb981eb778c77e0fe41b2e2e5f6e46
This commit is contained in:
justin-hopper 2013-07-10 17:23:32 -07:00
parent 563c274b48
commit a42419c4fe
2 changed files with 10 additions and 2 deletions

View File

@ -13,6 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
#
from trove.common import cfg
CONF = cfg.CONF
flavorref = {
'oneOf': [
@ -146,7 +149,8 @@ instance = {
"properties": {
"instance": {
"type": "object",
"required": ["name", "flavorRef", "volume"],
"required": ["name", "flavorRef",
"volume" if CONF.trove_volume_support else None],
"additionalProperties": False,
"properties": {
"name": non_empty_string,

View File

@ -38,7 +38,11 @@ LOG = logging.getLogger(__name__)
class InstanceController(wsgi.Controller):
"""Controller for instance functionality"""
schemas = apischema.instance
schemas = apischema.instance.copy()
if not CONF.trove_volume_support:
# see instance.models.create for further validation around this
LOG.info("Removing volume attributes from schema")
schemas['create']['properties']['instance']['required'].pop()
@classmethod
def get_action_schema(cls, body, action_schema):