Use call to report state when ovs_agent starts up

Make sure to report ovs_agent state when starting up, otherwise
ovs_agent start_time would not be updated and thus l2pop does
not send fdb entries.

Change-Id: Idd770a85a9eabff112d9613e75d8bb524020234a
Closes-Bug: #1347452
Add endpoint_type parameter to MetaInterfaceDriver

Previously MetaInterfaceDriver communicates with neutron-server
via 'publicURL' because it uses python-neutronclient without
endpoint_type and 'publicURL' is the default.
It causes error when a user intends to use internal or admin URL
for communication between MetaInterfaceDriver and neutron-server.

Change-Id: Id321d5a16a08a4bda618f98bb1eb7cb1b0b9eb08
Closes-bug: #1354285
Supply missing cisco_cfg_agent.ini file

cisco_cfg_agent.ini file was missed in the initial commit and
caused neutron startup issues. This patch supplies the proper
ini file and adds it back to neutron setup.cfg.
Also the introduced config options are put in a specific group
instead of default as was in the initial commit.

Change-Id: I74b3b77fe6e196524809580f522f91f3b62f5ba7
Closes-bug: #1351466
Added TAP_DEVICE_PREFIX info to common/constants

Change-Id: Ia84629732490585164237ca4f7d1db90bde9fbf2
Closes-Bug: 1361573
Check for ports in subnet before deleting it from Nuage VSD

There could exist a port in subnet in neutron in which case subnet delete
is not allowed. In the nuage's plugin code, this validation needs to
be handle prior to sending delete subnet request to backend.

Change-Id: Idd20d2f878a6274a012504108d01bd2237dc665a
Closes-bug: #1351522
Access correct key for template name

When an exception occurs while loading the config agent driver, the
handler tries to log a message, but accesses the wrong key to get the
template name. This causes another exception, which masks the original
exception.

This change accesses the correct key and performs logging inside a
with block to (defensively) preserve the exception context.

Change-Id: I3991bc4c509bbd8d68f7a1c8c8314404f2e0eafa
Closes-Bug: #1368900
NSX plugin: set VNIC_TYPE port binding attribute

A recent change has made this attribute required for nova
integration.
This patch adds this attribute to responses generated by the NSX
plugin, and also ensures relevant unit tests are executed for the
vmware NSX plugin.

Change-Id: Ieebab01b406909f66a40cc683763292a9ef6f218
Closes-Bug: #1370112
Separate Configuration from Freescale SDN ML2 mechanism Driver

- In the current implementation, CRD configuration is existing
  within the code of ML2 mechanism driver.

- When any other plugin/driver (like, Freescale FWaaS Plugin) need
  to use this configuration, it needs to duplicate the complete configuration.

- So the CRD configuration is moved to a separate file for use
  in other plugin/drivers.

- Unit testing of this MD is also updated.

Closes-Bug: #1368033

Change-Id: I488fee47803a494aae9df42f9c59fffa9843e727
Delete DB records instead of tables to speedup UT

Now that the schema is fixed for all of the plugins,
there isn't a need to delete and recreate the entire
schema for every unit test.

This patch clears the tables at the end of each test
instead of deleting them. This eliminated overhead seems
to save 10%+ execution time of the entire set of unit
tests.

Example of performance gain from tox -epy27 tests.unit.ml2:
Before: Ran 2495 tests in 284.186s
After: Ran 2495 tests in 223.299s

Change-Id: Ic5bcbb0cf941e0745890abc776d719e58bb42e35
Deletes FIP agent gw port when last VM is deleted

This patch deletes the FIP agent gateway port in
the plugin, when the last VM with FIP using this
FIP agent gw port on a Compute node gets deleted.

Closes-bug: #1367588

Change-Id: I71a9fa48544fa4bbd08ac6d83c99e6542c818009
Delete a broken subnet delete unit test

A test to delete a subnet in use was incorrectly
calling 'subnet' instead of 'subnets' in the API request
and asserting a 404 instead of a 409. Even the correct
version of this test is already covered by the
'test_port_prevents_subnet_deletion' method so this
commit just removes the broken test.

Change-Id: I3eac35abbb1d6f8429b4331948aecfc952284219
Set dsvm-functional job to use system packages

The functional job was breaking due to the interaction between
devstack installing neutron system-wide in editable mode (pip install
-e) and tox packaging in the same path.  Installing in editable
mode meant that neutron.egg-info/PKG_INFO could be updated (in this
case by tox) to change the installed version of the neutron package
without updating scripts that depended on the installed version
(e.g. rootwrap).  This fix is to set the dsvm-functional env to
use system packages and avoid having tox update PKG_INFO.

Change-Id: Icc38cacd69bc5843ccfcc60237a7102df6d8597f
Closes-bug: #1370347
Update URL of Ryu official site in ofagent README files

Change-Id: I1e9bdc3dffb8be705c0fcaf88bd914d27e10936d
Merge "Add endpoint_type parameter to MetaInterfaceDriver"
Merge "NSX plugin: set VNIC_TYPE port binding attribute"
Merge "Update URL of Ryu official site in ofagent README files"
Rework and enable VPNaaS UT for Cisco CSR REST

The Cisco CSR REST client library unit tests were developed in
Icehouse, using the httmock library. However, the community did
not want to add this library to global requirements, as there was
a similar httpretty library available (albeit with some short-
comings). As a result, the test module was renamed with a "no"
prefix, to prevent inclusion in automated tests.

Since then, a new library, requests-mock, has been added to global
requirements, to replace httpretty, and is being used on several
other projects.

This commit reworks the unit test to use requests-mock, instead of
httmock. The functionality is the same, but the mechanism (a
fixture with URI registration vs context manager) is different.

This commit provides coverage for the REST client code, by using a
mock for the Cisco CSR VM. The unit test module can be subclassed,
and used with a real CSR VM, for 3rd party CI testing, in the
future.

Change-Id: I55c8a253eb32985bc2016ae748b1ded58d021e1a
Closes-Bug: 1358470
HA routers master state now distributed amongst agents

We're currently running with no pre-emption, meaning that
the first router in a cluster to go up will be the master,
regardless of priority. Since the order in which we sent
notifications was constant, the same agent hosted the
master instances of all HA routers, defeating the idea
of load sharing.

Closes-Bug: #1365429
Change-Id: Ia6fe2bd0317c241bf7eb55915df7650dfdc68210
Only setup dhcp interface if dhcp is not active on network

When enabling (DhcpLocalProcess.enable()) dhcp for a network the agent
first sets dhcp interface, then checks if dhcp is curently active and
if it's true then the agent restarts dhcp.
Restart (DhcpBase.restart()) first disables dhcp and then enables it again
by calling DhcpLocalProcess.enable() recursively which in turn sets
dhcp interface again (it doesn't see the port created earlier as network
is not re-fetched from db). This leads to duplicate dhcp interface
for the network.

The fix is to only setup dhcp interface if dhcp is not active.

Closes-Bug: #1339968

Change-Id: I3a6d2fd5b18a97138ac5b699ecd4d4b30dbdbacb
Fix 500 error on retrieving metadata by invalid URI

An invalid URI should return a BadRequest error rather
than making the metadata proxy bomb out.

Closes-bug: #1371160

Change-Id: Ifb495f9e8929062a0c24d090c3e702109a38803a