coral_vagrant 0.2.8 → 0.4.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 +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -21
- data/VERSION +1 -1
- data/{example/Vagrantfile → Vagrantfile} +5 -7
- data/coral_vagrant.gemspec +13 -55
- metadata +20 -143
- data/bin/coral +0 -11
- data/example/cloud.json +0 -50
- data/lib/coral_vagrant.rb +0 -76
- data/lib/coral_vagrant/commands/coral/add.rb +0 -41
- data/lib/coral_vagrant/commands/coral/config.rb +0 -61
- data/lib/coral_vagrant/commands/coral/create.rb +0 -41
- data/lib/coral_vagrant/commands/coral/image.rb +0 -47
- data/lib/coral_vagrant/commands/coral/init.rb +0 -77
- data/lib/coral_vagrant/commands/coral/push.rb +0 -83
- data/lib/coral_vagrant/commands/coral/rm.rb +0 -37
- data/lib/coral_vagrant/commands/coral/run.rb +0 -52
- data/lib/coral_vagrant/commands/coral/send.rb +0 -42
- data/lib/coral_vagrant/commands/coral/update.rb +0 -60
- data/lib/coral_vagrant/commands/coral_base.rb +0 -166
- data/lib/plugin.rb +0 -25
- data/spec/coral_test_kernel.rb +0 -22
- data/spec/spec_helper.rb +0 -14
@@ -1,52 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralRun < ::Vagrant.plugin('2', :command)
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------
|
7
|
-
# Execution
|
8
|
-
|
9
|
-
def execute
|
10
|
-
options = {}
|
11
|
-
success = true
|
12
|
-
|
13
|
-
opts = OptionParser.new do |opts|
|
14
|
-
opts.banner = 'Usage: coral run --dir={plan_dir} {plan_name} ...'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
options[:repo] = '.'
|
18
|
-
opts.on('-r', '--repo REPO_DIR', 'Local directory of repository relative to the Vagrantfile root (.)') do |r|
|
19
|
-
options[:repo] = r
|
20
|
-
end
|
21
|
-
|
22
|
-
options[:directory] = 'plans'
|
23
|
-
opts.on('-d', '--dir DIRECTORY', 'Local directory that contains the plan(s) being executed (plans)') do |d|
|
24
|
-
options[:directory] = d
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
#---
|
29
|
-
|
30
|
-
plans = parse_options(opts)
|
31
|
-
return unless plans
|
32
|
-
|
33
|
-
plans.each do |plan_name|
|
34
|
-
@logger.debug("Running plan: #{plan_name}")
|
35
|
-
|
36
|
-
success = Coral.create_plan(plan_name, {
|
37
|
-
:home => Coral.vagrant,
|
38
|
-
:submodule => options[:repo],
|
39
|
-
:config_file => File.join([ options[:directory].to_s, "#{plan_name}.json" ]),
|
40
|
-
:logger => @logger,
|
41
|
-
:ui => @env.ui,
|
42
|
-
}).run(options)
|
43
|
-
|
44
|
-
break unless success
|
45
|
-
end
|
46
|
-
|
47
|
-
exit success ? 0 : 1
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralSend < ::Vagrant.plugin('2', :command)
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------
|
7
|
-
# Execution
|
8
|
-
|
9
|
-
def execute
|
10
|
-
options = {}
|
11
|
-
success = true
|
12
|
-
|
13
|
-
opts = OptionParser.new do |opts|
|
14
|
-
opts.banner = 'Usage: coral send {provider} ...'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
options[:tries] = 1
|
18
|
-
opts.on('-t', '--tries TRIES', 'Number of times to try sending to provider before stopping with an error (1)') do |t|
|
19
|
-
options[:tries] = t
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
options[:auth] = true
|
24
|
-
|
25
|
-
#---
|
26
|
-
|
27
|
-
providers = parse_options(opts)
|
28
|
-
return unless providers
|
29
|
-
|
30
|
-
raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if providers.length < 1
|
31
|
-
|
32
|
-
#---------
|
33
|
-
# Start
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
exit success ? 0 : 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralUpdate < ::Vagrant.plugin('2', :command)
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------
|
7
|
-
# Execution
|
8
|
-
|
9
|
-
def execute
|
10
|
-
options = {}
|
11
|
-
success = true
|
12
|
-
|
13
|
-
opts = OptionParser.new do |opts|
|
14
|
-
opts.banner = 'Usage: coral init -h [ {server_name} ... ]'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
options[:min] = 1
|
18
|
-
opts.on('-m', '--min TRIES', 'Minimum number of provision runs (1)') do |m|
|
19
|
-
options[:min] = m
|
20
|
-
end
|
21
|
-
|
22
|
-
options[:tries] = 1
|
23
|
-
opts.on('-t', '--tries TRIES', 'Number of provision attempts before stopping with an error (1)') do |t|
|
24
|
-
options[:tries] = t
|
25
|
-
end
|
26
|
-
|
27
|
-
options[:exit] = ''
|
28
|
-
opts.on('-e', '--exit CONDITIONS', 'Conditions on which to exit in the format separated by comma: "User[git]:ensure:created"') do |e|
|
29
|
-
options[:exit] = e
|
30
|
-
end
|
31
|
-
|
32
|
-
options[:repos] = ''
|
33
|
-
opts.on('-r', '--repos REPO_DIR,...', 'Local directories of repositories to push relative to the Vagrantfile root') do |r|
|
34
|
-
options[:repos] = r
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
options[:auth] = true
|
39
|
-
|
40
|
-
#---
|
41
|
-
|
42
|
-
servers = parse_options(opts)
|
43
|
-
return unless servers
|
44
|
-
|
45
|
-
with_target_vms(servers) do |vm|
|
46
|
-
@env.ui.info("Starting update run for: #{vm.name}")
|
47
|
-
|
48
|
-
success = Cloud::Server.new({
|
49
|
-
:cloud => Coral.vagrant,
|
50
|
-
:machine => vm,
|
51
|
-
:logger => @logger,
|
52
|
-
:ui => @env.ui,
|
53
|
-
}).update(options) if success
|
54
|
-
end
|
55
|
-
exit success ? 0 : 1
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,166 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module Command
|
4
|
-
class CoralBase < ::Vagrant.plugin("2", :command)
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Constructor / Destructor
|
8
|
-
|
9
|
-
def initialize(argv, env)
|
10
|
-
super(argv, env)
|
11
|
-
|
12
|
-
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
13
|
-
|
14
|
-
@subcommands = ::Vagrant::Registry.new
|
15
|
-
|
16
|
-
#------------
|
17
|
-
# Builders
|
18
|
-
|
19
|
-
#
|
20
|
-
# coral create --repo={cluster_repository} [ {project_path} ]
|
21
|
-
#
|
22
|
-
# {cluster_repository} -> Defaults to the coral cluster core
|
23
|
-
# {project_path} -> Defaults to the current directory (must be empty)
|
24
|
-
#
|
25
|
-
# * calls: coral init
|
26
|
-
#
|
27
|
-
#@subcommands.register(:create) { Coral::Vagrant::SubCommand::CoralCreate }
|
28
|
-
|
29
|
-
#
|
30
|
-
# coral add --repo={repository} {name} [ {type} ]
|
31
|
-
#
|
32
|
-
# {name} -> Name of the project (required)
|
33
|
-
# {type} -> Defaults to module (can be: cluster, profile, module)
|
34
|
-
# {repository} -> Defaults to a new template repository of {type}
|
35
|
-
#
|
36
|
-
#@subcommands.register(:add) { Coral::Vagrant::SubCommand::CoralAdd }
|
37
|
-
|
38
|
-
#
|
39
|
-
# coral rm {name} [ {type} ]
|
40
|
-
#
|
41
|
-
# {name} -> Name of the project (required)
|
42
|
-
# {type} -> Defaults to module (can be: cluster, profile, module)
|
43
|
-
#
|
44
|
-
#@subcommands.register(:rm) { Coral::Vagrant::SubCommand::CoralRemove }
|
45
|
-
|
46
|
-
#------------------------------
|
47
|
-
# Configuration / Deployment
|
48
|
-
|
49
|
-
#
|
50
|
-
# coral config --dir={config_dir} {config_name} [ {value} ]
|
51
|
-
#
|
52
|
-
# {config_name} -> Dot separated configuration name (dot = directory entry)
|
53
|
-
# {value} -> Configuration value (if we are setting the configuration)
|
54
|
-
# {config_dir} -> Root directory of configuration files (default: config)
|
55
|
-
#
|
56
|
-
#subcommands.register(:config) { Coral::Vagrant::SubCommand::CoralConfig }
|
57
|
-
|
58
|
-
#
|
59
|
-
# coral push --repos={repository_name},... [ {server_name} ... ]
|
60
|
-
#
|
61
|
-
# {server_name} -> Server name of a local or remote server to push attached repositories to
|
62
|
-
# {repository_name} -> Local repository name for a local/remote repository relationship
|
63
|
-
#
|
64
|
-
@subcommands.register(:push) { Coral::Vagrant::SubCommand::CoralPush }
|
65
|
-
|
66
|
-
#
|
67
|
-
# coral send {provider} ...
|
68
|
-
#
|
69
|
-
# {provider} -> Remote cloud provider on which to send and initialize the coral cluster
|
70
|
-
#
|
71
|
-
# * calls: coral init
|
72
|
-
# coral image
|
73
|
-
#
|
74
|
-
#@subcommands.register(:send) { Coral::Vagrant::SubCommand::CoralSend }
|
75
|
-
|
76
|
-
#
|
77
|
-
# coral image --servers={server_name},... {provider} ...
|
78
|
-
#
|
79
|
-
# {provider} -> Remote cloud provider on which to create the image
|
80
|
-
# {server_name} -> Server name of a cluster server to create an image of
|
81
|
-
#
|
82
|
-
#@subcommands.register(:image) { Coral::Vagrant::SubCommand::CoralImage }
|
83
|
-
|
84
|
-
#--------------
|
85
|
-
# Management
|
86
|
-
|
87
|
-
#
|
88
|
-
# coral init [ {server_name} ... ]
|
89
|
-
#
|
90
|
-
# {server_name} -> Server name of a cluster server to initialize
|
91
|
-
#
|
92
|
-
@subcommands.register(:init) { Coral::Vagrant::SubCommand::CoralInit }
|
93
|
-
|
94
|
-
#
|
95
|
-
# coral update [ {server_name} ... ]
|
96
|
-
#
|
97
|
-
# {server_name} -> Server name of a cluster server to update
|
98
|
-
#
|
99
|
-
@subcommands.register(:update) { Coral::Vagrant::SubCommand::CoralUpdate }
|
100
|
-
|
101
|
-
#
|
102
|
-
# coral run --dir={plan_dir} {plan_name} ...
|
103
|
-
#
|
104
|
-
# {plan_name} -> Name of JSON based execution plan to run
|
105
|
-
# {plan_dir} -> Root directory of exexution plan files (default: config/plans)
|
106
|
-
#
|
107
|
-
# * could call anything
|
108
|
-
#
|
109
|
-
#@subcommands.register(:run) { Coral::Vagrant::SubCommand::CoralRun }
|
110
|
-
end
|
111
|
-
|
112
|
-
#-----------------------------------------------------------------------------
|
113
|
-
# Help
|
114
|
-
|
115
|
-
def help
|
116
|
-
opts = OptionParser.new do |opts|
|
117
|
-
opts.banner = 'Usage: vagrant coral <command> [<args>]'
|
118
|
-
opts.separator ''
|
119
|
-
opts.separator 'Available subcommands:'
|
120
|
-
|
121
|
-
# Add the available subcommands as separators in order to print them
|
122
|
-
# out as well.
|
123
|
-
keys = []
|
124
|
-
@subcommands.each { |key, value| keys << key.to_s }
|
125
|
-
|
126
|
-
keys.sort.each do |key|
|
127
|
-
opts.separator " #{key}"
|
128
|
-
end
|
129
|
-
|
130
|
-
opts.separator ''
|
131
|
-
opts.separator 'For help on any individual command run `vagrant coral COMMAND -h`'
|
132
|
-
end
|
133
|
-
|
134
|
-
@env.ui.info(opts.help, :prefix => false)
|
135
|
-
end
|
136
|
-
|
137
|
-
#-----------------------------------------------------------------------------
|
138
|
-
# Execution
|
139
|
-
|
140
|
-
def execute
|
141
|
-
if @main_args.include?('-h') || @main_args.include?('--help')
|
142
|
-
# Print the help for all the cluster commands.
|
143
|
-
return help
|
144
|
-
end
|
145
|
-
|
146
|
-
# Fetch our command class if we have a subcommand.
|
147
|
-
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
148
|
-
|
149
|
-
# If there is no class mapping, we try running the subcommand as an
|
150
|
-
# execution plan.
|
151
|
-
if !command_class && @sub_command
|
152
|
-
command_class = @subcommands.get(:run)
|
153
|
-
@sub_args.unshift(@sub_command)
|
154
|
-
end
|
155
|
-
# If all else fails print the help and exit.
|
156
|
-
return help if !command_class || !@sub_command
|
157
|
-
|
158
|
-
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
159
|
-
|
160
|
-
# Initialize and execute the command class
|
161
|
-
command_class.new(@sub_args, @env).execute
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
data/lib/plugin.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require "vagrant"
|
4
|
-
rescue LoadError
|
5
|
-
raise "The Vagrant Coral plugin must be run within Vagrant."
|
6
|
-
end
|
7
|
-
|
8
|
-
# This is a sanity check to make sure no one is attempting to install
|
9
|
-
# this into an early Vagrant version.
|
10
|
-
if Vagrant::VERSION < "1.2.0"
|
11
|
-
raise "The Vagrant Coral plugin is only compatible with Vagrant 1.2+"
|
12
|
-
end
|
13
|
-
|
14
|
-
module VagrantPlugins
|
15
|
-
module Coral
|
16
|
-
class Plugin < ::Vagrant.plugin('2')
|
17
|
-
name 'coral plugins'
|
18
|
-
description 'The `coral` plugin provides an easy way to manage and sync coral clusters locally and on the cloud from within Vagrant.'
|
19
|
-
|
20
|
-
command('coral') do
|
21
|
-
::Coral::Vagrant::Command::CoralBase
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/coral_test_kernel.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
|
2
|
-
module Kernel
|
3
|
-
|
4
|
-
#-----------------------------------------------------------------------------
|
5
|
-
# Utilities
|
6
|
-
|
7
|
-
def capture
|
8
|
-
out = StringIO.new
|
9
|
-
$stdout = out
|
10
|
-
|
11
|
-
error = StringIO.new
|
12
|
-
$stderr = error
|
13
|
-
|
14
|
-
# Go do stuff!
|
15
|
-
yield
|
16
|
-
return out, error
|
17
|
-
|
18
|
-
ensure
|
19
|
-
$stdout = STDOUT
|
20
|
-
$stderr = STDERR
|
21
|
-
end
|
22
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rspec'
|
3
|
-
require 'stringio'
|
4
|
-
require 'coral_vagrant'
|
5
|
-
|
6
|
-
require 'coral_test_kernel'
|
7
|
-
|
8
|
-
#-------------------------------------------------------------------------------
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.mock_framework = :rspec
|
12
|
-
config.color_enabled = true
|
13
|
-
config.formatter = 'documentation'
|
14
|
-
end
|