Make flavorextradata ignore deleted flavors.

In _get_flavor_refs, don't retrieve inactive flavors.  Fixes bug 1026210.

Change-Id: I7c5d7848d2d1326d01770195e1c8a754bb673a7a
Merge "Partially implements blueprint xenapi-live-migration"
Merge "Raise NotImplementedError, not NotImplemented singleton"
Static FaultWrapper status_to_type map.

Avoid maintaining needless copies of this dict, by instantiating
lazily once and only once.

This approach will bring master into sync with the corresponding
patch proposed to stable/essex:

  https://review.openstack.org/9446

Change-Id: I8a7cd5fc4fe0effd436e91a6c481df7b0d5a8b01
Don't let failure to delete filesystem block deletion of instances in libvirt

During cleanup of instances, the libvirt driver tries to delete all
files under the /var/lib/nova/instances/$INSTANCENAME directory. If
Nova is running non-root, it is entirely possible for this to fail.
If this happens an OSError is raised and the result is an unkillable
instance. By catching and logging any OSError raised, we can ensure
that the instances are cleaned up as much as possible and not left
with unkillable instances.

Change-Id: I204b087c610396d917e94a6e35dd2f5e1c26704e
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Merge "Use _lookup_by_name instead of _conn.lookupByName"
Fix cloudpipe keypair creation. Add pipelib tests

Commit ec0a65d81fd11d26be77b45827a4dd7c77711675 introduced a new
internal key pair API, removing the _gen_key() method from the EC2 API.
pipelib.py used this method so as to generate the keypair of the
cloudpipe instance.

This commit also adds unittests for pipelib.py, thus fixes bug 828588

Change-Id: I0884289bac01ac5109dde4bdee5af55e7bfd5aa2
Allow NoMoreFloatingIps to bubble up to FaultWrapper

Fixes LP 1026167.

The fix for LP 1021721 caught the wrong exception in order to
address floating IP quota over-run. NoMoreFloatingIps is raised
when the floating range is exhausted, whereas FloatingIpLimitExceeded
is raised on over-quota.

Also the HTTPRequestEntityTooLarge exception raised is mapped
to 500 Server Error due to the required retry-after header being
left unset.

We now allow the NoMoreFloatingIps to bubble up to the FaultWrapper
middleware, where its mapped to a 404 status due to it extending
the NotFound exception.

Change-Id: Id35c487113059ec3053f2f9e9e7eca24854ac02c
fixes for nova-manage network list  if network has been deleted

this fix addresses the  bug #1021810
Currently command 'nova-manage network list' or
'nova-manage fixed list'  will return 'Command failed.' message when
there is no network defined or networks get deleted. This fix combined
with fixes to bug 1025827 will fix both command problem.
also change the print out message so that it can be translated.
code structure changes according to the suggestion from comments.

Change-Id: Id9a1a10217aac971cbbba9db5829c8478892db1a
Ensure 413 response for security group over-quota

Fixes LP 1021748

Instead of raising the relevant webob.exc exception directly,
we now follow the usual pattern of mapping in the FaultWrapper
middleware from an internal exception type to the corresponding
HTTP error.

Change-Id: Ifb43685e4f9b0b5bd53e74747d1f87aa5e119fb5
Merge "Update FilterSchedulerTestCase docstring"
Merge "Static FaultWrapper status_to_type map."
Fix SQL deadlock in quota reservations

Fixes bug 1026709

The code in quota_reserve acquires SQL locks in a different order than
the code in reservation_commit/reservation_rollback. This can result in
an SQL deadlock under heavy load. Due to an (unrelated) bug in
SQLAlchemy, this can result in this exception:

ResourceClosedError: This result object does not return rows. It has
been closed automatically.

This patch reorganizes the code to always fetch (and thusly lock) the
quota_usages table before the reservations table.

Change-Id: Ia364496a996870d754094915ea0501ff19052037
Fix error in error handler in instance_usage_audit task.

This fixes bug 1026307
In the periodic task that generates .exists notifications, if there is
an exception generating the notification for an instance, it attempts
to log the exception and continue. Alas, there is an error in the error
handler that clobbers the original error, preventing it from being logged.

Turns out a variable in for loop was 'instance_ref' in one part, but 'instance' in
except clause. Fixed.

Change-Id: Ic887d9078725ec9b676c4f49cf58b567759b6210
Ensure VHDs in staging area are sequenced properly.

This adds a check to raise a sensible error if the VHDs in the staging
area are not sequence numbered properly, meaning 0 to n-1 with no gaps.

The previous error was an UnboundLookupError which made it difficult to
pinpoint the root cause.

Change-Id: I6b9e4f854c271bf73711480568be384ba883775d
Revert "Attach ISO as separate disk if given proper instruction"

The following commit

  commit b63a3e8cbd8fe57d0be119368bf47964543270c2
  Author: Josh Kearney <josh@jk0.org>
  Date:   Fri Jul 13 15:57:54 2012 -0500

    Attach ISO as separate disk if given proper instruction.

    This gives the option to attach the ISO as a separate drive, like we do in
    XenServer, and boot from that instead of replacing the root drive.

    Fixes bug 914484.

    Change-Id: I0e0560f5fcbc361b60ff1284e7369997dd770fd9

Results in this XML config

  <devices>
    <disk type="file" device="cdrom">
      <driver type="qcow2" cache="none"/>
      <source file="instance-00000001/disk"/>
      <target bus="virtio" dev="vda"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver type="qcow2" cache="none"/>
      <source file="instance-00000001/disk"/>
      <target bus="ide" dev="vda"/>
    </disk>
   ...
  </devices>

which is broken in many ways

 - The same backing file is used in read/write mode on 2 disks
   which will cause data corruption on write.
 - The 'virtio' bus type does not allow device="cdrom" disks
 - The 'dev' attribute is given the same value on 2 disks

To compound the problems, the original commit completely lacks
any tests which would have caught the brokeness and/or identified
what was actually intended.

Change-Id: If1ec286f98fc91f9f411800bbb0adbf2797d2114
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Get rid of pointless 'suffix' parameter in libvirt imagebackend

The libvirt 'imagebackend' module has various methods which take
a 'name' and 'suffix' argument. They are never used in isolation,
however, so passing them separately has no benefit. Indeed all
but one caller passes a name which already has a suffix appended
The suffix argument can thus trivially be removed completely.

Change-Id: I2ee0f3d104a2eb5139fc85c2db68e36255b82dad
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Move setup of libvirt disk cachemode into imagebackend module

There is alot of repeated code setting the disk cache mode.
Move this into the imagebackend module so that it can be
done in one place

Change-Id: I7bff6b0b2e7e40a5aef3126634ca814082f8cf4f
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Don't set device='cdrom' for all disks in libvirt driver

When the root disk image was tagged as being an ISO image,
the libvirt driver would mistakenly set device='cdrom' for
all disks, instead of just the first image

Change-Id: Idf29df5c460f8ebefd2e462a53d72280d5af4c5e
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Ensure to use 'hdN' for IDE disk device in libvirt driver

When configuring the root disk for an image which is tagged as
an ISO, the libvirt driver sets the bus=ide, but still uses
the normal root device name, eg dev=vda. It must instead
use dev=hda for the IDE bus

Change-Id: If0a4c50043d6e4d9e54a5dcbdc05effbb72eced6
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>