Do not restrict flavor to only ID and integers

- Flavors with strings and not just ID/UUID strings are valid.
- Closes-Bug: 1209060

Change-Id: Idee389fce40f8982b263e1a4349a8565140b6584
This commit is contained in:
Chmouel Boudjnah 2013-08-07 14:55:53 +02:00
parent cb42b95f1f
commit f7d3948b23
2 changed files with 38 additions and 7 deletions

View File

@ -1,3 +1,18 @@
# Copyright (c) 2013, OpenStack
# 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 novaclient import exceptions
from novaclient.v1_1 import flavors
from novaclient.tests import utils
@ -85,6 +100,29 @@ class FlavorsTest(utils.TestCase):
cs.assert_called('POST', '/flavors', body)
self.assertTrue(isinstance(f, flavors.Flavor))
def test_create_with_id_as_string(self):
flavor_id = 'foobar'
f = cs.flavors.create("flavorcreate", 512,
1, 10, flavor_id, ephemeral=10,
is_public=False)
body = {
"flavor": {
"name": "flavorcreate",
"ram": 512,
"vcpus": 1,
"disk": 10,
"OS-FLV-EXT-DATA:ephemeral": 10,
"id": flavor_id,
"swap": 0,
"rxtx_factor": 1.0,
"os-flavor-access:is_public": False,
}
}
cs.assert_called('POST', '/flavors', body)
self.assertTrue(isinstance(f, flavors.Flavor))
def test_create_ephemeral_ispublic_defaults(self):
f = cs.flavors.create("flavorcreate", 512, 1, 10, 1234)

View File

@ -7,7 +7,6 @@ import urllib
from novaclient import base
from novaclient import exceptions
from novaclient import utils
from novaclient.openstack.common import uuidutils
class Flavor(base.Resource):
@ -148,12 +147,6 @@ class FlavorManager(base.ManagerWithFind):
if flavorid == "auto":
flavorid = None
elif not uuidutils.is_uuid_like(flavorid):
try:
flavorid = int(flavorid)
except (TypeError, ValueError):
raise exceptions.CommandError("Flavor ID must be an integer "
"or a UUID or auto.")
try:
swap = int(swap)