##// END OF EJS Templates
add default ip<x>z_config files
MinRK -
Show More
@@ -12,7 +12,7 b' c = get_config()'
12 # - Start using mpiexec.
12 # - Start using mpiexec.
13 # - Start using the Windows HPC Server 2008 scheduler
13 # - Start using the Windows HPC Server 2008 scheduler
14 # - Start using PBS
14 # - Start using PBS
15 # - Start using SSH (currently broken)
15 # - Start using SSH
16
16
17
17
18 # The selected launchers can be configured below.
18 # The selected launchers can be configured below.
@@ -22,14 +22,14 b' c = get_config()'
22 # - MPIExecControllerLauncher
22 # - MPIExecControllerLauncher
23 # - PBSControllerLauncher
23 # - PBSControllerLauncher
24 # - WindowsHPCControllerLauncher
24 # - WindowsHPCControllerLauncher
25 # c.Global.controller_launcher = 'IPython.kernel.launcher.LocalControllerLauncher'
25 # c.Global.controller_launcher = 'IPython.zmq.parallel.launcher.LocalControllerLauncher'
26
26
27 # Options are:
27 # Options are:
28 # - LocalEngineSetLauncher
28 # - LocalEngineSetLauncher
29 # - MPIExecEngineSetLauncher
29 # - MPIExecEngineSetLauncher
30 # - PBSEngineSetLauncher
30 # - PBSEngineSetLauncher
31 # - WindowsHPCEngineSetLauncher
31 # - WindowsHPCEngineSetLauncher
32 # c.Global.engine_launcher = 'IPython.kernel.launcher.LocalEngineSetLauncher'
32 # c.Global.engine_launcher = 'IPython.zmq.parallel.launcher.LocalEngineSetLauncher'
33
33
34 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
35 # Global configuration
35 # Global configuration
@@ -25,112 +25,112 b' c = get_config()'
25 # be imported in the controller for pickling to work.
25 # be imported in the controller for pickling to work.
26 # c.Global.import_statements = ['import math']
26 # c.Global.import_statements = ['import math']
27
27
28 # Reuse the controller's FURL files. If False, FURL files are regenerated
28 # Reuse the controller's JSON files. If False, JSON files are regenerated
29 # each time the controller is run. If True, they will be reused, *but*, you
29 # each time the controller is run. If True, they will be reused, *but*, you
30 # also must set the network ports by hand. If set, this will override the
30 # also must set the network ports by hand. If set, this will override the
31 # values set for the client and engine connections below.
31 # values set for the client and engine connections below.
32 # c.Global.reuse_furls = True
32 # c.Global.reuse_files = True
33
33
34 # Enable SSL encryption on all connections to the controller. If set, this
34 # Enable exec_key authentication on all messages. Default is True
35 # will override the values set for the client and engine connections below.
36 # c.Global.secure = True
35 # c.Global.secure = True
37
36
38 # The working directory for the process. The application will use os.chdir
37 # The working directory for the process. The application will use os.chdir
39 # to change to this directory before starting.
38 # to change to this directory before starting.
40 # c.Global.work_dir = os.getcwd()
39 # c.Global.work_dir = os.getcwd()
41
40
42 #-----------------------------------------------------------------------------
41 # The log url for logging to an `iploggerz` application. This will override
43 # Configure the client services
42 # log-to-file.
44 #-----------------------------------------------------------------------------
43 # c.Global.log_url = 'tcp://127.0.0.1:20202'
45
44
46 # Basic client service config attributes
45 # The specific external IP that is used to disambiguate multi-interface URLs.
46 # The default behavior is to guess from external IPs gleaned from `socket`.
47 # c.Global.location = '192.168.1.123'
47
48
48 # The network interface the controller will listen on for client connections.
49 # The ssh server remote clients should use to connect to this controller.
49 # This should be an IP address or hostname of the controller's host. The empty
50 # It must be a machine that can see the interface specified in client_ip.
50 # string means listen on all interfaces.
51 # The default for client_ip is localhost, in which case the sshserver must
51 # c.FCClientServiceFactory.ip = ''
52 # be an external IP of the controller machine.
53 # c.Global.sshserver = 'controller.example.com'
54
55 # the url to use for registration. If set, this overrides engine-ip,
56 # engine-transport client-ip,client-transport, and regport.
57 # c.RegistrationFactory.url = 'tcp://*:12345'
52
58
53 # The TCP/IP port the controller will listen on for client connections. If 0
59 # the port to use for registration. Clients and Engines both use this
54 # a random port will be used. If the controller's host has a firewall running
60 # port for registration.
55 # it must allow incoming traffic on this port.
61 # c.RegistrationFactory.regport = 10101
56 # c.FCClientServiceFactory.port = 0
57
62
58 # The client learns how to connect to the controller by looking at the
63 #-----------------------------------------------------------------------------
59 # location field embedded in the FURL. If this field is empty, all network
64 # Configure the Task Scheduler
60 # interfaces that the controller is listening on will be listed. To have the
65 #-----------------------------------------------------------------------------
61 # client connect on a particular interface, list it here.
62 # c.FCClientServiceFactory.location = ''
63
66
64 # Use SSL encryption for the client connection.
67 # The routing scheme. 'pure' will use the pure-ZMQ scheduler. Any other
65 # c.FCClientServiceFactory.secure = True
68 # value will use a Python scheduler with various routing schemes.
69 # python schemes are: lru, weighted, random, twobin. Default is 'weighted'.
70 # Note that the pure ZMQ scheduler does not support many features, such as
71 # dying engines, dependencies, or engine-subset load-balancing.
72 # c.ControllerFactory.scheme = 'pure'
66
73
67 # Reuse the client FURL each time the controller is started. If set, you must
74 # The pure ZMQ scheduler can limit the number of outstanding tasks per engine
68 # also pick a specific network port above (FCClientServiceFactory.port).
75 # by using the ZMQ HWM option. This allows engines with long-running tasks
69 # c.FCClientServiceFactory.reuse_furls = False
76 # to not steal too many tasks from other engines. The default is 0, which
77 # means agressively distribute messages, never waiting for them to finish.
78 # c.ControllerFactory.hwm = 1
79
80 # Whether to use Threads or Processes to start the Schedulers. Threads will
81 # use less resources, but potentially reduce throughput. Default is to
82 # use processes. Note that the a Python scheduler will always be in a Process.
83 # c.ControllerFactory.usethreads
70
84
71 #-----------------------------------------------------------------------------
85 #-----------------------------------------------------------------------------
72 # Configure the engine services
86 # Configure the Hub
73 #-----------------------------------------------------------------------------
87 #-----------------------------------------------------------------------------
74
88
75 # Basic config attributes for the engine services.
89 # Which class to use for the db backend. Currently supported are DictDB (the
90 # default), and MongoDB. Uncomment this line to enable MongoDB, which will
91 # slow-down the Hub's responsiveness, but also reduce its memory footprint.
92 # c.HubFactory.db_class = 'IPython.zmq.parallel.mongodb.MongoDB'
76
93
77 # The network interface the controller will listen on for engine connections.
94 # The heartbeat ping frequency. This is the frequency (in ms) at which the
78 # This should be an IP address or hostname of the controller's host. The empty
95 # Hub pings engines for heartbeats. This determines how quickly the Hub
79 # string means listen on all interfaces.
96 # will react to engines coming and going. A lower number means faster response
80 # c.FCEngineServiceFactory.ip = ''
97 # time, but more network activity. The default is 100ms
98 # c.HubFactory.ping = 100
81
99
82 # The TCP/IP port the controller will listen on for engine connections. If 0
100 # HubFactory queue port pairs, to set by name: mux, iopub, control, task. Set
83 # a random port will be used. If the controller's host has a firewall running
101 # each as a tuple of length 2 of ints. The default is to find random
84 # it must allow incoming traffic on this port.
102 # available ports
85 # c.FCEngineServiceFactory.port = 0
103 # c.HubFactory.mux = (10102,10112)
86
104
87 # The engine learns how to connect to the controller by looking at the
105 #-----------------------------------------------------------------------------
88 # location field embedded in the FURL. If this field is empty, all network
106 # Configure the client connections
89 # interfaces that the controller is listening on will be listed. To have the
107 #-----------------------------------------------------------------------------
90 # client connect on a particular interface, list it here.
91 # c.FCEngineServiceFactory.location = ''
92
108
93 # Use SSL encryption for the engine connection.
109 # Basic client connection config attributes
94 # c.FCEngineServiceFactory.secure = True
110
111 # The network interface the controller will listen on for client connections.
112 # This should be an IP address or interface on the controller. An asterisk
113 # means listen on all interfaces. The transport can be any transport
114 # supported by zeromq (tcp,epgm,pgm,ib,ipc):
115 # c.HubFactory.client_ip = '*'
116 # c.HubFactory.client_transport = 'tcp'
95
117
96 # Reuse the client FURL each time the controller is started. If set, you must
118 # individual client ports to configure by name: query_port, notifier_port
97 # also pick a specific network port above (FCClientServiceFactory.port).
119 # c.HubFactory.query_port = 12345
98 # c.FCEngineServiceFactory.reuse_furls = False
99
120
100 #-----------------------------------------------------------------------------
121 #-----------------------------------------------------------------------------
101 # Developer level configuration attributes
122 # Configure the engine connections
102 #-----------------------------------------------------------------------------
123 #-----------------------------------------------------------------------------
103
124
104 # You shouldn't have to modify anything in this section. These attributes
125 # Basic config attributes for the engine connections.
105 # are more for developers who want to change the behavior of the controller
126
106 # at a fundamental level.
127 # The network interface the controller will listen on for engine connections.
107
128 # This should be an IP address or interface on the controller. An asterisk
108 # c.FCClientServiceFactory.cert_file = u'ipcontroller-client.pem'
129 # means listen on all interfaces. The transport can be any transport
109
130 # supported by zeromq (tcp,epgm,pgm,ib,ipc):
110 # default_client_interfaces = Config()
131 # c.HubFactory.engine_ip = '*'
111 # default_client_interfaces.Task.interface_chain = [
132 # c.HubFactory.engine_transport = 'tcp'
112 # 'IPython.kernel.task.ITaskController',
133
113 # 'IPython.kernel.taskfc.IFCTaskController'
134 # set the engine heartbeat ports to use:
114 # ]
135 # c.HubFactory.hb = (10303,10313)
115 #
136
116 # default_client_interfaces.Task.furl_file = u'ipcontroller-tc.furl'
117 #
118 # default_client_interfaces.MultiEngine.interface_chain = [
119 # 'IPython.kernel.multiengine.IMultiEngine',
120 # 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine'
121 # ]
122 #
123 # default_client_interfaces.MultiEngine.furl_file = u'ipcontroller-mec.furl'
124 #
125 # c.FCEngineServiceFactory.interfaces = default_client_interfaces
126
127 # c.FCEngineServiceFactory.cert_file = u'ipcontroller-engine.pem'
128
129 # default_engine_interfaces = Config()
130 # default_engine_interfaces.Default.interface_chain = [
131 # 'IPython.kernel.enginefc.IFCControllerBase'
132 # ]
133 #
134 # default_engine_interfaces.Default.furl_file = u'ipcontroller-engine.furl'
135 #
136 # c.FCEngineServiceFactory.interfaces = default_engine_interfaces
@@ -29,10 +29,10 b' c = get_config()'
29 # c.Global.connect_delay = 0.1
29 # c.Global.connect_delay = 0.1
30 # c.Global.connect_max_tries = 15
30 # c.Global.connect_max_tries = 15
31
31
32 # By default, the engine will look for the controller's FURL file in its own
32 # By default, the engine will look for the controller's JSON file in its own
33 # cluster directory. Sometimes, the FURL file will be elsewhere and this
33 # cluster directory. Sometimes, the JSON file will be elsewhere and this
34 # attribute can be set to the full path of the FURL file.
34 # attribute can be set to the full path of the JSON file.
35 # c.Global.furl_file = u''
35 # c.Global.url_file = u'/path/to/my/ipcontroller-engine.json'
36
36
37 # The working directory for the process. The application will use os.chdir
37 # The working directory for the process. The application will use os.chdir
38 # to change to this directory before starting.
38 # to change to this directory before starting.
@@ -78,12 +78,7 b' c = get_config()'
78
78
79 # You should not have to change these attributes.
79 # You should not have to change these attributes.
80
80
81 # c.Global.shell_class = 'IPython.kernel.core.interpreter.Interpreter'
81 # c.Global.url_file_name = u'ipcontroller-engine.furl'
82
83 # c.Global.furl_file_name = u'ipcontroller-engine.furl'
84
85
86
87
82
88
83
89
84
@@ -18,7 +18,7 b' import logging'
18 from multiprocessing import Process
18 from multiprocessing import Process
19
19
20 import zmq
20 import zmq
21
21 from zmq.devices import ProcessMonitoredQueue
22 # internal:
22 # internal:
23 from IPython.utils.importstring import import_item
23 from IPython.utils.importstring import import_item
24 from IPython.utils.traitlets import Int, Str, Instance, List, Bool
24 from IPython.utils.traitlets import Int, Str, Instance, List, Bool
@@ -38,6 +38,8 b' class ControllerFactory(HubFactory):'
38 """Configurable for setting up a Hub and Schedulers."""
38 """Configurable for setting up a Hub and Schedulers."""
39
39
40 usethreads = Bool(False, config=True)
40 usethreads = Bool(False, config=True)
41 # pure-zmq downstream HWM
42 hwm = Int(0, config=True)
41
43
42 # internal
44 # internal
43 children = List()
45 children = List()
@@ -52,22 +54,28 b' class ControllerFactory(HubFactory):'
52
54
53 def start(self):
55 def start(self):
54 super(ControllerFactory, self).start()
56 super(ControllerFactory, self).start()
57 child_procs = []
55 for child in self.children:
58 for child in self.children:
56 child.start()
59 child.start()
57 if not self.usethreads:
60 if isinstance(child, ProcessMonitoredQueue):
58 signal_children([ getattr(c, 'launcher', c) for c in self.children ])
61 child_procs.append(child.launcher)
62 elif isinstance(child, Process):
63 child_procs.append(child)
64 if child_procs:
65 signal_children(child_procs)
59
66
60
67
61 def construct_schedulers(self):
68 def construct_schedulers(self):
62 children = self.children
69 children = self.children
63 mq = import_item(self.mq_class)
70 mq = import_item(self.mq_class)
64
71
72 maybe_inproc = 'inproc://monitor' if self.usethreads else self.monitor_url
65 # IOPub relay (in a Process)
73 # IOPub relay (in a Process)
66 q = mq(zmq.PUB, zmq.SUB, zmq.PUB, 'N/A','iopub')
74 q = mq(zmq.PUB, zmq.SUB, zmq.PUB, 'N/A','iopub')
67 q.bind_in(self.client_info['iopub'])
75 q.bind_in(self.client_info['iopub'])
68 q.bind_out(self.engine_info['iopub'])
76 q.bind_out(self.engine_info['iopub'])
69 q.setsockopt_out(zmq.SUBSCRIBE, '')
77 q.setsockopt_out(zmq.SUBSCRIBE, '')
70 q.connect_mon(self.monitor_url)
78 q.connect_mon(maybe_inproc)
71 q.daemon=True
79 q.daemon=True
72 children.append(q)
80 children.append(q)
73
81
@@ -75,7 +83,7 b' class ControllerFactory(HubFactory):'
75 q = mq(zmq.XREP, zmq.XREP, zmq.PUB, 'in', 'out')
83 q = mq(zmq.XREP, zmq.XREP, zmq.PUB, 'in', 'out')
76 q.bind_in(self.client_info['mux'])
84 q.bind_in(self.client_info['mux'])
77 q.bind_out(self.engine_info['mux'])
85 q.bind_out(self.engine_info['mux'])
78 q.connect_mon(self.monitor_url)
86 q.connect_mon(maybe_inproc)
79 q.daemon=True
87 q.daemon=True
80 children.append(q)
88 children.append(q)
81
89
@@ -83,16 +91,17 b' class ControllerFactory(HubFactory):'
83 q = mq(zmq.XREP, zmq.XREP, zmq.PUB, 'incontrol', 'outcontrol')
91 q = mq(zmq.XREP, zmq.XREP, zmq.PUB, 'incontrol', 'outcontrol')
84 q.bind_in(self.client_info['control'])
92 q.bind_in(self.client_info['control'])
85 q.bind_out(self.engine_info['control'])
93 q.bind_out(self.engine_info['control'])
86 q.connect_mon(self.monitor_url)
94 q.connect_mon(maybe_inproc)
87 q.daemon=True
95 q.daemon=True
88 children.append(q)
96 children.append(q)
89 # Task Queue (in a Process)
97 # Task Queue (in a Process)
90 if self.scheme == 'pure':
98 if self.scheme == 'pure':
91 self.log.warn("task::using pure XREQ Task scheduler")
99 self.log.warn("task::using pure XREQ Task scheduler")
92 q = mq(zmq.XREP, zmq.XREQ, zmq.PUB, 'intask', 'outtask')
100 q = mq(zmq.XREP, zmq.XREQ, zmq.PUB, 'intask', 'outtask')
101 q.setsockopt_out(zmq.HWM, self.hwm)
93 q.bind_in(self.client_info['task'][1])
102 q.bind_in(self.client_info['task'][1])
94 q.bind_out(self.engine_info['task'])
103 q.bind_out(self.engine_info['task'])
95 q.connect_mon(self.monitor_url)
104 q.connect_mon(maybe_inproc)
96 q.daemon=True
105 q.daemon=True
97 children.append(q)
106 children.append(q)
98 elif self.scheme == 'none':
107 elif self.scheme == 'none':
@@ -26,7 +26,7 b' from zmq.eventloop.zmqstream import ZMQStream'
26
26
27 # internal:
27 # internal:
28 from IPython.config.configurable import Configurable
28 from IPython.config.configurable import Configurable
29 from IPython.utils.traitlets import HasTraits, Instance, Int, Str, Dict, Set, List, Bool
29 from IPython.utils.traitlets import HasTraits, Instance, Int, CStr, Str, Dict, Set, List, Bool
30 from IPython.utils.importstring import import_item
30 from IPython.utils.importstring import import_item
31
31
32 from entry_point import select_random_ports
32 from entry_point import select_random_ports
@@ -138,18 +138,18 b' class HubFactory(RegistrationFactory):'
138
138
139 ping = Int(1000, config=True) # ping frequency
139 ping = Int(1000, config=True) # ping frequency
140
140
141 engine_ip = Str('127.0.0.1', config=True)
141 engine_ip = CStr('127.0.0.1', config=True)
142 engine_transport = Str('tcp', config=True)
142 engine_transport = CStr('tcp', config=True)
143
143
144 client_ip = Str('127.0.0.1', config=True)
144 client_ip = CStr('127.0.0.1', config=True)
145 client_transport = Str('tcp', config=True)
145 client_transport = CStr('tcp', config=True)
146
146
147 monitor_ip = Str('127.0.0.1', config=True)
147 monitor_ip = CStr('127.0.0.1', config=True)
148 monitor_transport = Str('tcp', config=True)
148 monitor_transport = CStr('tcp', config=True)
149
149
150 monitor_url = Str('')
150 monitor_url = CStr('')
151
151
152 db_class = Str('IPython.zmq.parallel.dictdb.DictDB', config=True)
152 db_class = CStr('IPython.zmq.parallel.dictdb.DictDB', config=True)
153
153
154 # not configurable
154 # not configurable
155 db = Instance('IPython.zmq.parallel.dictdb.BaseDB')
155 db = Instance('IPython.zmq.parallel.dictdb.BaseDB')
@@ -234,6 +234,7 b' class HubFactory(RegistrationFactory):'
234 sub = ctx.socket(zmq.SUB)
234 sub = ctx.socket(zmq.SUB)
235 sub.setsockopt(zmq.SUBSCRIBE, "")
235 sub.setsockopt(zmq.SUBSCRIBE, "")
236 sub.bind(self.monitor_url)
236 sub.bind(self.monitor_url)
237 sub.bind('inproc://monitor')
237 sub = ZMQStream(sub, loop)
238 sub = ZMQStream(sub, loop)
238
239
239 # connect the db
240 # connect the db
@@ -38,7 +38,7 b' from IPython.zmq.parallel.clusterdir import ('
38 #-----------------------------------------------------------------------------
38 #-----------------------------------------------------------------------------
39
39
40
40
41 default_config_file_name = u'ipcluster_config.py'
41 default_config_file_name = u'ipclusterz_config.py'
42
42
43
43
44 _description = """\
44 _description = """\
@@ -49,7 +49,7 b' from util import disambiguate_ip_address, split_url'
49
49
50
50
51 #: The default config file name for this application
51 #: The default config file name for this application
52 default_config_file_name = u'ipcontroller_config.py'
52 default_config_file_name = u'ipcontrollerz_config.py'
53
53
54
54
55 _description = """Start the IPython controller for parallel computing.
55 _description = """Start the IPython controller for parallel computing.
@@ -58,7 +58,7 b' The IPython controller provides a gateway between the IPython engines and'
58 clients. The controller needs to be started before the engines and can be
58 clients. The controller needs to be started before the engines and can be
59 configured using command line options or using a cluster directory. Cluster
59 configured using command line options or using a cluster directory. Cluster
60 directories contain config, log and security files and are usually located in
60 directories contain config, log and security files and are usually located in
61 your .ipython directory and named as "cluster_<profile>". See the --profile
61 your ipython directory and named as "cluster_<profile>". See the --profile
62 and --cluster-dir options for details.
62 and --cluster-dir options for details.
63 """
63 """
64
64
@@ -189,6 +189,7 b' class IPControllerAppConfigLoader(ClusterDirConfigLoader):'
189 help='The (2) ports the IOPub scheduler will listen on for client,engine '
189 help='The (2) ports the IOPub scheduler will listen on for client,engine '
190 'connections, respectively [default: random]',
190 'connections, respectively [default: random]',
191 metavar='Scheduler.iopub_ports')
191 metavar='Scheduler.iopub_ports')
192
192 paa('--scheme',
193 paa('--scheme',
193 type=str, dest='HubFactory.scheme',
194 type=str, dest='HubFactory.scheme',
194 choices = ['pure', 'lru', 'plainrandom', 'weighted', 'twobin','leastload'],
195 choices = ['pure', 'lru', 'plainrandom', 'weighted', 'twobin','leastload'],
@@ -198,6 +199,12 b' class IPControllerAppConfigLoader(ClusterDirConfigLoader):'
198 dest='ControllerFactory.usethreads', action="store_true",
199 dest='ControllerFactory.usethreads', action="store_true",
199 help='Use threads instead of processes for the schedulers',
200 help='Use threads instead of processes for the schedulers',
200 )
201 )
202 paa('--hwm',
203 dest='ControllerFactory.hwm', type=int,
204 help='specify the High Water Mark (HWM) for the downstream '
205 'socket in the pure ZMQ scheduler. This is the maximum number '
206 'of allowed outstanding tasks on each engine.',
207 )
201
208
202 ## Global config
209 ## Global config
203 paa('--log-to-file',
210 paa('--log-to-file',
@@ -206,9 +213,9 b' class IPControllerAppConfigLoader(ClusterDirConfigLoader):'
206 paa('--log-url',
213 paa('--log-url',
207 type=str, dest='Global.log_url',
214 type=str, dest='Global.log_url',
208 help='Broadcast logs to an iploggerz process [default: disabled]')
215 help='Broadcast logs to an iploggerz process [default: disabled]')
209 paa('-r','--reuse-key',
216 paa('-r','--reuse-files',
210 action='store_true', dest='Global.reuse_key',
217 action='store_true', dest='Global.reuse_files',
211 help='Try to reuse existing execution keys.')
218 help='Try to reuse existing json connection files.')
212 paa('--no-secure',
219 paa('--no-secure',
213 action='store_false', dest='Global.secure',
220 action='store_false', dest='Global.secure',
214 help='Turn off execution keys (default).')
221 help='Turn off execution keys (default).')
@@ -255,7 +262,7 b' class IPControllerApp(ApplicationWithClusterDir):'
255 self.default_config.Global.import_statements = []
262 self.default_config.Global.import_statements = []
256 self.default_config.Global.clean_logs = True
263 self.default_config.Global.clean_logs = True
257 self.default_config.Global.secure = True
264 self.default_config.Global.secure = True
258 self.default_config.Global.reuse_key = False
265 self.default_config.Global.reuse_files = False
259 self.default_config.Global.exec_key = "exec_key.key"
266 self.default_config.Global.exec_key = "exec_key.key"
260 self.default_config.Global.sshserver = None
267 self.default_config.Global.sshserver = None
261 self.default_config.Global.location = None
268 self.default_config.Global.location = None
@@ -293,24 +300,53 b' class IPControllerApp(ApplicationWithClusterDir):'
293 with open(fname, 'w') as f:
300 with open(fname, 'w') as f:
294 f.write(json.dumps(cdict, indent=2))
301 f.write(json.dumps(cdict, indent=2))
295 os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR)
302 os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR)
303
304 def load_config_from_json(self):
305 """load config from existing json connector files."""
306 c = self.master_config
307 # load from engine config
308 with open(os.path.join(c.Global.security_dir, 'ipcontroller-engine.json')) as f:
309 cfg = json.loads(f.read())
310 key = c.SessionFactory.exec_key = cfg['exec_key']
311 xport,addr = cfg['url'].split('://')
312 c.HubFactory.engine_transport = xport
313 ip,ports = addr.split(':')
314 c.HubFactory.engine_ip = ip
315 c.HubFactory.regport = int(ports)
316 c.Global.location = cfg['location']
296
317
318 # load client config
319 with open(os.path.join(c.Global.security_dir, 'ipcontroller-client.json')) as f:
320 cfg = json.loads(f.read())
321 assert key == cfg['exec_key'], "exec_key mismatch between engine and client keys"
322 xport,addr = cfg['url'].split('://')
323 c.HubFactory.client_transport = xport
324 ip,ports = addr.split(':')
325 c.HubFactory.client_ip = ip
326 c.Global.sshserver = cfg['ssh']
327 assert int(ports) == c.HubFactory.regport, "regport mismatch"
328
297 def construct(self):
329 def construct(self):
298 # This is the working dir by now.
330 # This is the working dir by now.
299 sys.path.insert(0, '')
331 sys.path.insert(0, '')
300 c = self.master_config
332 c = self.master_config
301
333
302 self.import_statements()
334 self.import_statements()
303
335 reusing = c.Global.reuse_files
304 if c.Global.secure:
336 if reusing:
337 try:
338 self.load_config_from_json()
339 except (AssertionError,IOError):
340 reusing=False
341 # check again, because reusing may have failed:
342 if reusing:
343 pass
344 elif c.Global.secure:
305 keyfile = os.path.join(c.Global.security_dir, c.Global.exec_key)
345 keyfile = os.path.join(c.Global.security_dir, c.Global.exec_key)
306 if not c.Global.reuse_key or not os.path.exists(keyfile):
346 key = str(uuid.uuid4())
307 key = str(uuid.uuid4())
347 with open(keyfile, 'w') as f:
308 with open(keyfile, 'w') as f:
348 f.write(key)
309 f.write(key)
349 os.chmod(keyfile, stat.S_IRUSR|stat.S_IWUSR)
310 os.chmod(keyfile, stat.S_IRUSR|stat.S_IWUSR)
311 else:
312 with open(keyfile) as f:
313 key = f.read().strip()
314 c.SessionFactory.exec_key = key
350 c.SessionFactory.exec_key = key
315 else:
351 else:
316 c.SessionFactory.exec_key = ''
352 c.SessionFactory.exec_key = ''
@@ -324,16 +360,18 b' class IPControllerApp(ApplicationWithClusterDir):'
324 self.log.error("Couldn't construct the Controller", exc_info=True)
360 self.log.error("Couldn't construct the Controller", exc_info=True)
325 self.exit(1)
361 self.exit(1)
326
362
327 f = self.factory
363 if not reusing:
328 cdict = {'exec_key' : key,
364 # save to new json config files
329 'ssh' : c.Global.sshserver,
365 f = self.factory
330 'url' : "%s://%s:%s"%(f.client_transport, f.client_ip, f.regport),
366 cdict = {'exec_key' : key,
331 'location' : c.Global.location
367 'ssh' : c.Global.sshserver,
332 }
368 'url' : "%s://%s:%s"%(f.client_transport, f.client_ip, f.regport),
333 self.save_connection_dict('ipcontroller-client.json', cdict)
369 'location' : c.Global.location
334 edict = cdict
370 }
335 edict['url']="%s://%s:%s"%((f.client_transport, f.client_ip, f.regport))
371 self.save_connection_dict('ipcontroller-client.json', cdict)
336 self.save_connection_dict('ipcontroller-engine.json', edict)
372 edict = cdict
373 edict['url']="%s://%s:%s"%((f.client_transport, f.client_ip, f.regport))
374 self.save_connection_dict('ipcontroller-engine.json', edict)
337
375
338
376
339 def save_urls(self):
377 def save_urls(self):
@@ -40,7 +40,7 b' from util import disambiguate_url'
40 #-----------------------------------------------------------------------------
40 #-----------------------------------------------------------------------------
41
41
42 #: The default config file name for this application
42 #: The default config file name for this application
43 default_config_file_name = u'ipengine_config.py'
43 default_config_file_name = u'ipenginez_config.py'
44
44
45
45
46 mpi4py_init = """from mpi4py import MPI as mpi
46 mpi4py_init = """from mpi4py import MPI as mpi
@@ -64,7 +64,7 b' IPython engines run in parallel and perform computations on behalf of a client'
64 and controller. A controller needs to be started before the engines. The
64 and controller. A controller needs to be started before the engines. The
65 engine can be configured using command line options or using a cluster
65 engine can be configured using command line options or using a cluster
66 directory. Cluster directories contain config, log and security files and are
66 directory. Cluster directories contain config, log and security files and are
67 usually located in your .ipython directory and named as "cluster_<profile>".
67 usually located in your ipython directory and named as "cluster_<profile>".
68 See the --profile and --cluster-dir options for details.
68 See the --profile and --cluster-dir options for details.
69 """
69 """
70
70
@@ -79,7 +79,7 b' class IPEngineAppConfigLoader(ClusterDirConfigLoader):'
79 super(IPEngineAppConfigLoader, self)._add_arguments()
79 super(IPEngineAppConfigLoader, self)._add_arguments()
80 paa = self.parser.add_argument
80 paa = self.parser.add_argument
81 # Controller config
81 # Controller config
82 paa('--file',
82 paa('--file', '-f',
83 type=unicode, dest='Global.url_file',
83 type=unicode, dest='Global.url_file',
84 help='The full location of the file containing the connection information fo '
84 help='The full location of the file containing the connection information fo '
85 'controller. If this is not given, the file must be in the '
85 'controller. If this is not given, the file must be in the '
@@ -39,7 +39,7 b' IPython controllers and engines (and your own processes) can broadcast log messa'
39 by registering a `zmq.log.handlers.PUBHandler` with the `logging` module. The
39 by registering a `zmq.log.handlers.PUBHandler` with the `logging` module. The
40 logger can be configured using command line options or using a cluster
40 logger can be configured using command line options or using a cluster
41 directory. Cluster directories contain config, log and security files and are
41 directory. Cluster directories contain config, log and security files and are
42 usually located in your .ipython directory and named as "cluster_<profile>".
42 usually located in your ipython directory and named as "cluster_<profile>".
43 See the --profile and --cluster-dir options for details.
43 See the --profile and --cluster-dir options for details.
44 """
44 """
45
45
General Comments 0
You need to be logged in to leave comments. Login now