Change parameters of add_timestamp in ComputeDriverCPUMonitor class

Change parameter 'cls' to 'self' in wrapper. 'cls' may mislead developpers
that this decorator returns a classmethod. Use functools.wraps to follow
the common pattern of decorator in nova.

closes-bug: #1288281

Change-Id: I6acbcba7297607dc6d07e8668ad07e6ca81d4456
Make sure leases are maintained until release

Dnsmasq asks nova-dhcpbridge for existing leases on reboot, but
we don't return addresses that have been deallocated but not yet
released. This modifies nova to return leased but not allocated
addresses. It also delays removing the vif until we disassociate
the ip so we still have access to the mac address.

Resolves-bug: 1300355

Change-Id: Id78d66aad5005f052a1b49002de0ef13ef5a298d
libvirt: optimize pause mode support

Commit bfb28fcf9031af4c695177663702ce05edbbfa4d added a method
call that checks if the libvirt driver support the
VIR_DOMAIN_START_PAUSED flag. This patch optimizes that by reading
the value at startup.

Change-Id: I0fc1edec55df609ab25b9999f4a0d077ddcf0be7
Add lock on API layer delete floating IP

There are potential race condition when multiple nova-api
service is running. We need to prevent the concurrent access to
the same floating ip, though db layer function is ok for floating
ip, the quota will be released more than one time and it will
lead to potential problem later

So the solution: check whether the db is *really* updated with the
value we want, which means the second operation will fail and
return None, so network api layer can handle it

Change-Id: I028938a4c387d21a8880ae168b161a763e7361ff
Closes-Bug: #1268569
Remove unused nova.crypto.compute_md5()

Remove nova.crypto.compute_md5() as it is:
 * unused
  * last user removed 3 years ago with commit bab3060
 * untested
 * incorrectly documented
  * return type is not a tuple, but a string
 * redundant
  * copied from boto which is a nova requirement
 * burdened with license text more verbose than associated code

Change-Id: Ia033d3359098fc0af8de00248dc14b4fe280e844
Support multi-version pydevd

We need to support multi-version pydevd
in order to supporting pycharm3 and pydev3 remote debug.
If we want to remote debug by pydev3 or pycharm3,
"from pydev import pydev" is not work,
need to "import pydevd" directly.

Change-Id: I975c859c46f81d7fe1ca3dfebe05040153471800
Delete in-process snapshot when deleting instance

Try to delete the image created to hold the snapshot when the snapshot
creation fails because either the instance doesn't exist or it is in the
deleting task_state.

Closes-Bug: #1296590
Change-Id: I422c4f10c348d189fee217b55e0766e73eb5b16c
Use strtime() specific timestamp regexp

Any datetime objects that get serialized via jsonutils.dumps() get
stringified using strtime() which includes decimal seconds and is
timezone naive.

Use a specific regexp to check the use of this format.

Note that included in here is a fixup to the doc samples for the
instance actions extension - the sample shows it using the
str(datetime) format when in fact it is using strtime. This came
about because before commit 68288b9 we were using a pre-serialized
timestamp in the fake instance actions. I just regenerated the samples
for this.

Full context here:

  http://lists.openstack.org/pipermail/openstack-dev/2014-April/033971.html

Change-Id: If52a2a664eccc8aed8a39d1a9dfb0209337c3c79
Remove quota-class logic from context and make unit tests pass

Continuation of quota-class removal started in
I1110022d6f628d03aaf363da707f2d2ef1600437.

Since we don't have an API to set quota-class any more, we don't need to
store it inside of the context. Also begin removing quota-class logic from
nova.quota to make test_quota pass with changes to context

Change-Id: I85dd24121a434b95dc6f0af180444d4258b50765
libvirt: Handle `listDevices` unsupported exception

It's possible that `listDevices` will return an exception if it's not
currently supported.

If this happens, the compute service will fail to start up.

The proposed solution is to catch this error, log a warning, and allow
the compute-service to continue initialization.

Change-Id: If152abd1080e9ba395de5d8ea10f5e0c476d4e2b
Closes-Bug: #1304721
Fix security group list when not defined for an instance

If an instance has an empty security group list an exception
is thrown due to iteration attempt of None.

To fix this, this patch modifies get_instance_security_group
to return an empty list instead of None.

Change-Id: I7efb3c3a58d7e20501d126c6d194479ca1d14166
Closes-Bug: #1291489
Clean up openstack-common.conf

oslo-incubator will introduce new integrity check in [1].
That will help developer find inconsistent issue while copying
from oslo-incubator. The check just outputs warnings. These are
changes according to warning:
 * sort the modules in openstack-common.conf
 * Fix wrong module names

[1] https://review.openstack.org/#/c/76901/

Change-Id: Ie939d46a72732357acc9dab03c0682b0e271a7ed
Related-Bug: #1295582
Fix wrong used ProcessExecutionError exception

This class has been moved to nova.openstack.common.processutils,
but a wrong usage is exists in nova.virt.libvirt.volume,
correct here.

Closes-bug: #1308839
Change-Id: I76f99b63dc5097b462dcff6ff63cbbb13d7580fb
VMware: prevent image snapshot if no root disk defined

If there is no root disk defined then the snapshot should
throw an exception.

Change-Id: I0549b8ca9ba41b734277600cb66a74b27ca72d88
Related-bug: #1297605
Remove logging in libvirt _connect_auth_cb to avoid eventlet locking

The _connect_auth_cb callback is logging a warning if credentials are
passed to the method from libvirt when connecting, but the comment right
above where the connection method is called on libvirt, it says don't do
any logging in that function because it can cause issues with how
eventlet does logging.

This has probably never been an issue because libvirt hasn't passed
credentials back to the callback, but if it did at some point we could
have a nasty locking problem so let's clean it up now.

See commit e4b0d8e9 for some related history.

The nested method is moved up a level so it can be tested directly.

Change-Id: Ie47aabbf81c5aeda9e12e1c9acc11f6c70c4bea7
Add a docstring to hacking unit tests

This commit adds a docstring to the hacking check unit tests
explaining how the tests work. To someone who isn't well versed with
how pep8/flake8 works the tests cases are a bit of black magic.

Change-Id: I5dc61612a5fec42443d8d89eaf700bb17b4b0842
Add Nova API Sample file & test for get keypair

This patch adds the new API Sample file and its test for Nova V2 and V3
get keypair APIs.

This patch extend the timstamps reg exp to allow the combination
of TZ and microsecond/

Closes-Bug: 1298769
Closes-Bug: 1298818

Change-Id: If695a23cf95862b7bec6fbc5bdf7fc1733d08d4a
Fix the explanation of HTTPNotFound for cell showing v2 API

This patch adds the explanation to cell showing in v2 API, when
the cell is not found, the exception of HTTPNotFound will return
more infomation.

Change-Id: I25dee08a04ad974af5309999527e0f173d2c2cab
Closes-Bug: #1316152
Code Improvement

Change code in wsgi.py.

Before:
if not is_dict(body[entity_name]):
    return False
return True

After:
return is_dict(body[entity_name])

Since this calling is in the end of the method I
can just return the result of the calling.

Change-Id: I834f26aa5a91abd18b8da10aef81f3aeb72a61ed
XenAPI: Remove unneeded instance argument from image downloading

The Xenapi image downloading code requires an instance argument
when launching a VM.  However, the downloading code doesn't
need the instance information as it doesn't use it for
any processing/debugging/loging.  We can remove this
argument safely.

Change-Id: Id8b531b74e5f0e59638b608bff93fc89b66b889d
Closes-bug: #1307662