Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/emr/exceptions.py
1567 views
1
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
15
class EmrError(Exception):
16
17
"""
18
The base exception class for Emr exceptions.
19
20
:ivar msg: The descriptive message associated with the error.
21
"""
22
fmt = 'An unspecified error occurred'
23
24
def __init__(self, **kwargs):
25
msg = self.fmt.format(**kwargs)
26
Exception.__init__(self, msg)
27
self.kwargs = kwargs
28
29
30
class MissingParametersError(EmrError):
31
32
"""
33
One or more required parameters were not supplied.
34
35
:ivar object_name: The object that has missing parameters.
36
This can be an operation or a parameter (in the
37
case of inner params). The str() of this object
38
will be used so it doesn't need to implement anything
39
other than str().
40
:ivar missing: The names of the missing parameters.
41
"""
42
fmt = ('aws: error: The following required parameters are missing for '
43
'{object_name}: {missing}.')
44
45
46
class EmptyListError(EmrError):
47
48
"""
49
The provided list is empty.
50
51
:ivar param: The provided list parameter
52
"""
53
fmt = ('aws: error: The prameter {param} cannot be an empty list.')
54
55
56
class MissingRequiredInstanceGroupsError(EmrError):
57
58
"""
59
In create-cluster command, none of --instance-group,
60
--instance-count nor --instance-type were not supplied.
61
"""
62
fmt = ('aws: error: Must specify either --instance-groups or '
63
'--instance-type with --instance-count(optional) to '
64
'configure instance groups.')
65
66
67
class InstanceGroupsValidationError(EmrError):
68
69
"""
70
--instance-type and --instance-count are shortcut option
71
for --instance-groups and they cannot be specified
72
together with --instance-groups
73
"""
74
fmt = ('aws: error: You may not specify --instance-type '
75
'or --instance-count with --instance-groups, '
76
'because --instance-type and --instance-count are '
77
'shortcut options for --instance-groups.')
78
79
80
class InvalidAmiVersionError(EmrError):
81
82
"""
83
The supplied ami-version is invalid.
84
:ivar ami_version: The provided ami_version.
85
"""
86
fmt = ('aws: error: The supplied AMI version "{ami_version}" is invalid.'
87
' Please see AMI Versions Supported in Amazon EMR in '
88
'Amazon Elastic MapReduce Developer Guide: '
89
'http://docs.aws.amazon.com/ElasticMapReduce/'
90
'latest/DeveloperGuide/ami-versions-supported.html')
91
92
93
class MissingBooleanOptionsError(EmrError):
94
95
"""
96
Required boolean options are not supplied.
97
98
:ivar true_option
99
:ivar false_option
100
"""
101
fmt = ('aws: error: Must specify one of the following boolean options: '
102
'{true_option}|{false_option}.')
103
104
105
class UnknownStepTypeError(EmrError):
106
107
"""
108
The provided step type is not supported.
109
110
:ivar step_type: the step_type provided.
111
"""
112
fmt = ('aws: error: The step type {step_type} is not supported.')
113
114
115
class UnknownIamEndpointError(EmrError):
116
117
"""
118
The IAM endpoint is not known for the specified region.
119
120
:ivar region: The region specified.
121
"""
122
fmt = 'IAM endpoint not known for region: {region}.' +\
123
' Specify the iam-endpoint using the --iam-endpoint option.'
124
125
126
class ResolveServicePrincipalError(EmrError):
127
128
"""
129
The service principal could not be resolved from the region or the
130
endpoint.
131
"""
132
fmt = 'Could not resolve the service principal from' +\
133
' the region or the endpoint.'
134
135
136
class LogUriError(EmrError):
137
138
"""
139
The LogUri is not specified and debugging is enabled for the cluster.
140
"""
141
fmt = ('aws: error: LogUri not specified. You must specify a logUri '
142
'if you enable debugging when creating a cluster.')
143
144
145
class MasterDNSNotAvailableError(EmrError):
146
147
"""
148
Cannot get dns of master node on the cluster.
149
"""
150
fmt = 'Cannot get DNS of master node on the cluster. '\
151
' Please try again after some time.'
152
153
154
class WrongPuttyKeyError(EmrError):
155
156
"""
157
A wrong key has been used with a compatible program.
158
"""
159
fmt = 'Key file file format is incorrect. Putty expects a ppk file. '\
160
'Please refer to documentation at http://docs.aws.amazon.com/'\
161
'ElasticMapReduce/latest/DeveloperGuide/EMR_SetUp_SSH.html. '
162
163
164
class SSHNotFoundError(EmrError):
165
166
"""
167
SSH or Putty not available.
168
"""
169
fmt = 'SSH or Putty not available. Please refer to the documentation '\
170
'at http://docs.aws.amazon.com/ElasticMapReduce/latest/'\
171
'DeveloperGuide/EMR_SetUp_SSH.html.'
172
173
174
class SCPNotFoundError(EmrError):
175
176
"""
177
SCP or Pscp not available.
178
"""
179
fmt = 'SCP or Pscp not available. Please refer to the documentation '\
180
'at http://docs.aws.amazon.com/ElasticMapReduce/latest/'\
181
'DeveloperGuide/EMR_SetUp_SSH.html. '
182
183
184
class SubnetAndAzValidationError(EmrError):
185
186
"""
187
SubnetId and AvailabilityZone are mutual exclusive in --ec2-attributes.
188
"""
189
fmt = ('aws: error: You may not specify both a SubnetId and an Availabili'
190
'tyZone (placement) because ec2SubnetId implies a placement.')
191
192
193
class RequiredOptionsError(EmrError):
194
195
"""
196
Either of option1 or option2 is required.
197
"""
198
199
fmt = ('aws: error: Either {option1} or {option2} is required.')
200
201
202
class MutualExclusiveOptionError(EmrError):
203
204
"""
205
The provided option1 and option2 are mutually exclusive.
206
207
:ivar option1
208
:ivar option2
209
:ivar message (optional)
210
"""
211
212
def __init__(self, **kwargs):
213
msg = ('aws: error: You cannot specify both ' +
214
kwargs.get('option1', '') + ' and ' +
215
kwargs.get('option2', '') + ' options together.' +
216
kwargs.get('message', ''))
217
Exception.__init__(self, msg)
218
219
220
class MissingApplicationsError(EmrError):
221
222
"""
223
The application required for a step is not installed when creating a
224
cluster.
225
226
:ivar applications
227
"""
228
229
def __init__(self, **kwargs):
230
msg = ('aws: error: Some of the steps require the following'
231
' applications to be installed: ' +
232
', '.join(kwargs['applications']) + '. Please install the'
233
' applications using --applications.')
234
Exception.__init__(self, msg)
235
236
237
class ClusterTerminatedError(EmrError):
238
239
"""
240
The cluster is terminating or has already terminated.
241
"""
242
fmt = 'aws: error: Cluster terminating or already terminated.'
243
244
245
class ClusterStatesFilterValidationError(EmrError):
246
247
"""
248
In the list-clusters command, customers can specify only one
249
of the following states filters:
250
--cluster-states, --active, --terminated, --failed
251
252
"""
253
fmt = ('aws: error: You can specify only one of the cluster state '
254
'filters: --cluster-states, --active, --terminated, --failed.')
255
256
257
class MissingClusterAttributesError(EmrError):
258
259
"""
260
In the modify-cluster-attributes command, customers need to provide
261
at least one of the following cluster attributes: --visible-to-all-users,
262
--no-visible-to-all-users, --termination-protected, --no-termination-protected,
263
--auto-terminate and --no-auto-terminate
264
"""
265
fmt = ('aws: error: Must specify one of the following boolean options: '
266
'--visible-to-all-users|--no-visible-to-all-users, '
267
'--termination-protected|--no-termination-protected, '
268
'--auto-terminate|--no-auto-terminate, '
269
'--unhealthy-node-replacement|--no-unhealthy-node-replacement.')
270
271
272
class InvalidEmrFsArgumentsError(EmrError):
273
274
"""
275
The provided EMRFS parameters are invalid as parent feature e.g.,
276
Consistent View, CSE, SSE is not configured
277
278
:ivar invalid: Invalid parameters
279
:ivar parent_object_name: Parent feature name
280
"""
281
282
fmt = ('aws: error: {parent_object_name} is not specified. Thus, '
283
' following parameters are invalid: {invalid}')
284
285
286
class DuplicateEmrFsConfigurationError(EmrError):
287
288
fmt = ('aws: error: EMRFS should be configured either using '
289
'--configuration or --emrfs but not both')
290
291
292
class UnknownCseProviderTypeError(EmrError):
293
294
"""
295
The provided EMRFS client-side encryption provider type is not supported.
296
297
:ivar provider_type: the provider_type provided.
298
"""
299
fmt = ('aws: error: The client side encryption type "{provider_type}" is '
300
'not supported. You must specify either KMS or Custom')
301
302
303
class UnknownEncryptionTypeError(EmrError):
304
305
"""
306
The provided encryption type is not supported.
307
308
:ivar provider_type: the provider_type provided.
309
"""
310
fmt = ('aws: error: The encryption type "{encryption}" is invalid. '
311
'You must specify either ServerSide or ClientSide')
312
313
314
class BothSseAndEncryptionConfiguredError(EmrError):
315
316
"""
317
Only one of SSE or Encryption can be configured.
318
319
:ivar sse: Value for SSE
320
:ivar encryption: Value for encryption
321
"""
322
323
fmt = ('aws: error: Both SSE={sse} and Encryption={encryption} are '
324
'configured for --emrfs. You must specify only one of the two.')
325
326
327
class InvalidBooleanConfigError(EmrError):
328
329
fmt = ("aws: error: {config_value} for {config_key} in the config file is "
330
"invalid. The value should be either 'True' or 'False'. Use "
331
"'aws configure set {profile_var_name}.emr.{config_key} <value>' "
332
"command to set a valid value.")
333
334
335
class UnsupportedCommandWithReleaseError(EmrError):
336
337
fmt = ("aws: error: {command} is not supported with "
338
"'{release_label}' release.")
339
340
class MissingAutoScalingRoleError(EmrError):
341
342
fmt = ("aws: error: Must specify --auto-scaling-role when configuring an "
343
"AutoScaling policy for an instance group.")
344
345
346