motherbrain 0.0.0.placeholder → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-version +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +196 -0
- data/COMMANDS.md +9 -0
- data/CONTRIBUTING.md +24 -0
- data/Dockerfile +26 -0
- data/Gemfile +60 -2
- data/Guardfile +30 -0
- data/LICENSE +10 -0
- data/MANIFESTS.md +90 -0
- data/OPERATORS_GUIDE.md +195 -0
- data/PLUGINS.md +268 -0
- data/README.md +304 -16
- data/Thorfile +123 -0
- data/VAGRANT.md +116 -0
- data/bin/boot +9 -0
- data/bin/mb +5 -0
- data/bin/mbsrv +5 -0
- data/config.json +32 -0
- data/features/cli/bootstrap_command/configurable_scripts.feature +32 -0
- data/features/cli/configure_command.feature +57 -0
- data/features/cli/environment_command/create_command.feature +22 -0
- data/features/cli/environment_command/destroy_command.feature +33 -0
- data/features/cli/environment_command/from_command.feature +29 -0
- data/features/cli/environment_command/list_command.feature +0 -0
- data/features/cli/node_limiting.feature +47 -0
- data/features/cli/plugin_command/list_command.feature +46 -0
- data/features/cli/service_command/service_command.feature +21 -0
- data/features/cli/template_command.feature +10 -0
- data/features/cli/validate_config.feature +46 -0
- data/features/step_definitions/bootstrap_steps.rb +57 -0
- data/features/step_definitions/chef_server_steps.rb +3 -0
- data/features/step_definitions/configuration_steps.rb +18 -0
- data/features/step_definitions/core_cli_steps.rb +33 -0
- data/features/step_definitions/environment_steps.rb +43 -0
- data/features/step_definitions/node_steps.rb +3 -0
- data/features/step_definitions/plugin_steps.rb +15 -0
- data/features/step_definitions/template_steps.rb +7 -0
- data/features/support/env.rb +68 -0
- data/lib/mb/api.rb +8 -0
- data/lib/mb/api/application.rb +7 -0
- data/lib/mb/api/endpoint.rb +5 -0
- data/lib/mb/api/helpers.rb +38 -0
- data/lib/mb/api/v1.rb +56 -0
- data/lib/mb/api/v1/config_endpoint.rb +12 -0
- data/lib/mb/api/v1/environments_endpoint.rb +174 -0
- data/lib/mb/api/v1/jobs_endpoint.rb +31 -0
- data/lib/mb/api/v1/plugins_endpoint.rb +90 -0
- data/lib/mb/api/validators.rb +5 -0
- data/lib/mb/api/validators/sem_ver.rb +18 -0
- data/lib/mb/application.rb +148 -0
- data/lib/mb/berkshelf.rb +50 -0
- data/lib/mb/bootstrap.rb +9 -0
- data/lib/mb/bootstrap/manager.rb +250 -0
- data/lib/mb/bootstrap/manifest.rb +131 -0
- data/lib/mb/bootstrap/routine.rb +199 -0
- data/lib/mb/bootstrap/template.rb +73 -0
- data/lib/mb/bootstrap/worker.rb +227 -0
- data/lib/mb/chef.rb +6 -0
- data/lib/mb/chef/config.rb +69 -0
- data/lib/mb/chef/run_list_item.rb +115 -0
- data/lib/mb/chef_mutex.rb +304 -0
- data/lib/mb/clean_room_base.rb +39 -0
- data/lib/mb/cli.rb +50 -0
- data/lib/mb/cli/base.rb +51 -0
- data/lib/mb/cli/shell.rb +29 -0
- data/lib/mb/cli/shell/basic.rb +11 -0
- data/lib/mb/cli/shell/color.rb +11 -0
- data/lib/mb/cli/shell/ext.rb +41 -0
- data/lib/mb/cli/sub_command.rb +95 -0
- data/lib/mb/cli/sub_command/component.rb +56 -0
- data/lib/mb/cli/sub_command/plugin.rb +232 -0
- data/lib/mb/cli_client.rb +178 -0
- data/lib/mb/cli_gateway.rb +426 -0
- data/lib/mb/cli_gateway/sub_commands.rb +3 -0
- data/lib/mb/cli_gateway/sub_commands/environment.rb +124 -0
- data/lib/mb/cli_gateway/sub_commands/plugin.rb +148 -0
- data/lib/mb/command.rb +88 -0
- data/lib/mb/command_invoker.rb +235 -0
- data/lib/mb/command_invoker/worker.rb +40 -0
- data/lib/mb/command_runner.rb +233 -0
- data/lib/mb/component.rb +245 -0
- data/lib/mb/config.rb +275 -0
- data/lib/mb/config_manager.rb +75 -0
- data/lib/mb/console.rb +35 -0
- data/lib/mb/cookbook_metadata.rb +73 -0
- data/lib/mb/core_ext.rb +3 -0
- data/lib/mb/core_ext/dir.rb +37 -0
- data/lib/mb/core_ext/enumerable.rb +48 -0
- data/lib/mb/core_ext/file.rb +24 -0
- data/lib/mb/core_ext/signal.rb +11 -0
- data/lib/mb/environment_manager.rb +195 -0
- data/lib/mb/error_handler.rb +212 -0
- data/lib/mb/errors.rb +693 -0
- data/lib/mb/file_system.rb +60 -0
- data/lib/mb/file_system/tempfile.rb +25 -0
- data/lib/mb/gear.rb +154 -0
- data/lib/mb/gears.rb +8 -0
- data/lib/mb/gears/dynamic_service.rb +218 -0
- data/lib/mb/gears/jmx.rb +24 -0
- data/lib/mb/gears/jmx/action.rb +46 -0
- data/lib/mb/gears/mysql.rb +20 -0
- data/lib/mb/gears/mysql/action.rb +190 -0
- data/lib/mb/gears/service.rb +163 -0
- data/lib/mb/gears/service/action.rb +58 -0
- data/lib/mb/gears/service/action_runner.rb +161 -0
- data/lib/mb/grape_ext.rb +3 -0
- data/lib/mb/grape_ext/endpoint.rb +13 -0
- data/lib/mb/group.rb +143 -0
- data/lib/mb/job.rb +183 -0
- data/lib/mb/job/state_machine.rb +34 -0
- data/lib/mb/job/states.rb +46 -0
- data/lib/mb/job_manager.rb +96 -0
- data/lib/mb/job_record.rb +67 -0
- data/lib/mb/job_ticket.rb +25 -0
- data/lib/mb/lock_manager.rb +116 -0
- data/lib/mb/logging.rb +134 -0
- data/lib/mb/logging/basic_format.rb +31 -0
- data/lib/mb/manifest.rb +128 -0
- data/lib/mb/mixin.rb +3 -0
- data/lib/mb/mixin/attribute_setting.rb +265 -0
- data/lib/mb/mixin/coded_exit.rb +49 -0
- data/lib/mb/mixin/locks.rb +54 -0
- data/lib/mb/mixin/services.rb +100 -0
- data/lib/mb/node_filter.rb +97 -0
- data/lib/mb/node_querier.rb +527 -0
- data/lib/mb/plugin.rb +300 -0
- data/lib/mb/plugin_manager.rb +589 -0
- data/lib/mb/provisioner.rb +186 -0
- data/lib/mb/provisioner/manager.rb +213 -0
- data/lib/mb/provisioner/manifest.rb +125 -0
- data/lib/mb/provisioner/provision_data.rb +96 -0
- data/lib/mb/provisioners.rb +5 -0
- data/lib/mb/provisioners/aws.rb +395 -0
- data/lib/mb/rest_gateway.rb +72 -0
- data/lib/mb/ridley_ext.rb +5 -0
- data/lib/mb/ridley_ext/cookbook_object.rb +15 -0
- data/lib/mb/srv_ctl.rb +183 -0
- data/lib/mb/test.rb +104 -0
- data/lib/mb/thor_ext.rb +49 -0
- data/lib/mb/upgrade.rb +6 -0
- data/lib/mb/upgrade/manager.rb +85 -0
- data/lib/mb/upgrade/worker.rb +149 -0
- data/lib/mb/version.rb +1 -1
- data/lib/motherbrain.rb +166 -2
- data/man/man_helper.rb +81 -0
- data/man/mb.1 +494 -0
- data/man/mb.1.html +300 -0
- data/man/mb.1.ronn.erb +62 -0
- data/motherbrain.gemspec +56 -20
- data/scripts/node_name.rb +14 -0
- data/spec/fixtures/cb_metadata.json +7 -0
- data/spec/fixtures/cb_metadata.rb +14 -0
- data/spec/fixtures/fake_id_rsa +27 -0
- data/spec/fixtures/fake_key.pem +27 -0
- data/spec/fixtures/myface-0.1.0/metadata.rb +14 -0
- data/spec/fixtures/myface-0.1.0/motherbrain.rb +0 -0
- data/spec/fixtures/test_env.json +15 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/support/actor_mocking.rb +7 -0
- data/spec/support/berkshelf.rb +24 -0
- data/spec/support/chef_server.rb +102 -0
- data/spec/support/doubles.rb +11 -0
- data/spec/support/klass.rb +10 -0
- data/spec/support/matchers/each.rb +12 -0
- data/spec/support/matchers/error_codes.rb +5 -0
- data/spec/support/matchers/exit_codes.rb +57 -0
- data/spec/support/matchers/jobs.rb +11 -0
- data/spec/support/spec_helpers.rb +145 -0
- data/spec/unit/mb/api/application_spec.rb +11 -0
- data/spec/unit/mb/api/helpers_spec.rb +5 -0
- data/spec/unit/mb/api/v1/config_endpoint_spec.rb +19 -0
- data/spec/unit/mb/api/v1/environments_endpoint_spec.rb +71 -0
- data/spec/unit/mb/api/v1/jobs_endpoint_spec.rb +24 -0
- data/spec/unit/mb/api/v1/plugins_endpoint_spec.rb +298 -0
- data/spec/unit/mb/api/v1_spec.rb +37 -0
- data/spec/unit/mb/api/validators/sem_ver_spec.rb +5 -0
- data/spec/unit/mb/application_spec.rb +19 -0
- data/spec/unit/mb/berkshelf_spec.rb +38 -0
- data/spec/unit/mb/bootstrap/manager_spec.rb +347 -0
- data/spec/unit/mb/bootstrap/manifest_spec.rb +333 -0
- data/spec/unit/mb/bootstrap/routine_spec.rb +393 -0
- data/spec/unit/mb/bootstrap/template_spec.rb +100 -0
- data/spec/unit/mb/bootstrap/worker_spec.rb +194 -0
- data/spec/unit/mb/chef/config_spec.rb +33 -0
- data/spec/unit/mb/chef/run_list_item_spec.rb +34 -0
- data/spec/unit/mb/chef_mutex_spec.rb +314 -0
- data/spec/unit/mb/clean_room_base_spec.rb +31 -0
- data/spec/unit/mb/cli/base_spec.rb +43 -0
- data/spec/unit/mb/cli/shell/basic_spec.rb +5 -0
- data/spec/unit/mb/cli/shell/color_spec.rb +5 -0
- data/spec/unit/mb/cli/shell/ext_spec.rb +11 -0
- data/spec/unit/mb/cli/shell_spec.rb +38 -0
- data/spec/unit/mb/cli/sub_command/base_spec.rb +102 -0
- data/spec/unit/mb/cli/sub_command/component_spec.rb +5 -0
- data/spec/unit/mb/cli/sub_command/plugin_spec.rb +91 -0
- data/spec/unit/mb/cli/sub_command_spec.rb +43 -0
- data/spec/unit/mb/cli/ui.rb +0 -0
- data/spec/unit/mb/cli_client_spec.rb +51 -0
- data/spec/unit/mb/cli_gateway_spec.rb +386 -0
- data/spec/unit/mb/command_invoker/worker_spec.rb +43 -0
- data/spec/unit/mb/command_invoker_spec.rb +230 -0
- data/spec/unit/mb/command_runner_spec.rb +299 -0
- data/spec/unit/mb/command_spec.rb +76 -0
- data/spec/unit/mb/component_spec.rb +185 -0
- data/spec/unit/mb/config_manager_spec.rb +31 -0
- data/spec/unit/mb/config_spec.rb +408 -0
- data/spec/unit/mb/cookbook_metadata_spec.rb +89 -0
- data/spec/unit/mb/core_ext/dir_spec.rb +92 -0
- data/spec/unit/mb/core_ext/enumerable_spec.rb +104 -0
- data/spec/unit/mb/core_ext/file_spec.rb +58 -0
- data/spec/unit/mb/core_ext/signal_spec.rb +24 -0
- data/spec/unit/mb/environment_manager_spec.rb +166 -0
- data/spec/unit/mb/error_handler_spec.rb +173 -0
- data/spec/unit/mb/errors_spec.rb +132 -0
- data/spec/unit/mb/file_system/tempfile_spec.rb +14 -0
- data/spec/unit/mb/file_system_spec.rb +69 -0
- data/spec/unit/mb/gear_spec.rb +125 -0
- data/spec/unit/mb/gears/dynamic_service_spec.rb +187 -0
- data/spec/unit/mb/gears/jmx/action_spec.rb +34 -0
- data/spec/unit/mb/gears/jmx_spec.rb +32 -0
- data/spec/unit/mb/gears/mysql/action_spec.rb +118 -0
- data/spec/unit/mb/gears/mysql_spec.rb +21 -0
- data/spec/unit/mb/gears/service/action_runner_spec.rb +182 -0
- data/spec/unit/mb/gears/service/action_spec.rb +44 -0
- data/spec/unit/mb/gears/service_spec.rb +124 -0
- data/spec/unit/mb/group_spec.rb +280 -0
- data/spec/unit/mb/job_manager_spec.rb +56 -0
- data/spec/unit/mb/job_record_spec.rb +60 -0
- data/spec/unit/mb/job_spec.rb +201 -0
- data/spec/unit/mb/locks_manager_spec.rb +88 -0
- data/spec/unit/mb/logging_spec.rb +133 -0
- data/spec/unit/mb/manifest_spec.rb +105 -0
- data/spec/unit/mb/mixin/attribute_setting_spec.rb +180 -0
- data/spec/unit/mb/mixin/coded_exit_spec.rb +25 -0
- data/spec/unit/mb/mixin/locks_spec.rb +32 -0
- data/spec/unit/mb/mixin/services_spec.rb +75 -0
- data/spec/unit/mb/node_filter_spec.rb +86 -0
- data/spec/unit/mb/node_querier_spec.rb +532 -0
- data/spec/unit/mb/plugin_manager_spec.rb +724 -0
- data/spec/unit/mb/plugin_spec.rb +247 -0
- data/spec/unit/mb/provisioner/manager_spec.rb +141 -0
- data/spec/unit/mb/provisioner/manifest_spec.rb +182 -0
- data/spec/unit/mb/provisioner/provision_data_spec.rb +113 -0
- data/spec/unit/mb/provisioner_spec.rb +251 -0
- data/spec/unit/mb/provisioners/aws_spec.rb +392 -0
- data/spec/unit/mb/provisioners/environment_factory_spec.rb +108 -0
- data/spec/unit/mb/rest_gateway_spec.rb +13 -0
- data/spec/unit/mb/ridley_ext/cookbook_object_spec.rb +105 -0
- data/spec/unit/mb/srv_ctl_spec.rb +142 -0
- data/spec/unit/mb/upgrade/manager_spec.rb +37 -0
- data/spec/unit/mb/upgrade/worker_spec.rb +219 -0
- data/spec/unit/motherbrain_spec.rb +58 -0
- data/templates/bootstrap.json +8 -0
- data/templates/motherbrain.rb +44 -0
- metadata +694 -15
- data/Rakefile +0 -1
data/lib/mb/errors.rb
ADDED
@@ -0,0 +1,693 @@
|
|
1
|
+
module MotherBrain
|
2
|
+
module Errors
|
3
|
+
class << self
|
4
|
+
# @return [Hash]
|
5
|
+
def error_codes
|
6
|
+
@error_codes ||= Hash.new
|
7
|
+
end
|
8
|
+
|
9
|
+
# @param [MBError] klass
|
10
|
+
#
|
11
|
+
# @raise [RuntimeError]
|
12
|
+
def register(klass)
|
13
|
+
if error_codes.has_key?(klass.error_code)
|
14
|
+
msg = "Unable to register exception #{klass}. The error_code #{klass.error_code} is already"
|
15
|
+
msg << " in use by #{error_codes[klass.error_code]}."
|
16
|
+
raise RuntimeError, msg
|
17
|
+
end
|
18
|
+
|
19
|
+
error_codes[klass.error_code] = klass
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param [MBError] klass
|
23
|
+
def unregister(klass)
|
24
|
+
error_codes.delete(klass.error_code)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class MBError < StandardError
|
30
|
+
DEFAULT_EXIT_CODE = 1
|
31
|
+
|
32
|
+
class << self
|
33
|
+
# @param [Integer] code
|
34
|
+
#
|
35
|
+
# @return [Integer]
|
36
|
+
def exit_code(code = DEFAULT_EXIT_CODE)
|
37
|
+
@exit_code ||= code
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param [Integer] code
|
41
|
+
#
|
42
|
+
# @return [Integer]
|
43
|
+
def error_code(code = -1)
|
44
|
+
return @error_code if @error_code
|
45
|
+
@error_code = code
|
46
|
+
Errors.register(self)
|
47
|
+
@error_code
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param [String] message
|
52
|
+
def initialize(message = nil)
|
53
|
+
super(message)
|
54
|
+
@message = message
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Integer]
|
58
|
+
def exit_code
|
59
|
+
self.class.exit_code
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Integer]
|
63
|
+
def error_code
|
64
|
+
self.class.error_code
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String]
|
68
|
+
def message
|
69
|
+
@message || self.class.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_s
|
73
|
+
"[err_code]: #{error_code} [message]: #{message}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_hash
|
77
|
+
{
|
78
|
+
code: error_code,
|
79
|
+
message: message
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# @param [Hash] options
|
84
|
+
# a set of options to pass to MultiJson.encode
|
85
|
+
#
|
86
|
+
# @return [String]
|
87
|
+
def to_json(options = {})
|
88
|
+
MultiJson.encode(self.to_hash, options)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Internal errors
|
93
|
+
class InternalError < MBError
|
94
|
+
exit_code(99)
|
95
|
+
error_code(1000)
|
96
|
+
end
|
97
|
+
|
98
|
+
class ArgumentError < InternalError
|
99
|
+
error_code(1001)
|
100
|
+
end
|
101
|
+
|
102
|
+
class AbstractFunction < InternalError
|
103
|
+
error_code(1002)
|
104
|
+
end
|
105
|
+
|
106
|
+
class ReservedGearKeyword < InternalError
|
107
|
+
error_code(1003)
|
108
|
+
end
|
109
|
+
|
110
|
+
class DuplicateGearKeyword < InternalError
|
111
|
+
error_code(1004)
|
112
|
+
end
|
113
|
+
|
114
|
+
class InvalidProvisionerClass < InternalError
|
115
|
+
error_code(1005)
|
116
|
+
end
|
117
|
+
|
118
|
+
class ProvisionerRegistrationError < InternalError
|
119
|
+
error_code(1006)
|
120
|
+
end
|
121
|
+
|
122
|
+
class ProvisionerNotRegistered < InternalError
|
123
|
+
error_code(1007)
|
124
|
+
end
|
125
|
+
|
126
|
+
class RemoteScriptError < InternalError
|
127
|
+
error_code(1008)
|
128
|
+
end
|
129
|
+
|
130
|
+
class RemoteCommandError < InternalError
|
131
|
+
|
132
|
+
attr_reader :host
|
133
|
+
|
134
|
+
def initialize(message, host=nil)
|
135
|
+
super(message)
|
136
|
+
@host = host if host
|
137
|
+
end
|
138
|
+
|
139
|
+
error_code(1009)
|
140
|
+
end
|
141
|
+
|
142
|
+
class RemoteFileCopyError < InternalError
|
143
|
+
error_code(1010)
|
144
|
+
end
|
145
|
+
|
146
|
+
class ActionNotSupported < InternalError
|
147
|
+
exit_code(103)
|
148
|
+
error_code(1011)
|
149
|
+
end
|
150
|
+
|
151
|
+
# TODO plugin error
|
152
|
+
class ServiceRunListNotFound < InternalError
|
153
|
+
|
154
|
+
def initialize(services)
|
155
|
+
if services.respond_to?(:join)
|
156
|
+
services = services.join(", ")
|
157
|
+
end
|
158
|
+
|
159
|
+
super("Service run list not found for the following services: #{services})")
|
160
|
+
end
|
161
|
+
|
162
|
+
error_code(1013)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Plugin loading errors
|
166
|
+
class PluginSyntaxError < MBError
|
167
|
+
exit_code(100)
|
168
|
+
error_code(2000)
|
169
|
+
end
|
170
|
+
|
171
|
+
class DuplicateGroup < PluginSyntaxError
|
172
|
+
error_code(2001)
|
173
|
+
end
|
174
|
+
|
175
|
+
class DuplicateChefAttribute < PluginSyntaxError
|
176
|
+
error_code(2002)
|
177
|
+
end
|
178
|
+
|
179
|
+
class ValidationFailed < PluginSyntaxError
|
180
|
+
error_code(2003)
|
181
|
+
end
|
182
|
+
|
183
|
+
class DuplicateAction < PluginSyntaxError
|
184
|
+
error_code(2004)
|
185
|
+
end
|
186
|
+
|
187
|
+
class DuplicateGear < PluginSyntaxError
|
188
|
+
error_code(2005)
|
189
|
+
end
|
190
|
+
|
191
|
+
class ActionNotFound < PluginSyntaxError
|
192
|
+
error_code(2006)
|
193
|
+
end
|
194
|
+
|
195
|
+
class GroupNotFound < PluginSyntaxError
|
196
|
+
error_code(2007)
|
197
|
+
end
|
198
|
+
|
199
|
+
class PluginLoadError < MBError
|
200
|
+
exit_code(101)
|
201
|
+
error_code(2008)
|
202
|
+
end
|
203
|
+
|
204
|
+
class InvalidCookbookMetadata < PluginLoadError
|
205
|
+
error_code(2009)
|
206
|
+
attr_reader :errors
|
207
|
+
|
208
|
+
def initialize(errors)
|
209
|
+
@errors = errors
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# Standard errors
|
214
|
+
class ChefRunnerError < MBError
|
215
|
+
exit_code(102)
|
216
|
+
error_code(3000)
|
217
|
+
end
|
218
|
+
|
219
|
+
class NoValueForAddressAttribute < ChefRunnerError
|
220
|
+
error_code(3001)
|
221
|
+
end
|
222
|
+
|
223
|
+
class JobNotFound < MBError
|
224
|
+
exit_code(106)
|
225
|
+
error_code(3002)
|
226
|
+
|
227
|
+
attr_reader :job_id
|
228
|
+
|
229
|
+
def initialize(id)
|
230
|
+
@job_id = id
|
231
|
+
end
|
232
|
+
|
233
|
+
def message
|
234
|
+
"No job with ID: '#{job_id}' found"
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
class PluginNotFound < MBError
|
239
|
+
exit_code(107)
|
240
|
+
error_code(3003)
|
241
|
+
|
242
|
+
attr_reader :name
|
243
|
+
attr_reader :version
|
244
|
+
|
245
|
+
def initialize(name, version = nil)
|
246
|
+
@name = name
|
247
|
+
@version = version
|
248
|
+
end
|
249
|
+
|
250
|
+
def message
|
251
|
+
msg = "No plugin named '#{name}'"
|
252
|
+
msg << " of version (#{version})" unless version.nil?
|
253
|
+
msg << " found"
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
class NoBootstrapRoutine < MBError
|
258
|
+
exit_code(108)
|
259
|
+
error_code(3004)
|
260
|
+
end
|
261
|
+
|
262
|
+
class PluginDownloadError < MBError
|
263
|
+
exit_code(109)
|
264
|
+
error_code(3005)
|
265
|
+
end
|
266
|
+
|
267
|
+
class CommandNotFound < MBError
|
268
|
+
exit_code(110)
|
269
|
+
error_code(3006)
|
270
|
+
|
271
|
+
attr_reader :name
|
272
|
+
attr_reader :parent
|
273
|
+
|
274
|
+
# @param [String] name
|
275
|
+
# name of the command that was not found
|
276
|
+
# @param [MB::Plugin, MB::Component] parent
|
277
|
+
# plugin that we searched for the command on
|
278
|
+
def initialize(name, parent)
|
279
|
+
@name = name
|
280
|
+
@parent = parent
|
281
|
+
end
|
282
|
+
|
283
|
+
def message
|
284
|
+
"#{parent.class} '#{parent}' does not have the command: '#{name}'"
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
class ComponentNotFound < MBError
|
289
|
+
exit_code(111)
|
290
|
+
error_code(3007)
|
291
|
+
|
292
|
+
attr_reader :name
|
293
|
+
attr_reader :plugin
|
294
|
+
|
295
|
+
# @param [String] name
|
296
|
+
# @param [MB::Plugin] plugin
|
297
|
+
def initialize(name, plugin)
|
298
|
+
@name = name
|
299
|
+
@plugin = plugin
|
300
|
+
end
|
301
|
+
|
302
|
+
def message
|
303
|
+
"Plugin #{plugin} does not have the component: '#{name}'"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
class InvalidConfig < MBError
|
308
|
+
exit_code(13)
|
309
|
+
error_code(3009)
|
310
|
+
|
311
|
+
# @return [ActiveModel::Errors]
|
312
|
+
attr_reader :errors
|
313
|
+
|
314
|
+
# @param [ActiveModel::Errors] errors
|
315
|
+
def initialize(errors)
|
316
|
+
@errors = errors
|
317
|
+
end
|
318
|
+
|
319
|
+
def message
|
320
|
+
msg = errors.collect do |key, messages|
|
321
|
+
"* #{key}: #{messages.join(', ')}"
|
322
|
+
end
|
323
|
+
msg.unshift "-----"
|
324
|
+
msg.unshift "Invalid Configuration File"
|
325
|
+
msg.join("\n")
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
class ConfigNotFound < MBError
|
330
|
+
exit_code(14)
|
331
|
+
error_code(3010)
|
332
|
+
end
|
333
|
+
|
334
|
+
class ConfigExists < MBError
|
335
|
+
exit_code(15)
|
336
|
+
error_code(3011)
|
337
|
+
end
|
338
|
+
|
339
|
+
class ChefConnectionError < MBError
|
340
|
+
exit_code(16)
|
341
|
+
error_code(3012)
|
342
|
+
end
|
343
|
+
|
344
|
+
class InvalidBootstrapManifest < MBError
|
345
|
+
exit_code(17)
|
346
|
+
error_code(3013)
|
347
|
+
end
|
348
|
+
|
349
|
+
class ResourceLocked < MBError
|
350
|
+
exit_code(18)
|
351
|
+
error_code(3014)
|
352
|
+
end
|
353
|
+
|
354
|
+
class InvalidProvisionManifest < MBError
|
355
|
+
exit_code(19)
|
356
|
+
error_code(3015)
|
357
|
+
end
|
358
|
+
|
359
|
+
class ManifestNotFound < MBError
|
360
|
+
exit_code(20)
|
361
|
+
error_code(3016)
|
362
|
+
end
|
363
|
+
|
364
|
+
class InvalidManifest < MBError
|
365
|
+
exit_code(21)
|
366
|
+
error_code(3017)
|
367
|
+
end
|
368
|
+
|
369
|
+
class ComponentNotVersioned < MBError
|
370
|
+
exit_code(22)
|
371
|
+
error_code(3018)
|
372
|
+
|
373
|
+
attr_reader :component_name
|
374
|
+
|
375
|
+
def initialize(component_name)
|
376
|
+
@component_name = component_name
|
377
|
+
end
|
378
|
+
|
379
|
+
def message
|
380
|
+
[
|
381
|
+
"Component '#{component_name}' is not versioned",
|
382
|
+
"You can version components with:",
|
383
|
+
" versioned # defaults to \"#{component_name}.version\"",
|
384
|
+
" versioned_with \"custom.version.attribute\""
|
385
|
+
].join "\n"
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
class InvalidLockType < MBError
|
390
|
+
exit_code(23)
|
391
|
+
error_code(3019)
|
392
|
+
end
|
393
|
+
|
394
|
+
class ConfigOptionMissing < MBError
|
395
|
+
exit_code(24)
|
396
|
+
error_code(3026)
|
397
|
+
end
|
398
|
+
|
399
|
+
class GearError < MBError
|
400
|
+
exit_code(104)
|
401
|
+
error_code(3020)
|
402
|
+
end
|
403
|
+
|
404
|
+
class ChefRunFailure < MBError
|
405
|
+
exit_code(105)
|
406
|
+
error_code(3021)
|
407
|
+
|
408
|
+
def initialize(errors)
|
409
|
+
@errors = errors
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
class ChefTestRunFailure < MBError
|
414
|
+
error_code(3022)
|
415
|
+
end
|
416
|
+
|
417
|
+
class RequiredFileNotFound < MBError
|
418
|
+
error_code(3023)
|
419
|
+
|
420
|
+
attr_reader :filename
|
421
|
+
attr_reader :required_for
|
422
|
+
|
423
|
+
def initialize(filename, options = {})
|
424
|
+
@filename = filename
|
425
|
+
@required_for = options[:required_for]
|
426
|
+
end
|
427
|
+
|
428
|
+
def message
|
429
|
+
msg = "#{@filename} does not exist, but is required"
|
430
|
+
msg += " for #{@required_for}" if @required_for
|
431
|
+
msg += "."
|
432
|
+
msg
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
class BootstrapTemplateNotFound < MBError
|
437
|
+
exit_code(106)
|
438
|
+
error_code(3024)
|
439
|
+
end
|
440
|
+
|
441
|
+
class InvalidEnvironmentJson < MBError
|
442
|
+
error_code(3025)
|
443
|
+
|
444
|
+
def initialize(path, json_error=nil)
|
445
|
+
@path = path
|
446
|
+
end
|
447
|
+
|
448
|
+
def message
|
449
|
+
msg = "Environment JSON contained in #{path} is invalid."
|
450
|
+
msg << "\n#{json_error.message}" if json_error and json_error.responds_to?(:message)
|
451
|
+
msg
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
class FileNotFound < MBError
|
456
|
+
error_code(3027)
|
457
|
+
|
458
|
+
def initialize(path)
|
459
|
+
@path = path
|
460
|
+
end
|
461
|
+
|
462
|
+
def message
|
463
|
+
"File does not exist: #{path}"
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
class InvalidDynamicService < MBError
|
468
|
+
error_code(3028)
|
469
|
+
|
470
|
+
def initialize(component, service_name)
|
471
|
+
@component = component
|
472
|
+
@service_name = service_name
|
473
|
+
end
|
474
|
+
|
475
|
+
def message
|
476
|
+
msg = "Both component: #{@component} and service name: #{@service_name} are required."
|
477
|
+
msg << "\nFormat should be in a dotted form - COMPONENT.SERVICE"
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
# Bootstrap errors
|
482
|
+
class BootstrapError < MBError
|
483
|
+
exit_code(24)
|
484
|
+
error_code(4000)
|
485
|
+
end
|
486
|
+
|
487
|
+
class GroupBootstrapError < BootstrapError
|
488
|
+
error_code(4001)
|
489
|
+
|
490
|
+
# @return [Array<String>]
|
491
|
+
attr_reader :groups
|
492
|
+
# @return [Hash]
|
493
|
+
attr_reader :host_errors
|
494
|
+
|
495
|
+
# @param [Hash] host_errors
|
496
|
+
#
|
497
|
+
# "cloud-3.riotgames.com" => {
|
498
|
+
# groups: ["database_slave::default"],
|
499
|
+
# result: {
|
500
|
+
# status: :ok
|
501
|
+
# message: ""
|
502
|
+
# bootstrap_type: :partial
|
503
|
+
# }
|
504
|
+
# }
|
505
|
+
def initialize(host_errors)
|
506
|
+
@groups = Set.new
|
507
|
+
@host_errors = Hash.new
|
508
|
+
|
509
|
+
host_errors.each do |host, host_info|
|
510
|
+
@host_errors[host] = host_info
|
511
|
+
host_info[:groups].each { |group| @groups.add(group) }
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
def message
|
516
|
+
err = ""
|
517
|
+
groups.each do |group|
|
518
|
+
err << "failure bootstrapping group #{group}\n"
|
519
|
+
host_errors.each do |host, host_info|
|
520
|
+
if host_info[:groups].include?(group)
|
521
|
+
err << " * #{host} #{host_info[:result]}\n"
|
522
|
+
end
|
523
|
+
end
|
524
|
+
err << "\n"
|
525
|
+
end
|
526
|
+
err
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
class CookbookConstraintNotSatisfied < BootstrapError
|
531
|
+
error_code(4002)
|
532
|
+
end
|
533
|
+
|
534
|
+
class InvalidAttributesFile < BootstrapError
|
535
|
+
error_code(4003)
|
536
|
+
end
|
537
|
+
|
538
|
+
class ValidatorPemNotFound < RequiredFileNotFound
|
539
|
+
error_code(4004)
|
540
|
+
|
541
|
+
def initialize(filename, options = { required_for: 'bootstrap' })
|
542
|
+
super
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
|
547
|
+
# Provision errors
|
548
|
+
class ProvisionError < MBError
|
549
|
+
exit_code(20)
|
550
|
+
error_code(5000)
|
551
|
+
end
|
552
|
+
|
553
|
+
class UnexpectedProvisionCount < ProvisionError
|
554
|
+
error_code(5001)
|
555
|
+
|
556
|
+
attr_reader :expected
|
557
|
+
attr_reader :got
|
558
|
+
|
559
|
+
def initialize(expected, got)
|
560
|
+
@expected = expected
|
561
|
+
@got = got
|
562
|
+
end
|
563
|
+
|
564
|
+
def message
|
565
|
+
"Expected '#{expected}' nodes to be provisioned but got: '#{got}'"
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
class ProvisionerNotStarted < ProvisionError
|
570
|
+
error_code(5002)
|
571
|
+
attr_reader :provisioner_id
|
572
|
+
|
573
|
+
def initialize(provisioner_id)
|
574
|
+
@provisioner_id = provisioner_id
|
575
|
+
end
|
576
|
+
|
577
|
+
def message
|
578
|
+
"No provisioner registered or started that matches the ID: '#{provisioner_id}'.\n"
|
579
|
+
"Registered provisioners are: #{MB::Provisioner.all.map(&:provisioner_id).join(', ')}"
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
# Chef errors
|
584
|
+
class ChefError < MBError
|
585
|
+
exit_code(26)
|
586
|
+
error_code(9000)
|
587
|
+
end
|
588
|
+
|
589
|
+
class NodeNotFound < ChefError
|
590
|
+
error_code(9001)
|
591
|
+
|
592
|
+
attr_reader :name
|
593
|
+
|
594
|
+
def initialize(name)
|
595
|
+
@name = name
|
596
|
+
end
|
597
|
+
|
598
|
+
def message
|
599
|
+
"A node named '#{name}' could not be found on the Chef server"
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
class EnvironmentNotFound < MBError
|
604
|
+
exit_code(12)
|
605
|
+
error_code(9002)
|
606
|
+
|
607
|
+
attr_reader :name
|
608
|
+
|
609
|
+
def initialize(name)
|
610
|
+
@name = name
|
611
|
+
end
|
612
|
+
|
613
|
+
def message
|
614
|
+
"An environment named '#{name}' could not be found"
|
615
|
+
end
|
616
|
+
end
|
617
|
+
|
618
|
+
class DataBagNotFound < ChefError
|
619
|
+
error_code(9003)
|
620
|
+
|
621
|
+
attr_reader :name
|
622
|
+
|
623
|
+
def initialize(name)
|
624
|
+
@name = name
|
625
|
+
end
|
626
|
+
|
627
|
+
def message
|
628
|
+
"A Data Bag named '#{name}' could not be found"
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
class DataBagItemNotFound < ChefError
|
633
|
+
error_code(9004)
|
634
|
+
|
635
|
+
attr_reader :data_bag_name
|
636
|
+
attr_reader :item_name
|
637
|
+
|
638
|
+
def initialize(data_bag_name, item_name)
|
639
|
+
@data_bag_name = data_bag_name
|
640
|
+
@item_name = item_name
|
641
|
+
end
|
642
|
+
|
643
|
+
def message
|
644
|
+
"An item named '#{item_name}' was not found in the '#{data_bag_name}' data bag."
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
class PrerequisiteNotInstalled < MBError
|
649
|
+
error_code(9005)
|
650
|
+
end
|
651
|
+
|
652
|
+
class EnvironmentExists < ChefError
|
653
|
+
error_code(9006)
|
654
|
+
|
655
|
+
attr_reader :name
|
656
|
+
|
657
|
+
def initialize(name)
|
658
|
+
@name = name
|
659
|
+
end
|
660
|
+
|
661
|
+
def message
|
662
|
+
"An environment named '#{name}' already exists in the Chef Server."
|
663
|
+
end
|
664
|
+
end
|
665
|
+
|
666
|
+
class NodeSaveFailed < ChefError
|
667
|
+
error_code(9007)
|
668
|
+
|
669
|
+
attr_reader :name
|
670
|
+
|
671
|
+
def initialize(name)
|
672
|
+
@name = name
|
673
|
+
end
|
674
|
+
|
675
|
+
def message
|
676
|
+
"Saving #{@name} failed. Node is not tagged as disabled in it's run list."
|
677
|
+
end
|
678
|
+
end
|
679
|
+
|
680
|
+
class NodeDisabled < ChefError
|
681
|
+
error_code(9008)
|
682
|
+
|
683
|
+
attr_reader :name
|
684
|
+
|
685
|
+
def initialize(name)
|
686
|
+
@name = name
|
687
|
+
end
|
688
|
+
|
689
|
+
def message
|
690
|
+
"#{@name} is disabled."
|
691
|
+
end
|
692
|
+
end
|
693
|
+
end
|