Correct lock path for storage-registry-lock

This fixes the lock path for storage-registry-lock to prevent a
potential data loss due to a race-condition scenario.  Since the
storage-registry-lock is used to modify a json blob that is
authoritative as to which nodes are using the storage so that
we don't remove any "in-use" backing files on the shared storage
segment (if in use).

The potential data-loss could occur in limited cases of the race
that the lock should prevent.  This can only occur if the image
cache cleanup is triggerd when a node has been eliminated from
the register_storage_use JSON incorrectly by this race condition.

Most of the time the race simplyresults in a corrupted json blob.

Fixes-bug: 1194696
Change-Id: Ib1a5785646e75dc90bdd2a7e69a697adc4fbb298
Windows instances require the timezone to be "localtime"

This was relatively simple to fix, assuming that the image used
to boot the windows instance has the os_type set to "windows".
The use of os_type in this manner is consistent with the
existing use in the Xen hypervisor driver.

DocImpact: if you're booting windows instances, then you need to
set the os_type image property in glance to "windows". Otherwise
your instances will have their clock timezone set to UTC, which
has unexpected side effects in windows.

Change-Id: Id6759a290ed25c9add97ac61bb7d165b3fb908b2
Closes-Bug: 1231254
xenapi: enforce filters after live-migration

Currently and network filters, including security groups, are
lost after a server has been live-migrated.

This partially fixes the issue by ensuring that security groups are
re-applied to the VM once it reached the destination, and been started.

This leaves a small amount of time during the live-migrate where the VM
is not protected. There is a further bug raised to close the rest of
this whole, but this helps keep the VM protected for the majority of the
time.

Fixes bug 1202266

Change-Id: I84fdb6e2a8ee38d75f243aadbe79945af1d6849d
Fix unicode string values missing in previous patch

Commit 61bedc9aa04b0bac21e5c4bd17d6d2c09e2d9e01 lost some code
around the str_or_none() helper in objects/utils.py during a
rebase which caused almost all of our values to not actually
be coerced to unicode. This adds that.

Also, the instance.uuid value can't (and shouldn't) be unicode,
so add a cstring() helper and convert it to use that so that
the above change doesn't try to make uuid be unicode. Also,
make str_value() enforce non-None-ness like cstring() to avoid
bugs where we get 'None' unexpectedly, and add a test for that
whole function, which was missing before.

Change-Id: I941545d38aee10f140610b268fbd9c744f6545f9
VMware: Fix SwitchNotFound error when network exists

In FlatNetworking mode, when a virtual network exists on the vCenter
host we still check for the presence of a physical adapter specified
in vlan_interface. This check is only needed if we are going to
create a new network on the vswitch associated with the interface.

This fix removes the check for the physical adapter and the vswitch
when network already exists.

Fixes: bug #1226238
Change-Id: I1eecf2c339534d8694ec6a8bdfaff5217ba2f8ef
Make sure periodic task sync_power_states continues on error

If an instance sync_power action fails with an exception, no more
instances will be synced. If the failure is permanent, this will block
other instances from having their power states synced for as long as
this keeps happening.

Make sure to catch and log such exceptions and then continue with the
next instance.

Change-Id: Ie3cf5d7f590cb680e712d76b7a32c630e82f362d
Closes-Bug: #1228160
Merge "xenapi: enforce filters after live-migration"
Fix log format error in lazy-load message

The just-merged patch to log lazy loads missed the format specifier
in instance.py. This adds that back.

Change-Id: I6f1641a96ccffac80e609e3d304e0f21f693f1fa
Merge "Fix unicode string values missing in previous patch"
Merge "VMware: Fix SwitchNotFound error when network exists"
Merge "Make sure periodic task sync_power_states continues on error"
Merge "Windows instances require the timezone to be "localtime""
Merge "Fix log format error in lazy-load message"
Merge "Correct lock path for storage-registry-lock"