Raise an error if module import fails!

Previously a missing module would cause the config file generator
to pass (mostly) silently with only a small message going to
stdout. If we can't import a module that seems like it is a bad
thing so lets just bail.

Change-Id: I391220e1344ba1785bf04654c7c5f52e2e8e82fc
Use multiprocessing.Event to ensure services have started

ServiceRestartTest.test_terminate_sigterm would often fail in my Jenkins
instance. It turns out that sometimes the test case would manage to send
its SIGTERM after the signal handler is put in place, but before we
enter the "try: except" block in _wait_for_exit_or_signal. This meant
that the SignalExit exception isn't caught and makes the process
terminate with non-zero exit code. To verify this, you can add a
time.sleep(3) right after self.handle_signal().

To avoid this race condition, we add a ready_callback argument to
Service.wait() that gets called when entering the try-catch block.
In the test, we pass an Event object and wait for it to be set before
proceeding. This also gets rid of the questionable call to "ps".

Change-Id: I598e8bc889b6c2627a62271627d17b44e01acbe4
Move LockFixture into a fixtures module

In Nova and other projects, fixtures are in test-requirements.txt and
NOT in requirements.txt so updating nova to use latest lockutils.py
is not possible. So let us move LockFixture out into it a separate
fixtures.py module where in theory we can add other fixtures as
well. See https://review.openstack.org/#/c/52153/ for an attempt to
try latest lockutils.py in Nova.

Change-Id: I12942d6390d06bb889d4145e708692fa886d99b5
Merge "Use multiprocessing.Event to ensure services have started"
Merge "Move LockFixture into a fixtures module"
Merge "Raise an error if module import fails!"
Transform the for loop to expression

In python 3, if the dict is changed in the loop, there will
be following error:
RuntimeError: dictionary changed size during iteration

Transform the "for loop" to expression to avoid it:
- Use dict() to keep capatibility for old Python version.
- six.iteritems() to avoid the following error:
  ValueError: too many values to unpack

Finally, _code_map contains all the classes that have http_status
attribute.

Close-Bug #1240725

Change-Id: I169b13546bcd0d87353dbca5a9b64229b704fe66