Make sure report_interval is less than service_down_time

If service_down_time is less than report_interval, services will
routinely be considered down, because they report in too rarely.
Add check for service_down_time vs report_interval, if report_interval
is larger than service_down_time, automatically change
service_down_time to be report_interval * 2.5

DocImpact

Closes bug #1255685

Change-Id: I1be42e1826142b8f3f2c39f3734bef713a12a693
Failure during termination should always leave state as Error(Deleting)

Delete is a non-reversible operation for the user, and once the
user has indicated that they want to delete the instance from that
point on is the system's problem to complete the delete as soon as
possible.

If anything fails during the delete that the system cannot recover
from then the instance should be left in an Error(Deleting) state.
Anything else, in particular reverting to an Active(None) state, makes
it look like the system has ignored the request.

Currently InstanceTerminationFailure is explicitly caught, but the
exception does not propagate so the instance_fault wrapper does not
get a chance to log the failure.  Also terminate_instance is wrapped
by reverts_task_state which resets the state to Active(None)

This change removes the revert_task_state wrapper and catches all
exceptions so that unhandled exceptions always leave the instance
in Error(Deleting)

Change-Id: I5fb1bbd56035792f566a6e076edfe7a69df006ef
Closes-Bug: 1254122
Use utils method when getting instance metadata and system metadata

Change-Id: Idab1ba25a8ec4c7dcc9efbb9d86e7248ae3c351e
Change unit test for availability_zones.reset_cache

Test_rest_availability_zone_reset_cache can not make sense
because the result of az._get_cache().get('cache') before
executing az.reset_cache() and after az.reset_cache() are
same.

This Patch will provide a reasonable test for it.

Change-Id: I7a27998bdf70f39077a5d79fc460974fc5806c3e
Closes-bug: #1258041
Recommend the right call instead of datetime.now()

Closes-Bug: #1258166
Change-Id: I92b94dbcd0405d8f2bb818ad1c44c4f4934c8bec
Fixes errors on start/stop unittest

The action name is incorrect on stop unittest, we should use "stop"
instead of "start".

Change-Id: I973e4f4591945f225e374797aebd1bbe00c3c9bd
Closes-Bug: #1257222
Add error as not-in-progress migration status

When a migration status becomes "error" the migration is no longer
in progress, i.e. it is in a terminal state.  However, the
migration_get_in_progress_by_host_and_node method returns migrations
that have an "error" status, causing, among other things, the
Resource Tracker to continually log messages about how an
Instance is not resizing, creating excessive noise in the logs,
especially since the fact that a migration is entering the "error"
status is already logged.  This change causes "error"-status
migrations to not be included when retrieving "in progress"
migrations.

Closes-Bug: #1258275

Change-Id: I67bfec9f91f89ff38422469a5d86e14c4fffa40b
Set a sane default for state_path

This change sets a sane default to state_path and puts the previous
state_path for tests only.

Because the default value of state_path changed, if this one isn't set in the
configuration file, pybasedir is not more used as replacement but /var/lib/nova
is used instead.

UpgradeImpact
DocImpact
Closes bug: #1240879

Change-Id: I94502bcfac8b372271acd0dbc1710c0e3009b8e1
baremetal: set capabilites explicitly

ComputeDriver, base class of compute drivers, has dict capabilities
to show if the compute driver implements some functions. Compute
manger will check this with capabilities['has_imagecache'] or
capabilities['supports_recreate'] directly. If use compute driver
baremetal, there is code path leading KeyError. Let set capabilites
explicitly to avoid this.

Partial-Bug: #1261636

Change-Id: I5097d271df0d6ad419f530787d890288163d06c5
Clean swap_volume rollback, on libvirt exception.

Handling swap_volume command's rollback on the manager side
instead of the API, to allow clean rollback.

Change-Id: I7d5c1e66bf01fd12fcaa783c1c3c90d92b009aea
Closes-Bug: #1222656
Make _change_index_columns use existing utility methods

The _change_index_columns method is doing a drop/add index operation and
since we have utility methods to do exactly that already, just re-use
them.

Change-Id: I5706c4512b1324aab64f70cd053c464d9a50e233
Remove update_service_capabilities from nova

From the comments of update_service_capabilities, it is said that
once publish_service_capabilities was removed, then we can begin the
process of its removal.

publish_service_capabilities has been removed in patch
I31c21055163e94b712d337568b16b9b7a224b52f, so we can remove
update_service_capabilities now.

Change-Id: I46be33462321f5e3ff0904bdff8dbfe2fbe115cd
Closes-Bug: #1263569
Fixing availability-zone not take effect error

when add/remove a host to one aggregate or update aggregate
metadata incluing availability_zone, "OS-EXT-AZ:availability_zone"
property of some instances in the host can not show correctly.

The cause is that when getting availability_zone of one instance,
it will try to get the value from cache first, but unfortunately
the cache does not update or reset in time, and it will keep one
hour if we do not change it.

This patch will add update or reset after adding/removing a host
to one aggregate or updating aggregate metadata including
availability_zone.

Change-Id: I5dd07f876471b5faf8fb1016e25a861124b7cb6f
Closes-bug: #1240374
Update log message when remove pci device

When remove pci device, the log message does not include exception
message even the exception has been caught.

This patch was put the exception to the warning message.

Change-Id: I3c604a3c80b501dedf1f0dd9fab9f399ae73f481
VMware: improve connection issue diagnostic

This exception block can swallow all issues with a connection
adding something to log the exception thrown can aid in
the troubelshooting of a Nova node's configuration. This is
invaluable when guiding someone in the field through setup
because they may mis-type a key value or misconfigure an IP.

Change-Id: I27e5ed5c51926cfeb6747980df02a396f566dd77
Add alias as prefix for flavor_rxtx v3

As v3 api rules, the extended attribute should be with extension
alias as prefix. So fix this case for flavor-rxtx v3 extension.

Closes-bug: 1252986
DocImpact

Change-Id: I9f5984a406d039245db4bef2df53cfe10a331cc2
fix log message in APIRouter

In _setup_ext_routes(...) and _setup_extensions(...)[0], there are three
logs telling that I'm setuping extensions routes, and these are done,
those failed. At line3 in [0], every resource woulld be logged before
the line 6-7 skip (conintue in Python). So here should be that I'm
'extending' resource, not 'extended'. Similiar in line 38 and line 43,
these two should be what is done and what is failed.

So this patch fix the first log from 'Extended' to 'Entending', and in
third log, 'extending' to 'extended' instend which makes context log
more reasonable.

[0] http://paste.openstack.org/show/60246/

Change-Id: I2de66f1a8e09945e1915b61771a55af6b630369c
Hyper-V:Preserve config drive image after the instance is resized

If we configure config_drive_cdrom=True in nova.conf,
the config drive image will be lost after the instance
is resized on hyperV. This is because nova compute will
not copy the disk file if the file's ResourceSubType
is not 'Virtual Hard Disk'.

This commit adds 'Virtual CD/DVD Disk' into disk_resources
to preserve the config drive image after the instance is
resized.

Closes-Bug: #1250324

Change-Id: Ia125a8b132d194ddc2230754fd1b813698b410a8
fix ips to 'ips' in APIRouter

Actually ips in `ips in init_only` would not be valued as True because
ips is a moudle object not a string. Fixing this to string 'ips' could
prevent potential issues and improve readability.

Change-Id: I74564349e1fef00e7430cfb0547b3ad87c8e471c
Allow deleting instances while uuid lock is held

Avoid issues where locked up operations on the instance prevent it
from being deleted by the user. Reasons for the lock up are a separate
issue and will be handled elsewhere, but terminating the instance
should not affect any tasks anyway. Any modification should already
gracefully handle the instance going away.

For more discussion about the issue see:
http://lists.openstack.org/pipermail/openstack-dev/2013-October/017454.html

Partial-Bug: #1248563

Change-Id: Ife26ffefccea11d6e9ca5fbd970192b322fc04fd