Add instanceset info to StopInstance response

Currently stopinstance response missing the instanceset
information with InstanceID, current state and previous
state details. It just returns the "True".

As per the AWS EC2 API reference document, the StopInstance
response elements should include the instanceset information
as below:
<StopInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
  <requestId>req-a7326465-5ce2-4ed6-ab89-394b38cca85f</requestId>
  <instancesSet>
    <item>
      <instanceId>i-00000001</instanceId>
      <currentState>
        <code>80</code>
        <name>stopped</name>
      </currentState>
      <previousState>
        <code>16</code>
        <name>running</name>
      </previousState>
    </item>
  </instancesSet>
</StopInstancesResponse>

Included the instanceset into stopinstance response elements
and updated the test cases for stopinstance response elements
in nova/tests/api/ec2/test_cloud.py file.

Closes-bug: #1321239

Change-Id: I4d8a6faf2689a7df71920183682fd1e403ce2a42
Send compute.instance.create.end after launched_at is set

Downstream consumers of notifications want to know when an instance was
launched from the compute.instance.create.end notification.  This value
was previously set in the notification but commit
70196c4854e6cc1cb566dc9fc5b1a3397a4b69ab changed things so that it was
no longer set.  It will now be set, and is tested to be set.

Change-Id: If5ac00529d52e3898cda7fd942535ed3ba2039d5
Closes-bug: 1338736
VMware: remove local variable

Make use of the instance.root_gb instead of reading the value
into a local variable.

TrivialFix

Change-Id: I2ae4a9d2f5383ff05f47d00550c1c917fedc5db9
Handle NotImplementedError in server_diagnostics v3 api

In libvirt driver, it doesn't implement the function of
get_instance_diagnostics().it returns http 500 error No.
we expect http 501 if the function is not implemented.

Change-Id: I59bfaa27b96284bd56917096e0c3fab0d277ba96
Closes-Bug: 1349680
Parse unicode cpu_info as json before using it

If the extra specs are some of this:
- (capabilities:cpu_info:vendor, Intel)
- (capabilities:cpu_info:topology:cores, 2)
- (capabilities:cpu_info:features, <in> rdtscp)

It doesn't work because the cpu_info is loaded as unicode in HostState.
The patch fix these cases by parsing the cpu_info to dict.
Update: use six.string_types instead of unicode.

Change-Id: Ieabf95b1e3e5893ced16c0571c29b13b252df5d1
Closes-Bug: #1331176
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
Fix ownership checking in get_networks_by_uuid

The code was elevating context before requesting networks which
means that the project_only code is skipped and all networks
could be retrieved. This means that the default networks returned
by FlatDhcpManager could include networks that belong to other
projects.

This fixes the issue by requesting the network without elevating
the context, re-enabling the proper project checking. It includes
tests to verify that the proper exception is raised when an
illegal network is requested and that the context has not been
elevated by the compute manager.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Icd3bc521003725cc3da9875dfd6532d5c5524f43
Closes-Bug: 1331092
Only get image location attributes if including locations

Commit 155eeabbfafd4f48b47fea5b403f61a6e5c28426 added 'direct_url' and
'locations' to the list of attributes to get from an image which makes a
call back to glance if the attributes aren't on the image, and can
result in a 404 if they aren't available, which would be in the glance
v1 API case.

This change simply passes the new include_locations parameter down to
_extract_attributes so we can do the proper filtering.

Change-Id: I903fa5c781fed52183b340dc3d9bc4b6598b21ce
Partial-Bug: #1351333
Merge "Parse unicode cpu_info as json before using it"
Merge "Fix ownership checking in get_networks_by_uuid"
Merge "VMware: remove local variable"
Merge "Send compute.instance.create.end after launched_at is set"
Merge "Add instanceset info to StopInstance response"
Merge "Only get image location attributes if including locations"
Merge "Handle NotImplementedError in server_diagnostics v3 api"