bcome 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bcome +16 -11
- data/bin/boot.rb +25 -23
- data/lib/bcome/version.rb +1 -1
- data/lib/become_object.rb +5 -0
- data/lib/helpers/fog_helper.rb +13 -2
- data/lib/workspace_context.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f21306ed54b699575e5cf11b63eeb0b0652775c
|
4
|
+
data.tar.gz: e70fdd58135f553d8544a2e3dae7fbfaeb2f9b99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec8d0eaff4dc3240adf07a45e4bea4dc9f67cacc3706b73bf5431749b2c39dcfa4285cc298bb50ee60af068f76ec327633f19025432df9e562f778aa0b2fd790
|
7
|
+
data.tar.gz: 5669e33e6261e4dacf18535f473627581452329b9d04d0f39cc0348faf5c77ae2f624337393f87ce9436a85c628690c3d18205a43e31da4ded6731d904564d76
|
data/bin/bcome
CHANGED
@@ -14,22 +14,27 @@ load Bcome::Boot.boot_path
|
|
14
14
|
unless @no_shell
|
15
15
|
require 'irb/ext/multi-irb'
|
16
16
|
IRB.parse_opts_with_ignoring_script
|
17
|
-
|
17
|
+
irb_method = (@direct_command && @direct_shell_commands.include?(@direct_command)) ? @direct_command.to_sym : nil
|
18
|
+
IRB.irb irb_method, @context_object
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
if @direct_command && @direct_command_on
|
22
|
+
if @direct_command == "ssh"
|
23
|
+
## We're SSH'ing directly to a node, indicated by an 'ssh' key at the end of our context breadcrumb
|
24
|
+
# called with, e.g. bcome platform:environment:node_name:ssh
|
25
|
+
@direct_command_on.node.ssh
|
26
|
+
elsif @direct_command == "run"
|
27
|
+
## We're directly excuting a command on a n node indicated by a 'run' key at the end of our context breadrumb
|
28
|
+
# called with, e.g. bcome platform:environment:node_name:run "command to execute"
|
29
|
+
params = ARGV[(1..(ARGV.size))].join("\s")
|
30
|
+
@direct_command_on.node.run(params)
|
31
|
+
else
|
32
|
+
@direct_command_on.send(@direct_command)
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
## We're going to directly execute a command on a node, indicated by the method name at the end of our context breadcrumb.
|
32
37
|
## This works for commands specified in the users own personal framework installation, either from a context command or from an orchestration hook
|
33
38
|
## e,g, bcome platform:environment:node_name:bootstrap
|
34
|
-
@context_object.send(@direct_execute_method) if @direct_execute_method
|
39
|
+
@context_object.send(@direct_execute_method) if @context_object && @direct_execute_method
|
35
40
|
|
data/bin/boot.rb
CHANGED
@@ -4,7 +4,6 @@ extensions_init_path = "#{Dir.pwd}/bcome/extensions_initializer.rb"
|
|
4
4
|
load extensions_init_path if File.exist?(extensions_init_path)
|
5
5
|
|
6
6
|
### Boot up bcome - used by the shell & exterior bcome processes
|
7
|
-
|
8
7
|
unless @no_shell
|
9
8
|
Dir[Dir.pwd + "/bcome/patches/**/*.rb"].each {|file| load file }
|
10
9
|
end
|
@@ -67,9 +66,9 @@ if quick_context
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
direct_commands = ["run", "ssh"]
|
71
|
-
|
72
|
-
@no_shell = true if direct_commands.include?(quick_contexts.last)
|
69
|
+
direct_commands = ["run", "ssh", "interactive"] # direct command executions that do not require an irb shell
|
70
|
+
@direct_shell_commands = ["interactive"] # where we need to jump into a context method directly, but require an irb shell
|
71
|
+
@no_shell = true if (direct_commands - @direct_shell_commands).include?(quick_contexts.last)
|
73
72
|
|
74
73
|
#########################
|
75
74
|
## QUICK CONTEXT & BOOT #
|
@@ -90,15 +89,13 @@ if quick_contexts.any?
|
|
90
89
|
spawn = false
|
91
90
|
quick_contexts.each_with_index do |resource_context_key, index|
|
92
91
|
|
93
|
-
if resource_context_key
|
94
|
-
@
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
@run_cmd = true
|
101
|
-
@run_on = @context_object
|
92
|
+
if direct_commands.include?(resource_context_key) && (index == (quick_contexts.size - 1))
|
93
|
+
unless @context_object.respond_to?(resource_context_key.to_sym)
|
94
|
+
puts "You cannot invoke '#{resource_context_key}' at this namespace level".danger
|
95
|
+
exit!
|
96
|
+
end
|
97
|
+
@direct_command = resource_context_key
|
98
|
+
@direct_command_on = @context_object
|
102
99
|
break
|
103
100
|
end
|
104
101
|
|
@@ -109,10 +106,9 @@ if quick_contexts.any?
|
|
109
106
|
# orchestration on it).
|
110
107
|
# e.g. you have a context command called 'deploy'. You may want to do the following:
|
111
108
|
# bcome platform:environment:deploy
|
112
|
-
|
113
109
|
unless next_context_resource && index <= (quick_contexts.size - 1)
|
114
110
|
if @context_object.respond_to_bcome_context_method?(resource_context_key.to_sym)
|
115
|
-
@no_shell = true
|
111
|
+
@no_shell = true
|
116
112
|
@direct_execute_method = resource_context_key.to_sym
|
117
113
|
break
|
118
114
|
end
|
@@ -126,19 +122,25 @@ if quick_contexts.any?
|
|
126
122
|
end
|
127
123
|
|
128
124
|
if next_context_resource.nil?
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
125
|
+
if @context_object.respond_to?(resource_context_key)
|
126
|
+
@context_object.send(resource_context_key)
|
127
|
+
exit!
|
128
|
+
else
|
129
|
+
puts "Cannot find any resource object named: #{resource_context_key}. Please check your breadcrumb and try again".failure
|
130
|
+
if @context_object.responds_to_list?
|
131
|
+
puts "\nYou may have been attempting to key into one of the following: ".failure
|
132
|
+
puts @context_object.mini_list + "\n"
|
133
|
+
end
|
134
|
+
exit!
|
135
|
+
end
|
135
136
|
end
|
136
137
|
|
138
|
+
BECOME.set(next_context_resource, @context_object, spawn) unless @no_shell
|
137
139
|
@context_object = next_context_resource
|
138
140
|
end
|
139
|
-
|
141
|
+
|
140
142
|
B_PIN = @context_object
|
141
|
-
B_PIN.init
|
143
|
+
B_PIN.init
|
142
144
|
else
|
143
145
|
B_PIN = ESTATE
|
144
146
|
ESTATE.init
|
data/lib/bcome/version.rb
CHANGED
data/lib/become_object.rb
CHANGED
@@ -91,6 +91,11 @@ module ::Bcome::BecomeObject
|
|
91
91
|
true
|
92
92
|
end
|
93
93
|
|
94
|
+
def mini_list
|
95
|
+
raise "Namespace does not respond to list" unless responds_to_list?
|
96
|
+
return resources.collect(&:identifier).join(", ").friendly
|
97
|
+
end
|
98
|
+
|
94
99
|
def list
|
95
100
|
if responds_to_list?
|
96
101
|
::RENDER.list_items(collection_key, resources)
|
data/lib/helpers/fog_helper.rb
CHANGED
@@ -7,9 +7,20 @@ module ::Bcome::FogHelper
|
|
7
7
|
def fog_client
|
8
8
|
@fog_client ||= get_fog_client
|
9
9
|
end
|
10
|
+
|
11
|
+
def ec2_filters
|
12
|
+
network_lookup[:ec2_server_lookup_filters] ? network_lookup[:ec2_server_lookup_filters] : { 'instance-id' => [] }
|
13
|
+
end
|
14
|
+
|
15
|
+
def reload!
|
16
|
+
@unfiltered_servers = fog_client.servers.all(ec2_filters)
|
17
|
+
@resources = do_load_resources
|
18
|
+
system("clear")
|
19
|
+
list
|
20
|
+
end
|
10
21
|
|
11
22
|
def unfiltered_servers
|
12
|
-
@unfiltered_servers ||= fog_client.servers.all(
|
23
|
+
@unfiltered_servers ||= fog_client.servers.all(ec2_filters)
|
13
24
|
end
|
14
25
|
|
15
26
|
def ec2_tags
|
@@ -24,7 +35,7 @@ module ::Bcome::FogHelper
|
|
24
35
|
|
25
36
|
if custom_filter_method
|
26
37
|
filter = ::Bcome::Filter::Ec2Filter.new(filtered_by_tags, self)
|
27
|
-
raise "
|
38
|
+
raise "Custom filter method #{custom_filter_method} is missing. Make sure you've added it".failure unless filter.respond_to?(custom_filter_method.to_sym)
|
28
39
|
return filter.send(custom_filter_method.to_sym)
|
29
40
|
else
|
30
41
|
return filtered_by_tags
|
data/lib/workspace_context.rb
CHANGED
@@ -5,6 +5,7 @@ class ::Bcome::WorkspaceContext
|
|
5
5
|
def set(object, current_object, spawn = true)
|
6
6
|
@object = object
|
7
7
|
main_context = IRB.conf[:MAIN_CONTEXT]
|
8
|
+
|
8
9
|
@object.main_context = main_context.workspace if main_context
|
9
10
|
@object.previous_workspace_object = current_object if current_object
|
10
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Roderick (Webzakimbo)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|