1 """
2 Module for storing static data structures
3 """
4 import os
5 import sys
6 import getpass
7 import tempfile
8
9
11 path = os.path.expanduser(path)
12 path = os.path.expandvars(path)
13 return path
14
15
17 if not os.path.exists(path):
18 try:
19 os.makedirs(path)
20 except OSError:
21 if exit_on_failure:
22 sys.stderr.write("!!! ERROR - %s *must* be a directory\n" %
23 path)
24 elif not os.path.isdir(path) and exit_on_failure:
25 sys.stderr.write("!!! ERROR - %s *must* be a directory\n" % path)
26 sys.exit(1)
27
28
33
34
35 VERSION = "0.93"
36 PID = os.getpid()
37 TMP_DIR = tempfile.gettempdir()
38 if os.path.exists("/tmp"):
39 TMP_DIR = "/tmp"
40 CURRENT_USER = 'unknown_user'
41 try:
42 CURRENT_USER = getpass.getuser()
43 except:
44 pass
45 SSH_TEMPLATE = 'ssh -i %s %s@%s'
46
47 STARCLUSTER_CFG_DIR = os.path.join(os.path.expanduser('~'), '.starcluster')
48 STARCLUSTER_CFG_FILE = os.path.join(STARCLUSTER_CFG_DIR, 'config')
49 STARCLUSTER_PLUGIN_DIR = os.path.join(STARCLUSTER_CFG_DIR, 'plugins')
50 STARCLUSTER_LOG_DIR = os.path.join(STARCLUSTER_CFG_DIR, 'logs')
51 STARCLUSTER_RECEIPT_DIR = "/var/run/starcluster"
52 STARCLUSTER_RECEIPT_FILE = os.path.join(STARCLUSTER_RECEIPT_DIR, "receipt.pkl")
53 STARCLUSTER_OWNER_ID = 342652561657
54
55 DEBUG_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'debug.log')
56 SSH_DEBUG_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'ssh-debug.log')
57 AWS_DEBUG_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'aws-debug.log')
58 CRASH_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'crash-report-%d.txt' % PID)
59
60
61 BASE_AMI_32 = "ami-899d49e0"
62 BASE_AMI_64 = "ami-999d49f0"
63 BASE_AMI_HVM = "ami-4583572c"
64
65 SECURITY_GROUP_PREFIX = "@sc"
66 SECURITY_GROUP_TEMPLATE = '-'.join([SECURITY_GROUP_PREFIX, "%s"])
67 MASTER_GROUP_NAME = "masters"
68 MASTER_GROUP = SECURITY_GROUP_TEMPLATE % MASTER_GROUP_NAME
69 MASTER_GROUP_DESCRIPTION = "StarCluster Master Nodes"
70 VOLUME_GROUP_NAME = "volumecreator"
71 VOLUME_GROUP = SECURITY_GROUP_TEMPLATE % VOLUME_GROUP_NAME
72
73 IGNORE_GROUPS = [MASTER_GROUP]
74
75 INSTANCE_STATES = ['pending', 'running', 'shutting-down',
76 'terminated', 'stopping', 'stopped']
77
78 VOLUME_STATUS = ['creating', 'available', 'in-use',
79 'deleting', 'deleted', 'error']
80 VOLUME_ATTACH_STATUS = ['attaching', 'attached', 'detaching', 'detached']
81
82 INSTANCE_TYPES = {
83 't1.micro': ['i386', 'x86_64'],
84 'm1.small': ['i386'],
85 'm1.large': ['x86_64'],
86 'm1.xlarge': ['x86_64'],
87 'c1.medium': ['i386'],
88 'c1.xlarge': ['x86_64'],
89 'm2.xlarge': ['x86_64'],
90 'm2.2xlarge': ['x86_64'],
91 'm2.4xlarge': ['x86_64'],
92 'cc1.4xlarge': ['x86_64'],
93 'cc2.8xlarge': ['x86_64'],
94 'cg1.4xlarge': ['x86_64'],
95 }
96
97 MICRO_INSTANCE_TYPES = ['t1.micro']
98
99 CLUSTER_COMPUTE_TYPES = ['cc1.4xlarge', 'cc2.8xlarge']
100
101 CLUSTER_GPU_TYPES = ['cg1.4xlarge']
102
103 CLUSTER_TYPES = CLUSTER_COMPUTE_TYPES + CLUSTER_GPU_TYPES
104
105 CLUSTER_REGIONS = ['us-east-1']
106
107 PROTOCOLS = ['tcp', 'udp', 'icmp']
108
109 WORLD_CIDRIP = '0.0.0.0/0'
110
111 DEFAULT_SSH_PORT = 22
112
113 AVAILABLE_SHELLS = {
114 "bash": True,
115 "zsh": True,
116 "csh": True,
117 "ksh": True,
118 "tcsh": True,
119 }
120
121 GLOBAL_SETTINGS = {
122
123 'default_template': (str, False, None, None, None),
124 'enable_experimental': (bool, False, False, None, None),
125 'refresh_interval': (int, False, 30, None, None),
126 'web_browser': (str, False, None, None, None),
127 'include': (list, False, [], None, None),
128 }
129
130 AWS_SETTINGS = {
131 'aws_access_key_id': (str, True, None, None, None),
132 'aws_secret_access_key': (str, True, None, None, None),
133 'aws_user_id': (str, False, None, None, None),
134 'ec2_cert': (str, False, None, None, None),
135 'ec2_private_key': (str, False, None, None, None),
136 'aws_port': (int, False, None, None, None),
137 'aws_ec2_path': (str, False, '/', None, None),
138 'aws_s3_path': (str, False, '/', None, None),
139 'aws_is_secure': (bool, False, True, None, None),
140 'aws_region_name': (str, False, None, None, None),
141 'aws_region_host': (str, False, None, None, None),
142 'aws_s3_host': (str, False, None, None, None),
143 'aws_proxy': (str, False, None, None, None),
144 'aws_proxy_port': (int, False, None, None, None),
145 'aws_proxy_user': (str, False, None, None, None),
146 'aws_proxy_pass': (str, False, None, None, None),
147 }
148
149 KEY_SETTINGS = {
150 'key_location': (str, True, None, None, __expand_all),
151 }
152
153 EBS_VOLUME_SETTINGS = {
154 'volume_id': (str, True, None, None, None),
155 'device': (str, False, None, None, None),
156 'partition': (int, False, None, None, None),
157 'mount_path': (str, True, None, None, None),
158 }
159
160 PLUGIN_SETTINGS = {
161 'setup_class': (str, True, None, None, None),
162 }
163
164 PERMISSION_SETTINGS = {
165
166 'ip_protocol': (str, False, 'tcp', PROTOCOLS, None),
167 'from_port': (int, True, None, None, None),
168 'to_port': (int, True, None, None, None),
169 'cidr_ip': (str, False, '0.0.0.0/0', None, None),
170
171
172
173
174
175
176 }
177
178 CLUSTER_SETTINGS = {
179 'spot_bid': (float, False, None, None, None),
180 'cluster_size': (int, True, None, None, None),
181 'cluster_user': (str, False, 'sgeadmin', None, None),
182 'cluster_shell': (str, False, 'bash', AVAILABLE_SHELLS.keys(), None),
183 'master_image_id': (str, False, None, None, None),
184 'master_instance_type': (str, False, None, INSTANCE_TYPES.keys(), None),
185 'node_image_id': (str, True, None, None, None),
186 'node_instance_type': (list, True, [], None, None),
187 'availability_zone': (str, False, None, None, None),
188 'keyname': (str, True, None, None, None),
189 'extends': (str, False, None, None, None),
190 'volumes': (list, False, [], None, None),
191 'plugins': (list, False, [], None, None),
192 'permissions': (list, False, [], None, None),
193 'disable_queue': (bool, False, False, None, None),
194 'force_spot_master': (bool, False, False, None, None),
195 }
196