Config drive: delete deprecated config var config_drive_tempdir

Commit 6e15d787fffcef8c4299fbaf1d5c715af1a34fa2 removed the use
of this configuration variable.

Change-Id: Ifd5baa8b7d579b0959cdb57b1335380a4129d652
Fixes Hyper-V driver WMI issue on 2008 R2

Trying to assign properties on default Hyper-V resource setting data
WMI objects results in an exceptions before Hyper-V 2012.
Cloning the objects before assigning them solves the issue.

A similar approach was previous already implemented and has been
incorrectly removed during a refactoring.

Co-Authored-By: Robert Tingirica <rtingirica@cloudbasesolutions.com>
Change-Id: If119154f8b4756be9f98c8acd376003c52eff44f
Closes-Bug: #1356884
Revert "Truncate encoded instance message to 255"

This reverts commit bd9c32289ff8cf1bc67c1395ad921c703aa4c489.

UTF-8 character bytes size varies from 1 to 6. If truncating a long
bytes string to 255, the last character may be cut in the middle,
so that UnicodeDecodeError will occur when converting it back to
unicode. Need to revert this code change and make a new patch.

Related-Bug: 1389102

Change-Id: Ie439cffe11d657e77397c9070a3923a61f68a678
Truncate encoded instance message to 255 or fewer

In nova/compute/utils.py function exception_to_dict truncates unicode
message to 255. However, in non-English locales, instance message may
be longer than 255 after encoding the unicode message to byte message.
Need to truncate the encoded byte message to 255 or fewer, in order to
ensure db insert operation succeed.

Change-Id: I62fa2830b22e367eb9486d09d3c8818a18ebd20d
Closes-Bug: 1389102
Extends use of ServiceProxy to more methods in HostAPI in cells

Cells prepend full cell path to the service ID before returning any
service related info. This means service ID is non numeric and can't
be cast into Service objects.  In cells, service_get_all method
in HostAPI (which is used to display list of services) strips out
the cell path from received IDs, creates Service objects using
remaining numerical ID and uses a ServiceProxy to associate cell paths
Service objects.
However, other service related methods do not do so. They include:
 - service_update (Used for enabling/disabling services)
 - service_get_all_by_host (Used for evacuation)
These functions try to cast received service info (with alphanumeric
service IDs) into Service objects and fail with a ValueError.
This leads to API cell throwing Error 500 for service-enable,
service-disable and evacuate.
This patch extends the ServiceProxy usage to both these methods. It
also changes the corresponding HostAPI tests.

Change-Id: Iff2707602d5fabfbe8438150b5ad74b3c31bb011
Closes-Bug: 1361180
Add decorator expected_errors for security_group extension

This patch add decorator expected_errors for all the APIs of
security_group that required by v2.1 API.

Partially implements blueprint v2-on-v3-api

Change-Id: I6ccf9f3b7d7137948d16481d82d00220a27d8541
Fix the cell API with string rpc_port failed

When cell create/update accept rpc_port as string, it will
return 500. This patch add code to covert the string as integer.

Change-Id: I8ace46731ac02f810b978c54843b6e137c9882be
Closes-Bug: #1389933
Limit tcp/udp port to be empty string in json-schema

tcp/udp port can be string and integer. Currently the json-schema accept
string, but it didn't limit the length of string, so there can be pass
emtpy string as tcp/udp port. This patch add string length limit to it.

Change-Id: I6c338a2417ae5f8817b24823b3d745dc1e0fbd58
Decrease admin context usage in _get_guest_config

commit 594b18a3 change the context for _get_guest_config
usage to either context given or admin context if it's not
specified. However, it has side effect on later functions
which use the context, so the scope of change the
context should be decreased and this patch fixed that bug.

Change-Id: I7bd96e2c3ee691bae51ac055f57650c14d4e10b4
Add debug log when over quota exception occurs

There are some weird logs showed in bug 1353962, with
current logs we can't decide which part is wrong.
Add more logs will help operater to know the real reason
that make the quota exceed.

If this change makes too much log out, after bug 1353962
is fixed, we can talk about remove those logs, but currently
it will be helpful.

Change-Id: I2ab1fb62efc06b1cee213920539980e331870bf5
Related-Bug: #1353962
Add CHAP credentials support

Currently, the Hyper-V driver ignores the according CHAP
credentials when logging in iSCSI targets. For this reason,
attaching volumes fails when CHAP authentication is enforced.

This patch adds one way CHAP authentication support.

Change-Id: Id4d8800ae08dc24a01fc146f65c68b0b41d49e3d
Fix exception handling in _get_host_metrics()

In resource_tracker.py, the exception path of _get_host_metrics()
misspells variable name 'monitor'. When exception occurs, this
misspelling prevents us to log warning message. This code change
corrects the misspelling.

Closes-Bug: 1394052

Change-Id: I8a99a4ceb53c89038e8b292a15ad9fd20daa4233
Fix connecting unnecessary iSCSI sessions issue

In Icehouse with "iscsi_use_multipath=true", attaching a multipath
iSCSI volume may create unnecessary iSCSI sessions.

The iscsiadm discovery command in connect_volume() returns all of the
targets in the Cinder node, not just the ones related to the multipath
volume which is specified by iqn.  If the storage has many targets,
connecting to all these volumes will also result in many unnecessary
connections.

There are two types of iSCSI multipath devices.  One which shares
the same iqn between multiple portals, and the other which use
different iqns on different portals. connect_volume() needs to
identify the type by checking iscsiadm the output if the iqn is
used by multiple portals.

This patch changes the behavior of attaching volume:

   1. Identify the type by checking the iscsiadm output.
   2. Connect to the correct targets by connect_to_iscsi_portal().

Closes-Bug: #1382440

Change-Id: I488ad0c09bf26a609e27d67b9ef60b65bb45e0ad
Sync server_external_events v2 to v2.1 Part 1

This syncs commit I18062b81e50c722ec96b4296ac39384493683ae3 which
was made to the v2 version of os-server-external-events but not
the v2.1 version.

Partially implements blueprint v2-on-v3-api

Change-Id: If0657744fac021f635ce292142c82239751ae2f2
Sync server_external_events v2 to v2.1 Part 2

This syncs commit 5e4a5f0d8c62ca6e94ae6db16e9fbe0428805158 which
was made to the v2 version of os-server-external-events but not
the v2.1 version.

Partially implements blueprint v2-on-v3-api

Change-Id: I458b28b1f3cf161b6d40ce3fd8b3a9c5d090bde7
Replacement `_` on `_LI` in all LOG.info - part 2

oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating. For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Change-Id: Iaebb239ef20a0da3df1e3552baf26f412d0fcdc0
Replacement `_` on `_LE` in all LOG.exception

oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating.  For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Added a hacking rule for the log exception about checking
translation for it.

Change-Id: If80ea6f177bb65afcdffce71550bb38fedcc54eb
Replacement `_` on `_LW` in all LOG.warning part 1

oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating. For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Added a hacking rule for the warning about checking
translation for it and checking logging level `warning` instead
alias `warn`.

Change-Id: I2bced49dc5a0408a94d5d20d85b20c682886edbe
Replacement `_` on `_LW` in all LOG.warning part 2

oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating. For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Change-Id: I5ab13610d3e10a68ae49f9fd7fac151aa66ea98d
Make notifications use Instance.get_flavor()

This makes the notifications.info_from_instance() method use the
Instance.get_flavor() method to retrieve flavor information, instead
of assuming that it is in system_metadata. This requires that it is
passed an Instance object, so this patch also converts the code to
make that assumption (which needs doing anyway) and fixes remaining
dict-using callers to pass the object. This will be required by a
subsequent patch to refactor flavor storage.

Related to blueprint flavor-from-sysmeta-to-blob

Change-Id: I6e4e07807cb6cd173d54137d4fe8d9b1a0d49709