Use the full string for localisation

Concatenating localized strings is bound to be confusing.
Give the full string so that translations can be tuned accordingly.

Change-Id: I84a5fa2939c02add5468c4ab4b6f2c4ea1a5f8f0
Abstract add_timestamp out of ComputeDriverCPUMonitor class

Move add_timestamp decorator into ResourceMonitorBase class,
then other monitor metrics can reuse it.

Change-Id: I060353b9e194b1882549fec07fc2a486aeb1fce0
replace type() to isinstance() in nova

In nova/utils.py, a func use the "type" method to
determine the type. It's bertter to use the "isinstance"
method instead.this bug is fixed in glance:
https://review.openstack.org/#/c/65611/4

Change-Id: I10d25d2308436239c50cf3932c212e22c45f92a8
Closes-Bug: #1267300
XenAPI: Use direct IO for writing config drive

If you don't use direct IO when writing to the device, the unplug
immediately following this may not succeed as the device may still
be in use.

Also add a sync to ensure the device is not being used at the point
of unplug.

Closes-bug: 1259163

Change-Id: I68f09835648b36772a7839af9718123a4c60734f
Fix potential fd leak

Always close the test socket.

Change-Id: Ic87b713a7791cf39ed5146754e1345fc662c894e
Capture exception for JSON load in virt.storage_users

If CONF.instances_path/compute_nodes is empty when the storage_users
tries to register the storage use (virt.storage_users.register_storage_use)
the exception is uncaught and raised. As a consequence, the image cache
manager won't run.

Closes-Bug: #1252659

Change-Id: If9ed5e75b0bc0b8f3a7c5fd7ec88f6399e4e59c6
API schema for v3 console_output API

By defining the API schema, it is possible to separate the validation
code from the API method. The API method can be more simple.
In addition, a response of API validation error can be consistent for
the whole Nova API.

Partially implements blueprint nova-api-validation-fw

Change-Id: Id6330e2250448c54679df4f27af25c2614a871f0
Alphabetize core list for V3 API plugins

Alphabetize list and one line per plugin for future managability.
Deferred from a review comment on a previous changeset:

https://review.openstack.org/#/c/53104/3/nova/api/openstack/__init__.py

Partially implements blueprint nova-v3-api

Change-Id: Iedfae644b97369cc9694df7a10444311418fffd0
Fix init of pci_stats in resource tracker

Because pci_stats is list of dict, i.e., [{}, {}, ...],
if pci_stats is null, its field should be '[]' not '{}'.

When making object models, we found this bug in PCI stuffs.

Related to blueprint pci-extra-info.

Change-Id: I06564cb541b050060e87fd3d334299df66f23dec
Error message is malformed when removing a sec group from an instance

In the current code the Error message string for a security group which is not
associated with an instance does not get expanded correctly, resulting in users
getting a message:

ERROR: [u'Security group %(security_group_name)s not assocaited with the
instance %(instance)s', {u'instance': u'71069945-5bea-4d53-b6ab-9026bfeebba4',
u'security_group_name': u'phil'}]

In addition fix a minor typo in this message, and clean up a few cases where
error messages are not being passed through _() for i18n.

Change-Id: I85856a135a62bc3415a355e0900ea12ea55f73ae
Closes-Bug: #1273266
Ignore 'dynamic' addr flag on bridge configuration

When setting the bridge up, if that flag is present but not
ignored, the delete command will fail and may leave the
interface and the bridge in an inconsistent state.

Closes-Bug: #1274611
Related-Bug: #1077066
Change-Id: Iff65d61d724d0de5d8173ac37f7f748aa23e5d8b
Destroy docker container if spawn fails to set up network

If docker driver failed to set up network when spawn an instance,
then the docker driver should also destroy the container to make
sure no garbage container left for such case.

Change-Id: I4496182d9f6a9bfd86b0a32edb19dcd975467e91
Closes-Bug: #1242815
Make nova-network use FixedIP object for associations

This makes nova-network manager use the FixedIP.associate*
calls instead of going direct to the database.

Related to blueprint nova-network-objects

Change-Id: I60f287f10bee45980e3671d73102a582c805436f
Fix a bug in v3 API doc

This patch changes the wrong variable names 'addFixedIp' and 'networkId',
which were not used in V3 multinic API. We use 'add_fixed_ip' and
'network_id' in V3 multinic API.

Closes-bug: #1265716

Change-Id: I0c91764603d941df6d011a3b1266eb354c0bc54f
VMware: Remove some unused variables

Remove unused variables from the following files:

* nova/tests/virt/vmwareapi/test_driver_api.py
* nova/virt/vmwareapi/driver.py
* nova/virt/vmwareapi/volumeops.py

There is no design to the above selection of files: this is simply as
I have encountered them.

Change-Id: I43ee2f71edf5872bfe1b1fe010e83435689501bb
Fix scheduler_hints parameter of v3 API

"create a server" API contains a scheduler_hints parameter which is
a hint where a server should boot.
According to scheduler-hints-post-req.json API sample, the parameter
name is "os-scheduler-hints:scheduler_hints":
  {
    "server" : {
      "name" : "new-server-test",
      "image_ref" : "..",
      "flavor_ref" : "..",
      "os-scheduler-hints:scheduler_hints": {
        "hypervisor": "xen",
        "near": "48e6a9f6-30af-47e0-bc04-acaed113bb4e"
      }
    }
  }

However create() of SchedulerHintsController tries to get its value
from invalid position where is the same level as "server":
  {
    "server" : {
      [..]
    },
    "os-scheduler-hints:scheduler_hints": {
      "hypervisor": "xen",
      "near": "48e6a9f6-30af-47e0-bc04-acaed113bb4e"
    }
  }

As the result, Nova cannot get the value from the right parameter.
To fix the problem, this patch merges both the parameter parser and
the validation code to server_create() like the other API extensions.
SchedulerHintsController becomes unnecessary, then this patch removes
the class.

Partially implements bp v3-api-inconsistencies

Change-Id: I4e0bcbde8e2d2171d0b2e18b72d2c2b3d88d7239
Fixed naming issue of variable in a debug statement formatting

Closes-bug: 1275802

Change-Id: I5bf57290ff3023f6d3332a92114cc4f235e1f4af
Hyper-V: Change variable in debug log message

The variable used in the log message is incorrect. The log message
outputs the file size instead of the internal VHD size.

Closes-bug #1275805

Change-Id: I270709098e058cf51bbe6494b903a461b3938d15
Add serializer capability to fake_notifier.

With the change to oslo.messaging.notify.Notifier, we have
introduced the serializer plugin.  In some implementations
this is used to modify the notfications/serialize data.  The
implementations will want to test their serializers and
the easiest way to do this is via the fake_notifier.
This change allows fake_notifier to act more like
notifier with serializer being a pass in as an argument.

The serializer is passed to subnotifiers created via
the prepare method.

Change-Id: I03ef9ed92366961d4e296381d149c54d7da97f70
Fix bittorrent URL configuration option

This change modifies bittorrent to give URL setting preference to the
configuration option first and then to entry point addins.  The thought
process is that users will want the ability to change the URL
via configuration.  The entry point is code and slower to address.

If the user really wants to use the entry point, they can leave
the configuration option empty.

Existing test cases updated to reflect new priority.

Change-Id: I5af94b4b50531fc7801e70d83b89dd7ed2bcf310