formatting and naming cleanup
This commit is contained in:
		@@ -17,9 +17,8 @@
 | 
				
			|||||||
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
#    See the License for the specific language governing permissions and
 | 
					#    See the License for the specific language governing permissions and
 | 
				
			||||||
#    limitations under the License.
 | 
					#    limitations under the License.
 | 
				
			||||||
"""
 | 
					
 | 
				
			||||||
Nova API daemon.
 | 
					"""Starter script for Nova API."""
 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
@@ -35,7 +34,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
 | 
				
			|||||||
from nova import api
 | 
					from nova import api
 | 
				
			||||||
from nova import flags
 | 
					from nova import flags
 | 
				
			||||||
from nova import utils
 | 
					from nova import utils
 | 
				
			||||||
from nova import server
 | 
					 | 
				
			||||||
from nova import wsgi
 | 
					from nova import wsgi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					FLAGS = flags.FLAGS
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,7 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""Combined starter script for Nova services."""
 | 
				
			||||||
  Twistd daemon for the nova compute nodes.
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eventlet
 | 
					import eventlet
 | 
				
			||||||
eventlet.monkey_patch()
 | 
					eventlet.monkey_patch()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,7 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""Starter script for Nova Compute."""
 | 
				
			||||||
  Twistd daemon for the nova compute nodes.
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eventlet
 | 
					import eventlet
 | 
				
			||||||
eventlet.monkey_patch()
 | 
					eventlet.monkey_patch()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,7 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""Starter script for Nova Network."""
 | 
				
			||||||
  Twistd daemon for the nova compute nodes.
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eventlet
 | 
					import eventlet
 | 
				
			||||||
eventlet.monkey_patch()
 | 
					eventlet.monkey_patch()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,7 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					""" Starter script for Nova Scheduler."""
 | 
				
			||||||
  Twistd daemon for the nova scheduler nodes.
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eventlet
 | 
					import eventlet
 | 
				
			||||||
eventlet.monkey_patch()
 | 
					eventlet.monkey_patch()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,7 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""Starter script for Nova Volume."""
 | 
				
			||||||
  Twistd daemon for the nova volume nodes.
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eventlet
 | 
					import eventlet
 | 
				
			||||||
eventlet.monkey_patch()
 | 
					eventlet.monkey_patch()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -159,12 +159,11 @@ class StrWrapper(object):
 | 
				
			|||||||
                return str(val)
 | 
					                return str(val)
 | 
				
			||||||
        raise KeyError(name)
 | 
					        raise KeyError(name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = FlagValues()
 | 
					FLAGS = FlagValues()
 | 
				
			||||||
gflags.FLAGS = FLAGS
 | 
					gflags.FLAGS = FLAGS
 | 
				
			||||||
gflags.DEFINE_flag(gflags.HelpFlag(), FLAGS)
 | 
					gflags.DEFINE_flag(gflags.HelpFlag(), FLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gflags.FLAGS = FLAGS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _wrapper(func):
 | 
					def _wrapper(func):
 | 
				
			||||||
    def _wrapped(*args, **kw):
 | 
					    def _wrapped(*args, **kw):
 | 
				
			||||||
@@ -187,6 +186,7 @@ DEFINE_multistring = _wrapper(gflags.DEFINE_multistring)
 | 
				
			|||||||
DEFINE_multi_int = _wrapper(gflags.DEFINE_multi_int)
 | 
					DEFINE_multi_int = _wrapper(gflags.DEFINE_multi_int)
 | 
				
			||||||
DEFINE_flag = _wrapper(gflags.DEFINE_flag)
 | 
					DEFINE_flag = _wrapper(gflags.DEFINE_flag)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HelpFlag = gflags.HelpFlag
 | 
					HelpFlag = gflags.HelpFlag
 | 
				
			||||||
HelpshortFlag = gflags.HelpshortFlag
 | 
					HelpshortFlag = gflags.HelpshortFlag
 | 
				
			||||||
HelpXMLFlag = gflags.HelpXMLFlag
 | 
					HelpXMLFlag = gflags.HelpXMLFlag
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -309,7 +309,6 @@ def call(context, topic, msg):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    class WaitMessage(object):
 | 
					    class WaitMessage(object):
 | 
				
			||||||
        def __call__(self, data, message):
 | 
					        def __call__(self, data, message):
 | 
				
			||||||
            LOG.debug('data %s, msg %s', data, message)
 | 
					 | 
				
			||||||
            """Acks message and sets result."""
 | 
					            """Acks message and sets result."""
 | 
				
			||||||
            message.ack()
 | 
					            message.ack()
 | 
				
			||||||
            if data['failure']:
 | 
					            if data['failure']:
 | 
				
			||||||
@@ -332,6 +331,10 @@ def call(context, topic, msg):
 | 
				
			|||||||
    except StopIteration:
 | 
					    except StopIteration:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    consumer.close()
 | 
					    consumer.close()
 | 
				
			||||||
 | 
					    # NOTE(termie): this is a little bit of a change from the original
 | 
				
			||||||
 | 
					    #               twisted-based code where returning a Failure
 | 
				
			||||||
 | 
					    #               instance from a deferred call is very similar to
 | 
				
			||||||
 | 
					    #               raising an exception
 | 
				
			||||||
    if isinstance(wait_msg.result, Exception):
 | 
					    if isinstance(wait_msg.result, Exception):
 | 
				
			||||||
        raise wait_msg.result
 | 
					        raise wait_msg.result
 | 
				
			||||||
    return wait_msg.result
 | 
					    return wait_msg.result
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										151
									
								
								nova/server.py
									
									
									
									
									
								
							
							
						
						
									
										151
									
								
								nova/server.py
									
									
									
									
									
								
							@@ -1,151 +0,0 @@
 | 
				
			|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Copyright 2010 United States Government as represented by the
 | 
					 | 
				
			||||||
# Administrator of the National Aeronautics and Space Administration.
 | 
					 | 
				
			||||||
# 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.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
Base functionality for nova daemons - gradually being replaced with twistd.py.
 | 
					 | 
				
			||||||
"""
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import daemon
 | 
					 | 
				
			||||||
from daemon import pidlockfile
 | 
					 | 
				
			||||||
import logging
 | 
					 | 
				
			||||||
import logging.handlers
 | 
					 | 
				
			||||||
import os
 | 
					 | 
				
			||||||
import signal
 | 
					 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
import time
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from nova import flags
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
flags.DEFINE_bool('daemonize', False, 'daemonize this process')
 | 
					 | 
				
			||||||
# NOTE(termie): right now I am defaulting to using syslog when we daemonize
 | 
					 | 
				
			||||||
#               it may be better to do something else -shrug-
 | 
					 | 
				
			||||||
# NOTE(Devin): I think we should let each process have its own log file
 | 
					 | 
				
			||||||
#              and put it in /var/logs/nova/(appname).log
 | 
					 | 
				
			||||||
#              This makes debugging much easier and cuts down on sys log
 | 
					 | 
				
			||||||
#              clutter.
 | 
					 | 
				
			||||||
flags.DEFINE_bool('use_syslog', True, 'output to syslog when daemonizing')
 | 
					 | 
				
			||||||
flags.DEFINE_string('logfile', None, 'log file to output to')
 | 
					 | 
				
			||||||
flags.DEFINE_string('logdir',  None, 'directory to keep log files in '
 | 
					 | 
				
			||||||
                                     '(will be prepended to $logfile)')
 | 
					 | 
				
			||||||
flags.DEFINE_string('pidfile', None, 'pid file to output to')
 | 
					 | 
				
			||||||
flags.DEFINE_string('working_directory', './', 'working directory...')
 | 
					 | 
				
			||||||
flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run')
 | 
					 | 
				
			||||||
flags.DEFINE_integer('gid', os.getgid(), 'gid under which to run')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def stop(pidfile):
 | 
					 | 
				
			||||||
    """
 | 
					 | 
				
			||||||
    Stop the daemon
 | 
					 | 
				
			||||||
    """
 | 
					 | 
				
			||||||
    # Get the pid from the pidfile
 | 
					 | 
				
			||||||
    try:
 | 
					 | 
				
			||||||
        pid = int(open(pidfile, 'r').read().strip())
 | 
					 | 
				
			||||||
    except IOError:
 | 
					 | 
				
			||||||
        message = "pidfile %s does not exist. Daemon not running?\n"
 | 
					 | 
				
			||||||
        sys.stderr.write(message % pidfile)
 | 
					 | 
				
			||||||
        return
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Try killing the daemon process
 | 
					 | 
				
			||||||
    try:
 | 
					 | 
				
			||||||
        while 1:
 | 
					 | 
				
			||||||
            os.kill(pid, signal.SIGTERM)
 | 
					 | 
				
			||||||
            time.sleep(0.1)
 | 
					 | 
				
			||||||
    except OSError, err:
 | 
					 | 
				
			||||||
        err = str(err)
 | 
					 | 
				
			||||||
        if err.find("No such process") > 0:
 | 
					 | 
				
			||||||
            if os.path.exists(pidfile):
 | 
					 | 
				
			||||||
                os.remove(pidfile)
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            print str(err)
 | 
					 | 
				
			||||||
            sys.exit(1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def serve(name, main):
 | 
					 | 
				
			||||||
    """Controller for server"""
 | 
					 | 
				
			||||||
    argv = FLAGS(sys.argv)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if not FLAGS.pidfile:
 | 
					 | 
				
			||||||
        FLAGS.pidfile = '%s.pid' % name
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    logging.debug("Full set of FLAGS: \n\n\n")
 | 
					 | 
				
			||||||
    for flag in FLAGS:
 | 
					 | 
				
			||||||
        logging.debug("%s : %s", flag, FLAGS.get(flag, None))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    action = 'start'
 | 
					 | 
				
			||||||
    if len(argv) > 1:
 | 
					 | 
				
			||||||
        action = argv.pop()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if action == 'stop':
 | 
					 | 
				
			||||||
        stop(FLAGS.pidfile)
 | 
					 | 
				
			||||||
        sys.exit()
 | 
					 | 
				
			||||||
    elif action == 'restart':
 | 
					 | 
				
			||||||
        stop(FLAGS.pidfile)
 | 
					 | 
				
			||||||
    elif action == 'start':
 | 
					 | 
				
			||||||
        pass
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        print 'usage: %s [options] [start|stop|restart]' % argv[0]
 | 
					 | 
				
			||||||
        sys.exit(1)
 | 
					 | 
				
			||||||
    daemonize(argv, name, main)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def daemonize(args, name, main):
 | 
					 | 
				
			||||||
    """Does the work of daemonizing the process"""
 | 
					 | 
				
			||||||
    logging.getLogger('amqplib').setLevel(logging.WARN)
 | 
					 | 
				
			||||||
    files_to_keep = []
 | 
					 | 
				
			||||||
    if FLAGS.daemonize:
 | 
					 | 
				
			||||||
        logger = logging.getLogger()
 | 
					 | 
				
			||||||
        formatter = logging.Formatter(
 | 
					 | 
				
			||||||
                name + '(%(name)s): %(levelname)s %(message)s')
 | 
					 | 
				
			||||||
        if FLAGS.use_syslog and not FLAGS.logfile:
 | 
					 | 
				
			||||||
            syslog = logging.handlers.SysLogHandler(address='/dev/log')
 | 
					 | 
				
			||||||
            syslog.setFormatter(formatter)
 | 
					 | 
				
			||||||
            logger.addHandler(syslog)
 | 
					 | 
				
			||||||
            files_to_keep.append(syslog.socket)
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            if not FLAGS.logfile:
 | 
					 | 
				
			||||||
                FLAGS.logfile = '%s.log' % name
 | 
					 | 
				
			||||||
            if FLAGS.logdir:
 | 
					 | 
				
			||||||
                FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
 | 
					 | 
				
			||||||
            logfile = logging.FileHandler(FLAGS.logfile)
 | 
					 | 
				
			||||||
            logfile.setFormatter(formatter)
 | 
					 | 
				
			||||||
            logger.addHandler(logfile)
 | 
					 | 
				
			||||||
            files_to_keep.append(logfile.stream)
 | 
					 | 
				
			||||||
        stdin, stdout, stderr = None, None, None
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if FLAGS.verbose:
 | 
					 | 
				
			||||||
        logging.getLogger().setLevel(logging.DEBUG)
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        logging.getLogger().setLevel(logging.WARNING)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    with daemon.DaemonContext(
 | 
					 | 
				
			||||||
            detach_process=FLAGS.daemonize,
 | 
					 | 
				
			||||||
            working_directory=FLAGS.working_directory,
 | 
					 | 
				
			||||||
            #pidfile=pidlockfile.TimeoutPIDLockFile(FLAGS.pidfile,
 | 
					 | 
				
			||||||
            #                                       acquire_timeout=1,
 | 
					 | 
				
			||||||
            #                                       threaded=False),
 | 
					 | 
				
			||||||
            stdin=stdin,
 | 
					 | 
				
			||||||
            stdout=stdout,
 | 
					 | 
				
			||||||
            stderr=stderr,
 | 
					 | 
				
			||||||
            uid=FLAGS.uid,
 | 
					 | 
				
			||||||
            gid=FLAGS.gid,
 | 
					 | 
				
			||||||
            files_preserve=files_to_keep):
 | 
					 | 
				
			||||||
        main(args)
 | 
					 | 
				
			||||||
@@ -55,11 +55,11 @@ def skip_if_fake(func):
 | 
				
			|||||||
            return func(*args, **kw)
 | 
					            return func(*args, **kw)
 | 
				
			||||||
    return _skipper
 | 
					    return _skipper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TrialTestCase(unittest.TestCase):
 | 
					class TestCase(unittest.TestCase):
 | 
				
			||||||
    """Test case base class for all unit tests"""
 | 
					    """Test case base class for all unit tests"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        """Run before each test method to initialize test environment"""
 | 
					        """Run before each test method to initialize test environment"""
 | 
				
			||||||
        super(TrialTestCase, self).setUp()
 | 
					        super(TestCase, self).setUp()
 | 
				
			||||||
        # NOTE(vish): We need a better method for creating fixtures for tests
 | 
					        # NOTE(vish): We need a better method for creating fixtures for tests
 | 
				
			||||||
        #             now that we have some required db setup for the system
 | 
					        #             now that we have some required db setup for the system
 | 
				
			||||||
        #             to work properly.
 | 
					        #             to work properly.
 | 
				
			||||||
@@ -105,7 +105,7 @@ class TrialTestCase(unittest.TestCase):
 | 
				
			|||||||
                fakerabbit.reset_all()
 | 
					                fakerabbit.reset_all()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            db.security_group_destroy_all(ctxt)
 | 
					            db.security_group_destroy_all(ctxt)
 | 
				
			||||||
            super(TrialTestCase, self).tearDown()
 | 
					            super(TestCase, self).tearDown()
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            self.reset_flags()
 | 
					            self.reset_flags()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -137,7 +137,7 @@ class TrialTestCase(unittest.TestCase):
 | 
				
			|||||||
        rpc.Consumer.attach_to_eventlet = _wrapped
 | 
					        rpc.Consumer.attach_to_eventlet = _wrapped
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class OLDTrialTestCase(trial_unittest.TestCase):
 | 
					class TrialTestCase(trial_unittest.TestCase):
 | 
				
			||||||
    """Test case base class for all unit tests"""
 | 
					    """Test case base class for all unit tests"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        """Run before each test method to initialize test environment"""
 | 
					        """Run before each test method to initialize test environment"""
 | 
				
			||||||
@@ -175,7 +175,6 @@ class OLDTrialTestCase(trial_unittest.TestCase):
 | 
				
			|||||||
            db.fixed_ip_disassociate_all_by_timeout(ctxt, FLAGS.host,
 | 
					            db.fixed_ip_disassociate_all_by_timeout(ctxt, FLAGS.host,
 | 
				
			||||||
                                                    self.start)
 | 
					                                                    self.start)
 | 
				
			||||||
            db.network_disassociate_all(ctxt)
 | 
					            db.network_disassociate_all(ctxt)
 | 
				
			||||||
            rpc.Consumer.attach_to_eventlet = self.originalAttach
 | 
					 | 
				
			||||||
            for x in self.injected:
 | 
					            for x in self.injected:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    x.stop()
 | 
					                    x.stop()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ class Context(object):
 | 
				
			|||||||
    pass
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AccessTestCase(test.TrialTestCase):
 | 
					class AccessTestCase(test.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(AccessTestCase, self).setUp()
 | 
					        super(AccessTestCase, self).setUp()
 | 
				
			||||||
        um = manager.AuthManager()
 | 
					        um = manager.AuthManager()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,13 +16,10 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#import logging
 | 
					import logging
 | 
				
			||||||
from M2Crypto import X509
 | 
					from M2Crypto import X509
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eventlet
 | 
					 | 
				
			||||||
logging = eventlet.import_patched('logging')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from nova import crypto
 | 
					from nova import crypto
 | 
				
			||||||
from nova import flags
 | 
					from nova import flags
 | 
				
			||||||
from nova import test
 | 
					from nova import test
 | 
				
			||||||
@@ -329,12 +326,12 @@ class AuthManagerTestCase(object):
 | 
				
			|||||||
            self.assertTrue(user.is_admin())
 | 
					            self.assertTrue(user.is_admin())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AuthManagerLdapTestCase(AuthManagerTestCase, test.TrialTestCase):
 | 
					class AuthManagerLdapTestCase(AuthManagerTestCase, test.TestCase):
 | 
				
			||||||
    auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver'
 | 
					    auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, *args, **kwargs):
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
        AuthManagerTestCase.__init__(self)
 | 
					        AuthManagerTestCase.__init__(self)
 | 
				
			||||||
        test.TrialTestCase.__init__(self, *args, **kwargs)
 | 
					        test.TestCase.__init__(self, *args, **kwargs)
 | 
				
			||||||
        import nova.auth.fakeldap as fakeldap
 | 
					        import nova.auth.fakeldap as fakeldap
 | 
				
			||||||
        FLAGS.redis_db = 8
 | 
					        FLAGS.redis_db = 8
 | 
				
			||||||
        if FLAGS.flush_db:
 | 
					        if FLAGS.flush_db:
 | 
				
			||||||
@@ -346,7 +343,7 @@ class AuthManagerLdapTestCase(AuthManagerTestCase, test.TrialTestCase):
 | 
				
			|||||||
                self.skip = True
 | 
					                self.skip = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AuthManagerDbTestCase(AuthManagerTestCase, test.TrialTestCase):
 | 
					class AuthManagerDbTestCase(AuthManagerTestCase, test.TestCase):
 | 
				
			||||||
    auth_driver = 'nova.auth.dbdriver.DbDriver'
 | 
					    auth_driver = 'nova.auth.dbdriver.DbDriver'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,7 +51,7 @@ IMAGES_PATH = os.path.join(OSS_TEMPDIR, 'images')
 | 
				
			|||||||
os.makedirs(IMAGES_PATH)
 | 
					os.makedirs(IMAGES_PATH)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CloudTestCase(test.TrialTestCase):
 | 
					class CloudTestCase(test.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(CloudTestCase, self).setUp()
 | 
					        super(CloudTestCase, self).setUp()
 | 
				
			||||||
        self.flags(connection_type='fake', images_path=IMAGES_PATH)
 | 
					        self.flags(connection_type='fake', images_path=IMAGES_PATH)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ from nova.compute import api as compute_api
 | 
				
			|||||||
FLAGS = flags.FLAGS
 | 
					FLAGS = flags.FLAGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ComputeTestCase(test.TrialTestCase):
 | 
					class ComputeTestCase(test.TestCase):
 | 
				
			||||||
    """Test case for compute"""
 | 
					    """Test case for compute"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        logging.getLogger().setLevel(logging.DEBUG)
 | 
					        logging.getLogger().setLevel(logging.DEBUG)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,7 +24,7 @@ FLAGS = flags.FLAGS
 | 
				
			|||||||
flags.DEFINE_string('flags_unittest', 'foo', 'for testing purposes only')
 | 
					flags.DEFINE_string('flags_unittest', 'foo', 'for testing purposes only')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class FlagsTestCase(test.TrialTestCase):
 | 
					class FlagsTestCase(test.TestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(FlagsTestCase, self).setUp()
 | 
					        super(FlagsTestCase, self).setUp()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ from nova import test
 | 
				
			|||||||
from nova.utils import parse_mailmap, str_dict_replace
 | 
					from nova.utils import parse_mailmap, str_dict_replace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ProjectTestCase(test.TrialTestCase):
 | 
					class ProjectTestCase(test.TestCase):
 | 
				
			||||||
    def test_authors_up_to_date(self):
 | 
					    def test_authors_up_to_date(self):
 | 
				
			||||||
        if os.path.exists('../.bzr'):
 | 
					        if os.path.exists('../.bzr'):
 | 
				
			||||||
            contributors = set()
 | 
					            contributors = set()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ from nova.auth import manager
 | 
				
			|||||||
FLAGS = flags.FLAGS
 | 
					FLAGS = flags.FLAGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NetworkTestCase(test.TrialTestCase):
 | 
					class NetworkTestCase(test.TestCase):
 | 
				
			||||||
    """Test cases for network code"""
 | 
					    """Test cases for network code"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(NetworkTestCase, self).setUp()
 | 
					        super(NetworkTestCase, self).setUp()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,7 @@ os.makedirs(os.path.join(OSS_TEMPDIR, 'images'))
 | 
				
			|||||||
os.makedirs(os.path.join(OSS_TEMPDIR, 'buckets'))
 | 
					os.makedirs(os.path.join(OSS_TEMPDIR, 'buckets'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ObjectStoreTestCase(test.TrialTestCase):
 | 
					class ObjectStoreTestCase(test.TestCase):
 | 
				
			||||||
    """Test objectstore API directly."""
 | 
					    """Test objectstore API directly."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
@@ -191,7 +191,7 @@ class TestSite(server.Site):
 | 
				
			|||||||
    protocol = TestHTTPChannel
 | 
					    protocol = TestHTTPChannel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class S3APITestCase(test.TrialTestCase):
 | 
					class S3APITestCase(test.TestCase):
 | 
				
			||||||
    """Test objectstore through S3 API."""
 | 
					    """Test objectstore through S3 API."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ from nova.api.ec2 import cloud
 | 
				
			|||||||
FLAGS = flags.FLAGS
 | 
					FLAGS = flags.FLAGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class QuotaTestCase(test.TrialTestCase):
 | 
					class QuotaTestCase(test.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        logging.getLogger().setLevel(logging.DEBUG)
 | 
					        logging.getLogger().setLevel(logging.DEBUG)
 | 
				
			||||||
        super(QuotaTestCase, self).setUp()
 | 
					        super(QuotaTestCase, self).setUp()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ from nova import test
 | 
				
			|||||||
FLAGS = flags.FLAGS
 | 
					FLAGS = flags.FLAGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RpcTestCase(test.TrialTestCase):
 | 
					class RpcTestCase(test.TestCase):
 | 
				
			||||||
    """Test cases for rpc"""
 | 
					    """Test cases for rpc"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(RpcTestCase, self).setUp()
 | 
					        super(RpcTestCase, self).setUp()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ class TestDriver(driver.Scheduler):
 | 
				
			|||||||
        return 'named_host'
 | 
					        return 'named_host'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SchedulerTestCase(test.TrialTestCase):
 | 
					class SchedulerTestCase(test.TestCase):
 | 
				
			||||||
    """Test case for scheduler"""
 | 
					    """Test case for scheduler"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(SchedulerTestCase, self).setUp()
 | 
					        super(SchedulerTestCase, self).setUp()
 | 
				
			||||||
@@ -73,7 +73,7 @@ class SchedulerTestCase(test.TrialTestCase):
 | 
				
			|||||||
        scheduler.named_method(ctxt, 'topic', num=7)
 | 
					        scheduler.named_method(ctxt, 'topic', num=7)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SimpleDriverTestCase(test.TrialTestCase):
 | 
					class SimpleDriverTestCase(test.TestCase):
 | 
				
			||||||
    """Test case for simple driver"""
 | 
					    """Test case for simple driver"""
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(SimpleDriverTestCase, self).setUp()
 | 
					        super(SimpleDriverTestCase, self).setUp()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,7 @@ class ExtendedService(service.Service):
 | 
				
			|||||||
        return 'service'
 | 
					        return 'service'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServiceManagerTestCase(test.TrialTestCase):
 | 
					class ServiceManagerTestCase(test.TestCase):
 | 
				
			||||||
    """Test cases for Services"""
 | 
					    """Test cases for Services"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_attribute_error_for_no_manager(self):
 | 
					    def test_attribute_error_for_no_manager(self):
 | 
				
			||||||
@@ -72,7 +72,7 @@ class ServiceManagerTestCase(test.TrialTestCase):
 | 
				
			|||||||
        self.assertEqual(serv.test_method(), 'service')
 | 
					        self.assertEqual(serv.test_method(), 'service')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServiceTestCase(test.TrialTestCase):
 | 
					class ServiceTestCase(test.TestCase):
 | 
				
			||||||
    """Test cases for Services"""
 | 
					    """Test cases for Services"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ FLAGS = flags.FLAGS
 | 
				
			|||||||
flags.DECLARE('instances_path', 'nova.compute.manager')
 | 
					flags.DECLARE('instances_path', 'nova.compute.manager')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LibvirtConnTestCase(test.TrialTestCase):
 | 
					class LibvirtConnTestCase(test.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(LibvirtConnTestCase, self).setUp()
 | 
					        super(LibvirtConnTestCase, self).setUp()
 | 
				
			||||||
        self.manager = manager.AuthManager()
 | 
					        self.manager = manager.AuthManager()
 | 
				
			||||||
@@ -123,7 +123,7 @@ class LibvirtConnTestCase(test.TrialTestCase):
 | 
				
			|||||||
        self.manager.delete_user(self.user)
 | 
					        self.manager.delete_user(self.user)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NWFilterTestCase(test.TrialTestCase):
 | 
					class NWFilterTestCase(test.TestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        super(NWFilterTestCase, self).setUp()
 | 
					        super(NWFilterTestCase, self).setUp()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@ from nova import utils
 | 
				
			|||||||
FLAGS = flags.FLAGS
 | 
					FLAGS = flags.FLAGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class VolumeTestCase(test.TrialTestCase):
 | 
					class VolumeTestCase(test.TestCase):
 | 
				
			||||||
    """Test Case for volumes."""
 | 
					    """Test Case for volumes."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,13 +129,6 @@ def debug(arg):
 | 
				
			|||||||
def runthis(prompt, cmd, check_exit_code=True):
 | 
					def runthis(prompt, cmd, check_exit_code=True):
 | 
				
			||||||
    logging.debug("Running %s" % (cmd))
 | 
					    logging.debug("Running %s" % (cmd))
 | 
				
			||||||
    rv, err = execute(cmd, check_exit_code=check_exit_code)
 | 
					    rv, err = execute(cmd, check_exit_code=check_exit_code)
 | 
				
			||||||
    #exit_code = subprocess.call(cmd.split(" "))
 | 
					 | 
				
			||||||
    #logging.debug(prompt % (exit_code))
 | 
					 | 
				
			||||||
    #if check_exit_code and exit_code != 0:
 | 
					 | 
				
			||||||
    #    raise ProcessExecutionError(exit_code=exit_code,
 | 
					 | 
				
			||||||
    #                                stdout=None,
 | 
					 | 
				
			||||||
    #                                stderr=None,
 | 
					 | 
				
			||||||
    #                                cmd=cmd)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def generate_uid(topic, size=8):
 | 
					def generate_uid(topic, size=8):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,7 +95,6 @@ if __name__ == '__main__':
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        from nova.tests.real_flags import *
 | 
					        from nova.tests.real_flags import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Establish redirect for STDERR
 | 
					    # Establish redirect for STDERR
 | 
				
			||||||
    sys.stderr.flush()
 | 
					    sys.stderr.flush()
 | 
				
			||||||
    err = open(FLAGS.tests_stderr, 'w+', 0)
 | 
					    err = open(FLAGS.tests_stderr, 'w+', 0)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user