Updated code to update attach_time of a volume while detaching

While detaching volume from an instance, attach_time of the
volume is not updated. This task updates volume['attach_time']
to NONE at detach_volume.

Also modified the default value of XML attribute
volume['attach_time'] '-' to ''(a 0 length string) to
maintain consistency with existing code.

Fixes bug: 1056122

Change-Id: If56ceda6caab80fb803fcf194ed1dfb18808ec3a
(cherry picked from commit ee2dd66c9c2350d9c4aa4ae535daed7e8d72dfb3)
XenAPI should only snapshot root disk

Change ID I3e2973 broke XenAPI migrations (resizes) as it caused snapshots
of all disks (including swap and ephemeral disks, if enabled) to be sent
over to the destination host.  The destination only expects vhds for the
root disk, named by sequence numbers.  swap and ephemeral disks ended up
with sequence numbers, also, messing up the re-building of the chain on
the destination.

Fixes bug 1064083

Change ID I3e2973 also didn't change the stub of VM.snapshot to
VDI.snapshot, but tests still passed due to the new code ignoring all
exceptions while snapshotting.  Potential issues in
snapshot_attached_here() would also be ignored due to excessive stubbing
in the xenapi migration testing.  This is also addressed here.

Change-Id: I145030f92a75615d056a30cabcb6ca97e34a8b6c
(cherry picked from commit fb101685cc14ed9b0396ce966e571d3fb457c32f)
Dis-associate an auto-assigned floating IP should return proper warning

Added new exception class CannotDissociateAutoAssignedFloatingIP and raised
exception instead of return.

Fixes bug 1061499

Change-Id: I348573a235c6b81653837267072b5c48fa15b8af
(cherry picked from commit ce04b13f26169e2d71b7d3122d3a769cb4348bf7)
Handle instances not being found in EC2 API responses.

Resolves bug 1080406 where InstanceNotFound was raised with None
as the instance id.

Change-Id: I805a9c8893f51ab22426e606ce260a04113f26e5
(cherry picked from commit c3639847011566f39a7bd08e29bab4a72847a333)
libvirt: ignore deleted domain while get block dev

The get_all_block_devices could raise libvirtError if domain was deleted
while listing instances. This will cause LibvirtISCSIVolumeDriver to fail
disconnect_volume. This patch ignores the domain that could not be found
to avoid this issue.

Fixes bug 1060836

Change-Id: I9dc994d8ca7fc084830adb4f6f9d3ca10e0fe577
(cherry picked from commit 5a16b8f3e230cad0fb8d1278b42e6754069e8501)
Fix XML response for return_reservation_id.

The XML serializer for create uses the server template for it's response.
However, when return_reservation_id is set, only a reservation_id is
going to be returned.

To enable the XML response to be serialized the reservation id is now
returned in a server tag/object.

This commit fixes bug 1061124

Change-Id: Ic74071b1d527c3f3752e296d3fd46a28a99beb76
Signed-off-by: Matthew Treinish <treinish@linux.vnet.ibm.com>
(cherry picked from commit 903b51e148c2f9e858b5ea0ca5b230ac308d76c5)
libvirt: continue detach if instance not found

Currently the libvirt code will always logout of the iscsi target
during detach error, but the exception will cause the volume to
remain in an attached state. This needs to be more consistent, so
This patch checks specifically for not found and logs a warning
and explicitly detaches. Any other exception will leave iscsi
logged in and leave the volume in the attached state.

Fixes bug 1057756

Change-Id: I23bb7f27e8a9b20fdbf62b0629ca8cc448f427c5
(cherry picked from commit cc02f6a5604892fb776158dab06b06f24a25cbfb)
Update db entry before upate the DHCP host file.

Update fixed IP db entry before upated the DHCP host file.

Fixes LP Bug #1078718

Change-Id: I75504acfc1c571219938d25a7c3b1a452d3f1cb9
(cherry picked from commit 51490807bd4dddaa01ba56620ba3a6b9b8ad75a3)
'BackupCreate' rotation parameter >= 0

In the extension 'admin-actions' of OpenStack Compute API, the action
create backups should only accept rotation parameter greater than or
equal to zero.

If the 'rotation' parameter is negative, OS API returns a badRequest
400 HTTP error.

Fixes LP bug #1071168

Change-Id: I6ef08fbecb0f88942cdb16193e9d2c3831866fe9
(cherry picked from commit 6eac65a8e13d3040c0c6561709f59b3d9bab5435)
Fix Incorrect Exception when metadata is over 255 characters

Need to be in sync with Essex. Throw a new exception in api.py when key or value
is over 255 chars. Catch this exception end return back HTTP error 413.

add extra lines in exception.py to make pep8 happy

Fixes bug 1004007

Change-Id: I67694e3a9600b7dd0b80c519327327568751c2a4
(cherry picked from commit db7798a973bb05af5d4668a9f9b20ce62e8a47af)
Fix config-file overrides for nova-dhcpbridge

nova-dhcpbridge can read in an alternate config file location but wasn't
using it to parse config options.  This fixes a regression introduced in
00786bc554a2dfacb3c6f02fbb7e9c98f35d4262.

This change is motivated by the fact that nova-dhcpbridge is passed to
dnsmasq in restart_dhcp() in nova/network/linux_net.py, and there is
currently no support for overriding config options for nova-dhcpbridge
in that call.  There is support for overriding the FLAGFILE env variable
in that call, but nova-dhcpbridge was ignoring that.  If I start
nova-network with an alternate config this provides a way for me to pass
that config to nova-dhcpbridge as well.

Change-Id: I002ea768500555a089bd1d5b0fea2354b27fba14
(cherry picked from commit ae0a0d54351e71e3d723d7c0c6de8db2cdbab772)
Declare vpn client option in pipelib

Due to some import refactoring, nova.network.manager isn't always
imported when running pipelib commands, so using the cnt_vpn_clients
option fails. A failing test could not be added because our testing
code imports nova.network.manager so the code config option always
exists in testing.

Fixes bug 1069573

Change-Id: I92b702556bfef2610b86a952dd6f9207fbab102a
(cherry picked from commit ae6920fb6b367b5aa75e02c72275e3149d02cd70)
Fix error on invalid delete_on_termination value

1. Fixed 500 error when an invalid value is passed to 'delete_on_termination'
parameter in 'block_device_mapping' of create server API (json request).
Converted the value to 'bool' (similar to XML request workflow) to fix issue.
2. Also added unit test coverage.

Fixes LP: #1060955

Change-Id: Ib35040f17a3712dac45ec1e3c2f32fee17db7c03
(cherry picked from commit 7c9761b3bb52788021b5bf0eb9726af833db4074)
Used instance uuid rather than id in remove-fixed-ip

remove-fixed-ip called db method fixed_ip_get_by_instance. but
fixed_ip_get_by_instance use instance uuid not id, so change to
uuid in remove-fixed-ip.

Fixed bug: #1065899

Change-Id: Ic7526c7e91933424c04be9bb91d4a98cfedd9b01
(cherry picked from commit 66521a1571f0922f791ae7f405129fb99b870f38)
Fixes live_migration missing migrate_data parameter in Hyper-V driver

Fixes Bug #1066513

Live migration on Hyper-V fails due to the parameter "migrate_data" that
has been added to the signature of live_migration(...) in
nova.virt.ComputeDriver.

This fix adds the new parameter.

Change-Id: I393f6706bc144838ae232dfb275460620bc203e2
(cherry picked from commit 448a578feb6edab148ef97328e57aeb06eb7360b)
Correct _extract_query_params in image.glance

Updates _params rather than params to ensure filters.

Fixes bug 1070138.

Change-Id: I4e71d19f120ea91d8dfca32785ccb0aa7b1c770b
(cherry picked from commit 1aec1f56f28cb52e843959a7d31f1f10c5f05407)
Fix use_single_default_gateway

With FlatDHCP and use_single_default_gateway nova-network creates
an invalid entry in the dnsmasq .opts file for the network that
contains a blank router option.  New instances will not receive
a default gateway.

Change-Id: I4c2da61def0681b7b253ae387bf83c069484e28b
Fixes: bug #1075859
(cherry picked from commit 1b455923446de6fcfee7166059db72b80ff51dfe)
libvirt: Regenerates xml instead of using on-disk

The libvirt.xml file is written on initial boot of the instance and
may not reflect the current state of the vm if volumes have been
attached. If the libvirt definition of the vm has been lost, it is
safer to regenerate it rather than attempt to load it from the
outdated file. This should properly bring back vms with attached
volumes.

Fixes bug 1073720

Change-Id: Iaa754700a149f09fc0c022fa664c06ad17f505f5
(cherry picked from commit b22c3302ccea6b4b9e685640accbfdbb2856d460)
Migrate DHCP host info during resize

Update instance host to migration_ref['dest_compute'] before
update_dhcp to make its DHCP host info will be written in dhcp-hostsfile.

Make similiar change in finish_revert_resize.

Fixes bug 1065440

Change-Id: I9d3e0ebf8512f98f2943999e7ad95bc58f2bf585
(cherry picked from commit 9ea41fc80b46b0c5adbab3ea191b92583feb02e0)
Merge "Updated code to update attach_time of a volume while detaching" into stable/folsom