Use a temp dir for CONF.state_path

external_pids will defaults to $state_path(/var/lib/neutron)/external/pids
which isn't accessible when running unit tests so use a tempdir for
CONF.state_path. This bug arose when oslo.config 1.3.0 came out which
fixed bug #1282250 (I4324bda6f3de3cdf05f8eb3cf16052c04018dec8) and
caused this issue.

Change-Id: I253c5ea85c51eff94399da0b9462d10a9c509a0f
Closes-Bug: #1301027
Replace HTTPSConnection in NEC plugin

Replace HTTPSConnection in NEC plugin PFC driver with Requests.

SSL Verification is from now on enabled by default.

This changes the default behaviour and is the primary intention of this
change: verify SSL certificates.

This might break existing configuration/setups where the SSL certificate
used by the NEC PFC driver would not pass the verification.

SecurityImpact
DocImpact
Partial-Bug: 1188189

Change-Id: I1e5fdc9c2ed5b812aa6509d1639bd499acc5c337
(cherry picked from commit 264b4a2523c165640f17aa4837f87ddfd0b49640)
Changed the message line of RouterInUse class

Implements: Changed the message line of RouterInUse class,
so user will not get confused with active or inactive ports
while deleting the router.

Closes-Bug: #1236372
Change-Id: I7a82550e2c6051f9e4940a8f1dd4401059e0a8d8
(cherry picked from commit 238689570145fdafe8e61967bb56133f167d39ab)
Only send notifications on uuid device_id's

Neutron assumes that all ports with the device_owner that start with
'compute:' are ports created by nova compute. Thus, when the debug agent
creates a port with device_owner = compute:probe the nova notifier
feature tells nova when this port is wired even though nova does not know
about it (doesn't really matter we just log an error). This patch adds a check
to make sure the device_id is a uuid as nova only uses uuids and the debug
agent uses the hostname for device_id.

Change-Id: I04e7195a1fb30bc37e1c0141315c053174f8722c
Closes-bug: #1288582
(cherry picked from commit 6b4fecb9de0aa80e66b31555001dca95d14c789f)
Log configuration values for OFA agent

When other agents start up, they log the configuration values
to their logs. This patch adds the same feature to the
Openflow agent.

fixes bug 1289139

Change-Id: Ibab20154805a12ec265a2499cbfd6c376c376130
(cherry picked from commit 7d1e49a08a170ecf4e2546b25c67d4a8d41fd34a)
Cisco VPN driver correct reporting for admin state chg

Depends on reference implementation change (81124 review) that will pass VPN
service admin up/down changes to the service driver (for subsequent passing
to the device driver).

This change will save the runtime state of the IPSec connections that have
been removed due to a VPN service down change, so that this can be reported
to the plugin properly. Otherwise, without the change, there is no info
on the downed connection and no change report so the plugin thinks the
connection is still active.

In addition, the status for the VPN service will reflect whether there are
any IPSec connections ACTIVE. If one or more are acive, the service will
be active, otherwise it will be DOWN.

Updated UT to add tests for admin state and status reporting. Also changed
some IPSec create UTs because they were not cleaning up correctly upon test
failures (only seen with a live CSR).

In the future, when the Cisco CSR REST API supports admin up/down support,
the IPSec connections will not be deleted, but instead will be shut down, in
response to an admin down event (and then brought up, for admin up). During
the down time, the state will be reported correctly and no run-time state
recording needed.

Change-Id: I294bfb400c31ef36dfe5d9e85b34845e5aef8515
Closes-Bug: 1291619
(cherry picked from commit c1ccc585bda70925a4cffe617743ef6472fe60c4)
fixes broken neutron-netns-cleanup

Some configuration parameters used in neutron.agent.linux.utils
were missing. The namespace attribute in the FakeNetwork object
was missing, and used in neutron.agent.linux.dhcp. Also, the
plugin object was missing for release_dhcp_port operation.

We provide a fake plugin object to accept current and any future
plugin calls as this is meant to be an standalone tool that
should work without any RPC connectivity.

FakeNetwork was switched for neutron.agent.linux.dhcp.NetModel
to follow any future changes in NetModel.

Two wrong called_once_with_args calls without assert were fixed.

Change-Id: Ia51ea9bd4c8eea6b250858964ad5286c933702e0
Closes-Bug: #1291915
Partial-Bug: #1297875
(cherry picked from commit 907bf41afbdb9f565c45a535f637c8928d0be52a)
Add unit test for add_vxlan in test_linux_ip_lib

This patch adds unit tests for the add_vxlan function in the test_linux_ip_lib.py
file.

Fixes bug: 1291974

Change-Id: I0238bedab7a3566aff1115a091ada494a01d2e02
(cherry picked from commit dd52ddb1e9322b3985ceba2db842e8201220f67f)
NSX plugin: return 400 for invalid gw certificate

Gateway certificates are validated by the NSX backend.
The code currently treats a failure in certification
validation as a backend failure and therefore returns
a 500 status code.

This patch changes this behaviour by returning a 400
status code and an appropriate error description.
To this aim a handler for 400 errors has been added to
the NSX API client.

Closes-Bug: #1293508

Change-Id: I196f14337e47cd40710a6d8a30bbe1cac5ffe05b
(cherry picked from commit 13c9f3b813f5bb368e311ba0d428fa759d68289a)
Redundant SG rule create calls in unit tests

This patch removes the redundant calls in the test cases.

Closes-Bug: #1302091
Change-Id: I509843b427dc454c0e6b2fd2cbff1bbbb284337f
(cherry picked from commit c49ec8b3ba10bb414a0f135d29ff3685e26d58b3)
Fix test MAC addresses to be valid

MAC addresses should have 6 octets - 'ff:ff:ff:ff:ff:ff'.

Change-Id: I9c2457d978ccce15549d3258961093a130375bff
Closes-bug: #1302282
(cherry picked from commit 5f042a64308cb00698b454da09b4a87f2ac3fafd)
Don't emit log for missing attribute check policy

A missing policy for validating whether an attribute should
be visible or not is a perfectly normal condition, and
there is no value in logging it.

Writing this information to the log is also having a
considerable performance impact on list operations.

Change-Id: Ie9d3ae6b249a5c49f6d81c1e56915174d8479a07
Closes-Bug: 1302467
(cherry picked from commit ef01fb553a141c012c8d8600edd6b709c5807111)
Return 409 for second firewall creation

Second firewall creation returns 500, but it is an expected behavior
of firewall reference implementation and an internal server error
should not be returned.

Change-Id: I9f537b238007d35172e2504591d9d3568ba3a41a
Closes-Bug: #1301105
(cherry picked from commit 9df867c672bfb3f80511086c889b744113c56604)
Fixing Arista CLI command

A minor change is made to the Arista API between ML2 Driver and the
back-end. This fix addresses this change to align Icehouse release with
Arista EOS releases.

Change-Id: Ia7cd3701c76d920a7e0d1334290c73ce7e8e5576
Closes-Bug: 1301093
(cherry picked from commit f3e9b6d6dc53d2e85c9085a1e3ec11b51f803948)
Fix function parsing the kernel version

Change-Id: Id56efb476144a18cd9eb7279bc0f602760a86173
Closes-Bug: #1300808
(cherry picked from commit d4fdac7ae596888b8e83d9559019eafb728cd3fe)
Stop using portbindings_db in BSN ML2 driver

Avoids using the portbindings_db in the Big Switch
ML2 driver since ML2 has deprecated that database for
its own version that tracks the same information.

Also eliminates unnecessary 'binding_host' field since
it is now always the same as as the 'portbinding:host_id'
field.

Closes-Bug: #1300628
Change-Id: I17d47cb446cdd2e989c3e0d01b797a81309faaa7
(cherry picked from commit c70c2719d700902854ef0381cb725722ac2da05e)
Update BigSwitch Name to its correct name

Update Neutron documentation and code comments to replace
"BigSwitch" name to "Big Switch"

Closes-Bug: #1299145
Change-Id: I7c14f6170871b361c8929898ee6af5d1a1f41714
(cherry picked from commit 408ef55d4ef1a9d246571511203ab337ba5346c6)
Add missing DB migrations for BSN ML2 plugin

Adds missing database migrations for the Big Switch
ML2 driver and plugin.

Closes-Bug: #1298459
Change-Id: I6a46a53e069353501d85c4c8400f98514d6f0162
(cherry picked from commit d3be7b040eaa61a4d0ac617026cf5c9132d3831e)
fixes tests using called_once_ without assert

A few tests were using mock's called_once, or called_once_with_args
instead of assert_called_once or assert_called_once_with_args. Those
methods return a bool that needs to be actively checked.

The tests are fixed to avoid them from passing if the call condition
is not met.

Change-Id: I21e5257b26b2a08cc8f0b108233d1d5cc0b97b89
Closes-bug: #1297875
(cherry picked from commit c6c4a20777921dc1b21e80edb96ccd957a054c68)
NSX: Fix pagination support

Add pagination support to the base plugin,
leaving the service plugin unaltered.

Minor tweaks to the UT where required to
avoid intermittent failures caused by random
ordering.

Closes-bug: 1295854

Change-Id: I03e9e104967716046909d6120426e879f714a5c8
(cherry picked from commit 16ce0ae2c2b50b4317cdb95e62246d805b3d76a9)