bcome 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d99a4af143d2075b4f499a92601ccc27a94dd96
4
- data.tar.gz: 282f22fcfc8fd304bd8f860ee1a727d42e26ab2a
3
+ metadata.gz: 65790bceb47d5870e33e4879362c00a154a06326
4
+ data.tar.gz: 2f940a8ee313e71752f66ed852048b3d48c6ad46
5
5
  SHA512:
6
- metadata.gz: dd94a30b7aa4c68c3735bf3c60e788745bd330723823cb8e62fd9458175a4185dd359835ccaa6e3373ea0f13e20645ddbaa9b081da29e831169a85e0f47b2bac
7
- data.tar.gz: 44daa435ece36665e1cc1c9e9e9abe4cdd9412ab6119fb41fa7ba9e5fb31c214c304bb042ad4c52b3a88100d8b37646c93912c737f4f519660bbeb17c84f15c8
6
+ metadata.gz: eb5e1c75221c5145890bae1c75112e82d8ff6ccdfa2b078bf7a7eb15f01230aeafdb9f8c4fe33458b36fb0f25669a49e2e4a807c84a8db476ea0b0b6783f36ba
7
+ data.tar.gz: 2c96b8e049ad3b1c18562670a9ed5fb419ce362572a442cc8ec96b4be9ffcaeded6cc9ed0e630afa22dd9e0c4beac041b05d72db8b5d3e44162d2b81f15b66a6
data/bin/bcome CHANGED
@@ -3,109 +3,14 @@
3
3
  # (C) Guillaume Roderick (webzakimbo)
4
4
  # MIT licence.
5
5
 
6
+ ## Load & Boot into namespace
7
+ require 'irb'
8
+ require "irb/completion"
6
9
  require 'bcome'
7
- Dir[Dir.pwd + "/bcome/patches/**/*.rb"].each {|file| load file }
8
10
 
9
- VERBOSE = true
10
- START_PROMPT = "bcome"
11
-
12
- # The ssh_mode identifier in platforms.yml signifying that this platform is to be accessed via an SSH bastion machine
13
- SSH_JUMP_MODE_IDENTIFIER = "jump"
14
-
15
- # The ssh mode identifier in platforms.yml signifying that this platform is to be accessed directly
16
- SSH_DIRECT_MODE_IDENTIFIER = "direct"
17
-
18
- # The SSH role in instances.yml signifying that an instance is an SSJ jump host
19
- SSH_JUMP_HOST_ROLE_IDENTIFIER = "sshjumphost"
20
-
21
- ## The base resource classes - may be overriden
22
- PLATFORM_STACK_KLASS = ::Bcome::Stack::Platform
23
- ENV_STACK_KLASS = ::Bcome::Stack::Environment
24
- INSTANCE_STACK_KLASS = ::Bcome::Stack::Instance
25
-
26
- ##################
27
- ## DEPENDENCIES ##
28
- ##################
29
-
30
- ## Filters are loaded lower down as modules, and hence need to be include first
31
- Dir[Dir.pwd + "/bcome/filters/**/*.rb"].each {|file| load file }
32
-
33
- quick_contexts = []
34
-
35
- BECOME = ::Bcome::WorkspaceContext.new
36
- ESTATE = ::Bcome::Stack::Estate.new
37
- RENDER = ::Bcome::RenderIrb.new
38
-
39
- ###########################
40
- ## MANAGE QUICK CONTEXTS #
41
- ###########################
42
- if ARGV[0]
43
- quick_context = ARGV[0]
44
- quick_context =~ /(.+):(.+)/
45
- platform_key = $1
46
- context_reference = $2
47
-
48
- unless platform_key && context_reference
49
- puts "Quick context is missing platform key or the context reference".failure
50
- exit 1
51
- end
52
-
53
- unless platform = ESTATE.resource_for_identifier(platform_key)
54
- puts "Cannot find platform named #{platform_key}".failure
55
- exit
56
- end
57
-
58
- unless platform.has_quick_contexts? && (context = platform.quick_context_for_reference(context_reference))
59
- puts "No quick context found on platform #{platform_key} for reference #{context_reference}".failure
60
- exit
61
- end
62
-
63
- quick_contexts = context[:keys]
64
- end
65
-
66
- ####################
67
- ## BASIC IRB SETUP #
68
- ####################
69
- IRB.setup nil
70
- IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
71
-
72
- #########################
73
- ## QUICK CONTEXT & BOOT #
74
- #########################
75
-
76
- context_object = ESTATE
77
-
78
- if quick_contexts.any?
79
-
80
- is_first_context = true
81
-
82
- spawn = false
83
- quick_contexts.each do |resource_context_key|
84
- next_context_resource = context_object.resource_for_identifier(resource_context_key)
85
-
86
- # Initialize our object namespace, but only from our lowest level namespace object. This
87
- # ensure we don't load more than we need.
88
- if is_first_context
89
- next_context_resource.init
90
- is_first_context = false
91
- end
92
-
93
- if next_context_resource.nil?
94
- puts "Cannot find any resources object named: #{resource_context_key}. Please check your quick contexts and try again".failure
95
- exit
96
- end
97
-
98
- BECOME.set(next_context_resource, context_object, spawn)
99
- context_object = next_context_resource
100
- end
101
- else
102
- ESTATE.init
103
- end
104
-
105
- ##################
106
- ## INIT SESSION ##
107
- ##################
11
+ load Bcome::Boot.boot_path
108
12
 
13
+ ## Load the shell
109
14
  require 'irb/ext/multi-irb'
110
15
  IRB.parse_opts_with_ignoring_script
111
- IRB.irb nil, context_object
16
+ IRB.irb nil, @context_object
@@ -0,0 +1,108 @@
1
+
2
+ ### Boot up bcome - used by the shell & exterior bcome processes
3
+
4
+ unless @no_shell
5
+ Dir[Dir.pwd + "/bcome/patches/**/*.rb"].each {|file| load file }
6
+ end
7
+
8
+ VERBOSE = true
9
+ START_PROMPT = "bcome"
10
+
11
+ # The ssh_mode identifier in platforms.yml signifying that this platform is to be accessed via an SSH bastion machine
12
+ SSH_JUMP_MODE_IDENTIFIER = "jump"
13
+
14
+ # The ssh mode identifier in platforms.yml signifying that this platform is to be accessed directly
15
+ SSH_DIRECT_MODE_IDENTIFIER = "direct"
16
+
17
+ # The SSH role in instances.yml signifying that an instance is an SSJ jump host
18
+ SSH_JUMP_HOST_ROLE_IDENTIFIER = "sshjumphost"
19
+
20
+ ## The base resource classes - may be overriden
21
+ PLATFORM_STACK_KLASS = ::Bcome::Stack::Platform
22
+ ENV_STACK_KLASS = ::Bcome::Stack::Environment
23
+ INSTANCE_STACK_KLASS = ::Bcome::Stack::Instance
24
+
25
+ ##################
26
+ ## DEPENDENCIES ##
27
+ ##################
28
+
29
+ ## Filters are loaded lower down as modules, and hence need to be include first
30
+ Dir[Dir.pwd + "/bcome/filters/**/*.rb"].each {|file| load file }
31
+
32
+ quick_contexts = []
33
+
34
+ BECOME = ::Bcome::WorkspaceContext.new
35
+ ESTATE = ::Bcome::Stack::Estate.new
36
+ RENDER = ::Bcome::RenderIrb.new
37
+
38
+ ###########################
39
+ ## MANAGE QUICK CONTEXTS #
40
+ ###########################
41
+
42
+ quick_context = @bcome_context ? @bcome_context : ARGV[0]
43
+
44
+ if quick_context
45
+ quick_context =~ /(.+):(.+)/
46
+ platform_key = $1
47
+ context_reference = $2
48
+
49
+ unless platform_key && context_reference
50
+ puts "Quick context is missing platform key or the context reference".failure
51
+ exit 1
52
+ end
53
+
54
+ unless platform = ESTATE.resource_for_identifier(platform_key)
55
+ puts "Cannot find platform named #{platform_key}".failure
56
+ exit
57
+ end
58
+
59
+ unless platform.has_quick_contexts? && (context = platform.quick_context_for_reference(context_reference))
60
+ puts "No quick context found on platform #{platform_key} for reference #{context_reference}".failure
61
+ exit
62
+ end
63
+
64
+ quick_contexts = context[:keys]
65
+ end
66
+
67
+ #########################
68
+ ## QUICK CONTEXT & BOOT #
69
+ #########################
70
+
71
+ @context_object = ESTATE
72
+
73
+ unless @no_shell
74
+ IRB.setup nil
75
+ IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
76
+ end
77
+
78
+ if quick_contexts.any?
79
+ is_first_context = true
80
+
81
+ spawn = false
82
+ quick_contexts.each do |resource_context_key|
83
+ next_context_resource = @context_object.resource_for_identifier(resource_context_key)
84
+
85
+ # Initialize our object namespace, but only from our lowest level namespace object. This
86
+ # ensures that we don't load more than we need.
87
+ if is_first_context
88
+ next_context_resource.init
89
+ is_first_context = false
90
+ end
91
+
92
+ if next_context_resource.nil?
93
+ puts "Cannot find any resources object named: #{resource_context_key}. Please check your quick contexts and try again".failure
94
+ exit
95
+ end
96
+
97
+ unless @no_shell
98
+ BECOME.set(next_context_resource, @context_object, spawn)
99
+ end
100
+
101
+ @context_object = next_context_resource
102
+ end
103
+
104
+ B_PIN = @context_object
105
+ B_PIN.init
106
+ else
107
+ ESTATE.init
108
+ end
@@ -1,5 +1,3 @@
1
- require 'irb'
2
- require "irb/completion"
3
1
  require 'colorize'
4
2
  require 'aws-sdk'
5
3
  require 'net/scp'
@@ -1,3 +1,3 @@
1
1
  module Bcome
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,9 @@
1
+ module Bcome
2
+ class Boot
3
+
4
+ def self.boot_path
5
+ return "#{File.dirname(__FILE__)}/../bin/boot.rb"
6
+ end
7
+
8
+ end
9
+ end
@@ -65,6 +65,10 @@ module ::Bcome::EnvironmentSSH
65
65
  return @ssh_mode[:ssh_user]
66
66
  end
67
67
 
68
+ def ssh_user
69
+ (@ssh_mode && ssh_mode_user) ? ssh_mode_user : `whoami`.gsub("\n","")
70
+ end
71
+
68
72
  def ssh_nat_user
69
73
  return @ssh_mode[:nat_user]
70
74
  end
@@ -3,7 +3,6 @@ module ::Bcome::Node
3
3
 
4
4
  include ::Bcome::InstanceCommand
5
5
  include ::Bcome::InstanceSsh
6
- include ::Bcome::InstanceCommand
7
6
 
8
7
  def machines
9
8
  [self] # for completion
@@ -31,7 +31,7 @@ module ::Bcome::Stack
31
31
  end
32
32
 
33
33
  def init
34
- puts "loading resources ... "
34
+ puts "loading resources #{self.class} "
35
35
  node
36
36
  end
37
37
 
@@ -3,6 +3,7 @@ module ::Bcome::Stack
3
3
 
4
4
  include ::Bcome::BecomeObject
5
5
  include ::Bcome::Functions
6
+ include ::Bcome::InstanceCommand
6
7
 
7
8
  class << self
8
9
  def collection_from_fog_data(parent, fog_instances)
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.0.8
4
+ version: 0.0.9
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: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -114,6 +114,7 @@ extra_rdoc_files: []
114
114
  files:
115
115
  - bin/bcome
116
116
  - bin/bcome-setup
117
+ - bin/boot.rb
117
118
  - documentation/configuration.md
118
119
  - documentation/examples/functions.yml-example
119
120
  - documentation/examples/network.yml-example
@@ -125,6 +126,7 @@ files:
125
126
  - lib/bcome.rb
126
127
  - lib/bcome/version.rb
127
128
  - lib/become_object.rb
129
+ - lib/boot.rb
128
130
  - lib/command.rb
129
131
  - lib/filters/base.rb
130
132
  - lib/filters/ec2_filter.rb