Merged trunk.
This commit is contained in:
		| @@ -45,6 +45,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     servers = [] | ||||
|     for api in flags.FLAGS.enabled_apis: | ||||
|         servers.append(service.WSGIService(api)) | ||||
|   | ||||
| @@ -41,6 +41,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     server = service.WSGIService('ec2') | ||||
|     service.serve(server) | ||||
|     service.wait() | ||||
|   | ||||
| @@ -41,6 +41,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     server = service.WSGIService('osapi') | ||||
|     service.serve(server) | ||||
|     service.wait() | ||||
|   | ||||
| @@ -43,6 +43,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     server = service.Service.create(binary='nova-compute') | ||||
|     service.serve(server) | ||||
|     service.wait() | ||||
|   | ||||
| @@ -43,6 +43,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     server = service.Service.create(binary='nova-network') | ||||
|     service.serve(server) | ||||
|     service.wait() | ||||
|   | ||||
| @@ -49,6 +49,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     router = s3server.S3Application(FLAGS.buckets_path) | ||||
|     server = wsgi.Server("S3 Objectstore", | ||||
|                          router, | ||||
|   | ||||
| @@ -22,6 +22,7 @@ | ||||
| import eventlet | ||||
| eventlet.monkey_patch() | ||||
|  | ||||
| import gettext | ||||
| import os | ||||
| import sys | ||||
|  | ||||
| @@ -33,6 +34,7 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), | ||||
| if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): | ||||
|     sys.path.insert(0, possible_topdir) | ||||
|  | ||||
| gettext.install('nova', unicode=1) | ||||
|  | ||||
| from nova import flags | ||||
| from nova import log as logging | ||||
| @@ -43,6 +45,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     server = service.Service.create(binary='nova-scheduler') | ||||
|     service.serve(server) | ||||
|     service.wait() | ||||
|   | ||||
| @@ -43,6 +43,7 @@ if __name__ == '__main__': | ||||
|     utils.default_flagfile() | ||||
|     flags.FLAGS(sys.argv) | ||||
|     logging.setup() | ||||
|     utils.monkey_patch() | ||||
|     server = service.Service.create(binary='nova-volume') | ||||
|     service.serve(server) | ||||
|     service.wait() | ||||
|   | ||||
| @@ -41,10 +41,13 @@ from nova.auth import signer | ||||
|  | ||||
|  | ||||
| FLAGS = flags.FLAGS | ||||
| flags.DEFINE_bool('use_deprecated_auth', | ||||
|                   False, | ||||
|                   'This flag must be set to use old style auth') | ||||
|  | ||||
| flags.DEFINE_list('allowed_roles', | ||||
|                   ['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'], | ||||
|                   'Allowed roles for project') | ||||
|  | ||||
| # NOTE(vish): a user with one of these roles will be a superuser and | ||||
| #             have access to all api commands | ||||
| flags.DEFINE_list('superuser_roles', ['cloudadmin'], | ||||
| @@ -814,7 +817,13 @@ class AuthManager(object): | ||||
|             s3_host = host | ||||
|             ec2_host = host | ||||
|         rc = open(FLAGS.credentials_template).read() | ||||
|         rc = rc % {'access': user.access, | ||||
|         # NOTE(vish): Deprecated auth uses an access key, no auth uses a | ||||
|         #             the user_id in place of it. | ||||
|         if FLAGS.use_deprecated_auth: | ||||
|             access = user.access | ||||
|         else: | ||||
|             access = user.id | ||||
|         rc = rc % {'access': access, | ||||
|                    'project': pid, | ||||
|                    'secret': user.secret, | ||||
|                    'ec2': '%s://%s:%s%s' % (FLAGS.ec2_scheme, | ||||
|   | ||||
| @@ -402,3 +402,14 @@ DEFINE_bool('resume_guests_state_on_host_boot', False, | ||||
|  | ||||
| DEFINE_string('root_helper', 'sudo', | ||||
|               'Command prefix to use for running commands as root') | ||||
|  | ||||
| DEFINE_bool('use_ipv6', False, 'use ipv6') | ||||
|  | ||||
| DEFINE_bool('monkey_patch', False, | ||||
|               'Whether to log monkey patching') | ||||
|  | ||||
| DEFINE_list('monkey_patch_modules', | ||||
|         ['nova.api.ec2.cloud:nova.notifier.api.notify_decorator', | ||||
|         'nova.compute.api:nova.notifier.api.notify_decorator'], | ||||
|         'Module list representing monkey ' | ||||
|         'patched module and decorator') | ||||
|   | ||||
| @@ -25,6 +25,9 @@ FLAGS = flags.FLAGS | ||||
|  | ||||
| flags.DEFINE_string('default_notification_level', 'INFO', | ||||
|                     'Default notification level for outgoing notifications') | ||||
| flags.DEFINE_string('default_publisher_id', FLAGS.host, | ||||
|                     'Default publisher_id for outgoing notifications') | ||||
|  | ||||
|  | ||||
| WARN = 'WARN' | ||||
| INFO = 'INFO' | ||||
| @@ -39,6 +42,30 @@ class BadPriorityException(Exception): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| def notify_decorator(name, fn): | ||||
|     """ decorator for notify which is used from utils.monkey_patch() | ||||
|  | ||||
|         :param name: name of the function | ||||
|         :param function: - object of the function | ||||
|         :returns: function -- decorated function | ||||
|  | ||||
|     """ | ||||
|     def wrapped_func(*args, **kwarg): | ||||
|         body = {} | ||||
|         body['args'] = [] | ||||
|         body['kwarg'] = {} | ||||
|         for arg in args: | ||||
|             body['args'].append(arg) | ||||
|         for key in kwarg: | ||||
|             body['kwarg'][key] = kwarg[key] | ||||
|         notify(FLAGS.default_publisher_id, | ||||
|                             name, | ||||
|                             FLAGS.default_notification_level, | ||||
|                             body) | ||||
|         return fn(*args, **kwarg) | ||||
|     return wrapped_func | ||||
|  | ||||
|  | ||||
| def publisher_id(service, host=None): | ||||
|     if not host: | ||||
|         host = FLAGS.host | ||||
|   | ||||
| @@ -147,6 +147,7 @@ class _AuthManagerBaseTestCase(test.TestCase): | ||||
|                         '/services/Cloud')) | ||||
|  | ||||
|     def test_can_get_credentials(self): | ||||
|         self.flags(use_deprecated_auth=True) | ||||
|         st = {'access': 'access', 'secret': 'secret'} | ||||
|         with user_and_project_generator(self.manager, user_state=st) as (u, p): | ||||
|             credentials = self.manager.get_environment_rc(u, p) | ||||
|   | ||||
| @@ -134,3 +134,24 @@ class NotifierTestCase(test.TestCase): | ||||
|         self.assertEqual(msg['event_type'], 'error_notification') | ||||
|         self.assertEqual(msg['priority'], 'ERROR') | ||||
|         self.assertEqual(msg['payload']['error'], 'foo') | ||||
|  | ||||
|     def test_send_notification_by_decorator(self): | ||||
|         self.notify_called = False | ||||
|  | ||||
|         def example_api(arg1, arg2): | ||||
|             return arg1 + arg2 | ||||
|  | ||||
|         example_api = nova.notifier.api.notify_decorator( | ||||
|                             'example_api', | ||||
|                              example_api) | ||||
|  | ||||
|         def mock_notify(cls, *args): | ||||
|             self.notify_called = True | ||||
|  | ||||
|         self.stubs.Set(nova.notifier.no_op_notifier, 'notify', | ||||
|                 mock_notify) | ||||
|  | ||||
|         class Mock(object): | ||||
|             pass | ||||
|         self.assertEqual(3, example_api(1, 2)) | ||||
|         self.assertEqual(self.notify_called, True) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Brian Lamar
					Brian Lamar