Revert pause/unpause state when host restart

Give following scenario for instance task state
1) start to pause an active instance
2) the nova-compute died because of unexpected situation
3) when nova-compute start again , it's task state is pausing
it should be changed to None because host restarted

Also ,for the paused instance and its state is unpausing,
we need to unpase the instance.

Change-Id: If72a36dafd894ac47c0b255d701a3f9965ff2590
Closes-Bug: #1290639
libvirt: use qemu (qdisk) disk driver for Xen >= 4.2.0

According to the Xen ML [1] "qdisk is better supported and blktap is
unmaintained, we choose qdisk over blktap whenever possible" (change was
introduced in Xen's commit 0166217 [2]). The Xen documentation states
that the disk driver "should not be specified, in which case libxl will
automatically determine the most suitable backend" [3]. However, even if
libvirt does it OK [4] not setting the driver name so that libxl chooses
the best backend, it sets the file format to 'raw' so that a wrong
backend will be chosen by libxl.  Since 'qdisk' seems to be the
preferred option, it seems safe to set it as the backend.

[1] http://lists.xen.org/archives/html/xen-devel/2013-08/msg02633.html
[2] http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=0166217103e18368424fbd5ffff01c1ea50d0b17
[3] http://xenbits.xen.org/docs/unstable/misc/xl-disk-configuration.txt
[4] http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/libxl/libxl_conf.c;h=1210500858b00b1d10b0bc921ab8b5efc87e630f;hb=HEAD#l847

Closes-Bug: #1326238
Change-Id: Ia52d52a01916fac92dc8e648c462e237c0bfc915
libvirt: vif tests should use a flavor object

Some part of the tests code are still using a dictionary
to simulate flavor data structure.
However, it has been in fact changed to being a nova object.

Changing these part to be an object.

Change-Id: Idb0e1ca8fa09e1a36ba0f62175f01ee856e3f31b
tests: update _get_instance_xml to accept custom flavor object

Currently LibvirtVifTestCase._get_instance_xml creates a default
flavor object and uses it for all tests. This makes it dificult
to test settings that are being activated by values in extra
spects.

Allowing the method to accept a flavor object and use the default
one, if not provided.

Change-Id: I3835aa5e6cf09268b132b9de377004c0e8df9cb0
Use admin only common test case in admin action unit test cases

This patch use nova.tests.unit.api.openstack.compute.plugins.v3
.admin_only_action_common as the base class of AdminActionsTest
which can be shared by v2 and v21

Partially implements blueprint v2-on-v3-api
Change-Id: I16b59e8db59242b8e7b626cc77d0fff6bfc062e4
Share lock_server unit test between V2 & V2.1

This patch moves lock_server unit test from v3 directory to contrib
and makes it shared by V2 and V21.

PS. lock_server unit test cases was removed from admin actions unit
test case.

Partially implements blueprint v2-on-v3-api

Change-Id: I9cee1ae5075d6e7a7cd7aa05b105e487c239d24a
Share pause_server unit test between V2 & V2.1

This patch moves pause_server unit test from v3 directory to contrib
and makes it shared by V2 and V21.

PS. pause_server unit test cases was removed from admin actions unit
test case.

Partially implements blueprint v2-on-v3-api

Change-Id: Ideb30ec8501b4e98cb2ddaa4194bdf19002999ab
Share suspend_server unit test between V2 & V2.1

This patch moves suspend_server unit test from v3 directory to contrib
and makes it shared by V2 and V21.

PS. suspend_server unit test cases was removed from admin actions unit
test case.

Partially implements blueprint v2-on-v3-api
Change-Id: I44d9bf8d70f8a9c6916a18c354285e950c2fa550
Share CreateBackup unit test between V2 & V2.1

This patch moves CreateBackup unit test from v3 directory to contrib
and makes it shared by V2 and V21.

PS. create_backup unit test cases was removed from admin actions unit
test case.

Partially implements blueprint v2-on-v3-api
Change-Id: I607acc7406f8538a644749f9fb218d160e3e306d
Add API validation schema for volume_attachments

This patch adds API validation schema for volume_attachments.

Update volume required only Volume Id in request body but sample
files used to pass 'device' also.
This patch also correct those API sample files-
doc/v3/api_samples/os-volumes/update-volume-req.json
nova/tests/functional/v3/api_samples/os-volumes/update-volume-req.json.tpl

DocImpact

Partially implements blueprint v2-on-v3-api

Change-Id: I489272528fe4f4c43ab781d6a1a46742b1702c76
Correct InvalidAggregateAction translation&format.

InvalidAggregateAction .looks like:
 class InvalidAggregateAction(Invalid):
     msg_fmt = _("Cannot perform action '%(action)s' on aggregate "
     "%(aggregate_id)s. Reason: %(reason)s.")

The values for action are not well formed and reason are not translated.
This patch fixs those problems

Change-Id: I9ed20badde8a38eb71c5f121f30e4d54ad50022e
Closes-Bug: #1278736
Add debug log for url not found

I got following error from unit tests
apparently it's not helpful to know what's the root cause to make the failure
This patch adds a debug log

2014-11-21 16:47:52,943 DEBUG [nova.openstack.common.fileutils] Reloading cached file /tmp/tmpTBjKpX/tmpiC7e2k/policy.json
2014-11-21 16:47:52,950 DEBUG [nova.openstack.common.policy] Rules successfully reloaded
2014-11-21 16:47:52,951 WARNING [nova.openstack.common.policy] Can not find policy directories policy.d
2014-11-21 16:47:52,954 DEBUG [nova.network.minidns] minidns file is |/tmp/tmpTBjKpX/tmpdjtU4j/dnstest.txt|
2014-11-21 16:47:52,955 DEBUG [nova.network.minidns] minidns file is |/tmp/tmpTBjKpX/tmpCHMwMh/dnstest.txt|
2014-11-21 16:47:52,958 DEBUG [nova.network.minidns] minidns file is |/tmp/tmpTBjKpX/tmpggVMPv/dnstest.txt|
2014-11-21 16:47:52,959 DEBUG [nova.network.minidns] minidns file is |/tmp/tmpTBjKpX/tmpz2Ptbv/dnstest.txt|
}}}

Traceback (most recent call last):
  File "/home/jichen/git/nova/nova/tests/unit/api/openstack/compute/contrib/test_virtual_interfaces.py", line 84, in test_get_virtual_interfaces_list
    self.assertEqual(res.status_int, 200)
  File "/home/jichen/git/nova/.venv/local/lib/python2.7/site-packages/testtools/testcase.py", line 348, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/home/jichen/git/nova/.venv/local/lib/python2.7/site-packages/testtools/testcase.py", line 433, in assertThat
    raise mismatch_error
MismatchError: 404 != 200

Change-Id: I30a302cf624f023cb7e2228ced7774036a6d7fba
Fix type of uniq_security_groups0project_id0name0deleted

Migration 190 created uniq_security_groups0project_id0name0deleted but
added it to the model as an index instead of a UniqueConstraint.

Change-Id: Id01c2207a6d2b59cc0f9c4301d696d8a3dd82df7
Partially-implements: blueprint validate-migrations-and-model
libvirt: video RAM setting should be passed in kb to libvirt

Currently, video RAM setting is being set in MB in both
flavor extra_spec and the image property, however, it is not
being translated to KB, in the instance XML config.

Change-Id: Ie1091c08a011d650a7bb0ff0337337ceae7b111b
Closes-Bug: #1373239
Drop support for legacy server groups

A previous commit dropped the scheduler filters needed for legacy
server groups to work.  This patch completes removing that support.
If someone attempts to create a server with a group hint that contains
a name instead of a UUID, it will return a proper HTTP failure.

Change-Id: Ic8a92c8ec1f5bbb240803448014757f89facbb4d
libvirt: Set guest machine type on system z

The domain XML for guests on system z must have the machine type
"s390-ccw-virtio" to set up the device addresses properly. The
default value "s390-virtio" (without "ccw") which is listed by
libvirts get_host_capabilities call cannot be used properly for
guests.

Partial-Implements blueprint libvirt-kvm-systemz

Change-Id: Ib9cfb0ad8db3fe9bfc6b1302761f728fe56c0602
Merge "Use admin only common test case in admin action unit test cases"
Merge "Share lock_server unit test between V2 & V2.1"
Merge "Share pause_server unit test between V2 & V2.1"
Merge "Share suspend_server unit test between V2 & V2.1"