coral_vagrant 0.2.8 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/coral_vagrant.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
home = File.dirname(__FILE__)
|
2
|
-
|
3
|
-
$:.unshift(home) unless
|
4
|
-
$:.include?(home) || $:.include?(File.expand_path(home))
|
5
|
-
|
6
|
-
#-------------------------------------------------------------------------------
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'optparse'
|
10
|
-
require 'vagrant'
|
11
|
-
require 'coral_cloud'
|
12
|
-
require 'coral_plan'
|
13
|
-
|
14
|
-
#---
|
15
|
-
|
16
|
-
# Include top level Vagrant commands
|
17
|
-
[ :coral_base ].each do |name|
|
18
|
-
require File.join('coral_vagrant', 'commands', name.to_s + '.rb')
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'plugin.rb'
|
22
|
-
|
23
|
-
#---
|
24
|
-
|
25
|
-
# Include Coral Vagrant commands
|
26
|
-
Dir.glob(File.join(home, 'coral_vagrant', 'commands', 'coral', '*.rb')).each do |file|
|
27
|
-
require file
|
28
|
-
end
|
29
|
-
|
30
|
-
#*******************************************************************************
|
31
|
-
# Coral Vagrant Library
|
32
|
-
#
|
33
|
-
# This provides a data model and commands that interface with Vagrant.
|
34
|
-
#
|
35
|
-
# Author:: Adrian Webb (mailto:adrian.webb@coraltech.net)
|
36
|
-
# License:: GPLv3
|
37
|
-
module Coral
|
38
|
-
|
39
|
-
#-----------------------------------------------------------------------------
|
40
|
-
# Constructor / Destructor
|
41
|
-
def self.init_vagrant(directory, submodule = '', config_file = [ 'config', 'cloud.json' ])
|
42
|
-
return Coral::Vagrant.init(directory, submodule, config_file)
|
43
|
-
end
|
44
|
-
|
45
|
-
#-----------------------------------------------------------------------------
|
46
|
-
# Accessors / Modifiers
|
47
|
-
|
48
|
-
def self.vagrant
|
49
|
-
return Coral::Vagrant.get
|
50
|
-
end
|
51
|
-
|
52
|
-
#*******************************************************************************
|
53
|
-
|
54
|
-
module Vagrant
|
55
|
-
|
56
|
-
VERSION = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
|
57
|
-
|
58
|
-
#-----------------------------------------------------------------------------
|
59
|
-
# Constructor / Destructor
|
60
|
-
|
61
|
-
def self.init(directory, submodule = '', config_file = [ 'config', 'cloud.json' ])
|
62
|
-
return Coral.create_cloud(:vagrant, {
|
63
|
-
:directory => directory,
|
64
|
-
:submodule => submodule,
|
65
|
-
:config_file => config_file,
|
66
|
-
})
|
67
|
-
end
|
68
|
-
|
69
|
-
#-----------------------------------------------------------------------------
|
70
|
-
# Accessors / Modifiers
|
71
|
-
|
72
|
-
def self.get
|
73
|
-
return Coral.cloud(:vagrant)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralAdd < ::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 add -h --repo={repository} {name} [ {type} ]'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
options[:repo] = ''
|
18
|
-
opts.on('-r', '--repo REPOSITORY', "Git repository URL of sub-project to add to project type") do |r|
|
19
|
-
options[:repo] = r
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
#---
|
24
|
-
|
25
|
-
args = parse_options(opts)
|
26
|
-
return unless args
|
27
|
-
|
28
|
-
raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if args.length < 1
|
29
|
-
|
30
|
-
project_name = args[0]
|
31
|
-
project_type = ( args.size < 2 ? 'module' : args[1] )
|
32
|
-
|
33
|
-
#---------
|
34
|
-
# Start
|
35
|
-
|
36
|
-
exit success ? 0 : 1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralConfig < ::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 config -ha --dir={config_dir} {config_name} [ {value} ]'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
opts.on('-a', '--add', 'Add configuration value to existing values instead of overriding') do |a|
|
18
|
-
options[:add] = a
|
19
|
-
end
|
20
|
-
|
21
|
-
options[:repo] = '.'
|
22
|
-
opts.on('-r', '--repo REPO_DIR', 'Local directory of repository relative to the Vagrantfile root (.)') do |r|
|
23
|
-
options[:repo] = r
|
24
|
-
end
|
25
|
-
|
26
|
-
options[:directory] = 'config'
|
27
|
-
opts.on('-d', '--dir DIRECTORY', 'Root directory of configuration files (config)') do |d|
|
28
|
-
options[:directory] = d
|
29
|
-
end
|
30
|
-
|
31
|
-
options[:ext] = 'json'
|
32
|
-
opts.on('-e', '--ext FILE_EXTENSION', 'Configuration file extension (json)') do |e|
|
33
|
-
options[:ext] = e
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
#---
|
38
|
-
|
39
|
-
args = parse_options(opts)
|
40
|
-
return unless args
|
41
|
-
|
42
|
-
raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if args.length < 1
|
43
|
-
|
44
|
-
config_elements = args[0].gsub(/\s+/, '').split(/\@/)
|
45
|
-
property = config_elements.pop
|
46
|
-
config_file = File.join(config_elements)
|
47
|
-
|
48
|
-
raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp unless property && config_file
|
49
|
-
|
50
|
-
config_file = "#{config_file}." + options[:ext]
|
51
|
-
value = ( args.size < 2 ? nil : args[1] )
|
52
|
-
|
53
|
-
#---------
|
54
|
-
# Start
|
55
|
-
|
56
|
-
exit success ? 0 : 1
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralCreate < ::Vagrant.plugin('2', :command)
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------
|
7
|
-
# Execution
|
8
|
-
|
9
|
-
def execute
|
10
|
-
options = {}
|
11
|
-
success = true
|
12
|
-
default_repo = 'git://github.com/coralnexus/cluster-core.git'
|
13
|
-
|
14
|
-
#---
|
15
|
-
|
16
|
-
opts = OptionParser.new do |opts|
|
17
|
-
opts.banner = 'Usage: coral create -h --repo={cluster_repository} [ {project_path} ]'
|
18
|
-
opts.separator ""
|
19
|
-
|
20
|
-
options[:repo] = default_repo
|
21
|
-
opts.on('-r', '--repo REPOSITORY', "Git repository URL of Coral cluster to start project from (#{default_repo})") do |r|
|
22
|
-
options[:repo] = r
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
#---
|
27
|
-
|
28
|
-
args = parse_options(opts)
|
29
|
-
return unless args
|
30
|
-
|
31
|
-
project_path = ( args.empty? ? '.' : args[0] )
|
32
|
-
|
33
|
-
#---------
|
34
|
-
# Start
|
35
|
-
|
36
|
-
exit success ? 0 : 1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralImage < ::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 image --servers={server_name},... {provider} ...'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
options[:tries] = 1
|
18
|
-
opts.on('-t', '--tries TRIES', 'Number of times to try imaging the servers before stopping with an error (1)') do |t|
|
19
|
-
options[:tries] = t
|
20
|
-
end
|
21
|
-
|
22
|
-
options[:servers] = ''
|
23
|
-
opts.on('-s', '--servers SERVER_NAME,...', 'Server names of servers to image on the specified providers') do |r|
|
24
|
-
options[:servers] = r
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
options[:auth] = true
|
29
|
-
|
30
|
-
#---
|
31
|
-
|
32
|
-
providers = parse_options(opts)
|
33
|
-
return unless providers
|
34
|
-
|
35
|
-
raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if providers.length < 1
|
36
|
-
|
37
|
-
#---------
|
38
|
-
# Start
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
exit success ? 0 : 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralInit < ::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 -hdf [ {server_name} ... ]'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
opts.on('-d', '--destroy', 'Remove existing servers and start from scratch') do |d|
|
18
|
-
options[:destroy] = d
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on('-f', '--force', 'Destroy without confirmation') do |f|
|
22
|
-
options[:force] = f
|
23
|
-
end
|
24
|
-
|
25
|
-
#---
|
26
|
-
|
27
|
-
options[:min] = 1
|
28
|
-
opts.on('-m', '--min TRIES', 'Minimum number of provision runs (1)') do |m|
|
29
|
-
options[:min] = m
|
30
|
-
end
|
31
|
-
|
32
|
-
options[:tries] = 1
|
33
|
-
opts.on('-t', '--tries TRIES', 'Number of provision attempts before stopping with an error (1)') do |t|
|
34
|
-
options[:tries] = t
|
35
|
-
end
|
36
|
-
|
37
|
-
options[:exit] = ''
|
38
|
-
opts.on('-e', '--exit CONDITIONS', 'Conditions on which to exit in the format separated by a comma: "User[git]:ensure:created"') do |e|
|
39
|
-
options[:exit] = e
|
40
|
-
end
|
41
|
-
|
42
|
-
options[:repos] = ''
|
43
|
-
opts.on('-r', '--repos REPO_DIR,...', 'Local directories of repositories to syncronize remotes relative to the Vagrantfile root') do |r|
|
44
|
-
options[:repos] = r
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
options[:min] = 1
|
49
|
-
options[:auth] = true
|
50
|
-
|
51
|
-
#---
|
52
|
-
|
53
|
-
servers = parse_options(opts)
|
54
|
-
return unless servers
|
55
|
-
|
56
|
-
with_target_vms(servers) do |vm|
|
57
|
-
@env.ui.info("Starting initialization run for: #{vm.name}")
|
58
|
-
|
59
|
-
server = Cloud::Server.new({
|
60
|
-
:cloud => Coral.vagrant,
|
61
|
-
:machine => vm,
|
62
|
-
:logger => @logger,
|
63
|
-
:ui => @env.ui,
|
64
|
-
})
|
65
|
-
|
66
|
-
if options[:destroy]
|
67
|
-
success = server.destroy(options) if success
|
68
|
-
end
|
69
|
-
success = server.start(options) if success
|
70
|
-
success = server.update(options) if success
|
71
|
-
end
|
72
|
-
exit success ? 0 : 1
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralPush < ::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 push -hcet --repos={repository_name},... [ {server_name} ... ]'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
opts.on('-c', '--commit', 'Commit any uncommitted changes before pushing to remotes') do |c|
|
18
|
-
options[:commit] = c
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on('-e', '--empty', 'Allow commits with no changes') do |e|
|
22
|
-
options[:allow_empty] = e
|
23
|
-
end
|
24
|
-
|
25
|
-
opts.on('-t', '--tags', 'Push all local tags with selected branch') do |t|
|
26
|
-
options[:tags] = t
|
27
|
-
end
|
28
|
-
|
29
|
-
#---
|
30
|
-
|
31
|
-
options[:message] = ''
|
32
|
-
opts.on('-m', '--message MESSAGE', 'Commit message') do |m|
|
33
|
-
options[:message] = m
|
34
|
-
end
|
35
|
-
|
36
|
-
options[:author] = ''
|
37
|
-
opts.on('-a', '--author AUTHOR', 'Author of the changes being committed if different from the committer') do |a|
|
38
|
-
options[:author] = a
|
39
|
-
end
|
40
|
-
|
41
|
-
options[:branch] = ''
|
42
|
-
opts.on('-b', '--branch BRANCH', 'Local branch of the remotes to push') do |b|
|
43
|
-
options[:branch] = b
|
44
|
-
end
|
45
|
-
|
46
|
-
options[:repos] = ''
|
47
|
-
opts.on('-r', '--repos REPO_DIR,...', 'Local directories of repositories to push relative to the Vagrantfile root') do |r|
|
48
|
-
options[:repos] = r
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
options[:auth] = true
|
53
|
-
|
54
|
-
#---
|
55
|
-
|
56
|
-
remotes = parse_options(opts)
|
57
|
-
return unless remotes
|
58
|
-
|
59
|
-
if remotes.empty?
|
60
|
-
remotes = [ 'all' ]
|
61
|
-
end
|
62
|
-
|
63
|
-
remotes.each do |remote_name|
|
64
|
-
@env.ui.info("Starting push for: #{remote_name}")
|
65
|
-
|
66
|
-
server = Cloud::Server.new({
|
67
|
-
:cloud => Coral.vagrant,
|
68
|
-
:machine => remote_name,
|
69
|
-
:logger => @logger,
|
70
|
-
:ui => @env.ui,
|
71
|
-
})
|
72
|
-
|
73
|
-
if options[:commit]
|
74
|
-
success = server.commit(options) if success
|
75
|
-
end
|
76
|
-
success = server.push(options) if success
|
77
|
-
end
|
78
|
-
exit success ? 0 : 1
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
module Vagrant
|
3
|
-
module SubCommand
|
4
|
-
class CoralRemove < ::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 rm -h {name} [ {type} ]'
|
15
|
-
opts.separator ''
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
#---
|
20
|
-
|
21
|
-
args = parse_options(opts)
|
22
|
-
return unless args
|
23
|
-
|
24
|
-
raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if args.length < 1
|
25
|
-
|
26
|
-
project_name = args[0]
|
27
|
-
project_type = ( args.size < 2 ? 'module' : args[1] )
|
28
|
-
|
29
|
-
#---------
|
30
|
-
# Start
|
31
|
-
|
32
|
-
exit success ? 0 : 1
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|