-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.py
80 lines (57 loc) · 2.18 KB
/
environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
environment settings for CacheManager client
"""
import socket
import filesystem
__version__ = "$Rev: 822 $"
__author__ = "[email protected] (David Rybach)"
__copyright__ = "Copyright 2012, RWTH Aachen University"
class GenericClientEnvironment:
"""environment specific settings.
selects server, cache directory, and remote file system implementation
depending on the environment of the client (e.g. the hostname)
to be customized in derived classes
"""
def server(self, config):
"""return the hostname of the master"""
return config.MASTER_HOST
def cacheDir(self, config):
"""return the local cache directory"""
return config.CACHE_DIR
def remoteFileSystem(self, config):
"""return a RemoteFileSystem object to use.
use filesytem.SshRemoteFileSystem if hard disks on other nodes
are accessible by SSH connection
use filesystem.NfsRemoteFileSystem if hard disks on other nodes
are accessible by a network file system (e.g. NFS) and mounted
on the compute nodes
"""
return filesystem.SshRemoteFileSystem(config)
class ClientEnvironmentI6 (GenericClientEnvironment):
"""configuration used at i6
two environments are defined: "i6" and "cluster".
selection is based on the hostname of the client
SSH connections are used for both environments
this class can used as an example for multi-environment setups
"""
isCluster = None
def __init__(self):
if ClientEnvironmentI6.isCluster is None:
# check hostname only once
ClientEnvironmentI6.isCluster = ClientEnvironmentI6._isCluster()
def server(self, config):
if ClientEnvironmentI6.isCluster:
s = config.MASTER_HOST_CLUSTER
else:
s = config.MASTER_HOST_I6
return s
def cacheDir(self, config):
if ClientEnvironmentI6.isCluster:
cache = config.CACHE_DIR_CLUSTER
else:
cache = config.CACHE_DIR_I6
return cache
@staticmethod
def _isCluster():
hostname = socket.gethostname()
return (hostname[0:10] == "cluster-cn" or hostname[:3] == "cn-")