Convert host value from unicode to a string.

The memcached API expects string format, not unicode.
Convert the host value to a string before creating
the cache_key and passing it to memcached.

Fixes: bug #1158958
Change-Id: I26e86b7fb61b4b3380a14686bd2faa9f58017999
Ensure only pickle-able objects live in metadata

Conductor api has been added to InstanceMetadata object, but it cannot
be serialised. This breaks storing metadata in memcache, because the
information needs to be passed through pickle.

Since the field was not used outside of the constructor, it can be
removed to fix the problem.
Also add a test that pickles a sample InstanceMetadata to catch similar
failures in the future.

Fixes bug 1160900

Change-Id: I7e8cef5a131290eaa1402d48295026bcac6baff6
Use Cluster reference to reduce SDK calls

The vmware compute driver retrieves the cluster reference
for every spawn and volume operation. The solution is to
retrieve the reference once from the __init__() of
vmwareapi/driver.py and reuse the same in other methods.
This will reduce the number of VI SDK calls made.

Fix for bug 1130222

Change-Id: I2179733ee4ab1b2aea919de0ad4c10631cf005ea
Accepts aws-sdk-java timestamp format

The aws-sdk-java timestamp format is "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
which contains millisecond representation. However, the current
implementation does not accept this kind of format.

References:
https://github.com/aws/aws-sdk-java/blob/master/src/main/java/com/amazonaws/auth/QueryStringSigner.java#L173

Adds ability to parse this format in ec2utils.is_ec2_timestamp_expired.

Fixes bug 1156445.

Change-Id: I389ff8b9c6c91b699538b889add264d66dbb8131
Add missing unit tests for FlavorActionController

Fixes bug 1115575

Change-Id: I81740bd30d03fd3c5d9b1dcc7f73e1b7a2b757c7
Better iptables DROP removal.

With the introduction of configurable iptables DROP rules in
nova-network, we need to cleanup possibly more than one drop
rule, depending on what DROP action was in place when the rule
was created. This patch handles this for the simple case where
the drop action has just been configured. More complicated
scenarios will need to be handled manually.

Change-Id: I660607ff6e23ca545f96e536d1084d972bc7c7a2
Return proper error message when network conflicts

Fixes bug 1158075
When creating a network which is already existing, we got
an internal server error which can't show the error reason.
This patch returns conflict error(HTTP 409) instead of
internal server error(HTTP 500), so that users can know
the error reason from the error message.

Change-Id: I9e39a7152e37756b34b1c8d77de057012743f0f7
Return 409 on creating/importing same name keypair

* Removed the DB look up on creating and importing a keypair.
* Added unique constraint on user_id and name columns of key_pairs
table.

Fixes LP: #1086333.

Change-Id: I2fd4697f9269d2be13bd977e65ba4ca4a27b9ac6
Remove gettext.install() from nova/__init__.py

The gettext.install() function installs a builtin _() function which
translates a string in the translation domain supplied to the install()
function. If gettext.install() is called multiple times, it's the last
call to the function which wins and the last supplied translation domain
which is used e.g.

 >>> import os
 >>> os.environ['LANG'] = 'ja.UTF-8'
 >>> import gettext
 >>> gettext.install('keystone', unicode=1, localedir='/opt/stack/keystone/keystone/locale')
 >>> print _('Invalid syslog facility')
 無効な syslog ファシリティ
 >>> gettext.install('nova', unicode=1, localedir='/opt/stack/nova/nova/locale')
 >>> print _('Invalid syslog facility')
 Invalid syslog facility

Usually this function is called early on in a toplevel script and we
assume that no other code will call it and override the installed _().
However, in Nova, we have taken a shortcut to avoid having to call it
explicitly from each script and instead call it from nova/__init__.py.

This shortcut would be perfectly fine if we were absolutely sure that
nova modules would never be imported from another program. It's probably
quite incorrect for a program to use nova code (indeed, if we wanted to
support this, Nova code shouldn't use the default _() function) but
nevertheless there are some corner cases where it happens. For example,
the keystoneclient auth_token middleware tries to import cfg from
nova.openstack.common and this in turn causes gettext.install('nova')
in other projects like glance or quantum.

To avoid any doubt here, let's just rip out the shortcut and always
call gettext.install() from the top-level script.

Change-Id: If4125d6bcbde63df95de129ac5c83b4a6d6f130a
Merge "Convert host value from unicode to a string."
Merge "Add missing unit tests for FlavorActionController"
Merge "Better iptables DROP removal."
Merge "Ensure only pickle-able objects live in metadata"
Merge "Return proper error message when network conflicts"
Merge "Remove gettext.install() from nova/__init__.py"
Merge "Use Cluster reference to reduce SDK calls"
Merge "Accepts aws-sdk-java timestamp format"
Merge "Return 409 on creating/importing same name keypair"