attach/detach interface should raise exception when instance is locked

when instance is locked, exception should be raised if attach and
detach an interface operation is performed. This patch add instance
lock check for the 2 APIs, catch and process the exception at API layer.

Change-Id: I6c0b05dafb9d480c8f0002bcc8306cb65a32aaf7
Closes-Bug: #1275741
Use instance data instead of flavor in simple_tenant_usage extension

The simple_tenant_usage extension gets the flavor data from the instance
and then looks up the flavor from the database to return usage information.
Since we now store all of the flavor data in the instance itself,
we should use that information instead of what the flavor currently
says is right. This both (a) makes it more accurate and (b)
avoids us failing to return usage info if a flavor disappears.

Change-Id: I1472d78e8e920013a1db5c76e04715fa04b696c2
Closes-Bug: #1276731
Add test cases for validate_extra_spec_keys

There is no unit test cases for function flavors.validate_extra_spec_keys,
this patch adds for it

Change-Id: I689aad1ce7428687c723ecd2eba243fccb3342bf
Closes-Bug: #1292316
VMware: remove double import

"import mock" was done twice.

Change-Id: Ibc38d27d7fd8b57b193cbe37d2abd89b823ed43f
Add exception handling in "nova diagnostics"

when using "nova diagnostics" with a not running
instance, user will get an incorrect message. This
change handles that exception.

Change-Id: Ia2aa76a5c2c2aeed446411700d74d547dd73cf90
Closes-bug: #1289079
Check image exists before calling inject_data

os.stat removal is needed for network-based image backends

Partly revert Change-Id: I264540de736c2bcb92567826fe5ba672e1244ba2
Partly fixes bug #1257674

Change-Id: I83e95fec6f08bc36f0e2b299fb269ceaa3500243
Fix network-api direct database hits in metadata server

The metadata server was using a couple of methods from the network
api that caused direct-to-database accesses. Those are no longer
necessary with the object modeling of network resources. This patch
converts those to use objects and avoid the direct database
traffic.

Change-Id: Iea48f74387afa35af3889eebdfa1af169a52ad1d
Closes-bug: #1306009
Merge "Add test cases for validate_extra_spec_keys"
Merge "Check image exists before calling inject_data"
Merge "attach/detach interface should raise exception when instance is locked"
Merge "VMware: remove double import"
Merge "Add exception handling in "nova diagnostics""
Merge "Use instance data instead of flavor in simple_tenant_usage extension"
Merge "Fix network-api direct database hits in metadata server"