Make compute only auto-confirm its own instances

Fixes bug 1030226

Change-Id: I0e0cf0c9950f34b1bdab856b2e1c6872b29fdedc
Turn on base image cleanup by default.

Essex shipped with the libvirt image cache manager hobbled so it
wouldn't delete unused base images. Its been a while and we haven't
had a new bug reported in ages. Let's turn it on for Folsom. This
is tracked by bug 1029674.

Change-Id: I5529232bf4a316f844d383d5f5a3c0c287d59c1f
Avoid error during snapshot of ISO booted instance

Fixes bug #1023492

If you boot an instance from an image with disk_format=iso and then
attempt to snapshot (i.e. nova image-create) you currently get a
traceback because we do:

  qemu-img convert -f qcow2 -O iso -s $snap $disk $out

and 'iso' is not a format that qemu-img knows anything about.

When booting the image, we use qemu-img to detect that the file is
a raw image so we avoid having to special case disk_format=iso
there. However, there's no way of avoiding the special casing when
extracting a snapshot.

Note 1 - it's not very clever to take a snapshot of a read-only
disk downloaded from glance and upload it back to glance again.
Adding such smarts would be a nice enhancement.

Note 2 - only the destination format is important here because
we can only be extracting from a qcow2 image since snapshots
only work where use_cow_images=True. See also #1030844.

Change-Id: I21ff6db8ebb59a83d27f224283fb76f582c38a0e
reduce debugging from utils.trycmd()

In the case where the command fails, we're returning
the err anyway and the caller can log if required.

In the discard_warnings=True case, then the caller
has explicitly asked to suppress the warnings,
so don't log this noise either.

Fixes bug: 1030609
Change-Id: I075c21aa6508182ae6dd030cf41ec31916559957
Merge "Make compute only auto-confirm its own instances"
Use common parse_isotime in GlanceImageService

Rather than reimplement openstack-common's isotime functionality,
just use what's provided for us!

Change-Id: Id44eab3c34ae2c682d27d1563c6baaf68b979d2b
Fix rootwrapper with tgt-admin

Dont use the full path when calling tgt-admin.

LP: #1030850

Change-Id: Ifc7a1960aa67325e9219309e06de292010d7ec46
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Resize.end now includes the correct instance_type

Fixes bug 1031004. Moves the notification to the destination compute node
so that the correct instance_type attributes are assigned.

Change-Id: I5886154ddd7a9768dc5d82dc4e43e9e0f681ee04
Merge "Avoid error during snapshot of ISO booted instance"
sync openstack-common log changes with nova

don't throw exceptions if %(color)s tag is used

fixes bug #1030078

If the log format strings include the %(color)s key in them and you
enable file logging, your log files won't work, and instead you'll
see exceptions on the console as the default python log handler doesn't
support that keyword.

This approach stubs out the extra keywords to be empty strings to avoid
the KeyError. Tests are also added to demonstrate the KeyError as defined
behavior, and test that color codes can be passed.

Change-Id: I24b2f45dd5a38b27b8cc5a70e0084d367e218172
Merge "Resize.end now includes the correct instance_type"
Reverts fix lp1031004

The fix was incorrectly applied to the resize.end event. There was a
miscommunication about the resize.end versus resize.finish event

Change-Id: I301b46bbb7684d70946a426ce371eaf1198b97df
Send a full instance in rebuild_instance.

Change the rebuild_instance method of the compute
rpc API to take a full instance over rpc instead of just
the instance UUID.  This cuts down on database access needed
by nova-compute.

This patch also includes fixes for a couple of places that were getting
the instance name using the old instance.name syntax.  It must be
instance['name'].  These no-db-messaging patches are making it so more
code paths have an instance as a dict (received over rpc) instead of
the SQLAlchemy model (looked up from the db on the compute node).

Part of blueprint no-db-messaging.

Change-Id: I21647a5a5cbf71a2c498f6fee2e4adbe30b8f2ea
Send a full instance in remove_fixed_ip_from_instance.

Change the remove_fixed_ip_from_instance method of the compute
rpc API to take a full instance over rpc instead of just
the instance UUID.  This cuts down on database access needed
by nova-compute.

Part of blueprint no-db-messaging.

Change-Id: Iee0daf068be9814ef0ba06a69111a45a2e198cbb
Fix image_type=base after snapshot

When an instance is snapshotted, the resultant image should have the
image_type property set to "snapshot".  However, if the base image
already had image_type set to "base", the image_type on the snapshot
will also be set to "base".  This turns out to be because we set
image properties in two different places.  The first is when the
image record is created in glance, which occurs in
nova.compute.api:API._create_image(); this is when image_type is set
to "snapshot".  However, in nova.virt.xenapi.vm_utils:upload_image(),
all the properties from the base image are copied over, so all the
properties set by _create_image() could be overwritten.

The quick solution was to extend the non_inheritable_image_properties
configuration setting to also cover the image properties set by
_create_image().  Long-term, these two metadata-setting processes
need to be more closely unified.  (It should be noted that the
upload_image() function contains a TODO stating that the code should
move into the compute manager, so it can be shared across
hypervisors…)

Fixes bug 1031079.

Change-Id: I936bc147fb823eca67e40084cba5c3bc1a7fe73a
Compute: VM-Mode should use instance dict.

Instance dicts no longer support attribute-style access.

Change-Id: Ia5191aa14ad7cc62630bd6b0df8aaccb87e51e03
Merge "Send a full instance in rebuild_instance."
Merge "Send a full instance in remove_fixed_ip_from_instance."
Convert virtual_interfaces to using instance_uuid.

This review converts virtual_interfaces from tracking their
instances with instance_id to using instance_uuid.

This should be the last review for blueprint finish-uuid-conversion.

Change-Id: I303bba009fa37c72394369c8338e6e759f794cd0
Merge "Fix image_type=base after snapshot"