summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-05 06:01:18 +0000
committerGerrit Code Review <review@openstack.org>2012-09-05 06:01:18 +0000
commit9bb97b04b1b3034b32bcf3bcfc5f190408db5579 (patch)
tree617e6e8c77ad35f964a02cee2cb2d1b66348c89e
parentc69982ef66cf8a3b5c891bc7c5d22d62b0c87cd4 (diff)
parent15e266ce2b9100f3fd8f98230b9ffab9adb163f4 (diff)
Merge "Makes sure new flavors default to is_public=True"
-rw-r--r--nova/api/openstack/compute/contrib/flavormanage.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_flavor_manage.py39
2 files changed, 40 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/flavormanage.py b/nova/api/openstack/compute/contrib/flavormanage.py
index e3d57f3a1..d6bd87005 100644
--- a/nova/api/openstack/compute/contrib/flavormanage.py
+++ b/nova/api/openstack/compute/contrib/flavormanage.py
@@ -65,7 +65,7 @@ class FlavorManageController(wsgi.Controller):
ephemeral_gb = vals.get('OS-FLV-EXT-DATA:ephemeral')
swap = vals.get('swap')
rxtx_factor = vals.get('rxtx_factor')
- is_public = vals.get('os-flavor-access:is_public')
+ is_public = vals.get('os-flavor-access:is_public', True)
try:
flavor = instance_types.create(name, memory_mb, vcpus,
diff --git a/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py b/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py
index 68d8ee750..7406b0fd9 100644
--- a/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py
+++ b/nova/tests/api/openstack/compute/contrib/test_flavor_manage.py
@@ -117,6 +117,45 @@ class FlavorManageTest(test.TestCase):
for key in expected["flavor"]:
self.assertEquals(body["flavor"][key], expected["flavor"][key])
+ def test_create_public_default(self):
+ flavor = {
+ "flavor": {
+ "name": "test",
+ "ram": 512,
+ "vcpus": 2,
+ "disk": 1,
+ "OS-FLV-EXT-DATA:ephemeral": 1,
+ "id": 1234,
+ "swap": 512,
+ "rxtx_factor": 1,
+ }
+ }
+
+ expected = {
+ "flavor": {
+ "name": "test",
+ "ram": 512,
+ "vcpus": 2,
+ "disk": 1,
+ "OS-FLV-EXT-DATA:ephemeral": 1,
+ "id": 1234,
+ "swap": 512,
+ "rxtx_factor": 1,
+ "os-flavor-access:is_public": True,
+ }
+ }
+
+ self.stubs.Set(instance_types, "create", fake_create)
+ url = '/v2/fake/flavors'
+ req = webob.Request.blank(url)
+ req.headers['Content-Type'] = 'application/json'
+ req.method = 'POST'
+ req.body = jsonutils.dumps(flavor)
+ res = req.get_response(fakes.wsgi_app())
+ body = jsonutils.loads(res.body)
+ for key in expected["flavor"]:
+ self.assertEquals(body["flavor"][key], expected["flavor"][key])
+
def test_instance_type_exists_exception_returns_409(self):
expected = {
"flavor": {