Handle UnicodeEncodeError in validate_integer

validate_integer can be potentially passed user
supplied data which causes a UnicodeEncodeError
exception during validation rather than just ValueError.
This change handles the UnicodeEncode exception
so validate_integer treats it as invalid input.

Change-Id: I5177789299b02448ed53e1b7fc23ccdaee1b70d3
Partial-Bug: 1243037
Allow some instance polling periodic tasks to hit db slave

If your deployment has a slave configured, poll_*instance* periodic
tasks will send their reads to the slave. If you have no slave
configured, there is no change to behavior.

Note for developers, I have targeted all the easy tasks. By this I
mean tasks that were already using the InstanceList object and the
get_all_by_filters or get_all_by_host methods. I will slaveify the
other tasks in seperate reviews since they also require conversion
to using objects.

Change-Id: I4bead5d350d633d726d4564b4bc1baec2e2977b7
Partially-implements: blueprint periodic-tasks-to-db-slave
Fix image cache periodic task concurrent access bug

This fix catch the exception and ignore a disk file absent
exception. It will defer the image cache clean to next round
image cache periodic task because it's not harmful.
Refer to detailed info, log analysis and root cause in defect.

Change-Id: I3a431bf389658f976edf5c847c04b7e0aac496fd
Closes-Bug: #1261442
Catch InstanceIsLocked exception on server actions

If the server is locked, server actions raise 409 error, and the error
message is like "Instance is in an invalid state for 'pause(action name)'". The
error message is inappropriate, two points:
1. the state is valid for pause
2. the message doesn't tell that the instance is locked

The patch fixes the problem, and will modify on v2 and v3.

Change-Id: I7e21037b9abca5a3fd0f64dd5621e88dcf1a3c21
Closes-Bug: #1256873
Fix lxc rootfs attached two devices in some action

During resizing/rebooting a lxc container, create_domain action
will be called and lxc rootfs will be attached to device again.
So before this action, We need to teardown the container to
make sure lxc_root_device is detached when container is destroyed.

Closes-bug: #1243083
Related-bug: #1208387

Change-Id: Idd1862c7f212dc253b6273b07b020c86a94e658e
Ensure instance action event list in order

For two events also most happening at the same time, e.g. schedule and
run_instance, instance-action may fail to do the correct sorting because
the "create_at" column in db has the same value.

This change fixes this issue by sorting in "create_at" first, and then
in database generated "id" column, both in descending order.

Closes-bug: 1254764

Change-Id: I245a577ef2821fa7f3316bb8a21b7e6370498dd0
VMware: update test file names

The tests files names all had prefix vmwareapi. This is no longer
needed as the test files are now under the vmwareapi directory.

The patch also fixed the permission for the file test_vm_util.py.

Change-Id: I87955a0a4d4d2b2c1dd55203658707ce7c6038f0
Adds new method nova.utils.get_hash_str

Some modules are using their own method to generate hex from
string.
This patch adds a new method "get_hash_str" in nova.utils and
cleans every module needs to use it.

Change-Id: I2fa7dd2ea12c1d516224132d13454d109bb6c1e3
The private method _text_node should be used as function

If the class method does not reference any of the class attributes
it may be more clear to define the method as a static function instead.

Change-Id: I273e00fc4ab6fecafcd7bdeaf3b809a6688025c5
xenapi: refactor resize_up_root_vdi

Some refactoring to move things into vm_utils where possible, and
setting the stage for resizing ephemeral disks.

Needed by blueprint xenapi-resize-ephemeral-disks
Change-Id: Iba26ddb8b3d9041981317c47bb3b53733c004cea
xenapi: refactor generate_ephemeral

Refactoring generate_ephemeral so it will be easier to generate
individual ephemeral disks when required.

Needed by blueprint xenapi-resize-ephemeral-disks
Change-Id: I7032bd4c7d80adb62f8d5ece085170c6b89e267d
xenapi: resize up ephemeral disks

After adding the ability to migrate ephemeral disks, we were unable to
perform any resize of ephemeral disks.

This change implements the ability to increase the size of ephemeral
disks, if that is required be the selected flavor.

Unlike with the root disk, we attempt to expand the partition and
filesystem will never be touched by the resize up process.

However, after this change, you will still not be able to resize down
the ephemeral disks. This function has proved very error prone when
dealing with root disks, so we are not implementing this feature for
ephemeral disks, and will error on requests to reduce the size of
ephemeral disks.

Implements blueprint xenapi-resize-ephemeral-disks
Change-Id: I218e9db9f5c912335c96da9831b300513213d33d
Merge "xenapi: refactor resize_up_root_vdi"
Merge "xenapi: refactor generate_ephemeral"
Merge "xenapi: resize up ephemeral disks"
Merge "Allow some instance polling periodic tasks to hit db slave"
Merge "The private method _text_node should be used as function"
Merge "Adds new method nova.utils.get_hash_str"
Merge "Fix image cache periodic task concurrent access bug"
Merge "Handle UnicodeEncodeError in validate_integer"