1
2 """
3 StarCluster Exception Classes
4 """
5 import os
6 from starcluster import static
7 from starcluster.logger import log
8 from starcluster.templates.config import config_template, copy_paste_template
9
16 return "%s: %s" % (self.__class__.__name__, self.msg)
17
19 """Base class for all SSH related errors"""
20
22 """Raised when ssh fails to to connect to a host (socket error)"""
24 self.msg = "failed to connect to host %s on port %s" % (host,port)
25
27 """Raised when an ssh connection fails to authenticate"""
29 self.msg = "failed to authenticate to host %s as user %s" % (user, host)
30
33 self.msg = "No password or key specified"
34
37
40 self.msg = "AMI %s does not exist" % image_id
41
44 self.msg = "instance %s does not exist" % instance_id
45
48 self.msg = "security group %s does not exist" % sg_name
49
52 self.msg = "keypair %s does not exist" % keyname
53
56 self.msg = "zone %s does not exist" % zone
57
60 self.msg = "volume %s does not exist" % vol_id
61
64 self.msg = "instance %s is not running" % instance_id
65
68 self.msg = "bucket name %s is not valid" % bucket_name
69
72 self.msg = "image name %s is not valid" % image_name
73
76 self.msg = "No certificate file (pem) file specified"
77
80 self.msg = "No certificate file (pem) file specified"
81
84 self.msg = "EC2 certificate file %s does not exist" % key
85
88 self.msg = "EC2 private key file %s does not exist" % key
89
90 -class SpotHistoryError(AWSError):
91 - def __init__(self, start, end):
92 self.msg = "no spot price history for the dates specified: " + \
93 "%s - %s" % (start, end)
94
97 self.msg = "Invalid date specified: %s" % date
98
100 """Base class for all config related errors"""
101
104
107 self.msg = "No valid sections defined in config file %s" % cfg_file
108
111 self.msg = 'Plugin "%s" not found in config' % plugin
112
115 msg = 'Cluster templates %s each have DEFAULT=True in your config.'
116 msg += ' Only one cluster can be the default. Please pick one.'
117 l = ''
118 if len(defaults) == 2:
119 tmpl_list = ' and '.join(defaults)
120 else:
121 first = defaults[0:-1]
122 last = defaults[-1]
123 tmpl_list = ', and '.join([', '.join(first), last])
124 self.msg = msg % tmpl_list
125
128 msg = "No default cluster template specified. To set the default cluster "
129 msg += "template, set DEFAULT_TEMPLATE in the [global] section "
130 msg += "of the config to the name of one of your cluster templates "
131 if options:
132 msg +='(' + ', '.join(options) + ')'
133 self.msg = msg
134
140
142 cfg_parent_dir = os.path.dirname(self.cfg)
143 if not os.path.exists(cfg_parent_dir):
144 os.makedirs(cfg_parent_dir)
145 cfg_file = open(self.cfg, 'w')
146 cfg_file.write(config_template)
147 cfg_file.close()
148 log.info("Config template written to %s. Please customize this file." %
149 self.cfg)
150
152 print 'Options:'
153 print '--------'
154 print '[1] Show the StarCluster config template'
155 print '[2] Write config template to %s' % self.cfg
156 print '[q] Quit'
157 resp = raw_input('\nPlase enter your selection: ')
158 if resp == '1':
159 print self.template
160 elif resp == '2':
161 print
162 self.create_config()
163
166 self.msg = "key %s not found in config" % keyname
167
170 self.msg = "invalid device specified: %s" % device
171
174 self.msg = "invalid partition specified: %s" % part
175
177 """Base class for plugin errors"""
178
180 """Raised when an error is encountered while loading a plugin"""
181
183 """Raised when plugin contains syntax errors"""
184
186 """Base class for validation related errors"""
187
189 """Raised when Cluster class fails to create a receipt on the master node"""
190
192 """Cluster validation related errors"""
193
195 """Raised when two or more settings conflict with each other"""
196
198 """Raised when user specified a zone that is not the same as the zone of the
199 volumes being attached"""
200 - def __init__(self, zone, common_vol_zone):
201 self.msg = "zone %s does not match common volume zone %s" % (zone, common_vol_zone)
202
205 self.msg = 'Volumes %s are not in the same availability zone' % ', '.join(volumes)
206
208 """
209 Exception raised when user requests a cluster template that does not exist
210 """
212 self.msg = "cluster template %s does not exist" % cluster_name
213
215 """
216 Exception raised when user requests a running cluster that does not exist
217 """
219 self.msg = "cluster %s does not exist" % cluster_name
220
223 self.msg = "Cluster with tag name %s already exists. " % cluster_name
224 self.msg += "\n\nEither choose a different tag name, or stop the "
225 self.msg += "existing cluster using:"
226 self.msg += "\n\n $ starcluster stop %s" % cluster_name
227 self.msg += "\n\nIf you wish to use these existing instances anyway, " + \
228 "pass --no-create to the start command"
229
232 self.msg = "Request to start cluster '%s' was cancelled" % tag
233 self.msg += "\n\nPlease be aware that instances may still be running. "
234 self.msg += "\nYou can check this from the output of:"
235 self.msg += "\n\n $ starcluster listclusters"
236 self.msg += "\n\nIf you wish to destroy these instances please run:"
237 self.msg += "\n\n $ starcluster stop %s" % tag
238 self.msg += "\n\nYou can then use:\n\n $ starcluster listinstances"
239 self.msg += "\n\nto verify that the instances have been terminated."
240 self.msg += "\n\nAnother option is to use the AWS management console to"
241 self.msg += "\nterminate the instances manually."
242 self.msg += "\n\nIf you would like to re-use these instances, rerun the"
243 self.msg += "\nsame start command with the --no-create option"
244
247 self.msg = "Request to create volume was cancelled"
248 self.msg += "\n\nPlease be aware that the volume host instance may still"
249 self.msg += " be running. "
250 self.msg += "\n\nTo destroy this instance please run:"
251 self.msg += "\n\n $ starcluster stop %s" % static.VOLUME_GROUP_NAME
252 self.msg += "\n\nand then use\n\n $ starcluster listinstances"
253 self.msg += "\n\nto verify that this instance has been terminated."
254 self.msg += "\n\nAnother option is to use the AWS management console to"
255 self.msg += "\nterminate this instance manually."
256
258 - def __init__(self, bucket, image_name):
259 self.msg = "Request to createimage was cancelled"
260 self.msg += "\n\nDepending on how far along the process was before it "
261 self.msg += "was cancelled, \nsome intermediate files might still be "
262 self.msg += "around in /mnt on the instance. "
263 self.msg += "\n\nAlso, some of these intermediate files "
264 self.msg += "might have been uploaded to S3 in the '%s' bucket" % bucket
265 self.msg += "\nyou specified. You can check this by running: "
266 self.msg += "\n\n $ starcluster showbucket %s\n\n" % bucket
267 self.msg += "and looking for files like '%s.manifest.xml' " % image_name
268 self.msg += "or '%s.part.*'" % image_name
269 self.msg += "\nRe-executing the same creatimage command should take care "
270 self.msg += "of these \nintermediate files and will also automatically "
271 self.msg += "override any partially uploaded files in S3."
272
275 self.msg = "%s is an experimental feature for this " % feature_name
276 self.msg += "release. \nIf you wish to test this feature, set "
277 self.msg += "ENABLE_EXPERIMENTAL=True \nin the [global] section of the "
278 self.msg += "config. \nYou have officially been warned :D"
279