1
2 """
3 StarCluster Exception Classes
4 """
5
6 import os
7
8 from starcluster import static
9 from starcluster.logger import log
10 from starcluster.templates import config, user_msgs
11
12
16
19
21 return "%s: %s" % (self.__class__.__name__, self.msg)
22
23
25 """Raised when command is not found on the system's PATH """
27 self.msg = "command not found: '%s'" % cmd
28
29
31 """Raised when command is not found on a *remote* system's PATH """
33 self.msg = "command not found on remote system: '%s'" % cmd
34
35
37 """Base class for all SSH related errors"""
38
39
41 """Raised when ssh fails to to connect to a host (socket error)"""
43 self.msg = "failed to connect to host %s on port %s" % (host, port)
44
45
47 """Raised when an ssh connection fails to authenticate"""
49 self.msg = "failed to authenticate to host %s as user %s" % (host,
50 user)
51
52
55 self.msg = "No password or key specified"
56
57
59 """Base exception for all AWS related errors"""
60
61
64 self.msg = "region %s does not exist" % region_name
65
66
69 self.msg = "AMI %s does not exist" % image_id
70
71
73 - def __init__(self, instance_id, label='instance'):
74 self.msg = "%s '%s' does not exist" % (label, instance_id)
75
76
78 - def __init__(self, instance_id, state, label='instance'):
79 self.msg = "%s %s is not running (%s)" % (label, instance_id, state)
80
81
84 self.msg = "security group %s does not exist" % sg_name
85
86
89 self.msg = "keypair %s does not exist" % keyname
90
91
94 self.msg = "zone %s does not exist in region %s" % (zone, region)
95
96
99 self.msg = "volume %s does not exist" % vol_id
100
101
104 self.msg = "snapshot %s does not exist" % snap_id
105
106
109 self.msg = "bucket with name '%s' already exists on S3\n" % bucket_name
110 self.msg += "(NOTE: S3's bucket namepsace is shared by all AWS users)"
111
112
115 self.msg = "bucket '%s' does not exist" % bucket_name
116
117
120
121
124 self.msg = "bucket name %s is not valid" % bucket_name
125
126
129 self.msg = "image name %s is not valid" % image_name
130
131
134 self.msg = "No Amazon user id specified in config (AWS_USER_ID)"
135
136
139 self.msg = "No certificate file (pem) specified in config (EC2_CERT)"
140
141
144 self.msg = "No private certificate file (pem) file specified in " + \
145 "config (EC2_PRIVATE_KEY)"
146
147
150 self.msg = "EC2 certificate file %s does not exist" % key
151
152
155 self.msg = "EC2 private key file %s does not exist" % key
156
157
158 -class SpotHistoryError(AWSError):
159 - def __init__(self, start, end):
160 self.msg = "no spot price history for the dates specified: " + \
161 "%s - %s" % (start, end)
162
163
166 self.msg = "Invalid date specified: %s" % date
167
168
170 """Base class for all config related errors"""
171
172
175
176
179 self.msg = "No valid sections defined in config file %s" % cfg_file
180
181
184 self.msg = 'Plugin "%s" not found in config' % plugin
185
186
189 msg = "No default cluster template specified. To set the default "
190 msg += "cluster template, set DEFAULT_TEMPLATE in the [global] section"
191 msg += " of the config to the name of one of your cluster templates "
192 if options:
193 msg += '(' + ', '.join(options) + ')'
194 self.msg = msg
195
196
202
204 cfg_parent_dir = os.path.dirname(self.cfg)
205 if not os.path.exists(cfg_parent_dir):
206 os.makedirs(cfg_parent_dir)
207 cfg_file = open(self.cfg, 'w')
208 cfg_file.write(config.config_template)
209 cfg_file.close()
210 log.info("Config template written to %s. Please customize this file." %
211 self.cfg)
212
214 print 'Options:'
215 print '--------'
216 print '[1] Show the StarCluster config template'
217 print '[2] Write config template to %s' % self.cfg
218 print '[q] Quit'
219 resp = raw_input('\nPlease enter your selection: ')
220 if resp == '1':
221 print self.template
222 elif resp == '2':
223 print
224 self.create_config()
225
226
229 self.msg = "key %s not found in config" % keyname
230
231
234 self.msg = "invalid device specified: %s" % device
235
236
239 self.msg = "invalid partition specified: %s" % part
240
241
243 """Base class for plugin errors"""
244
245
247 """Raised when an error is encountered while loading a plugin"""
248
249
251 """Raised when plugin contains syntax errors"""
252
253
255 """Base class for validation related errors"""
256
257
259 """Raised when creating/loading a cluster receipt fails"""
260
261
263 """Cluster validation related errors"""
264
265
267 """Raised when two or more settings conflict with each other"""
268
269
271 """Raised when user specifies an invalid IP protocol for permission"""
273 self.msg = "protocol %s is not a valid ip protocol. options: %s" % \
274 (protocol, ', '.join(static.PROTOCOLS))
275
276
278 """Raised when user specifies an invalid port range for permission"""
279 - def __init__(self, from_port, to_port, reason=None):
280 self.msg = ''
281 if reason:
282 self.msg += "%s\n" % reason
283 self.msg += "port range is invalid: from %s to %s" % (from_port,
284 to_port)
285
286
288 """Raised when user specifies an invalid CIDR ip for permission"""
290 self.msg = "cidr_ip is invalid: %s" % cidr
291
292
294 """
295 Raised when a zone has been specified that does not match the common
296 zone of the volumes being attached
297 """
298 - def __init__(self, zone, common_vol_zone):
299 cvz = common_vol_zone
300 self.msg = ("availability_zone setting '%s' does not " +
301 "match the common volume zone '%s'") % (zone, cvz)
302
303
306 vlist = ', '.join(volumes)
307 self.msg = 'Volumes %s are not in the same availability zone' % vlist
308
309
311 """
312 Exception raised when user requests a cluster template that does not exist
313 """
315 self.msg = "cluster template %s does not exist" % cluster_name
316
317
319 """
320 Exception raised when user requests a running cluster that does not exist
321 """
323 self.msg = "cluster %s is not running" % cluster_name
324
325
327 """
328 Exception raised when user requests a running cluster that does not exist
329 """
331 self.msg = "cluster %s does not exist" % cluster_name
332
333
335 - def __init__(self, cluster_name, is_ebs=False, stopped_ebs=False):
343
344
347 self.msg = "Request to start cluster '%s' was cancelled" % tag
348 self.msg += "\n\nPlease be aware that instances may still be running."
349 self.msg += "\nYou can check this from the output of:"
350 self.msg += "\n\n $ starcluster listclusters"
351 self.msg += "\n\nIf you wish to destroy these instances please run:"
352 self.msg += "\n\n $ starcluster stop %s" % tag
353 self.msg += "\n\nYou can then use:\n\n $ starcluster listinstances"
354 self.msg += "\n\nto verify that the instances have been terminated."
355 self.msg += "\n\nAnother option is to use the AWS management console"
356 self.msg += "\nto terminate the instances manually."
357 self.msg += "\n\nIf you would like to re-use these instances, rerun"
358 self.msg += "\nthe same start command with the --no-create option"
359
360
363 self.msg = "Request to create volume was cancelled"
364 self.msg += "\n\nPlease be aware that the volume host instance"
365 self.msg += " may still be running. "
366 self.msg += "\n\nTo destroy this instance please run:"
367 self.msg += "\n\n $ starcluster terminate %s" % \
368 static.VOLUME_GROUP_NAME
369 self.msg += "\n\nand then use\n\n $ starcluster listinstances"
370 self.msg += "\n\nto verify that this instance has been terminated."
371 self.msg += "\n\nAnother option is to use the AWS management console "
372 self.msg += "to terminate\nthis instance manually."
373
374
376 - def __init__(self, bucket, image_name):
377 self.msg = "Request to create an S3 AMI was cancelled"
378 self.msg += "\n\nDepending on how far along the process was before it "
379 self.msg += "was cancelled, \nsome intermediate files might still be "
380 self.msg += "around in /mnt on the instance."
381 self.msg += "\n\nAlso, some of these intermediate files might "
382 self.msg += "have been uploaded to \nS3 in the '%(bucket)s' bucket "
383 self.msg += "you specified. You can check this by running:"
384 self.msg += "\n\n $ starcluster showbucket %(bucket)s\n\n"
385 self.msg += "and looking for files like: "
386 self.msg += "'%(iname)s.manifest.xml' or '%(iname)s.part.*'"
387 self.msg += "\nRe-executing the same s3image command "
388 self.msg += "should take care of these \nintermediate files and "
389 self.msg += "will also automatically override any\npartially uploaded "
390 self.msg += "files in S3."
391 self.msg = self.msg % {'bucket': bucket, 'iname': image_name}
392
393
394 CancelledS3ImageCreation = CancelledCreateImage
395
396
398 - def __init__(self, is_ebs_backed, image_name):
399 self.msg = "Request to create EBS image %s was cancelled" % image_name
400 if is_ebs_backed:
401 self.msg += "\n\nDepending on how far along the process was "
402 self.msg += "before it was cancelled, \na snapshot of the image "
403 self.msg += "host's root volume may have been created.\nPlease "
404 self.msg += "inspect the output of:\n\n"
405 self.msg += " $ starcluster listsnapshots\n\n"
406 self.msg += "and clean up any unwanted snapshots"
407 else:
408 self.msg += "\n\nDepending on how far along the process was "
409 self.msg += "before it was cancelled, \na new volume and a "
410 self.msg += "snapshot of that new volume may have been created.\n"
411 self.msg += "Please inspect the output of:\n\n"
412 self.msg += " $ starcluster listvolumes\n\n"
413 self.msg += " and\n\n"
414 self.msg += " $ starcluster listsnapshots\n\n"
415 self.msg += "and clean up any unwanted volumes or snapshots"
416
417
420 self.msg = "%s is an experimental feature for this " % feature_name
421 self.msg += "release. \nIf you wish to test this feature, set "
422 self.msg += "ENABLE_EXPERIMENTAL=True \nin the [global] section of the"
423 self.msg += " config. \nYou have officially been warned :D"
424
425
428 self.msg = msg
429 self.exceptions = exceptions
430
433
441
442
444 main_msg = """\
445 The cluster '%(tag)s' was either created by a previous stable or development \
446 version of StarCluster or you manually created the '%(group)s' group. In any \
447 case '%(tag)s' cannot be used with this version of StarCluster (%(version)s).
448
449 """
450
451 insts_msg = """\
452 The cluster '%(tag)s' currently has %(num_nodes)d active nodes.
453
454 """
455
456 no_insts_msg = """\
457 The cluster '%(tag)s' does not have any nodes and is safe to terminate.
458
459 """
460
461 terminate_msg = """\
462 Please terminate the cluster using:
463
464 $ starcluster terminate %(tag)s
465 """
466
480