Fix getattr usage

Class 'object' has no '__getattr__' member as pylint pointed out.
Use the getattr function.

Change-Id: I38c6075ac477e2fe33870bed64b0e5e986175305
Removes unnecessary db query for instance type

The instance type information is already available in the instance
hash. This removes a db query and also reduces the likelyhood of a
race condtion where the instance type could change between the
point where boot API call was made and the request hits the compute
node.

blueprint no-db-compute

Change-Id: I8372a8c88049a8dacef86a7034c6df94c40c3001
Move host aggregate operations to VirtAPI

This patch moves the following virt driver host aggregate
operations to the VirtAPI:

  aggregate_get_by_host()
  aggregate_metadata_get()
  aggregate_metadata_add()
  aggregate_metadata_delete()

In the process, a bug was found in the xenapi/host.py code
that raises an AggregateHostNotFound error in such a way that
a KeyError is generated. This changes that behavior to raise
a NotFound instead, since the former expects you to already
know the aggregate_id, which we do not. This patch extends the
XenAPI host_maintenance_mode test to exercise this error path,
as well as the one where a host is not found within the returned
aggregate.

Related to bp/no-db-compute

Change-Id: I006665bfb27774d2eeb713b79c188ca53f6fb00b
Move security groups and firewall ops to VirtAPI

This patch moves the following network security-related
methods to VirtAPI:

  security_group_get_by_instance()
  security_group_rule_get_by_security_group()
  provider_fw_rule_get_all()

In order to make this change, the _provider_rules() method
of the FirewallDriver was changed from being a staticmethod
to a regular instance method. All uses of it were in the
context of an actual instance, so I saw no reason to keep
it static, which would have complicated the use of the VirtAPI
methods.

Related to bp:no-db-compute

Change-Id: I260c96b6aa4bbab694b74087f704b6405360b0bf
Add some xenapi Bittorrent tests

When the bittorrent support was added to the xenapi driver, no
tests were added. This patch adds a few, specifically around the
use of instance_system_metadata fetches from the database.

Change-Id: I165acd002e35e30c46fc60fc4de1ca6e07bb8845
Make instance_system_metadata load with instance

Right now, instance['system_metadata'] is demand-loaded at the
first use. This adds the necessary db fu to make it load at
instance_get_*() time.

Change-Id: Id29342fd34fe710b797b23558ef0fde8809231bc
Avoid unnecessary system_metadata db lookup

The bittorrent code in the xenapi driver added a specific database
query for the instance_system_metadata. This query is unnecessary,
as the system_metadata is available in the instance object itself.
This patch removes the queries and adds the small amount of
format translation required.

Change-Id: If72593289e18d2c45db8e782972eb9051e10d740
Switch from FLAGS to CONF in tests

Use the global CONF variable instead of FLAGS. This is purely a cleanup
since FLAGS is already just another reference to CONF.

We leave the nova.flags imports until a later cleanup commit since
removing them may cause unpredictable problems due to config options not
being registered.

Change-Id: Ic0168188dfe214fc81af04c8a9644d2d9f31600d
Switch from FLAGS to CONF in nova.compute

Use the global CONF variable instead of FLAGS. This is purely a cleanup
since FLAGS is already just another reference to CONF.

We leave the nova.flags imports until a later cleanup commit since
removing them may cause unpredictable problems due to config options not
being registered.

Change-Id: I0488b406dcf9f9459810337b62b6932d71a623a9
improve session handling around quotas

blueprint db-session-cleanup

Change-Id: I7606f69c0945b810deae098000717c7bcf96e77d
improve sessions for reservation

improve session handling for
  reservation_(get|destroy)

blueprint db-session-cleanup

Change-Id: I1b6e9a903ef8c3df7449201a2103dc720cdf0e31
improve session handling around virtual_interfaces

improve session handling around
 virtual_interface_(get|delete|delete_by_instance)

blueprint db-session-cleanup

Change-Id: I7ce5a5bb6f079d83d79c1f7ed00994af0af09f1e
Merge "Switch from FLAGS to CONF in nova.compute"
Merge "Switch from FLAGS to CONF in tests"
Merge "Removes unnecessary db query for instance type"
Merge "Move host aggregate operations to VirtAPI"
Merge "Move security groups and firewall ops to VirtAPI"
Merge "Add some xenapi Bittorrent tests"
Merge "Make instance_system_metadata load with instance"
Merge "Avoid unnecessary system_metadata db lookup"