sync periodic_task fix from incubator

Set the value of time the periodic task was last run to a multiple of the
spacing value rather than the actual last time run. This ensures tasks runs
regularly but avoids synchronizing that interval with other nodes.

This patch also removes the coalescing of tasks which are _nearby_ (0.2
seconds away).

4dbd3aa Make periodic tasks run on regular spacing interval
21249f1 Fix parenthesis typo misunderstanding in periodic_task

Change-Id: I8873545578f104fd204fbc25493350128b2bc8d4
Clear entries in Cisco N1KV specific tables on rollback

During rollback operations, resources are cleaned up from neutron
database but leaves a few stale entries in the n1kv specific tables.
This change addresses the proper clean up of tables. i.e. VLAN/VXLAN
allocation tables, profile binding and vm network table.

Change-Id: I7a09d34f3a9dee0a43b76c5d781ee9eb9938953a
Closes-bug: #1336596
Missing max_routes in neutron.conf

We have the define of "max_routes" in neutron/db/extraroute_db.py
but we do not have them in neutron.conf.

Change-Id: I4a9586023b7d09a64296b44f4d9285f30be1fd63
Closes-Bug: #1341378
Cisco: Fix test cases which make incorrect create requests

Some test cases in the test_n1kv_plugin module are sending more than
one dictionary while creating the network profile resources. This
patch corrects these erroneous test cases while preserving the test
cases intended behavior.

Change-Id: I99de0b708218cf5217ecf47c74a30f75d0733e25
Closes-bug: #1347963
Use method's logger in log decorator

Previously decorators shared logger. This patch makes LOG object in
closure for every decorated method in order to use correct logging
level.

Closes-Bug: #1340778
Change-Id: If907acbab34f8bf23e1277e66c3ddd839f668764
update vsm credential correctly

Today if we modify the n1kv VSM credential in the cisco_plugins.ini, the
older VSM ip address remains in the db, and all requests are sent to
the older VSM. This patch deletes all n1kv VSM credentials on neutron
start up before adding the newer VSM credentials. Hence making sure
that there is only one n1kv VSM IP address and credential in the db.

Change-Id: I772a86bf896a1d3d9c69c545ce6918b0fe3a2e48
Closes-Bug: #1341014
Log methods using rpc communcation

In Icehouse was used rpc library from oslo-incubator. Because the code
wasn't mature enough it was running in DEBUG mode. After migrating to
oslo.messaging we don't need to have debug level in oslo.messaging but
it's good to have communication logged.

Closes-Bug: #1340696
Change-Id: I4f68545053912f96affc1bbcd64fcd7efe8d18c0
VMWare: don't notify on disassociate_floatingips()

L3 agent notifications don't make sense for NSX VMWare plugin since
there is no L3 agent in such setup, so disabling them here.

Updated a unit test to check that notification is indeed not requested.

Change-Id: I9c7c32d02d466098d22df8f10448361c3d99174c
Related-Bug: 1330955
VPNaaS: Separate validation for Cisco impl

Moving validation logic from Cisco service driver, into a
validation subclass, so that it'll be applied during the
persistence phase (so validation failures can block the
persistence, instead of setting to error state).

This is part of the effort to separate out L3 validation
and builds upon the reference implementation changes being
reviewed in 102351.

Note: One unit test is commented out, due to a bug in
oslo.messaging 1.3.0. It will be uncommented later, once
1.4.0.0.a3 or newer is available for use.

Change-Id: I6040e6d8ab32b707bcf67a0882507b7ee2d4bebe
Partial-Implementation: blueprint l3-svcs-vendor-validation
Return a tuple of None's instead of one None

The expected return value of _commit_port_binding is something that
can be unpacked into two values. This changes the condition where a
concurrent delete was detected to return a 2-tuple of None's
instead of a bare None to prevent an iterable error.

Closes-Bug: #1342880
Change-Id: I9d3a51eab33819ffda6a65a00c3b5d1006a3577e
Fixed audit notifications for dhcp-agent-network

dhcp-agent-network-add and dhcp-agent-network-remove do not
generate audit notifications which are used for security
compliance.
CRUD operations of core network resources are handled by
neutron/api/v2/base.py. In base.py, each of create(), update(),
delete() methods makes calls to oslo.messaging.Notifier.info()
to generate these notifications.
In the proposed fix, it is fixed in a similar fashion in
extensions/dhcpagentscheduler.py inside create() and delete()
methods by introducing info() method calls inside them.

Change-Id: Ia23b981b2fbe739d22ebaa7bb0975fb9e39f881b
Closes-Bug: 1317008
ML2: Update a comment after the recent bind_port change

A missing comment update in
commit b1677dcb80ce8b83aadb2180efad3527a96bd3bc.

No functional changes.

Change-Id: Icf1bd66a8c093d0b40632e22be662a3c8ba5c48b
call security_groups_member_updated in port_update

When a running VM is added to a security group, all existing VMs (ports)
in the security group should be notified/updated - otherwise they would
have incorrect rules, not knowing the new VM/port added.

The current behavior would only update the port of the added VM. This
patch forces an security_groups_member_updated() call for all the
security groups that have ports removed or added.

Change-Id: Ibdcd74f47043762386b62f3ec0fa1723060446ac
Closes-Bug: 1316618
Set nullable=False on tenant_id in apic_contracts table

The cisco_ml2_apic_contracts table has a tenant_id field that is not nullable
since it is the primary key. The HasTenant mixin does not allow setting
nullable=False, so use sa.Column() explicitly for this.

Change-Id: If8e96e76fad0bfcf2bfd71b0223624f1da4517c9
Closes-bug: #1342756
Add rule for updating network's router:external attribute

Set admin_only rule for update_network:router:external in policy.json

Also, change the default value of router:external from attr.ATTR_NOT_SPECIFIED
to False, because each time we try to get or update a network the dict with
its attributes is extended by _extend_network_dict_l3 function which adds
router:external=False to the dict if this attribute is not specified.
Thus, if the default value is not specified, router:external is considered
to be updated in any case and the policy rule is applied.

Change-Id: I899d98c7d8c9d9863ac5d8f992b6a2d507ec4482
Closes-Bug: 1338880
OFAgent: Share codes of l2-population in OVS agent

This is step 1 implementation of OFAgent l2-population.
OFAgent partially uses codes in OVS agent on implementation of l2-population.
We share these codes adding mixin class for OVS to l2-population rpc.
We use a ryu library instead of executing a ovs-vsctl command
and on OFAgent l2-population is no longer optional.
Also a function of local arp responder will be implemented on step 2.

related commit: b6133c35dd587f6b01e8ec12757347b2767713a6

Partially implements: blueprint ofagent-l2pop

Change-Id: I99a2adfd380a9fefe34c53e0dabc21d8cf5936cc
Modify L3 Agent for Distributed Routers

This patch is an enhancement to the existing L3 Agent.
This allows the L3 Agent to support distributed routers
by enhancing the router object to function across
multiple nodes.

Utilized two new types of namespaces:

- FIP to handle multiple VM fips and routers per node
- SNAT to handle centralized SNAT per router

Rules and tables are enhanced and added to support routing
across distributed routers without going to a centralized
router.

Finally, a new configuration param 'agent_mode' is introduced
and it controls what the L3 agent can do: the available values
are: 'legacy', 'dvr', 'dvr_snat' (more details inline).

The l3-scheduler uses the newly introduced agent_mode to
determine what L3 agent to select during the scheduling
process.

Partially-Implements: blueprint neutron-ovs-dvr

DocImpact

Change-Id: Icead821bb74372b15aac2e5cefe8ad7f08c037ab
Co-Authored-By: Rajeev Grover <rajeev.grover@hp.com>
ML2 mechanism driver for SR-IOV capable NIC based switching, Part 2

This set of changes introduces SRIOV NIC Agent to run with
ML2 mechanism driver for SR-IOV capable NIC based switching.
This is the second part of a 2 part commit.

The review is submitted in two parts:
- Part 1
    The Mechanism Driver to support port binding for SR-IOV virtual
	functions of SRIOV capable switching NICs.

- Part2 (this part)
    The SRIOV NIC Based L2 Agent.
	Use  configurable list of mappings physical_networks to PF
        interfaces and configurable list of mappings PF interfaces
        to list of excluded VFs to get list of Virtual Functions that agent should manage.
	Current implementation supports admin state updates.

Co-authored-by: Samer Deeb <samerd@mellanox.com>
Partially implements: blueprint ml2-sriov-nic-switch

Change-Id: I533ccee067935326d5837f90ba321a962e8dc2a6
Merge "Return a tuple of None's instead of one None"
Merge "Missing max_routes in neutron.conf"