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
Big Switch: Check for 'id' in port before lookup

Check for the presence of the 'id' key before trying
to do a lookup based on the value. This is necessary
because a 'fields' param to get_port(s) may exclude
the 'id' field before the host_id lookup.

Closes-Bug: #1358668
Change-Id: If30567d5deaeabd2de6c6287fac7a81695a41cc5
Remove binding:profile update from Mellanox ML2 MD

Remove temporary work-around that populates physical_network in
binding:profile. Now when both neutron and nova use binding:vif_details
to pass attributes to plug neutron port, this work-around is not nequired.
Remove related temporary code from ML2 plugin.

Change-Id: Ib37203af396f31080b1b27b500a571c20917f5a4
Closes-Bug: 1360762
Subnets with prefix length 0 are invalid

This patch changes the API behaviour to return a 400 error
when a subnet with /0 prefix length is specified.

This kind of subnet hardly make any sense, and also cannot
possibly work when DHCP is enabled.

Change-Id: I8f822f14b91475dcf86ea44ee607013e61cbb6f7
Closes-Bug: #1362651
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
Clarify message when no probes are cleared

Log number of probes which were deleted by
using neutron-debug probe-clear
Closes-Bug: #1333103

Change-Id: I5b53f0c4651c6df491d414d7d65f98c4a84a5987
Remove absolute path in KillFilter for metadata-proxy

This commit fix the problem of killing neutron-ns-metadata-proxy
when running in Virtual Environment.

Change-Id: I987dd87e19c218846a48e58b61679b4153d97f66
Closes-bug: #1363773
Big Switch: Retry on 503 errors from backend

Retries requests to the backend controller up to 3
additional times with 3 seconds in between each request
if a 503 service unavailable message was returned.
The scenarios that return 503 messages from floodlight
are normally short lived locks for things like OpenStack
synchronization or upgrade blocks. Retrying should work
in the majority of cases.

Closes-Bug: #1357105
Change-Id: Ifacd3a384cfc797ba6d6af5f3c8649c333473259
Avoid auto-scheduling for distributed routers

The reason for this is twofold:

- It may relieve contention on DB access while
  both servers and l3 agents are busy setting up
  and syncing routers down respectively.

- It prevents accidental placement of namespaces
  during the L3 sync_routers process, as auto
  scheduling without taking into account the state
  of the L3 agents, as well as the state of the
  routers being processed, may overrule the placement
  decision made during router operations.

Partial-bug: #1356121
Partial-bug: #1359326

Change-Id: Ia677ce212145d6cee65adeb1d8ae594e6ac5e34d
ofagent: Remove @author tags and update copyright notices

When writing these modules, ofagent team (kakuma, yamamoto) thought
that @author tag was OpenStack's style to represent authorships.
But it turned out to be wrong.  Acutally there seems to be a consensus
not to use them.  So, replace them back to the original Ryu-style
copyright notices.

Change-Id: Icc9fdd1850c0c1dbd354bb3312199a7f6849925a
shared policy shouldn't have unshared rules

A shared firewall policy should always have shared rules. So the following
cases should not be allowed:
1.Create shared policy with unshared rules
2.Update policy shared=True when it has unshared rules
3.Update policy with shared=True and unshared rules
4.Update shared policy with unshared rules

Change-Id: I3d71899c328d3fefa96c1f99d6ba706160e445cc
Closes-bug: 1334981
Fix AttributeError when setting external gateway on DVR router

DVR routers will have this manager initialized only after one
or more subnets have been attached to the router. To address
the issue, make sure the manager is defined and handle the snat
rules appropriately.

This patch also makes _update_arp_entry more defensive; this is
because the arp update process can be affected by the same issue:
the router may not have internal ports at the time the request
come in. This is likely when VM's port creation and router
configuration overlap slightly.

Closes-bug: #1353006

Change-Id: Ib46852f5b264e5ef2e2d499d3351f8974e393011
Co-authored-by: Rajeev Grover <rajeev.grover@hp.com>
Fix metadata agent's auth info caching

metadata agent does not implement auth info cache correctly but
retrieves from keystone every time

Change-Id: Ifc1f580185d7600b48aaf80d112fc80e0c4253f2
Closes-bug: #1365352
Add requests_mock to test-requirements.txt

Already in global-requirements. Will use for VPN unit tests
(bug 116018).

Change-Id: I140caebd3bc4f4cbf9563698bf0143f68456c762
Closes-Bug: 1358472
Add unit-test assert to check dict is superset of dict

Several VPN unit tests need the ability to check that an expected
dict is found in the actual dict output (and that other elements are
ignored - like auth tokens).

Since this will be of use to other components, adding this to the
base test case.

Note: There is a similar assertDictContainsSubset(), however, it is
not supported in 2.6 and has been deprecated in 3.2. A different, and
hopefully clearer, name is used for this method.

Change-Id: I8becf9cfad966874f8463a9c835331f2f17d2ead
Closes-Bug: 1366797
Neutron should not use the neutronclient utils module for import_class

Fixes code to use openstack.common.importutils instead.

Change-Id: Ia449f8b1d7d03f37483cfdc595ad77e71ea6598c
Closes-bug: 1366917
Add the unit tests for ml2.rpc module

Increase coverage of unit tests until 100% for ml2.rpc module.

Closes-bug: #1269136

Change-Id: I87c40e6462018df6a4dc70c6a1285de55f827877
NSX: Correct allowed_address_pair return value on create_port

This patch fixes the NSX plugin to return [] rather than None for a
port does not have any allowed_address_pairs when a create_port api
call is made. Currently the NSX plugin is failing every patch because
now tempest is checking for this value to be [].

Change-Id: Ic82c564ff62000c367c544f44a76694be9375790
Closes-bug: 1366921
Call unbind_snat_servicenode from schedule router

Refactor to move the call to plugin.unbind_snat_servicenode from
schedule_snat_router to _schedule_router.  This is a move to pave the
way for removing hints from schedule router.

Partial-bug: #1353266
Partial-bug: #1356639
Co-Authored-By: Swaminathan Vasudevan <swaminathan.vasudevan@hp.com>

Change-Id: I062d8cc3cb870bbaa033d5b107a7dd868dfafa19
Remove hints from schedule_router

Partial-bug: #1353266
Partial-bug: #1356639
Co-Authored-By: Swaminathan Vasudevan <swaminathan.vasudevan@hp.com>

Change-Id: Ie6b55e5d0d70be74b19c91994e52eb1719e32fef