Loadbalancer class

Change-Id: Id787834fcfa6d723bf843a5cbcc41d057973935b
Generate the haproxy configuration

Change-Id: I02053792b7e133edf9a7fe667d92dcdba154089d
Fix couple of concurrency issues in TCP library

TcpServer::AcceptHandlerInternal inserts the new session into the
SesesionMap, releases the mutex and checks if the session has been
closed. If so, it subsequently calls DeleteSession on the session.
This can result in a duplicate delete if the application deletes
the session (by calling DeleteSession or ClearSessions) after the
mutex is released and also returns false from AcceptSession.

Fix is to not insert the session into SessionMap if AcceptSession
returns false.  Just need to make sure that we close the session.
Also ensure that we close the session if we are unable to make it
non-blocking.

TcpServer::ConnectHandler inserts the session into the SesesionMap,
releases the mutex and checks if the session has been closed.  If
so, it erases it from the SessionMap using the iterator returned
by the insert operation.  The iterator may not be valid anymore if
the application deletes the session (by calling DeleteSession or
ClearSessions) after the mutex is released.

Fix is to not use the iterator and instead erase from the SessionMap
by finding the session again.

Change-Id: I6c1754e75e46e29b37fd64fd89a12ffd572fa97e
Make bgp_server_test more robust

Terminate the BgpSessionManager when BgpServer is destroyed instead
of calling ClearSessions directly from ~BgpSessionManager. Doing so
takes care of a deadlock wherein ClearSessions could get called when
a session is being destroyed from a call to DeleteSession.

Make sure that BgpSessionManager does not accept any sessions after
it has called ClearSessions.  Otherwise those sessions get added to
the SessionSet and prevent BgpSessionManager from getting deleted.

Do not delete a BgpPeer till the state machine WorkQueue has been
drained completely.  This prevents an EvTcpDleteSession event from
getting deleted without being processed, hence preventing a leak of
the BgpSession.  The session would otherwise get deleted only when
the BgpSessionManager itself is terminated.

Fix an issue in state machine wherein a BgpOpen received on a stale
session caused a FSM error. A BgpOpen should cause a FSM error only
if it's received on the session currently being used by Established
peer.

Add a few more tests to bgp_server_test. Cleanup to consistently use
counts >= 3 in all tests that wait for specific counters to go up.

Sprinkle const in order make WorkQueue::IsQueueEmpty a const method.

Change-Id: Id1761667d68fe293ab0ddc099db1f508f8504769
Use staticmethod call to convert the function

Change-Id: I3931eb5c4926fcf4f4098b6b30007fbac15b798d
EventManager must NOT be static. During termination, SandeshSession, SandeshClient, SandeshClientSM and its Timers are deleted as part of EventManager destruction. The Timer and TcpSession Client APIs rely on sets of intrusive ptrs, which are also static. We will crash if these sets are deleted before the SandeshSession or Timer objects. This is happening for SandeshClientSM timers during analytics systemless test, and was making the test fail.
Change-Id: If15544364371d9efb8cdca064f17b725ef55af36
Add a service vm test

Change-Id: I3b352ee78d8ea17ef8d08db957a3e8ae725c5c91
Need to allow for python requests package 2.x

Change-Id: Ia1779670f51bfd0b3ca0ce8de9235dd41e6115a3
Make bgp_peer_membership_test nore robust

Change-Id: If54e06d850341704c814ad52281375bac9c02857
Check subnet CIDR is only IP version 4

Change-Id: Iad1edef2c1e3ff734f7fad0a01e2edffd763d72e
Bug 1352511: allow duplicate instance-ip object for ports owned by routers

Change-Id: I4eab7aebd8da425d7a2a64068f0b7d61d835d829
(cherry picked from commit a27149e43be4de2643dda4a2d24d21012288230a)
Implement more orderly termination of XmppServer

Do not accept incoming sessions if the XmppServer is deleted.  This
stops the WorkQueue from building up after delete is triggered.

Move the call to TcpServer::Shutdown back to DeleteActor::Shutdown as
we no longer accept incoming sessions if the XmppServer is deleted.
The latter is a more watertight fix than calling TcpServer::Shutdown
immediately.

Use a mutex to prevent a race condition where the main thread triggers
deletion of the XmppServer and an IO thread accepts a new session and
creates a new XmppServerConnection as a dependent of the now deleted
XmppServer.

Add Terminate method to clear any leaked TcpSessions and shutdown the
WorkQueue.  This is mostly paranoia because the WorkQueue is expected
to have been drained before LifetimeManager destroys the XmppServer's
DeleteActor.

Change-Id: I3acb3889f15c616ad85a2716a147552c43a55ecd
Stabilize bgp_xmpp_test

Use StateMachineTest and XmppStateMachineTest instead of the
base classes so that sessions can come up in timely manner.

Clean up includes and add a bit more tracing to the output.

Change-Id: I64f4fcefa481b46da15ccf9318fb00a655c053b5
raise AddressPairMatchesPortFixedIPAndMac

Change-Id: Ie916d658c3eb4888e3c09a4ecfc5b91ccf6364ed
Set the port owner to project it belongs

Change-Id: I0a2b892fb754afc4f44d2ca946633f0bc17fa2ec
Add database and logger classes to service monitor
This is initial effort of reorganization of service monitor code

Change-Id: I80191f1e7ad83fad35eb23bb986f0aaf8ad0afa1
Merge "Check subnet CIDR is only IP version 4"
Merge "Add database and logger classes to service monitor This is initial effort of reorganization of service monitor code"
Port list takes too much times to return

When a classic user list ports without any filters, the command takes
too much time to return.

Change-Id: I81498ddc044174e6d6f93bb21df3285f48df6df4
Merge "raise AddressPairMatchesPortFixedIPAndMac"