Fix instance cross AZ check when attaching volumes

For CONF.cinder_cross_az_attach=False, we currently only check the desired AZ
during scheduling but don't actually check the final AZ of the node.

When attaching volumes to running instances we need to check the actual
AZ on the instance and not the desired AZ at boot time. The desired AZ
attribute is optional at boot and may not be set or the desired AZ
could be different from the final AZ.
When we are booting with a volume however we don't know the final AZ so we
check on the desired AZ.

Closes-Bug: #1255347
Change-Id: Ied912c171100a450754d315027bf5c407ac067bb
(cherry picked from commit 18a1486293b15c5713ac1352b9b9b30fdf2b7413)
postgresql: use postgres db instead of template1

In PostgreSQL template1 database is kind of special, as all new databases are
copied from it, when you do CREATE DATABASE. This implies a few restrictions:
e.g. you can't have more than one active session to template1, if one of them
tries to create a database. It will fail with:

    ERROR: source database "template1" is being accessed by other users

Using of postgres database instead of template1 resolves this issue.

Closes-Bug: #1355929

Change-Id: I8b1a36163984fbef6be66964456072d32da6a9d0
(cherry picked from commit 02fa15b4caaa414930b6ddf6a3a9fe8019751c26)
Merge "Fix instance cross AZ check when attaching volumes" into stable/icehouse
Merge "postgresql: use postgres db instead of template1" into stable/icehouse
Fix XML UnicodeEncode serialization error

The generic Nova XMLSerializer code will currently attempt
to cast to str the value for all leaf nodes. This patch
ensures that no attempt is made to convert unicode which
can cause a UnicodeEncode error. We don't need to convert
unicode for XML text and regardless we encode to UTF-8 at
a later point.

Change-Id: I8135d2b9a67db62b0eafdd301b7fdb67a5dd72cc
Closes-Bug: #1279172
(cherry picked from commit 53fe8696314fb73ca9943fce998d96fa6d0414b4)
(cherry picked from commit 3136cfc11f034cf0b17888f7348e80d38d563c2e)