corl 0.4.15 → 0.4.16

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.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +6 -1
  3. data/Gemfile.lock +76 -30
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/bootstrap/bootstrap.sh +5 -2
  7. data/bootstrap/os/ubuntu/00_base.sh +1 -1
  8. data/bootstrap/os/ubuntu/01_git.sh +9 -0
  9. data/bootstrap/os/ubuntu/05_ruby.sh +7 -4
  10. data/bootstrap/os/ubuntu/06_puppet.sh +2 -2
  11. data/corl.gemspec +23 -9
  12. data/lib/CORL/action/authorize.rb +2 -5
  13. data/lib/CORL/action/bootstrap.rb +1 -5
  14. data/lib/CORL/action/build.rb +2 -10
  15. data/lib/CORL/action/destroy.rb +2 -7
  16. data/lib/CORL/action/exec.rb +1 -5
  17. data/lib/CORL/action/image.rb +1 -5
  18. data/lib/CORL/action/images.rb +12 -10
  19. data/lib/CORL/action/ip.rb +21 -0
  20. data/lib/CORL/action/lookup.rb +5 -3
  21. data/lib/CORL/action/machines.rb +12 -10
  22. data/lib/CORL/action/provision.rb +4 -7
  23. data/lib/CORL/action/regions.rb +12 -10
  24. data/lib/CORL/action/seed.rb +9 -10
  25. data/lib/CORL/action/spawn.rb +29 -15
  26. data/lib/CORL/action/ssh.rb +1 -5
  27. data/lib/CORL/action/start.rb +1 -5
  28. data/lib/CORL/action/stop.rb +1 -5
  29. data/lib/CORL/action/vagrantfile.rb +55 -0
  30. data/lib/CORL/configuration/file.rb +4 -1
  31. data/lib/CORL/machine/physical.rb +1 -1
  32. data/lib/CORL/machine/vagrant.rb +358 -0
  33. data/lib/CORL/node/local.rb +2 -3
  34. data/lib/CORL/node/vagrant.rb +238 -0
  35. data/lib/core/facade.rb +25 -2
  36. data/lib/core/mixin/macro/network_settings.rb +35 -1
  37. data/lib/core/plugin/action.rb +53 -5
  38. data/lib/core/plugin/configuration.rb +19 -5
  39. data/lib/core/plugin/fog_machine.rb +1 -1
  40. data/lib/core/plugin/fog_node.rb +9 -9
  41. data/lib/core/plugin/machine.rb +6 -13
  42. data/lib/core/plugin/network.rb +23 -7
  43. data/lib/core/plugin/node.rb +69 -36
  44. data/lib/core/plugin/provisioner.rb +1 -2
  45. data/lib/core/vagrant/Vagrantfile +7 -0
  46. data/lib/core/vagrant/commands/launcher.rb +66 -0
  47. data/lib/core/vagrant/config.rb +308 -0
  48. data/lib/core/vagrant/plugins.rb +33 -0
  49. data/lib/core/vagrant/provisioner/config.rb +39 -0
  50. data/lib/core/vagrant/provisioner/provisioner.rb +46 -0
  51. data/lib/corl.rb +8 -0
  52. data/locales/en.yml +13 -1
  53. metadata +120 -59
@@ -8,8 +8,7 @@ class Provision < Plugin::CloudAction
8
8
 
9
9
  def configure
10
10
  super do
11
- codes :network_failure,
12
- :provision_failure
11
+ codes :provision_failure
13
12
 
14
13
  register :dry_run, :bool, false
15
14
  end
@@ -20,9 +19,9 @@ class Provision < Plugin::CloudAction
20
19
 
21
20
  def execute
22
21
  super do |node, network|
23
- if network && node
24
- info('corl.actions.provision.start')
25
-
22
+ info('corl.actions.provision.start')
23
+
24
+ ensure_node(node) do
26
25
  success = true
27
26
 
28
27
  if CORL.admin?
@@ -47,8 +46,6 @@ class Provision < Plugin::CloudAction
47
46
  myself.status = code.provision_failure unless success
48
47
  end
49
48
  end
50
- else
51
- myself.status = code.network_failure
52
49
  end
53
50
  end
54
51
  end
@@ -30,19 +30,21 @@ class Regions < Plugin::CloudAction
30
30
  super do |local_node, network|
31
31
  info('corl.actions.regions.start')
32
32
 
33
- if node = network.test_node(settings[:node_provider])
34
- if regions = node.regions
35
- regions.each do |region|
36
- render(sprintf("> %s", region), { :prefix => false })
37
- end
33
+ ensure_network(network) do
34
+ if node = network.test_node(settings[:node_provider])
35
+ if regions = node.regions
36
+ regions.each do |region|
37
+ render(sprintf("> %s", region), { :prefix => false })
38
+ end
38
39
 
39
- myself.result = regions
40
- success('corl.actions.regions.results', { :regions => regions.length }) if regions.length > 1
40
+ myself.result = regions
41
+ success('corl.actions.regions.results', { :regions => regions.length }) if regions.length > 1
42
+ else
43
+ myself.status = code.region_load_failure
44
+ end
41
45
  else
42
- myself.status = code.region_load_failure
46
+ myself.status = code.node_load_failure
43
47
  end
44
- else
45
- myself.status = code.node_load_failure
46
48
  end
47
49
  end
48
50
  end
@@ -49,7 +49,7 @@ class Seed < Plugin::CloudAction
49
49
  super do |node, network|
50
50
  info('corl.actions.seed.start')
51
51
 
52
- if node && network
52
+ ensure_node(node) do
53
53
  admin_exec do
54
54
  network_path = lookup(:corl_network)
55
55
  backup_path = File.join(Dir.tmpdir(), 'corl')
@@ -69,13 +69,14 @@ class Seed < Plugin::CloudAction
69
69
 
70
70
  render("Seeding network configuration from #{settings[:project_reference]}")
71
71
  project = CORL.project(extended_config(:project, {
72
- :directory => network_path,
73
- :reference => project_info.get(:reference, nil),
74
- :url => project_info.get(:url, settings[:project_reference]),
75
- :revision => project_info.get(:revision, settings[:project_branch]),
76
- :create => true,
77
- :pull => true,
78
- :keys => keys
72
+ :directory => network_path,
73
+ :reference => project_info.get(:reference, nil),
74
+ :url => project_info.get(:url, settings[:project_reference]),
75
+ :revision => project_info.get(:revision, settings[:project_branch]),
76
+ :create => true,
77
+ :pull => true,
78
+ :keys => keys,
79
+ :internal_ip => CORL.public_ip # Needed for seeding Vagrant VMs
79
80
  }), project_info[:provider])
80
81
 
81
82
  if project
@@ -105,8 +106,6 @@ class Seed < Plugin::CloudAction
105
106
  myself.status = code.key_store_failure
106
107
  end
107
108
  end
108
- else
109
- myself.status = code.network_load_failure
110
109
  end
111
110
  end
112
111
  end
@@ -10,23 +10,20 @@ class Spawn < Plugin::CloudAction
10
10
 
11
11
  def configure
12
12
  super do
13
- codes :network_failure,
14
- :key_failure,
13
+ codes :key_failure,
15
14
  :node_create_failure
16
15
 
17
16
  register :groups, :array, []
18
17
  register :region, :str, nil
19
18
  register :machine_type, :str, nil
20
19
  register :image, :str, nil
21
- register :user, :str, :root
20
+ register :user, :str, nil
22
21
  register :hostnames, :array, nil
23
22
 
24
23
  keypair_config
25
24
 
26
25
  config.defaults(CORL.action_config(:bootstrap))
27
26
  config.defaults(CORL.action_config(:seed))
28
-
29
- config[:project_reference].default = "github:::coraltech/cluster-test[master]"
30
27
  end
31
28
  end
32
29
 
@@ -45,18 +42,32 @@ class Spawn < Plugin::CloudAction
45
42
 
46
43
  def execute
47
44
  super do |node, network|
48
- info('corl.actions.spawn.start')
49
-
50
- if network
45
+ ensure_network(network) do
51
46
  if keypair && keypair_clean
52
47
  hostnames = []
53
48
  results = []
54
49
  node_provider = settings.delete(:node_provider)
55
50
 
51
+ if CORL.vagrant? && ! CORL.loaded_plugins(:node).keys.include?(node_provider.to_sym)
52
+ settings[:machine_type] = node_provider
53
+ settings[:user] = :vagrant unless settings[:user]
54
+ node_provider = :vagrant
55
+ end
56
+ unless settings[:user]
57
+ settings[:user] = :root
58
+ end
59
+
60
+ info('corl.actions.spawn.start', { :node_provider => node_provider })
61
+
56
62
  settings.delete(:hostnames).each do |hostname|
57
63
  hostnames << extract_hostnames(hostname)
58
64
  end
59
65
  hostnames.flatten.each do |hostname|
66
+ if hostname.is_a?(Hash)
67
+ settings[:public_ip] = hostname[:ip]
68
+ hostname = hostname[:hostname]
69
+ end
70
+
60
71
  if settings[:parallel]
61
72
  results << network.future.add_node(node_provider, hostname, settings)
62
73
  else
@@ -68,8 +79,6 @@ class Spawn < Plugin::CloudAction
68
79
  else
69
80
  myself.status = code.key_failure
70
81
  end
71
- else
72
- myself.status = code.network_failure
73
82
  end
74
83
  end
75
84
  end
@@ -82,14 +91,19 @@ class Spawn < Plugin::CloudAction
82
91
 
83
92
  if hostname.match(/([^\[]+)\[([^\]]+)\](.*)/)
84
93
  before = $1
85
- range = $2
94
+ extra = $2.strip
86
95
  after = $3
87
96
 
88
- low, high = range.split(/\s*\-\s*/)
89
- range = Range.new(low, high)
97
+ if extra.match(/\-/)
98
+ low, high = extra.split(/\s*\-\s*/)
99
+ range = Range.new(low, high)
90
100
 
91
- range.each do |item|
92
- hostnames << "#{before}#{item}#{after}"
101
+ range.each do |item|
102
+ hostnames << "#{before}#{item}#{after}"
103
+ end
104
+
105
+ elsif extra.match(/\d+\.\d+\.\d+\.\d+/)
106
+ hostnames = [ { :hostname => "#{before}#{after}", :ip => extra } ]
93
107
  end
94
108
  else
95
109
  hostnames = [ hostname ]
@@ -8,8 +8,6 @@ class Ssh < Plugin::CloudAction
8
8
 
9
9
  def configure
10
10
  super do
11
- codes :network_failure
12
-
13
11
  register :ssh_nodes, :array, nil do |values|
14
12
  if values.nil?
15
13
  warn('corl.actions.bootstrap.errors.ssh_nodes_empty')
@@ -49,7 +47,7 @@ class Ssh < Plugin::CloudAction
49
47
 
50
48
  def execute
51
49
  super do |local_node, network|
52
- if network
50
+ ensure_network(network) do
53
51
  batch_success = network.batch(settings[:ssh_nodes], settings[:node_provider], false) do |node|
54
52
  render_options = { :id => node.id, :hostname => node.hostname }
55
53
 
@@ -64,8 +62,6 @@ class Ssh < Plugin::CloudAction
64
62
  success
65
63
  end
66
64
  myself.status = code.batch_error unless batch_success
67
- else
68
- myself.status = code.network_failure
69
65
  end
70
66
  end
71
67
  end
@@ -8,8 +8,6 @@ class Start < Plugin::CloudAction
8
8
 
9
9
  def configure
10
10
  super do
11
- codes :network_failure
12
-
13
11
  register :start_nodes, :array, nil do |values|
14
12
  if values.nil?
15
13
  warn('corl.actions.start.errors.start_nodes_empty')
@@ -47,14 +45,12 @@ class Start < Plugin::CloudAction
47
45
 
48
46
  def execute
49
47
  super do |local_node, network|
50
- if network
48
+ ensure_network(network) do
51
49
  batch_success = network.batch(settings[:start_nodes], settings[:node_provider], settings[:parallel]) do |node|
52
50
  info('corl.actions.start.start', { :provider => node.plugin_provider, :name => node.plugin_name })
53
51
  node.start
54
52
  end
55
53
  myself.status = code.batch_error unless batch_success
56
- else
57
- myself.status = code.network_failure
58
54
  end
59
55
  end
60
56
  end
@@ -8,8 +8,6 @@ class Stop < Plugin::CloudAction
8
8
 
9
9
  def configure
10
10
  super do
11
- codes :network_failure
12
-
13
11
  register :stop_nodes, :array, nil do |values|
14
12
  if values.nil?
15
13
  warn('corl.actions.stop.errors.stop_nodes_empty')
@@ -47,14 +45,12 @@ class Stop < Plugin::CloudAction
47
45
 
48
46
  def execute
49
47
  super do |local_node, network|
50
- if network
48
+ ensure_network(network) do
51
49
  batch_success = network.batch(settings[:stop_nodes], settings[:node_provider], settings[:parallel]) do |node|
52
50
  info('corl.actions.stop.start', { :provider => node.plugin_provider, :name => node.plugin_name })
53
51
  node.stop
54
52
  end
55
53
  myself.status = code.batch_error unless batch_success
56
- else
57
- myself.status = code.network_failure
58
54
  end
59
55
  end
60
56
  end
@@ -0,0 +1,55 @@
1
+
2
+ module CORL
3
+ module Action
4
+ class Vagrantfile < Plugin::CloudAction
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Settings
8
+
9
+ def configure
10
+ super do
11
+ codes :vagrant_backup_failure,
12
+ :vagrant_save_failure,
13
+ :network_save_failure
14
+ end
15
+ end
16
+
17
+ #-----------------------------------------------------------------------------
18
+ # Action operations
19
+
20
+ def execute
21
+ super do |node, network|
22
+ info('corl.actions.vagrantfile.start')
23
+
24
+ ensure_network(network) do
25
+ generated_vagrantfile_name = File.join(CORL.lib_path, 'core', 'vagrant', 'Vagrantfile')
26
+ project_vagrantfile_name = File.join(network.directory, 'Vagrantfile')
27
+ success = true
28
+
29
+ corl_vagrantfile = Util::Disk.read(generated_vagrantfile_name)
30
+
31
+ if File.exists?(project_vagrantfile_name)
32
+ unless FileUtils.mv(project_vagrantfile_name, "#{project_vagrantfile_name}.backup", :force => true)
33
+ myself.status = code.vagrant_backup_failure
34
+ success = false
35
+ end
36
+ end
37
+
38
+ if success
39
+ unless Util::Disk.write(project_vagrantfile_name, corl_vagrantfile)
40
+ myself.status = code.vagrant_save_failure
41
+ success = false
42
+ end
43
+
44
+ if success
45
+ unless network.save({ :files => 'Vagrantfile' })
46
+ myself.status = code.network_save_failure
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -175,9 +175,12 @@ class File < CORL.plugin_class(:configuration)
175
175
  separate.export.each do |config_name, router_data|
176
176
  info = search[config_name]
177
177
  provider = info[:provider]
178
- file = info[:file]
178
+ file = info[:file]
179
+ file_dir = ::File.dirname(file)
179
180
  deleted_keys = deleted_keys - [ config_name ]
180
181
 
182
+ FileUtils.mkdir_p(file_dir) unless Dir.exists?(file_dir)
183
+
181
184
  if renderer = CORL.translator(method_config, provider)
182
185
  rendering = renderer.generate(router_data)
183
186
 
@@ -40,7 +40,7 @@ class Physical < CORL.plugin_class(:machine)
40
40
  #---
41
41
 
42
42
  def public_ip
43
- CORL.ip_address
43
+ CORL.public_ip
44
44
  end
45
45
 
46
46
  #---