Optimize query in _select_dhcp_ips_for_network_ids

Only query the DB for relevant columns instead of
all of the port columns.

 Conflicts:
        neutron/db/securitygroups_rpc_base.py

Partial-Bug: #1373851
(cherry picked from commit 8d430a7f2e903dda06d8d75d6abcd63423c4c0a1)

Change-Id: I32cd4a0bc6799ce77cea13188676308e3e641d19
BSN: Set inconsistency record on delete failure

Set a bad value in the consistency DB on a delete
failure so a sync is triggered the next time the backend
servers become available.

This fixes the issue where the backend servers are unavailable
when an object is deleted from ML2 but not deleted from the
backend.

Conflicts:
	neutron/tests/unit/bigswitch/test_servermanager.py

Closes-Bug: #1377350
Change-Id: I24713a03af4d3499645241f900de1f572689c235
(cherry picked from commit e9f001a63a555f067c4567a88613d14853442524)
Merge "Optimize query in _select_dhcp_ips_for_network_ids" into stable/icehouse
Merge "BSN: Set inconsistency record on delete failure" into stable/icehouse
Fix hostname validation for nameservers

Fixes the hostname validation to align with the RFC's demands[1].
This was done by replacing the full regex with a function that
broke the FQDN into individual components that were easier to
reason about with regular expressions.

Also added several test cases for domains so if someone wants
to convert it back to pure regex there will be better test vectors.

1. RFC 1123 says an all-digit hostname is allowed in section 2.1. It
   says that this more liberal syntax MUST be supported.

Conflicts:
	neutron/tests/unit/test_attributes.py

Closes-Bug: #1396932
Change-Id: I003cf14d95070707e43e40d55da62e11a28dfa4e
(cherry picked from commit 35662d07628452d14306f5197871ad64f6396ff3)
Fix enable_metadata_network flag

The following patch: 9569b2fe broke the desired functionality of
the enable_metadata_network flag, by not allowing the metadata
proxy to be spawn for 'metadata networks', which are used for
accessing the metadata service when the logical router is not
implemented through the l3 agent.

This patch enables spawning of the metadata proxy for metadata
networks when the appropriate flag is set to True.

The patch also adds rather pedant unit test coverage for the
should_enable_metadata method which previously had no unit test.

Closes-bug: 1394020
(cherry picked from commit c45842af38da322b93d1200451a4a254abfcaed1)

Conflicts:
	neutron/agent/dhcp_agent.py
	neutron/tests/unit/test_linux_dhcp.py

Change-Id: I8dca1fce9fbc83e75ba7e4ce948531427bf7e88b
Notifier: Catch NotFound error from nova

If neutron sends a single event to nova and the server_uuid isn't found
in nova. The python-novaclient will raise a 404 error. This patch ensures
we explicitly catch that exception and use LOG.warning instead of LOG.exception
as this is not an error and can happen when deleting an instance if neutron
detects that the port_status goes down before the port is deleted because
nova first unplugs the vif and then deletes it from neutron.

Closes-bug: #1309187
(cherry picked from commit c049583e80d9b2234557a11b77d843549f1efa65)

Conflicts:
	neutron/notifiers/nova.py

Change-Id: I7e72da61ccf4c1a3ccc48feb0fdf3d165cdda388