bcome 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/bcome +8 -39
- data/lib/bcome.rb +12 -3
- data/lib/objects/bcome/version.rb +3 -0
- data/lib/objects/bootup.rb +81 -0
- data/lib/objects/command/local.rb +40 -0
- data/lib/objects/config_factory.rb +36 -0
- data/lib/objects/driver/base.rb +30 -0
- data/lib/objects/driver/bucket.rb +20 -0
- data/lib/objects/driver/ec2.rb +44 -0
- data/lib/objects/driver/static.rb +4 -0
- data/lib/objects/exception/argument_error_invoking_method_from_command_line.rb +7 -0
- data/lib/objects/exception/base.rb +15 -0
- data/lib/objects/exception/can_only_subselect_on_inventory.rb +7 -0
- data/lib/objects/exception/cannot_find_internal_registry_klass.rb +7 -0
- data/lib/objects/exception/cannot_find_subselection_parent.rb +7 -0
- data/lib/objects/exception/cant_find_key_in_cloud_tags.rb +7 -0
- data/lib/objects/exception/cant_find_key_in_metadata.rb +7 -0
- data/lib/objects/exception/cant_find_proxy_host_by_identifier.rb +7 -0
- data/lib/objects/exception/cant_find_proxy_host_by_namespace.rb +7 -0
- data/lib/objects/exception/could_not_initiate_ssh_connection.rb +7 -0
- data/lib/objects/exception/could_not_initiate_ssh_connection_through_backend_proxy.rb +7 -0
- data/lib/objects/exception/deprecation_warning.rb +11 -0
- data/lib/objects/exception/duplicate_command_line_argument_key.rb +7 -0
- data/lib/objects/exception/ec2_driver_missing_provisioning_region.rb +7 -0
- data/lib/objects/exception/failed_to_run_local_command.rb +7 -0
- data/lib/objects/exception/interactive_session_halt.rb +4 -0
- data/lib/objects/exception/invalid_bcome_breadcrumb.rb +7 -0
- data/lib/objects/exception/invalid_breadcrumb.rb +7 -0
- data/lib/objects/exception/invalid_context_command.rb +7 -0
- data/lib/objects/exception/invalid_identifier.rb +7 -0
- data/lib/objects/exception/invalid_machines_cache_config.rb +7 -0
- data/lib/objects/exception/invalid_matcher_query.rb +7 -0
- data/lib/objects/exception/invalid_meta_data_config.rb +7 -0
- data/lib/objects/exception/invalid_network_config.rb +7 -0
- data/lib/objects/exception/invalid_network_driver_type.rb +7 -0
- data/lib/objects/exception/invalid_proxy_config.rb +7 -0
- data/lib/objects/exception/invalid_regexp_matcher_in_registry.rb +7 -0
- data/lib/objects/exception/invalid_registry_arguments_type.rb +7 -0
- data/lib/objects/exception/invalid_registry_data_config.rb +7 -0
- data/lib/objects/exception/invalid_restriction_key_in_registry.rb +7 -0
- data/lib/objects/exception/invalid_ssh_config.rb +7 -0
- data/lib/objects/exception/inventories_cannot_have_subviews.rb +7 -0
- data/lib/objects/exception/malformed_command_line_arguments.rb +7 -0
- data/lib/objects/exception/method_invocation_requires_parameter.rb +7 -0
- data/lib/objects/exception/method_name_conflict_in_registry.rb +7 -0
- data/lib/objects/exception/missing_argument_for_registry_command.rb +7 -0
- data/lib/objects/exception/missing_description_on_view.rb +7 -0
- data/lib/objects/exception/missing_execute_on_registry_object.rb +7 -0
- data/lib/objects/exception/missing_identifier_on_view.rb +7 -0
- data/lib/objects/exception/missing_ip_address_on_server.rb +7 -0
- data/lib/objects/exception/missing_network_config.rb +7 -0
- data/lib/objects/exception/missing_params_for_rsync.rb +7 -0
- data/lib/objects/exception/missing_params_for_scp.rb +7 -0
- data/lib/objects/exception/missing_subselection_key.rb +7 -0
- data/lib/objects/exception/missing_type_on_view.rb +7 -0
- data/lib/objects/exception/no_node_found_for_breadcrumb.rb +7 -0
- data/lib/objects/exception/no_node_named_by_identifier.rb +7 -0
- data/lib/objects/exception/node_identifiers_must_be_unique.rb +7 -0
- data/lib/objects/exception/orchestration_script_does_not_exist.rb +7 -0
- data/lib/objects/exception/proxy_host_node_does_not_have_public_ip_address.rb +7 -0
- data/lib/objects/exception/unknown_method_for_namespace.rb +7 -0
- data/lib/objects/interactive/session.rb +45 -0
- data/lib/objects/interactive/session_item/base.rb +36 -0
- data/lib/objects/interactive/session_item/capture_input.rb +20 -0
- data/lib/objects/interactive/session_item/transparent_ssh.rb +111 -0
- data/lib/objects/modules/context.rb +13 -0
- data/lib/objects/modules/registry_management.rb +14 -0
- data/lib/objects/modules/ui_output.rb +9 -0
- data/lib/objects/modules/workspace_commands.rb +198 -0
- data/lib/objects/modules/workspace_menu.rb +128 -0
- data/lib/objects/node/attributes.rb +47 -0
- data/lib/objects/node/base.rb +248 -0
- data/lib/objects/node/cache_handler.rb +24 -0
- data/lib/objects/node/collection.rb +51 -0
- data/lib/objects/node/factory.rb +108 -0
- data/lib/objects/node/inventory/base.rb +88 -0
- data/lib/objects/node/inventory/defined.rb +112 -0
- data/lib/objects/node/inventory/subselect.rb +54 -0
- data/lib/objects/node/meta/base.rb +36 -0
- data/lib/objects/node/meta/cloud.rb +4 -0
- data/lib/objects/node/meta/local.rb +4 -0
- data/lib/objects/node/meta_data_factory.rb +23 -0
- data/lib/objects/node/meta_data_loader.rb +32 -0
- data/lib/objects/node/resources/base.rb +98 -0
- data/lib/objects/node/resources/inventory.rb +25 -0
- data/lib/objects/node/resources/sub_inventory.rb +56 -0
- data/lib/objects/node/server/base.rb +218 -0
- data/lib/objects/node/server/dynamic.rb +39 -0
- data/lib/objects/node/server/static.rb +31 -0
- data/lib/objects/orchestration/base.rb +13 -0
- data/lib/objects/orchestrator.rb +24 -0
- data/lib/objects/parser/bread_crumb.rb +31 -0
- data/lib/objects/progress_bar.rb +30 -0
- data/lib/objects/registry/arguments/base.rb +36 -0
- data/lib/objects/registry/arguments/command_line.rb +35 -0
- data/lib/objects/registry/arguments/console.rb +15 -0
- data/lib/objects/registry/command/base.rb +66 -0
- data/lib/objects/registry/command/external.rb +55 -0
- data/lib/objects/registry/command/group.rb +76 -0
- data/lib/objects/registry/command/internal.rb +34 -0
- data/lib/objects/registry/command_list.rb +33 -0
- data/lib/objects/registry/loader.rb +70 -0
- data/lib/objects/ssh/bootstrap.rb +19 -0
- data/lib/objects/ssh/command.rb +46 -0
- data/lib/objects/ssh/command_exec.rb +65 -0
- data/lib/objects/ssh/connection_handler.rb +101 -0
- data/lib/objects/ssh/driver.rb +204 -0
- data/lib/objects/ssh/proxy_data.rb +56 -0
- data/lib/objects/ssh/script_exec.rb +43 -0
- data/lib/objects/system/local.rb +30 -0
- data/lib/objects/workspace.rb +75 -0
- data/patches/irb.rb +20 -7
- data/patches/string.rb +75 -0
- data/patches/string_stylesheet.rb +61 -0
- metadata +175 -93
- data/bin/bcome-bash-setup +0 -18
- data/bin/bcome-setup +0 -43
- data/bin/boot.rb +0 -148
- data/bin/boot_no_shell.rb +0 -3
- data/filters/ec2_filter.rb +0 -12
- data/lib/bcome/version.rb +0 -3
- data/lib/become_object.rb +0 -111
- data/lib/boot.rb +0 -13
- data/lib/command.rb +0 -56
- data/lib/context_functions.rb +0 -65
- data/lib/filters/base.rb +0 -10
- data/lib/filters/ec2_filter.rb +0 -4
- data/lib/functions.rb +0 -70
- data/lib/helpers/command_helper.rb +0 -13
- data/lib/helpers/environment_ssh.rb +0 -122
- data/lib/helpers/fog_helper.rb +0 -108
- data/lib/helpers/instance_command.rb +0 -71
- data/lib/helpers/instance_ssh.rb +0 -83
- data/lib/helpers/selections.rb +0 -117
- data/lib/interactive/interactive_session_halt.rb +0 -4
- data/lib/interactive/session.rb +0 -44
- data/lib/interactive/session_item/base.rb +0 -30
- data/lib/interactive/session_item/transparent_ssh.rb +0 -133
- data/lib/nodes/base.rb +0 -60
- data/lib/nodes/environment.rb +0 -30
- data/lib/nodes/estate.rb +0 -44
- data/lib/nodes/instance.rb +0 -94
- data/lib/nodes/platform.rb +0 -17
- data/lib/nodes/view.rb +0 -31
- data/lib/object.rb +0 -21
- data/lib/orchestrator/command_group/base.rb +0 -56
- data/lib/orchestrator/command_group/custom.rb +0 -13
- data/lib/orchestrator/command_group/direct.rb +0 -53
- data/lib/orchestrator/direct_command/group.rb +0 -21
- data/lib/orchestrator/direct_command/instance.rb +0 -19
- data/lib/orchestrator/factory.rb +0 -38
- data/lib/orchestrator/loader.rb +0 -47
- data/lib/orchestrator/node_target/all.rb +0 -14
- data/lib/orchestrator/node_target/all_excluding_roles.rb +0 -14
- data/lib/orchestrator/node_target/all_with_roles.rb +0 -14
- data/lib/orchestrator/node_target/base.rb +0 -43
- data/lib/orchestrator/node_target/single.rb +0 -12
- data/lib/orchestrator/recipe.rb +0 -60
- data/lib/orchestrator/registry.rb +0 -37
- data/lib/orchestrator/validate_and_set.rb +0 -10
- data/lib/patches/string.rb +0 -86
- data/lib/progress_bar.rb +0 -31
- data/lib/render_irb.rb +0 -53
- data/lib/scp.rb +0 -40
- data/lib/ssh.rb +0 -51
- data/lib/stack/base.rb +0 -148
- data/lib/stack/environment.rb +0 -222
- data/lib/stack/estate.rb +0 -50
- data/lib/stack/instance.rb +0 -130
- data/lib/stack/platform.rb +0 -74
- data/lib/stack/view.rb +0 -56
- data/lib/workspace_context.rb +0 -40
data/lib/nodes/instance.rb
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Node
|
|
2
|
-
class Instance < ::Bcome::Node::Base
|
|
3
|
-
|
|
4
|
-
include ::Bcome::InstanceCommand
|
|
5
|
-
include ::Bcome::InstanceSsh
|
|
6
|
-
|
|
7
|
-
def environment
|
|
8
|
-
@environment = (@environment ? @environment : stack_peer.environment.node)
|
|
9
|
-
@environment
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def machines
|
|
13
|
-
[self] # for completion
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def identifier
|
|
17
|
-
stack_peer.override_instance_identifier_for_wbz_stacks? ? wbz_overriden_identifier : @identifier
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
## START SSH CONNECTION STUFF --
|
|
21
|
-
def ssh_connect!(bootstrap = false)
|
|
22
|
-
|
|
23
|
-
net_ssh_params = { :keys => ssh_keys(bootstrap), :paranoid => false }
|
|
24
|
-
net_ssh_params[:proxy] = proxy(bootstrap) if proxy(bootstrap)
|
|
25
|
-
begin
|
|
26
|
-
@ssh_con = ::Net::SSH.start(ip_address, ssh_user(bootstrap), net_ssh_params)
|
|
27
|
-
rescue Net::SSH::ConnectionTimeout
|
|
28
|
-
raise "Could not initiate connection to #{self.namespace}"
|
|
29
|
-
end
|
|
30
|
-
return @ssh_con
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def ssh_connection(bootstrap = false)
|
|
34
|
-
return has_open_ssh_con? ? @ssh_con : ssh_connect!(bootstrap)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def has_open_ssh_con?
|
|
38
|
-
@ssh_con && !@ssh_con.closed?
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def ssh_keys(bootstrap = false)
|
|
42
|
-
bootstrap ? [bootstrap_settings[:key]] : keys
|
|
43
|
-
end
|
|
44
|
-
######## END SSH CONNECTION STUFF --
|
|
45
|
-
|
|
46
|
-
def wbz_overriden_identifier
|
|
47
|
-
prefix = stack_peer.overriden_identifier_prefix
|
|
48
|
-
@identifier =~ /#{prefix}(.+)/
|
|
49
|
-
return $1 ? $1 : @identifier
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def ip_address
|
|
53
|
-
environment.ssh_mode_type == ::SSH_DIRECT_MODE_IDENTIFIER ? public_ip_address : @external_network_interface_address
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def bootstrap_settings
|
|
57
|
-
environment.bootstrap_settings
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def proxy(bootstrap = false)
|
|
61
|
-
environment.proxy(bootstrap)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def display_ip_address
|
|
65
|
-
return "xxx.xxx.xxx.xx" if @identifier == "bastionserver"
|
|
66
|
-
return @public_ip_address
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def public_ip_address
|
|
70
|
-
return @public_ip_address
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def hostname_map
|
|
74
|
-
return "ip-#{ip_address.to_s.gsub(".","-")}"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def ec2_hostname
|
|
78
|
-
return "#{hostname_map}.ec2.internal"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def role
|
|
82
|
-
@role
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def namespace
|
|
86
|
-
"#{environment.namespace}/#{identifier}"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def local_download_path
|
|
90
|
-
"#{Dir.pwd}#{environment.namespace}/#{identifier}"
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
end
|
|
94
|
-
end
|
data/lib/nodes/platform.rb
DELETED
data/lib/nodes/view.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Node
|
|
2
|
-
class View < ::Bcome::Node::Base
|
|
3
|
-
|
|
4
|
-
include ::Bcome::EnvironmentSSH
|
|
5
|
-
|
|
6
|
-
def machines
|
|
7
|
-
if instances.empty?
|
|
8
|
-
stack_peer.do_load_resources
|
|
9
|
-
end
|
|
10
|
-
instances
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def identifier
|
|
14
|
-
@environment
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def bootstrap_settings
|
|
18
|
-
@bootstrap_settings
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def namespace
|
|
22
|
-
"#{platform.namespace}/#{@environment.identifier}/#{identifier}"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def set_instances(loaded_resources)
|
|
26
|
-
@instances = loaded_resources.collect(&:node)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
data/lib/object.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
class Object
|
|
2
|
-
|
|
3
|
-
def is_sudo?
|
|
4
|
-
@sudo
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def sudo_state
|
|
8
|
-
is_sudo? ? "on" : "off"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def set_irb_prompt(conf)
|
|
12
|
-
conf[:PROMPT][:CUSTOM] = {
|
|
13
|
-
:PROMPT_N => "\e[1m:\e[m ",
|
|
14
|
-
:PROMPT_I => "\e[1m#{BECOME.irb_prompt} #{is_sudo? ? " sudo ".danger : ""}>\e[m ", # high voltage
|
|
15
|
-
:PROMPT_C => "\e[1m#{BECOME.irb_prompt} >\e[m ",
|
|
16
|
-
:RETURN => ::VERBOSE ? "%s \n" : "\n"
|
|
17
|
-
}
|
|
18
|
-
conf[:PROMPT_MODE] = :CUSTOM
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::CommandGroup
|
|
2
|
-
class Base
|
|
3
|
-
|
|
4
|
-
class << self
|
|
5
|
-
def new_of_type_from(json, node_targets, all_machines, direct_command_groups)
|
|
6
|
-
raise "Missing command type in #{json.inspect}" unless json.has_key?(:type)
|
|
7
|
-
raise "Invalid command of type #{json[:type]} in #{json.inspect}" unless klass_for_type.keys.include?(json[:type])
|
|
8
|
-
|
|
9
|
-
klass = klass_for_type[json[:type]]
|
|
10
|
-
|
|
11
|
-
command_group = klass.new(json)
|
|
12
|
-
command_group.set_machines(node_targets)
|
|
13
|
-
|
|
14
|
-
if klass == ::Bcome::Orchestrator::CommandGroup::Direct
|
|
15
|
-
command_group.direct_command_groups = direct_command_groups
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
return command_group
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def klass_for_type
|
|
22
|
-
{
|
|
23
|
-
"DIRECT" => ::Bcome::Orchestrator::CommandGroup::Direct,
|
|
24
|
-
"CUSTOM" => ::Bcome::Orchestrator::CommandGroup::Custom
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
attr_reader :machines
|
|
30
|
-
|
|
31
|
-
include ::Bcome::Orchestrator::ValidateAndSet
|
|
32
|
-
|
|
33
|
-
def initialize(json)
|
|
34
|
-
validate_and_set(json)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def json_attributes
|
|
38
|
-
raise "json_attributes should be overidden on derived Orchestrator::Command classes"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def set_machines(node_targets)
|
|
42
|
-
@machines ||= node_targets.select{ |nt|
|
|
43
|
-
nt.target_key == @target_nodes_key
|
|
44
|
-
}.collect(&:node_selections).flatten!
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def json_attributes
|
|
48
|
-
[:target_nodes_key]
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def execute!(*params)
|
|
52
|
-
raise "Should be overidden"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::CommandGroup
|
|
2
|
-
class Custom < ::Bcome::Orchestrator::CommandGroup::Base
|
|
3
|
-
|
|
4
|
-
def json_attributes
|
|
5
|
-
super + [:bcome_command]
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def execute!(current_context_machines, is_bootstrap)
|
|
9
|
-
::Bcome::Orchestrator::CustomCommand.send(@bcome_command, current_context_machines, is_bootstrap)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::CommandGroup
|
|
2
|
-
class Direct < ::Bcome::Orchestrator::CommandGroup::Base
|
|
3
|
-
|
|
4
|
-
attr_reader :commands, :direct_command_groups
|
|
5
|
-
|
|
6
|
-
def initialize(*params)
|
|
7
|
-
super
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def json_attributes
|
|
11
|
-
super + [:direct_command_set_key]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def direct_command_groups=(groups)
|
|
15
|
-
@direct_command_groups = groups.select{|dcg| dcg.direct_command_set_identifier == @direct_command_set_key}
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def commands
|
|
19
|
-
@commands ||= set_commands
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def execute!(current_context_machines, bootstrap)
|
|
23
|
-
# Per command group
|
|
24
|
-
@direct_command_groups.each do |direct_command_group|
|
|
25
|
-
# Per unique machine instance
|
|
26
|
-
machines.each do |machine|
|
|
27
|
-
kommands = []
|
|
28
|
-
direct_command_group.command_instances.flatten.each do |command_instance|
|
|
29
|
-
kommands << ::Bcome::Command.new(:command => command_instance.cmd, :instance => machine, :bootstrap => bootstrap, :success_exit_codes => command_instance.success_exit_codes)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
begin
|
|
33
|
-
execute_commands(kommands)
|
|
34
|
-
rescue Net::SSH::AuthenticationFailed => e
|
|
35
|
-
if machine.bootstrap_settings
|
|
36
|
-
## Fallback to execute commands without bootstrap set
|
|
37
|
-
kommands.each {|kommand| kommand.bootstrap = true }
|
|
38
|
-
execute_commands(kommands)
|
|
39
|
-
else
|
|
40
|
-
raise e
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def execute_commands(commands)
|
|
48
|
-
ssh = ::Bcome::Ssh.new(commands)
|
|
49
|
-
ssh.execute!
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::DirectCommand
|
|
2
|
-
class Group
|
|
3
|
-
|
|
4
|
-
include ::Bcome::Orchestrator::ValidateAndSet
|
|
5
|
-
|
|
6
|
-
attr_reader :commands, :direct_command_set_identifier, :description
|
|
7
|
-
|
|
8
|
-
def initialize(json)
|
|
9
|
-
validate_and_set(json)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def command_instances
|
|
13
|
-
@command_instances ||= commands.collect{|raw_command| ::Bcome::Orchestrator::DirectCommand::Instance.new(raw_command)}
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def json_attributes
|
|
17
|
-
[:direct_command_set_identifier, :commands, :description]
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::DirectCommand
|
|
2
|
-
class Instance
|
|
3
|
-
|
|
4
|
-
include ::Bcome::Orchestrator::ValidateAndSet
|
|
5
|
-
|
|
6
|
-
attr_reader :cmd, :bootstrap, :success_exit_codes
|
|
7
|
-
|
|
8
|
-
def initialize(json)
|
|
9
|
-
validate_and_set(json)
|
|
10
|
-
@bootstrap = json[:bootstrap] ? json[:bootstrap] : false
|
|
11
|
-
@success_exit_codes = json[:success_exit_codes]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def json_attributes
|
|
15
|
-
[:cmd]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/orchestrator/factory.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module Bcome::Orchestrator
|
|
2
|
-
module Factory
|
|
3
|
-
|
|
4
|
-
class << self
|
|
5
|
-
def create_recipes_from_json(json, node_targets, all_machines, direct_commands)
|
|
6
|
-
validate_json_collection(json)
|
|
7
|
-
return json.collect{|instance_json| ::Bcome::Orchestrator::Recipe.new(instance_json, node_targets, all_machines, direct_commands) }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def create_command_groups_from_json(json, node_targets, all_machines, direct_commands)
|
|
11
|
-
validate_json_collection(json)
|
|
12
|
-
return json.collect{|instance_json| ::Bcome::Orchestrator::CommandGroup::Base.new_of_type_from(instance_json, node_targets, all_machines, direct_commands) }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def create_node_targets_from_json(json, machines)
|
|
16
|
-
validate_json_collection(json)
|
|
17
|
-
user_defined_targets = json.collect{|instance_json| ::Bcome::Orchestrator::NodeTarget::Base.new_of_type_from(instance_json, machines) }
|
|
18
|
-
return user_defined_targets + system_node_targets(machines)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def system_node_targets(machines)
|
|
22
|
-
[
|
|
23
|
-
::Bcome::Orchestrator::NodeTarget::All.new(:node_selections => machines, :target_key => "all")
|
|
24
|
-
]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def create_direct_commands_from_json(json)
|
|
28
|
-
validate_json_collection(json)
|
|
29
|
-
return json.collect{|instance_json| ::Bcome::Orchestrator::DirectCommand::Group.new(instance_json) }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def validate_json_collection(json)
|
|
33
|
-
raise "Cannot create Orchestrator recipes - expecting a JSON array" unless json.is_a?(Array)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
end
|
data/lib/orchestrator/loader.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
module Bcome::Orchestrator
|
|
2
|
-
class Loader
|
|
3
|
-
|
|
4
|
-
def initialize(machines, registry_for_context)
|
|
5
|
-
@recipes_path = "#{config_path}/recipes.yml"
|
|
6
|
-
@machine_targets_path = "#{config_path}/node_target_selectors.yml"
|
|
7
|
-
@direct_commands_path = "#{config_path}/direct_command_sets.yml"
|
|
8
|
-
@machines = machines
|
|
9
|
-
@registry_for_context = registry_for_context
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def config_path
|
|
13
|
-
defined?(::OrchestratorResource::CONFIG_PATH) ? ::OrchestratorResource::CONFIG_PATH : "#{Dir.pwd}/bcome/config/orchestration"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def recipes
|
|
17
|
-
@recipes ||= ::Bcome::Orchestrator::Factory.create_recipes_from_json(do_load_recipes, node_targets, @machines, direct_commands)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def node_targets
|
|
21
|
-
@node_targets ||= ::Bcome::Orchestrator::Factory.create_node_targets_from_json(do_load_machine_targets, @machines)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def direct_commands
|
|
25
|
-
@direct_commands ||= ::Bcome::Orchestrator::Factory.create_direct_commands_from_json(do_load_direct_commands)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def do_load_recipes
|
|
29
|
-
return json_from_file(@recipes_path).select{|r| @registry_for_context.include?(r[:recipe_identifier]) }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def do_load_direct_commands
|
|
33
|
-
return json_from_file(@direct_commands_path)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def do_load_machine_targets
|
|
37
|
-
return json_from_file(@machine_targets_path)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def json_from_file(file_path)
|
|
41
|
-
raise "Cannot load file #{file_path}" unless File.exist?(file_path)
|
|
42
|
-
file_contents = File.read(file_path)
|
|
43
|
-
return YAML.load(file_contents)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::NodeTarget
|
|
2
|
-
class All < ::Bcome::Orchestrator::NodeTarget::Base
|
|
3
|
-
|
|
4
|
-
def initialize(params)
|
|
5
|
-
@node_selections = params[:node_selections]
|
|
6
|
-
@target_key = params[:target_key]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def override_validate_and_set?
|
|
10
|
-
true
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module ::Bcome::Orchestrator::NodeTarget
|
|
2
|
-
class AllExcludingRoles < ::Bcome::Orchestrator::NodeTarget::Base
|
|
3
|
-
|
|
4
|
-
def set_machines(machines)
|
|
5
|
-
exclusion_roles = @selectors[:exclusion_roles]
|
|
6
|
-
raise "No exclusion roles set for node target of type all_excluding_roles" unless exclusion_roles
|
|
7
|
-
|
|
8
|
-
@node_selections = machines.select{|machine|
|
|
9
|
-
!exclusion_roles.include?(machine.role)
|
|
10
|
-
}
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
end
|