Просмотр исходного кода

Add 'conductor_rpc_timeout' config option.

Nashwan Azhari 8 лет назад
Родитель
Сommit
2bb7f66b33
1 измененных файлов с 14 добавлено и 2 удалено
  1. 14 2
      coriolis/conductor/rpc/client.py

+ 14 - 2
coriolis/conductor/rpc/client.py

@@ -1,17 +1,29 @@
 # Copyright 2016 Cloudbase Solutions Srl
 # Copyright 2016 Cloudbase Solutions Srl
 # All Rights Reserved.
 # All Rights Reserved.
 
 
+from oslo_config import cfg
 import oslo_messaging as messaging
 import oslo_messaging as messaging
 
 
 from coriolis import rpc
 from coriolis import rpc
 
 
 VERSION = "1.0"
 VERSION = "1.0"
 
 
+conductor_opts = [
+    cfg.IntOpt("conductor_rpc_timeout",
+               help="Number of seconds until RPC calls to the "
+                    "conductor timeout.")
+]
+
+CONF = cfg.CONF
+CONF.register_opts(conductor_opts, 'conductor')
+
 
 
 class ConductorClient(object):
 class ConductorClient(object):
-    def __init__(self):
+    def __init__(self, timeout=None):
         target = messaging.Target(topic='coriolis_conductor', version=VERSION)
         target = messaging.Target(topic='coriolis_conductor', version=VERSION)
-        self._client = rpc.get_client(target)
+        if timeout is None:
+            timeout = CONF.conductor.conductor_rpc_timeout
+        self._client = rpc.get_client(target, timeout=timeout)
 
 
     def create_endpoint(self, ctxt, name, endpoint_type, description,
     def create_endpoint(self, ctxt, name, endpoint_type, description,
                         connection_info):
                         connection_info):