Aaron Rosen 300486546b Allow nvp_api to load balance requests
The current version of the nvp_api client does not load balance
requests across multiple controllers. Instead, it just sends all the requests
to one controller and if there is a controller failure it will failover
to use another controller. This blueprint implements the ablility to
utilize all controllers at once.

blueprint nvp-api-client-loadbalance-request

Change-Id: I331be2a23ae360a95786152d5f116359f690d9f3
2013-01-08 00:39:32 -05:00

34 lines
1.0 KiB
Python

# Copyright 2012 Nicira, Inc.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# @author: Aaron Rosen, Nicira Networks, Inc.
import httplib
def _conn_str(conn):
if isinstance(conn, httplib.HTTPSConnection):
proto = "https://"
elif isinstance(conn, httplib.HTTPConnection):
proto = "http://"
else:
raise TypeError(_('_conn_str() invalid connection type: %s') %
type(conn))
return "%s%s:%s" % (proto, conn.host, conn.port)