Adding networking rules to vm's on compute service startup

Fixes bug 1027105

Restarting nova-compute resulted in a new empty iptables chain
"nova-compute-FORWARD" being create. This commit adds a single
call to plug_vifs which ensures the appropriate filters (and
bridge) are present on service startup.

Change-Id: I51cbb56acbb244ddddd951a26d3168cf5a9c0314
(cherry picked from commit c2e957ceb555b88084033d9a1c15a4f338b1476e)
use boto's HTTPResponse class for versions of boto >=2.5.2

Fixes bug: 1027984

Change-Id: I2101ddaa78ede90f39b55d28aab73e7f5a816af5
Convert remaining network API casts to calls

Fix for Bug 1021340

During compute/terminate_instance networking is de-allocated by a call to
network/api/deallocate_for_instance(), which is implemented as an rpc.cast to
the network manager. This in turn will eventually call
network/manager/deallocate_fixed_ip(), which in turn call the compute API to
trigger a security group refresh, which will get the instance from the database

However because original call to the network manager is a cast there is a chance
that the compute manager will delete the instance record in the DB before the
compute API (in the network manager) tries to retrieve the instance. At this
point the security group refresh fails (leaving rules in place which are a
security risk when the IP is reused), and potentially stopping otheraspects
of the network deallocation from completing.

Changing this from rpc.call to rpc.cast will fix this issue.

Aside from this specific use of a cast there are 4 other casts in the
network API:
  add_fixed_ip_to_instance
  remove_fixed_ip_from_instance
  add_network_to_project
  release_floating_ip

and to avoid other timing issues these will also be converted to calls.

Change-Id: I5cdcc628293d3e7cf165c5ffe4883f138783f73f
(cherry picked from commit 34f9d7e974d0e09c723e0a04ed6eecd1b482e77d)
Moving where the fixed ip deallocation happens.

Fixes bug 1021352.

In network/manager/deallocate_fixed_ip the call
to mark the IP as no longer allocated occurs before
the call to update security group rules. This means
that if an error occurs in the security group
processing, or if for some reason it is very slow
there is a risk that that the address is reused by
another tenant before the rules relating to this address
have been fully revoked.

Moving the db call to after the call to trigger the
security group refresh would avoid the issue when an
error occurs (the fixed_ip should not be released in
this case).

Change-Id: Iaba1af5c9a17fbbb82e42522b1060773de61550a
(cherry picked from commit 44132acbe91092de1188a3015a2c7155b5ec774c)
fix the qpid_heartbeat option so that it's effective

The 'hearbeat' typo caused this setting to be ineffective.

Present Since: essex-1-861-gbe96c43
Fixes bug: 1030430
Change-Id: Ibb9d7484b9d11a6904cc9e2a8dde6d9164ee05b1
ensure libguestfs mounts are cleaned up

Make a few attempts to umount the libguestfs
mounts, in case other processes are accessing
the mounts (like udev etc.)

If we still can't umount after 5 attempts
(with average delay of about 1s between each),
then initiate a lazy umount so that the mounts
might be automatically cleaned up at some stage.
We wait a further 10s after initiating the lazy
umount, before raising an exception.

Addresses the original issue in bug 1013689

Change-Id: Ib5ede9f705c833825a19308c140f99c5bf3a776f
(cherry picked from commit 5eea8879b6f3268dcaba326193bef0ed75470bb7)
Merge "Adding networking rules to vm's on compute service startup" into stable/essex
Merge "use boto's HTTPResponse class for versions of boto >=2.5.2" into stable/essex
Merge "Convert remaining network API casts to calls" into stable/essex
Merge "Moving where the fixed ip deallocation happens." into stable/essex
Merge "ensure libguestfs mounts are cleaned up" into stable/essex
Drop AES functions and pycrypto dependency

At some point IV parameter has been removed making these functions
dangerous to use unless keys are unique on every message. Since the
functions were added the original consumer has disappeared too. With
no more users it's better to get rid of the incomplete encryption system
entirely.

These were the only functions using pycrypto module directly, so it was
also removed from the dependency list.

Fixes bug: 1033178
Change-Id: I57b0a0a42dac455d5baae3d726aea1507121aa4d
(cherry picked from commit 56d3d29ad2451bd0e753e7878827a08b458b726b)
Prohibit file injection writing to host filesystem

This is a refinement of the previous fix in commit 2427d4a9,
which does the file name canonicalization as the root user.
This is required so that guest images could not for example,
protect malicious symlinks in a directory only readable by root.

Fixes bug: 1031311, CVE-2012-3447
Change-Id: I7f7cdeeffadebae7451e1e13f73f1313a7df9c5c
Merge "fix the qpid_heartbeat option so that it's effective" into stable/essex
Merge "Drop AES functions and pycrypto dependency" into stable/essex
Make flavorextradata ignore deleted flavors.

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

This change was made on trunk in https://review.openstack.org/#/c/9995/

Change-Id: I967faa661cd4177a54079a966ca8912923c5f61b
Final versioning for 2012.1.2

Change-Id: Ifc576f7e4ff8149cda524e0607fc7a36d1e4024f
Bump version to 2012.1.3

Set version to 2012.1.3, but with final=False

See http://wiki.openstack.org/StableBranchRelease

Change-Id: If242da1cf3d777ca8d0ebd6af306332816606d83
Restore libvirt block storage connections on reboot.

Fixes bug 1036902 -- Backported version for stable/essex.

There are a number of cases where block storage connections are not
properly restored, impacting libvirt in particular. The most common
case is a VM which has block storage attached via iSCSI, whereby the
physical system is rebooted. When the system comes back up and
starts nova-compute, the iSCSI connections are NOT recreated for the
instances slated to be resumed (assuming
resume_guests_state_on_host_boot is set).

The patch changes the compute manager to pass block_storage_info via
driver.reboot() and driver.resume_state_on_host_boot(). The fix is
actually only present in the libvirt driver. However, all the other
drivers were updated to accept the additional, optional function
arg.

With the changes in place, iSCSI connections for libvirt are
re-established after a hypervisor reboot with
resume_guests_state_on_host_boot=True and on every hard_reboot.
The latter is intended so that users have a last ditch option for
recovering their VMs without administrative involvement.

Change-Id: I8ab3a138b559ee0aa1535a928282e9c372ec5651
Makes sure instance deletion ok with deleted data

Commit 5ad1dea4 added changed the network deallocation code to
work with deleted instances. This was done by setting the context
to read deleted records. Unfortunately this was done a little too
broadly, leading to a new bug where a deleted floating_ip will
cause an instance to not be able to be deleted.

This fixes the issue by limiting the use of read_deleted context
to only the places it is trying to access the instance record. It
adds a test  to verify that the code works with a duplicate
deleted floating_ip and updates the existing test for a deleted
instance to exercise the entire code path.

Fixes bug 1038266

Change-Id: I1aef94369e5bcf951e78e89b1eded5305cf36b53
(cherry-picked from commit 1f98e28a80077760394201f79de04a0924b9ad3f)