corl 0.4.16 → 0.4.17

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.
@@ -9,13 +9,19 @@ class Plugin < ::Vagrant.plugin('2')
9
9
 
10
10
  name '[C]oral [O]rchestration and [R]esearch [L]ibrary'
11
11
  description 'The `corl` plugin provides an easy way to develop and test CORL networks locally from within Vagrant.'
12
-
13
- @@command_dir = File.join(File.dirname(__FILE__), 'commands')
14
- @@provisioner_dir = File.join(File.dirname(__FILE__), 'provisioner')
12
+
13
+ @@directory = File.dirname(__FILE__)
14
+ @@action_dir = File.join(@@directory, 'actions')
15
+ @@command_dir = File.join(@@directory, 'commands')
16
+ @@provisioner_dir = File.join(@@directory, 'provisioner')
17
+
18
+ #---
19
+
20
+ nucleon_require(@@directory, :action)
21
+ nucleon_require(@@command_dir, :launcher)
15
22
 
16
23
  # Commands (only one, which launches Nucleon actions)
17
- command(:corl) do
18
- nucleon_require(@@command_dir, :launcher)
24
+ command(:corl) do
19
25
  Command::Launcher # Meta command for action launcher
20
26
  end
21
27
 
@@ -28,6 +34,22 @@ class Plugin < ::Vagrant.plugin('2')
28
34
  nucleon_require(@@provisioner_dir, :provisioner)
29
35
  Provisioner::CORL
30
36
  end
37
+
38
+ # Action hooks
39
+ action_hook 'init-keys', :machine_action_up do |hook|
40
+ nucleon_require(@@action_dir, :init_keys)
41
+ hook.after Vagrant::Action::Builtin::WaitForCommunicator, Action::InitKeys
42
+ end
43
+
44
+ action_hook 'create-shares', :machine_action_up do |hook|
45
+ nucleon_require(@@action_dir, :create_shares)
46
+ hook.after Action::InitKeys, Action::CreateShares
47
+ end
48
+
49
+ action_hook 'delete-cache', :machine_action_destroy do |hook|
50
+ nucleon_require(@@action_dir, :delete_cache)
51
+ hook.after Vagrant::Action::Builtin::ProvisionerCleanup, Action::DeleteCache
52
+ end
31
53
  end
32
54
  end
33
55
  end
@@ -9,31 +9,70 @@ class CORL < ::Vagrant.plugin("2", :config)
9
9
 
10
10
  def initialize
11
11
  super
12
- @network_path = UNSET_VALUE
13
- @network = UNSET_VALUE
14
- @node = UNSET_VALUE
12
+ @network = UNSET_VALUE
13
+ @node = UNSET_VALUE
14
+
15
+ @force_updates = false
16
+ @user_home = UNSET_VALUE
17
+ @user_home_env_var = UNSET_VALUE
18
+
19
+ @root_user = UNSET_VALUE
20
+ @root_home = UNSET_VALUE
21
+
22
+ @bootstrap = false
23
+ @bootstrap_path = UNSET_VALUE
24
+ @bootstrap_glob = UNSET_VALUE
25
+ @bootstrap_init = UNSET_VALUE
26
+ @auth_files = UNSET_VALUE
27
+
28
+ @seed = false
29
+ @project_reference = UNSET_VALUE
30
+ @project_branch = UNSET_VALUE
31
+
32
+ @provision = true
33
+ @dry_run = false
15
34
  end
16
35
 
17
36
  #---
18
37
 
19
38
  def finalize!
20
39
  super
40
+ @user_home = nil if @user_home == UNSET_VALUE
41
+ @user_home_env_var = nil if @user_home_env_var == UNSET_VALUE
42
+
43
+ @root_user = nil if @root_user == UNSET_VALUE
44
+ @root_home = nil if @root_home == UNSET_VALUE
45
+
46
+ @bootstrap_path = nil if @bootstrap_path == UNSET_VALUE
47
+ @bootstrap_glob = nil if @bootstrap_glob == UNSET_VALUE
48
+ @bootstrap_init = nil if @bootstrap_init == UNSET_VALUE
49
+ @auth_files = nil if @auth_files == UNSET_VALUE
50
+
51
+ @project_reference = nil if @project_reference == UNSET_VALUE
52
+ @project_branch = nil if @project_branch == UNSET_VALUE
21
53
  end
22
54
 
23
55
  #-----------------------------------------------------------------------------
24
56
  # Property accessor / modifiers
25
57
 
26
- attr_accessor :network_path, :network, :node
58
+ attr_accessor :network, :node
59
+ attr_accessor :force_updates, :user_home, :user_home_env_var, :root_user, :root_home
60
+
61
+ attr_accessor :bootstrap, :bootstrap_path, :bootstrap_glob, :bootstrap_init, :auth_files
62
+ attr_accessor :seed, :project_reference, :project_branch
63
+ attr_accessor :provision, :dry_run
27
64
 
28
65
  #-----------------------------------------------------------------------------
29
66
  # Validation
30
67
 
31
68
  def validate(machine)
32
- errors = _detected_errors
69
+ errors = _detected_errors
70
+
71
+ # TODO: Validation (with action config validators)
72
+
33
73
  { "CORL provisioner" => errors }
34
74
  end
35
75
  end
36
76
  end
37
77
  end
38
78
  end
39
-
@@ -21,25 +21,51 @@ class CORL < ::Vagrant.plugin("2", :provisioner)
21
21
 
22
22
  def provision
23
23
  @machine.communicate.tap do |comm|
24
- network_path = config.network_path
25
- network = config.network
26
- node = config.node
27
-
28
- # Make sure the CORL network directory is properly set up
29
- comm.sudo("rm -Rf #{network_path}")
30
- comm.sudo("ln -s /vagrant #{network_path}")
24
+ unless ::CORL::Vagrant.command
25
+ # Hackish solution to ensure our code has access to Vagrant machines.
26
+ # This serves as a Vagrant VM manager.
27
+ ::CORL::Vagrant.command = Command::Launcher.new([], @machine.env)
28
+ end
29
+
30
+ network = config.network
31
+ node = config.node
31
32
 
32
- # Make sure the CORL SSH keys are allowed
33
- if node.public_key
34
- ssh_key = ::CORL::Util::Disk.read(node.public_key)
35
-
36
- if ssh_key && ! ssh_key.empty?
37
- comm.execute("echo '#{ssh_key}' > \$HOME/.ssh/authorized_keys")
38
- node.set_cache_setting(:use_private_key, true)
39
- end
33
+ if network && node
34
+ # Provision the server
35
+ network.init_node(node, clean(::CORL.config(:vagrant_node_init, {
36
+ :force => config.force_updates,
37
+ :home => config.user_home,
38
+ :home_env_var => config.user_home_env_var,
39
+ :root_user => config.root_user,
40
+ :root_home => config.root_home,
41
+ :bootstrap => config.bootstrap,
42
+ :bootstrap_path => config.bootstrap_path,
43
+ :bootstrap_glob => config.bootstrap_glob,
44
+ :bootstrap_init => config.bootstrap_init,
45
+ :auth_files => config.auth_files,
46
+ :seed => config.seed,
47
+ :project_reference => config.project_reference,
48
+ :project_branch => config.project_branch,
49
+ :provision => config.provision,
50
+ :dry_run => config.dry_run
51
+ }).export))
40
52
  end
41
53
  end
42
54
  end
55
+
56
+ #-----------------------------------------------------------------------------
57
+ # Utilities
58
+
59
+ def clean(options)
60
+ options.keys.each do |key|
61
+ value = options[key]
62
+ if value.nil?
63
+ options.delete(key)
64
+ end
65
+ end
66
+ options
67
+ end
68
+ protected :clean
43
69
  end
44
70
  end
45
71
  end
data/lib/corl.rb CHANGED
@@ -15,6 +15,7 @@
15
15
 
16
16
  lib_dir = File.dirname(__FILE__)
17
17
  core_dir = File.join(lib_dir, 'core')
18
+ mod_dir = File.join(core_dir, 'mod')
18
19
  mixin_dir = File.join(core_dir, 'mixin')
19
20
  mixin_action_dir = File.join(mixin_dir, 'action')
20
21
  macro_dir = File.join(mixin_dir, 'macro')
@@ -27,10 +28,6 @@ vagrant_dir = File.join(core_dir, 'vagrant')
27
28
 
28
29
  $:.unshift(lib_dir) unless $:.include?(lib_dir) || $:.include?(File.expand_path(lib_dir))
29
30
 
30
- #---
31
-
32
- require 'rubygems'
33
-
34
31
  require 'nucleon_base'
35
32
  CORL = Nucleon
36
33
 
@@ -50,6 +47,11 @@ I18n.load_path << File.expand_path(File.join('..', 'locales', 'en.yml'), lib_dir
50
47
  #-------------------------------------------------------------------------------
51
48
  # Include CORL libraries
52
49
 
50
+ # Monkey patches (depreciate as fast as possible)
51
+ nucleon_require(mod_dir, :facter_loader)
52
+
53
+ #---
54
+
53
55
  # Mixins for classes
54
56
  Dir.glob(File.join(mixin_dir, '*.rb')).each do |file|
55
57
  require file
@@ -5,8 +5,8 @@ begin
5
5
  # Load network if it exists
6
6
  if CORL.admin?
7
7
  network_path = Facter.value("corl_network")
8
- network_config = CORL.config(:network, { :directory => network_path, :name => network_path })
9
- network = CORL.network(CORL.sha1(network_config), network_config, :default)
8
+ network_config = CORL.config(:network, { :directory => network_path })
9
+ network = CORL.network(network_path, network_config, :default)
10
10
 
11
11
  if network && node = network.local_node
12
12
  Facter.add(:corl_provider) do
@@ -37,7 +37,10 @@ This function returns the string-ified form of a given value.
37
37
  config = CORL::Config.init_flat(options, contexts, default_options)
38
38
  end
39
39
 
40
- value = CORL.template(config, provider).render(data)
40
+ template = CORL.template(config, provider)
41
+ value = template.render(data)
42
+
43
+ CORL.remove_plugin(template)
41
44
 
42
45
  if config.get(:debug, false)
43
46
  CORL.ui.info("\n", { :prefix => false })
data/locales/en.yml CHANGED
@@ -161,6 +161,9 @@ en:
161
161
  stop:
162
162
  start: |-
163
163
  Stopping %{provider} machine %{name}
164
+ reboot:
165
+ start: |-
166
+ Rebooting %{provider} machine %{name}
164
167
  destroy:
165
168
  start: |-
166
169
  Destroying %{provider} machine %{name}
@@ -173,3 +176,15 @@ en:
173
176
  Whether or not to build the provisioner catalog without configuring the system (default %{default_value})
174
177
  start: |-
175
178
  Starting provision run
179
+ vagrant:
180
+ actions:
181
+ init_keys:
182
+ start: |-
183
+ Initializing CORL development keys...
184
+ create_shares:
185
+ start: |-
186
+ Creating CORL specific shares...
187
+ delete_cache:
188
+ start: |-
189
+ Clearing CORL cache for this machine...
190
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Webb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nucleon
@@ -232,6 +232,7 @@ files:
232
232
  - lib/CORL/action/lookup.rb
233
233
  - lib/CORL/action/machines.rb
234
234
  - lib/CORL/action/provision.rb
235
+ - lib/CORL/action/reboot.rb
235
236
  - lib/CORL/action/regions.rb
236
237
  - lib/CORL/action/seed.rb
237
238
  - lib/CORL/action/spawn.rb
@@ -257,6 +258,7 @@ files:
257
258
  - lib/core/mixin/action/keypair.rb
258
259
  - lib/core/mixin/lookup.rb
259
260
  - lib/core/mixin/macro/network_settings.rb
261
+ - lib/core/mod/facter_loader.rb
260
262
  - lib/core/mod/fog_aws_server.rb
261
263
  - lib/core/mod/fog_rackspace_server.rb
262
264
  - lib/core/mod/hiera_backend.rb
@@ -272,6 +274,10 @@ files:
272
274
  - lib/core/util/puppet/resource.rb
273
275
  - lib/core/util/puppet/resource_group.rb
274
276
  - lib/core/vagrant/Vagrantfile
277
+ - lib/core/vagrant/action.rb
278
+ - lib/core/vagrant/actions/create_shares.rb
279
+ - lib/core/vagrant/actions/delete_cache.rb
280
+ - lib/core/vagrant/actions/init_keys.rb
275
281
  - lib/core/vagrant/commands/launcher.rb
276
282
  - lib/core/vagrant/config.rb
277
283
  - lib/core/vagrant/plugins.rb