]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Control active number of REST calls from Cisco N1kv plugin to VSM
authorAbhishek Raut <abhraut@cisco.com>
Sat, 14 Jun 2014 15:14:24 +0000 (08:14 -0700)
committerAbhishek Raut <abhraut@cisco.com>
Fri, 20 Jun 2014 03:35:35 +0000 (20:35 -0700)
Add a config parameter to Cisco N1kv plugin to determine the total
number of active REST calls that can be made to the VSM.

Change-Id: I66433ef5673d35badcd3adc2defa43e578d4094f
Closes-Bug: #1329099

etc/neutron/plugins/cisco/cisco_plugins.ini
neutron/plugins/cisco/common/config.py
neutron/plugins/cisco/n1kv/n1kv_client.py

index e065e73a41bfd737d5ad692493a71a0795cb416f..5249bb8cd4d9cdb1ec13be3aeefa3026fcb63bc5 100644 (file)
 #
 # poll_duration =
 # Example: poll_duration = 180
+
+# (IntOpt) Number of threads to use to make HTTP requests to the VSM.
+#
+# http_pool_size = 4
index a4a1196a8d8e9459c9c5935ebff44ef21bb2980b..c3f25093e04b3a67c38093beb1312a3a4643ce8a 100644 (file)
@@ -80,6 +80,8 @@ cisco_n1k_opts = [
                help=_("N1K policy profile for network node")),
     cfg.StrOpt('poll_duration', default='10',
                help=_("N1K Policy profile polling duration in seconds")),
+    cfg.IntOpt('http_pool_size', default=4,
+               help=_("Number of threads to use to make HTTP requests")),
 ]
 
 cfg.CONF.register_opts(cisco_opts, "CISCO")
index 7389eadfb31a867b1f162562aca9b4a51d4427ff..541750835a9c8954bcbaad8d717f5cb7d7617774 100644 (file)
@@ -18,6 +18,7 @@
 # @author: Rudrajit Tapadar, Cisco Systems, Inc.
 
 import base64
+import eventlet
 import netaddr
 import requests
 
@@ -28,6 +29,7 @@ from neutron.openstack.common import log as logging
 from neutron.plugins.cisco.common import cisco_constants as c_const
 from neutron.plugins.cisco.common import cisco_credentials_v2 as c_cred
 from neutron.plugins.cisco.common import cisco_exceptions as c_exc
+from neutron.plugins.cisco.common import config as c_conf
 from neutron.plugins.cisco.db import network_db_v2
 from neutron.plugins.cisco.extensions import n1kv
 
@@ -122,6 +124,8 @@ class Client(object):
     encap_profiles_path = "/encapsulation-profile"
     encap_profile_path = "/encapsulation-profile/%s"
 
+    pool = eventlet.GreenPool(c_conf.CISCO_N1K.http_pool_size)
+
     def __init__(self, **kwargs):
         """Initialize a new client for the plugin."""
         self.format = 'json'
@@ -433,11 +437,12 @@ class Client(object):
             body = jsonutils.dumps(body, indent=2)
             LOG.debug(_("req: %s"), body)
         try:
-            resp = requests.request(method,
-                                    url=action,
-                                    data=body,
-                                    headers=headers,
-                                    timeout=self.timeout)
+            resp = self.pool.spawn(requests.request,
+                                   method,
+                                   url=action,
+                                   data=body,
+                                   headers=headers,
+                                   timeout=self.timeout).wait()
         except Exception as e:
             raise c_exc.VSMConnectionFailed(reason=e)
         LOG.debug(_("status_code %s"), resp.status_code)