summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-08-31 16:03:25 -0400
committerBrian Waldon <brian.waldon@rackspace.com>2011-08-31 16:03:25 -0400
commit6d206c85968ade7413191b2deeb4be0e2ae1a9b7 (patch)
tree501b78cf289f7dfa52776585783e5b9307c945ce
parent615e17eac9663b7909dfa6f70e6327d099774e20 (diff)
parent964bf2f246eddd31eb49fde1c589ccdc55d8f45b (diff)
downloadnova-6d206c85968ade7413191b2deeb4be0e2ae1a9b7.tar.gz
nova-6d206c85968ade7413191b2deeb4be0e2ae1a9b7.tar.xz
nova-6d206c85968ade7413191b2deeb4be0e2ae1a9b7.zip
merging trunk
-rw-r--r--nova/context.py2
-rw-r--r--nova/notifier/api.py3
-rw-r--r--nova/tests/test_context.py33
-rw-r--r--nova/tests/test_xenapi.py37
4 files changed, 36 insertions, 39 deletions
diff --git a/nova/context.py b/nova/context.py
index b917a1d81..5c22641a0 100644
--- a/nova/context.py
+++ b/nova/context.py
@@ -38,7 +38,7 @@ class RequestContext(object):
self.roles = roles or []
self.is_admin = is_admin
if self.is_admin is None:
- self.admin = 'admin' in self.roles
+ self.is_admin = 'admin' in [x.lower() for x in self.roles]
self.read_deleted = read_deleted
self.remote_address = remote_address
if not timestamp:
diff --git a/nova/notifier/api.py b/nova/notifier/api.py
index 6ef4a050e..043838536 100644
--- a/nova/notifier/api.py
+++ b/nova/notifier/api.py
@@ -122,4 +122,5 @@ def notify(publisher_id, event_type, priority, payload):
driver.notify(msg)
except Exception, e:
LOG.exception(_("Problem '%(e)s' attempting to "
- "send to notification system." % locals()))
+ "send to notification system. Payload=%(payload)s" %
+ locals()))
diff --git a/nova/tests/test_context.py b/nova/tests/test_context.py
new file mode 100644
index 000000000..b2507fa59
--- /dev/null
+++ b/nova/tests/test_context.py
@@ -0,0 +1,33 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2011 OpenStack LLC
+#
+# 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 nova import context
+from nova import test
+
+
+class ContextTestCase(test.TestCase):
+
+ def test_request_context_sets_is_admin(self):
+ ctxt = context.RequestContext('111',
+ '222',
+ roles=['admin', 'weasel'])
+ self.assertEquals(ctxt.is_admin, True)
+
+ def test_request_context_sets_is_admin_upcase(self):
+ ctxt = context.RequestContext('111',
+ '222',
+ roles=['Admin', 'weasel'])
+ self.assertEquals(ctxt.is_admin, True)
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 2f0559366..45dad3516 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -16,7 +16,6 @@
"""Test suite for XenAPI."""
-import eventlet
import functools
import json
import os
@@ -203,42 +202,6 @@ class XenAPIVMTestCase(test.TestCase):
self.context = context.RequestContext(self.user_id, self.project_id)
self.conn = xenapi_conn.get_connection(False)
- def test_parallel_builds(self):
- stubs.stubout_loopingcall_delay(self.stubs)
-
- def _do_build(id, proj, user, *args):
- values = {
- 'id': id,
- 'project_id': proj,
- 'user_id': user,
- 'image_ref': 1,
- 'kernel_id': 2,
- 'ramdisk_id': 3,
- 'instance_type_id': '3', # m1.large
- 'os_type': 'linux',
- 'architecture': 'x86-64'}
- network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
- {'broadcast': '192.168.0.255',
- 'dns': ['192.168.0.1'],
- 'gateway': '192.168.0.1',
- 'gateway6': 'dead:beef::1',
- 'ip6s': [{'enabled': '1',
- 'ip': 'dead:beef::dcad:beff:feef:0',
- 'netmask': '64'}],
- 'ips': [{'enabled': '1',
- 'ip': '192.168.0.100',
- 'netmask': '255.255.255.0'}],
- 'label': 'fake',
- 'mac': 'DE:AD:BE:EF:00:00',
- 'rxtx_cap': 3})]
- instance = db.instance_create(self.context, values)
- self.conn.spawn(self.context, instance, network_info)
-
- gt1 = eventlet.spawn(_do_build, 1, self.project_id, self.user_id)
- gt2 = eventlet.spawn(_do_build, 2, self.project_id, self.user_id)
- gt1.wait()
- gt2.wait()
-
def test_list_instances_0(self):
instances = self.conn.list_instances()
self.assertEquals(instances, [])