1
2 """
3 Module for storing static data structures
4 """
5 import os
6 import sys
7 import getpass
8 import tempfile
9
10
12 path = os.path.expanduser(path)
13 path = os.path.expandvars(path)
14 return path
15
16
18 if not os.path.exists(path):
19 try:
20 os.makedirs(path)
21 except OSError:
22 if exit_on_failure:
23 sys.stderr.write("!!! ERROR - %s *must* be a directory\n" %
24 path)
25 elif not os.path.isdir(path) and exit_on_failure:
26 sys.stderr.write("!!! ERROR - %s *must* be a directory\n" % path)
27 sys.exit(1)
28
29
34
35
36 VERSION = "0.92.1"
37 PID = os.getpid()
38 TMP_DIR = tempfile.gettempdir()
39 if os.path.exists("/tmp"):
40 TMP_DIR = "/tmp"
41 CURRENT_USER = 'unknown_user'
42 try:
43 CURRENT_USER = getpass.getuser()
44 except:
45 pass
46 SSH_TEMPLATE = 'ssh -i %s %s@%s'
47
48 STARCLUSTER_CFG_DIR = os.path.join(os.path.expanduser('~'), '.starcluster')
49 STARCLUSTER_CFG_FILE = os.path.join(STARCLUSTER_CFG_DIR, 'config')
50 STARCLUSTER_PLUGIN_DIR = os.path.join(STARCLUSTER_CFG_DIR, 'plugins')
51 STARCLUSTER_LOG_DIR = os.path.join(STARCLUSTER_CFG_DIR, 'logs')
52 STARCLUSTER_RECEIPT_DIR = "/var/run/starcluster"
53 STARCLUSTER_RECEIPT_FILE = os.path.join(STARCLUSTER_RECEIPT_DIR, "receipt.pkl")
54 STARCLUSTER_OWNER_ID = 342652561657
55
56 DEBUG_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'debug.log')
57 SSH_DEBUG_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'ssh-debug.log')
58 AWS_DEBUG_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'aws-debug.log')
59 CRASH_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'crash-report-%d.txt' % PID)
60
61
62 BASE_AMI_32 = "ami-8cf913e5"
63 BASE_AMI_64 = "ami-0af31963"
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 'cg1.4xlarge': ['x86_64'],
94 }
95
96 MICRO_INSTANCE_TYPES = ['t1.micro']
97
98 CLUSTER_COMPUTE_TYPES = ['cc1.4xlarge']
99
100 CLUSTER_GPU_TYPES = ['cg1.4xlarge']
101
102 CLUSTER_TYPES = CLUSTER_COMPUTE_TYPES + CLUSTER_GPU_TYPES
103
104 CLUSTER_REGIONS = ['us-east-1']
105
106 PROTOCOLS = ['tcp', 'udp', 'icmp']
107
108 WORLD_CIDRIP = '0.0.0.0/0'
109
110 DEFAULT_SSH_PORT = 22
111
112 AVAILABLE_SHELLS = {
113 "bash": True,
114 "zsh": True,
115 "csh": True,
116 "ksh": True,
117 "tcsh": True,
118 }
119
120 GLOBAL_SETTINGS = {
121
122 'default_template': (str, False, None, None, None),
123 'enable_experimental': (bool, False, False, None, None),
124 'refresh_interval': (int, False, 30, None, None),
125 'web_browser': (str, False, None, None, None),
126 'include': (list, False, [], None, None),
127 }
128
129 AWS_SETTINGS = {
130 'aws_access_key_id': (str, True, None, None, None),
131 'aws_secret_access_key': (str, True, None, None, None),
132 'aws_user_id': (str, False, None, None, None),
133 'ec2_cert': (str, False, None, None, None),
134 'ec2_private_key': (str, False, None, None, None),
135 'aws_port': (int, False, None, None, None),
136 'aws_ec2_path': (str, False, '/', None, None),
137 'aws_s3_path': (str, False, '/', None, None),
138 'aws_is_secure': (bool, False, True, None, None),
139 'aws_region_name': (str, False, None, None, None),
140 'aws_region_host': (str, False, None, None, None),
141 'aws_s3_host': (str, False, None, None, None),
142 }
143
144 KEY_SETTINGS = {
145 'key_location': (str, True, None, None, __expand_all),
146 }
147
148 EBS_VOLUME_SETTINGS = {
149 'volume_id': (str, True, None, None, None),
150 'device': (str, False, None, None, None),
151 'partition': (int, False, None, None, None),
152 'mount_path': (str, True, None, None, None),
153 }
154
155 PLUGIN_SETTINGS = {
156 'setup_class': (str, True, None, None, None),
157 }
158
159 PERMISSION_SETTINGS = {
160
161 'ip_protocol': (str, False, 'tcp', PROTOCOLS, None),
162 'from_port': (int, True, None, None, None),
163 'to_port': (int, True, None, None, None),
164 'cidr_ip': (str, False, '0.0.0.0/0', None, None),
165
166
167
168
169
170
171 }
172
173 CLUSTER_SETTINGS = {
174 'spot_bid': (float, False, None, None, None),
175 'cluster_size': (int, True, None, None, None),
176 'cluster_user': (str, False, 'sgeadmin', None, None),
177 'cluster_shell': (str, False, 'bash', AVAILABLE_SHELLS.keys(), None),
178 'master_image_id': (str, False, None, None, None),
179 'master_instance_type': (str, False, None, INSTANCE_TYPES.keys(), None),
180 'node_image_id': (str, True, None, None, None),
181 'node_instance_type': (list, True, [], None, None),
182 'availability_zone': (str, False, None, None, None),
183 'keyname': (str, True, None, None, None),
184 'extends': (str, False, None, None, None),
185 'volumes': (list, False, [], None, None),
186 'plugins': (list, False, [], None, None),
187 'permissions': (list, False, [], None, None),
188 'disable_queue': (bool, False, False, None, None),
189 'force_spot_master': (bool, False, False, None, None),
190 }
191