Fix logic for aggregate_metadata_get_by_host_with_key test case

After deleting a3 metadata, it is the host that once has such metadata
should be tested.

Change-Id: I79c40aa977911cd327d478ad8d9f147e19325017
Removed copyright from empty files

According to policy change in HACKING:
http://docs.openstack.org/developer/hacking/#openstack-licensing
empty files should no longer contain copyright notices.
Please note, Oslo (nova/openstack/common) not changed!

Closes-bug: #1262424
Change-Id: I26b7d1eabb189f06219b70495d229389b9d3f260
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
Add UNSHELVING and RESCUING into IoOPSFilter consideration state

IoOpsFilter will take instance in following state
task_states.RESIZE_MIGRATING, task_states.REBUILDING, task_states.RESIZE_PREP,
task_states.IMAGE_SNAPSHOT, task_states.IMAGE_BACKUP
into consideration ,if the instance on this host exceed the maximum
number of instance allowed to do I/O the scheduler will fail on the host

UNSHELVING and RESCUING are also I/O related so IoOps need to include them

Change-Id: I141470254c824e7e57e6734ae0e016c432b85c00
Closes-Bug: #1295558
No longer any need to pass admin context to aggregate DB API methods

No longer need to pass an elevated context because the check of
admin has been removed in following patch:
https://review.openstack.org/67026

This patch removes the admin context elevated
method in nova/scheduler sub-folder since it's not required any more.

Change-Id: Ib768c97c9e84a9db44d866fa5fbfc4665ad7c73e
Partial-Bug: #1279216
Remove unnecessary passing of task_state to check_instance_state

Remove cases where task_state=[None] was passed to check_instance_state
when that is essentially the default value anyway

Change-Id: I49b6449b9ae43a5cfcf5a1ccac5ee9a64d2b3f3c
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
Nova utils: add in missing translation

The method validating the hypervisor version would throw
an exception that did not have a translation.

Change-Id: I6284d313a553757b90bd6b2c4946c6aa84ea17cd
Scheduler: remove test scheduling methods that are not used

The test code no longer uses the following methods:
 - fake_get_group_filtered_hosts
 - fake_get_group_filtered_affinity_hosts

This patch removes those methods.

Change-Id: I0a005fb1301ce78cc2ec365429015c08d58f446e
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
Fix AvailabilityZone check for hosts in multiple aggregates

Check for multiple AZ was distinct when adding an host to an aggregate
and when updating an aggregate (or its metadata), which was leading to
possible corner-cases where logics were different.

This patch proposes a single way for checking for both API methods and
also adds an extra control on the possibility to have an aggregate with
its metadata AZ set to the configuration default value (eg. 'nova') and
where it was possible to subsequently have one host in two disctinct AZs
Fixed that scenerio as it is a gap, Nova as of now preventing to have
one host in two distinct AZs.

Change-Id: Ida6aa507f34f36a436adaafe1f7609963c59a9bc
Partial-Bug: #1277230
Add specific doc build option to tox

Add doc venv to align with other OpenStack projects (such as keystone,
heat and nova-specs) who are using 'docs' for there doc builds.

Change-Id: I37771db339d864b2b938d1c02d15d38b07093493
Ignore errors when deleting non-existing vifs

If an instance fails during its network creation (for example
if the network-vif-plugged event doesn't arrive in time) a
subsequent delete will also fail when it tries to delete the
vif, leaving the instance in a Error(deleting) state.

This can be avoided by including the "--if-exists" option to
the ovs-vsctl command so that the command doesn't fail if the
vif doesn't exist.

Change-Id: Ic613c9d6e0619f51fcd931e62f6d6bce404ebe81
Closes-bug: #1308544
Set the volume access mode during volume attach

cinderclient supports an optional keyword argument named 'mode'
for volumes.attach(), which allows you to set the access mode of
a volume at attach time. The keyword argument is not passed in
by nova when it attaches a read-only volume, making the volume
access mode default to 'rw' instead of the desired 'ro'. This
patch finds the access mode of the volume and passes it to
cinderclient, so the correct access mode is used at attach
time.

Change-Id: Ib62f454292e60114f96debbad96c4a356dc32a21
Closes-Bug: #1307088
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
Update block_device_info to contain swap and ephemeral disks

An ephemeral or swap disk is attached to an instance on boot
as follows: nova boot --flavor FLAVOR --image IMAGE_ID
--swap 512 --ephemeral size=2 INSTANCE.  When a hard reboot is
performed on the instance, nova fails to recreate the
appropriate libvirt XML definition, containing the ephemeral
disk.  This is because the correct block_device_info dict that
is passed to the compute manager's reboot_instance method does
not contain swap or ephemeral disk key values that are necessary
to recreate those disks.  In addition to nova boot, the correct
block_device_info dict is also needed by nova rebuild, reboot,
resize, and migrate to recreate those disks.  This patch updates
_get_instance_volume_block_device_info (renamed
_get_instance_block_device_info) to return the swap and ephemeral
disk key values, in addition to the block_device_mapping it
already returns today.

Change-Id: Iec329d1c12a48ea90ba9d57decd0996fde6544f0
Closes-Bug: #1305423
Remove unnecessary wrapper for 5 compute APIs

There are 5 APIs in compute layer:
check_instance_shared_storage
change_instance_metadata
add_fixed_ip_to_instance
remove_fixed_ip_from_instance
reset_network
has unnecessary wrapper, this patch removed them

reverts_task_state is a wrapper to restore instance task state
when some thing wrong in executing the task,
change_instance_metadata, add_fixed_ip_to_instance
remove_fixed_ip_from_instance, reset_network doesn't change the state,
so no need to wrap it

wrap_instance_fault is a wrapper to catch the exception related to
instances, check_instance_shared_storage is not related to it

Change-Id: I2c4779c01854c2c8bac40e7379ad2fc4d0a7478a