Fix security group race condition while listing and deleting rules

Previously, there was a race condition that could occur if one was listing
a security group which contained a rule which referenced another security
group as an additional api call is used to look up the security group's
name which is returned (rather than id) via the API. The problem occurs if
this security group is deleted in which case a 404 was raised.
This patch fixes this issue by catching the 404 and ignoring the rule as
its already deleted as there is a constraint enforced that you cannot
delete a security group if another security group has a rule that references
that security group.

Change-Id: I3855b8d3a1bd2f7c88901da071f9bd5581bd56e4
Closes-bug: 1262566
Add helpers to create per-aggregate filters

This patchset introduce a new file of utility methods
to deal with aggregate metadata.
As well it updates related filters to use this new logic.
* AggregateRamFilter
* AggregateCoreFilter,
* AggregateTypeAffinityFilter

Closes-Bug: #1301340
Change-Id: I5e4aebe9e61cfbdc7b9e6b5de0788fc6670eb936
VCDriver - Ignore host in Maintenance mode in stats update

The VCDriver during stats update checks only for connected hosts.
However hosts which are in connected state to the Cluster can
be set to Maintenance mode.
The cluster does not boot instances to hosts which are in
maintenance mode.
Hence the VCDriver should check for hosts which are in
maintenance mode and ignore them for stats update.
VISDK API returns True for the property inMaintenanceMode for
Hosts which are in maintenance mode

Change-Id: Ieaf7530ed2d98c59c5450e8cb75e209823193d49
Closes-Bug: #1316674
Fix migration and instance resize update order

This commit switches the order in which migrations and instances are
updated when resizing an instance. Previously, if you set
resize_confirm_window to some small value, your resize instance could go
into error state because the periodic task was run after the migration
was updated but before the instance object was updated. This change makes it
so the instance is always updated before the migration.

The _test_finish_resize test case has also been refactored to enforce
saving the instance object before the migration object. In the event
that the instance object is saved after the migration, like the previous
implementation, the test cases will fail since the states of the
migrations will be out of sync in the _mig_save assertions.

Closes-Bug: #1321298
Change-Id: I0490fc4b4e03b36eb01a06a95ea761f4cf8df469
Catch InstanceInfoCacheNotFound during build_instances

instance.refresh() is raising InstanceInfoCacheNotFound which is logged
by the conductor and would cause all following builds to fail in a
multiple build request situation.  The cause appears to be a race
condition which should be addressed separately, but for now this
exception should be caught, logged, then ignored.

Change-Id: Ibf9e6687933ee90dad54b1998b243ef7256d79ca
Closes-bug: 1324793
VMware: Fix memory leaks caused by caches

Using suds objects as keys for the DatastoreBrowser cache is incorrect
because they don't implement __eq__ and __hash__ for the VIM types.
This always results in cache miss and the cache grows with every spawn()
operation.

This patch fix this by using the 'value' property (which is string) of
the MoRef as key.

Change-Id: I2bcaf87e733d51055566aee41bb0a7e254027ba9
Closes-Bug: 1316433
Merge "Add helpers to create per-aggregate filters"
Merge "VMware: Fix memory leaks caused by caches"
Merge "Catch InstanceInfoCacheNotFound during build_instances"
Merge "Fix security group race condition while listing and deleting rules"
Merge "VCDriver - Ignore host in Maintenance mode in stats update"
Merge "Fix migration and instance resize update order"