Bump stable/grizzly next version to 2013.1.4

Change-Id: I817767bcb618edf94363aa34dd0eb6ce897ce141
No relevant message when stop a stopped VM

When user tries to stop a stopped VM, there is no need to stop it again,
and We need return it's vm_state.

Fixes bug 1181934

Change-Id: I71772dfcead440cb49b6ccdbb4e1a891475bb75e
(cherry picked from commit 62ca3783ce4fcc0b03e96936972abc83b54c772f)
Fix simultaneous timeout with smart iptables usage

Simultaneous boots were getting timeouts in allocate_for_network.
This was due to our inefficient use of iptables where we attempt
to recreate the same rules over and over using initialize_gateway,
plug, and restart_dhcp.

This patch makes the iptables code a little bit smarter by only
shelling out if the rule list has changed. Note that there is
a small difference in the interpretation of duplicate rules.
Previously, the last copy of the rule would win whereas now
the first copy of the rule will win. Multiple copies of the same
rule were never supported. This means the only thing that one
needs to remember is it is necessary to remove a rule and re-add
it if you want to move it later in the list.

Fixes bug 1199433

Change-Id: I9920f8d6aa269d9b3bfd88a8dbbb00f859deb158
(cherry picked from commit 176c483cdf2bc8eff7cfff4a9b0ac0dd98239da1)
Remove invalid block_device_mapping volume_size of ''

Parsing block_device_mapping from strings sometimes results in
volume_size being set to '' or u''.  This causes a problem when
inserting into PostgreSQL, which insists that integer columns
actually contain integers.  Remove invalid device_size before
inserting or updating block_device_mapping database records.

(cherry picked from commit 188a94c898bcf07f9fe42ef2f3b5ee4aa8859b49)

Fixes: Bug #1171190
Change-Id: If9132a96604b5b0e3a6df96624e565e016d5c9a3
Set launch_index to right value

Fix bug 1212648

When boot multiple instances in one request, the launch_index
was not increased.

The fix was increase the launch_index one by one for each instances
in one request.

Conflicts:
	nova/compute/api.py
	nova/tests/compute/test_compute.py

Change-Id: I27dde8cfae52853d33277c3d8e0e65c91bc6280b
(cherry picked from commit c8f0a545bfafdc72bae0a43df78ae51835e35232)
Check instance on dest once during block migration

During live block migrations both pre_live_migration and
pre_block_migration check for the presence of the instance on
the destination and create the instance dir if it doesn't exist.

As a result the call to pre_block_migration always fails as
pre_live_migration has already created the instance dir on the
destination.

As it turns out the pre_block_migration call is completely
unnecessary. The libvirt driver is the only driver that uses the
call and the work it does can easily be done in the existing
pre_live_migration call. In order to streamline things we
completely remove the pre_block_migration call from all
drivers. Additionally we update the function definition for
pre_live_migration to pass needed disk info down to the
virt drivers.

Fixes bug: #1193359

(cherry picked from commit 659ec75eaf052742a6269e0aae258f1c874749f7)

Conflicts:
	nova/compute/manager.py
	nova/tests/test_libvirt.py
	nova/virt/libvirt/driver.py
	nova/virt/xenapi/driver.py

Change-Id: Id9dfe482db3471d6a1b9b6c7d59a5ddc48775d7f
Fix VMwareVCDriver to support multi-datastore

This fixes the issue of VCDriver selecting the first datastore of
Cluster while provisioning instances. User can provide a regex to
match with the desired datastores.

Fixes: bug #1104994

(cherry picked from commit 9579ece88962ec86bd54d7930c764105e38f5db6)

Conflicts:

        etc/nova/nova.conf.sample
        nova/tests/test_vmwareapi.py
        nova/tests/test_vmwareapi_vm_util.py
        nova/virt/vmwareapi/driver.py
        nova/virt/vmwareapi/vm_util.py
        nova/virt/vmwareapi/vmops.py

Change-Id: I319b0d8afd03e9fef00ea0c8c799790714685104
fix broken WSDL logic

vSphere driver incorrectly assumes that a WSDL is locally required.
A local WSDL is only needed as a work-around for certain situations.

Fixes bug 1171215

cherry picked from commit cf3cc74fcb65de3c59f98db001267e05ae405186

Change-Id: I1cc81d96e263ad586b903a74dc9d5c602d475dc9
VMware: Ensure Quantum networking works with VMware drivers

Fixes bug 1202042

A new utility method, is_quantum, is added. This returns True
if Quantum is used by the network_api_class.

(cherry picked from commit 2d7520264a4610068630d7664eeff70fb5e8c681)

Change-Id: Iaf22a43c8e36a7e5825574a082491354e4523619
fix libguestfs mount order when inspecting

variable `mounts` sorted value is
[
    ('/boot', '/dev/vda1'),
    ('/', '/dev/vda2'),
    ('/var', '/dev/vda5'),
    ('/home', '/dev/vda6'),
    ('/home/q', '/dev/vda7')
]
but `/boot` directory is in `/` partition.

Fixes: Bug #1210371
Change-Id: I3d9cd59237bc4fc277415104c9170d2e372a1c25
Cherry picked: a8613dd59383c150ac8762398838236759bad7b1
Enforce flavor access during instance boot

The code in the servers API did not pass the context when retrieving
flavor details.  That means it would use an admin context instead,
bypassing all flavor access control checks.

This patch includes the fix, and the corresponding unit test for the v2
API.

Closes-bug: #1212179

(cherry picked from commit 4054cc4a22a1fea997dec76afb5646fd6c6ea6b9)

Conflicts:
	nova/api/openstack/compute/plugins/v3/servers.py
	nova/api/openstack/compute/servers.py
	nova/tests/api/openstack/compute/plugins/v3/test_servers.py
	nova/tests/api/openstack/compute/test_servers.py

Change-Id: I681ae9965e19767df22fa74c3315e4e03a459d3b
Merge "Enforce flavor access during instance boot" into stable/grizzly
Merge "Fix simultaneous timeout with smart iptables usage" into stable/grizzly
Merge "No relevant message when stop a stopped VM" into stable/grizzly
libvirt: fix {attach,detach}_interface()

* The get_config() method now takes 6 arguments, instead of 5
  previously. This change has been introduced by commit 08f8773b.

* LibvirtConnTestCase: add the test_attach_interface_get_config() and
  test_detach_interface_get_config() methods to prevent future
  failures.

Fixes bug #1212565

(cherry picked from commit ff4863cca3012b2060bff788456c1b98b03d46d5)

Conflicts:
	nova/tests/test_libvirt.py
	nova/virt/libvirt/driver.py

Change-Id: I4e874f59595c3afe820103a27036519df1a126ff
Merge "fix broken WSDL logic" into stable/grizzly
Delete expired instance console auth tokens

Instance console auth tokens never get deleted from the cache
before the instnace is deleted, this is a waste of memory. now
we check if tokens are expired then remove them from the cache
before store new tokens.

Fix bug #1209134

Co-authored-by: Takashi Natsume <natsume.takashi@lab.ntt.co.jp>
(cherry picked from commit e3bbf2e81137bbcdc39bdfb4c4ff62f30c37afda)
Conflicts:
	nova/tests/consoleauth/test_consoleauth.py

Change-Id: I8dd5089ebaed3b3d91932f1f1558bbe302cd5675
Fix Qpid when sending long messages (from oslo)

This is commit 4f97479ad in oslo-incubator

Qpid has a limitation where it cannot serialize a dict containing a
string greater than 65535 characters. This change alters the Qpid
implementation to JSON encode the dict before sending it, but only if
Qpid would fail to serialize it. This maintains as much backward
compatibility as possible, though long messages will still fail if they
are sent to an older receiver.

The first part of this fix was ported to Grizzly in Ib52e9458a to allow
receiving messages from Havana using the new format. Even though this
change will modify the message format, it will only do it when messages
are longer than 65K which would be broken anyway and could cause serious
bugs like the one linked below.

Fixes bug 1215091

Change-Id: I505b648c3d0e1176ec7a3fc7d1646fa5a5232261
Refresh network info cache for secgroups

Before updating security group rules, we need to make sure that
the info cache is up-to-date. Without this source groups are not
updated properly. This was a regression introduced in commit
85aac04704350566d6b06aa7a3b99649946c672c which fixed a potential
DOS using source groups.

Fixes bug 1216720

Conflicts:
	nova/network/manager.py
	nova/tests/network/test_manager.py

Change-Id: I6b5115df53f2e159ea506ef966cd49cedd35f83d
(cherry picked from commit 8679b2c8e7f9fddc31a74ad00f6705bca00a762b)
Make nbd reservation thread-safe

Avoid the situation where two local threads choose the same nbd number
for injecting files into the instance. If this happened quickly enough
nova was left with one qemu-nbd hanging and blocking the device forever.

Fixes bug 1207422

Change-Id: I18864b19ebd30669534e45ca7a50e12f61207302
(cherry picked from commit e4ed9e3726b87e4f37138867f752b0588f3626a0)