sahara 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -2
- data/README.md +18 -5
- data/lib/sahara.rb +19 -1
- data/lib/sahara/command/commit.rb +5 -4
- data/lib/sahara/command/off.rb +5 -4
- data/lib/sahara/command/on.rb +7 -4
- data/lib/sahara/command/rollback.rb +5 -4
- data/lib/sahara/command/{sandbox.rb → root.rb} +36 -23
- data/lib/sahara/command/status.rb +5 -4
- data/lib/sahara/session.rb +106 -211
- data/lib/sahara/version.rb +1 -1
- data/sahara.gemspec +0 -1
- metadata +59 -98
- data/.rvmrc +0 -5
- data/Gemfile.lock +0 -45
- data/Vagrantfile.multi +0 -12
- data/Vagrantfile.single +0 -33
- data/lib/sahara/command/vagrant.rb +0 -5
- data/lib/sahara/shell.rb +0 -58
- data/lib/vagrant_init.rb +0 -8
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# Notice
|
2
|
+
|
3
|
+
- Sahara does not work with Vagrant 1.0 or lower.
|
4
|
+
- If you want to install an old version for Vagrant 1.0, you have to run the command like "gem install sahara -v 0.0.13"
|
5
|
+
- But I strongly recommend you to upgrade your Vagrant to latest version.
|
6
|
+
|
1
7
|
# Description
|
2
8
|
|
3
9
|
Sahara allows vagrant to operate in sandbox mode.
|
@@ -14,10 +20,17 @@ Many kudos go to the creators of [vagrant](http://vagrantup.com)
|
|
14
20
|
|
15
21
|
# Installation
|
16
22
|
|
17
|
-
|
23
|
+
From source:
|
24
|
+
<pre>
|
25
|
+
bundle install
|
26
|
+
rake build
|
27
|
+
vagrant plugin install pkg/sahara-0.0.xx.gem
|
28
|
+
</pre>
|
18
29
|
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
This is now available as gem:
|
31
|
+
<pre>
|
32
|
+
vagrant plugin install sahara
|
33
|
+
</pre>
|
22
34
|
|
23
|
-
|
35
|
+
# License
|
36
|
+
This is licensed under the MIT license.
|
data/lib/sahara.rb
CHANGED
@@ -1 +1,19 @@
|
|
1
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require "vagrant"
|
5
|
+
require File.expand_path("../sahara/session", __FILE__)
|
6
|
+
|
7
|
+
module Sahara
|
8
|
+
class Plugin < Vagrant.plugin("2")
|
9
|
+
name "sahara"
|
10
|
+
description <<-DESC
|
11
|
+
Sahara
|
12
|
+
DESC
|
13
|
+
|
14
|
+
command("sandbox") do
|
15
|
+
require File.expand_path("../sahara/command/root", __FILE__)
|
16
|
+
Command::Root
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Sahara
|
2
2
|
module Command
|
3
|
-
class Commit <
|
3
|
+
class Commit < Vagrant.plugin("2", :command)
|
4
4
|
def execute
|
5
5
|
|
6
6
|
options = {}
|
@@ -16,9 +16,10 @@ module Sahara
|
|
16
16
|
argv = parse_options(opts)
|
17
17
|
return if !argv
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
ses = Sahara::Session::Command.new(@app, @env)
|
20
|
+
|
21
|
+
with_target_vms(argv, :reverse => true) do |machine|
|
22
|
+
ses.commit(machine)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
data/lib/sahara/command/off.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Sahara
|
2
2
|
module Command
|
3
|
-
class Off <
|
3
|
+
class Off < Vagrant.plugin("2", :command)
|
4
4
|
def execute
|
5
5
|
|
6
6
|
options = {}
|
@@ -16,9 +16,10 @@ module Sahara
|
|
16
16
|
argv = parse_options(opts)
|
17
17
|
return if !argv
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
ses = Sahara::Session::Command.new(@app, @env)
|
20
|
+
|
21
|
+
with_target_vms(argv, :reverse => true) do |machine|
|
22
|
+
ses.off(machine)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
data/lib/sahara/command/on.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
1
3
|
module Sahara
|
2
4
|
module Command
|
3
|
-
class On <
|
5
|
+
class On < Vagrant.plugin("2", :command)
|
4
6
|
def execute
|
5
7
|
|
6
8
|
options = {}
|
@@ -16,9 +18,10 @@ module Sahara
|
|
16
18
|
argv = parse_options(opts)
|
17
19
|
return if !argv
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
ses = Sahara::Session::Command.new(@app, @env)
|
22
|
+
|
23
|
+
with_target_vms(argv, :reverse => true) do |machine|
|
24
|
+
ses.on(machine)
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Sahara
|
2
2
|
module Command
|
3
|
-
class Rollback <
|
3
|
+
class Rollback < Vagrant.plugin("2", :command)
|
4
4
|
def execute
|
5
5
|
|
6
6
|
options = {}
|
@@ -16,9 +16,10 @@ module Sahara
|
|
16
16
|
argv = parse_options(opts)
|
17
17
|
return if !argv
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
ses = Sahara::Session::Command.new(@app, @env)
|
20
|
+
|
21
|
+
with_target_vms(argv, :reverse => true) do |machine|
|
22
|
+
ses.rollback(machine)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,30 +1,43 @@
|
|
1
|
-
require 'sahara'
|
2
1
|
require 'optparse'
|
3
|
-
require 'sahara/command/status'
|
4
|
-
require 'sahara/command/on'
|
5
|
-
require 'sahara/command/commit'
|
6
|
-
require 'sahara/command/rollback'
|
7
|
-
require 'sahara/command/off'
|
8
2
|
|
9
|
-
module Sahara
|
3
|
+
module Sahara
|
10
4
|
module Command
|
11
|
-
class
|
12
|
-
def initialize(argv,env)
|
5
|
+
class Root < Vagrant.plugin("2", :command)
|
6
|
+
def initialize(argv, env)
|
13
7
|
super
|
14
8
|
|
15
9
|
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
16
10
|
|
17
|
-
@subcommands =
|
18
|
-
@subcommands.register(:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
@subcommands = Vagrant::Registry.new
|
12
|
+
@subcommands.register(:on) do
|
13
|
+
require_relative "on"
|
14
|
+
On
|
15
|
+
end
|
16
|
+
|
17
|
+
@subcommands.register(:off) do
|
18
|
+
require_relative "off"
|
19
|
+
Off
|
20
|
+
end
|
21
|
+
|
22
|
+
@subcommands.register(:commit) do
|
23
|
+
require_relative "commit"
|
24
|
+
Commit
|
25
|
+
end
|
26
|
+
|
27
|
+
@subcommands.register(:rollback) do
|
28
|
+
require_relative "rollback"
|
29
|
+
Rollback
|
30
|
+
end
|
31
|
+
|
32
|
+
@subcommands.register(:status) do
|
33
|
+
require_relative "status"
|
34
|
+
Status
|
35
|
+
end
|
23
36
|
end
|
24
37
|
|
25
38
|
def execute
|
26
39
|
if @main_args.include?("-h") || @main_args.include?("--help")
|
27
|
-
# Print the help for all the
|
40
|
+
# Print the help for all the sub-commands.
|
28
41
|
return help
|
29
42
|
end
|
30
43
|
|
@@ -40,10 +53,10 @@ module Sahara
|
|
40
53
|
|
41
54
|
# Prints the help out for this command
|
42
55
|
def help
|
43
|
-
opts = OptionParser.new do |
|
44
|
-
|
45
|
-
|
46
|
-
|
56
|
+
opts = OptionParser.new do |o|
|
57
|
+
o.banner = "Usage: vagrant plugin <command> [<args>]"
|
58
|
+
o.separator ""
|
59
|
+
o.separator "Available subcommands:"
|
47
60
|
|
48
61
|
# Add the available subcommands as separators in order to print them
|
49
62
|
# out as well.
|
@@ -51,11 +64,11 @@ module Sahara
|
|
51
64
|
@subcommands.each { |key, value| keys << key.to_s }
|
52
65
|
|
53
66
|
keys.sort.each do |key|
|
54
|
-
|
67
|
+
o.separator " #{key}"
|
55
68
|
end
|
56
69
|
|
57
|
-
|
58
|
-
|
70
|
+
o.separator ""
|
71
|
+
o.separator "For help on any individual command run `vagrant plugin COMMAND -h`"
|
59
72
|
end
|
60
73
|
|
61
74
|
@env.ui.info(opts.help, :prefix => false)
|
@@ -2,7 +2,7 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module Sahara
|
4
4
|
module Command
|
5
|
-
class Status <
|
5
|
+
class Status < Vagrant.plugin("2", :command)
|
6
6
|
|
7
7
|
def execute
|
8
8
|
|
@@ -19,9 +19,10 @@ module Sahara
|
|
19
19
|
argv = parse_options(opts)
|
20
20
|
return if !argv
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
ses = Sahara::Session::Command.new(@app, @env)
|
23
|
+
|
24
|
+
with_target_vms(argv, :reverse => true) do |machine|
|
25
|
+
ses.status(machine)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
data/lib/sahara/session.rb
CHANGED
@@ -1,240 +1,135 @@
|
|
1
1
|
require 'pp'
|
2
2
|
|
3
|
-
require 'sahara/shell'
|
4
|
-
|
5
3
|
module Sahara
|
6
4
|
module Session
|
5
|
+
class Command
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
@env = env
|
10
|
+
@vboxcmd=determine_vboxcmd
|
11
|
+
@sandboxname="sahara-sandbox"
|
12
|
+
end
|
13
|
+
|
14
|
+
def determine_vboxcmd
|
15
|
+
if windows?
|
16
|
+
# On Windows, we use the VBOX_INSTALL_PATH environmental
|
17
|
+
if ENV.has_key?("VBOX_INSTALL_PATH")
|
18
|
+
# The path usually ends with a \ but we make sure here
|
19
|
+
path = File.join(ENV["VBOX_INSTALL_PATH"], "VBoxManage.exe")
|
20
|
+
return "\"#{path}\""
|
21
|
+
end
|
22
|
+
else
|
23
|
+
# for other platforms assume it is on the PATH
|
24
|
+
return "VBoxManage"
|
15
25
|
end
|
16
|
-
else
|
17
|
-
# for other platforms assume it is on the PATH
|
18
|
-
return "VBoxManage"
|
19
26
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
|
28
|
+
def windows?
|
29
|
+
%W[mingw mswin].each do |text|
|
30
|
+
return true if RbConfig::CONFIG["host_os"].downcase.include?(text)
|
31
|
+
end
|
32
|
+
false
|
25
33
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def self.status(selection)
|
36
|
-
self.initialize
|
37
|
-
|
38
|
-
on_selected_vms(selection) do |boxname|
|
39
|
-
if is_snapshot_mode_on?(boxname)
|
40
|
-
puts "[#{boxname}] - snapshot mode is on"
|
41
|
-
else
|
42
|
-
puts "[#{boxname}] - snapshot mode is off"
|
34
|
+
|
35
|
+
def list_snapshots(machine)
|
36
|
+
snapshotlist=Array.new
|
37
|
+
instance_id = machine.id
|
38
|
+
output = `#{@vboxcmd} showvminfo --machinereadable "#{instance_id}"`
|
39
|
+
snapshotresult=output.scan(/SnapshotName.*=(.*)/).flatten
|
40
|
+
snapshotresult.each do |result|
|
41
|
+
clean=result.gsub(/\"/,'').chomp
|
42
|
+
snapshotlist << clean
|
43
43
|
end
|
44
|
+
snapshotlist
|
44
45
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
puts "[#{boxname}] - snapshot mode is already on"
|
46
|
+
|
47
|
+
def status(machine)
|
48
|
+
if !self.is_vm_created?(machine) then
|
49
|
+
puts "[#{machine.name}] VM is not created"
|
50
|
+
return
|
51
|
+
end
|
52
|
+
if self.is_snapshot_mode_on?(machine) then
|
53
|
+
puts "[#{machine.name}] Sandbox mode is on"
|
54
54
|
else
|
55
|
-
|
56
|
-
|
57
|
-
#Creating a snapshot
|
58
|
-
puts "[#{boxname}] - Enabling sandbox"
|
59
|
-
|
60
|
-
execute("#{@vboxcmd} snapshot \"#{instance_uuid}\" take \"#{@sandboxname}\" --pause")
|
55
|
+
puts "[#{machine.name}] Sandbox mode is off"
|
61
56
|
end
|
62
|
-
|
63
57
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
58
|
+
|
59
|
+
def is_snapshot_mode_on?(machine)
|
60
|
+
snapshots=self.list_snapshots(machine)
|
61
|
+
return snapshots.include?(@sandboxname)
|
62
|
+
end
|
63
|
+
|
64
|
+
def off(machine)
|
65
|
+
if !self.is_vm_created?(machine) then
|
66
|
+
puts "[#{machine.name}] VM is not created"
|
67
|
+
return
|
68
|
+
end
|
69
|
+
if self.is_snapshot_mode_on?(machine) then
|
70
|
+
instance_id = machine.id
|
71
|
+
`#{@vboxcmd} snapshot "#{instance_id}" delete "#{@sandboxname}" `
|
74
72
|
else
|
75
|
-
|
76
|
-
|
77
|
-
#Discard snapshot so current state is the latest state
|
78
|
-
puts "[#{boxname}] - unwinding sandbox"
|
79
|
-
execute("#{@vboxcmd} snapshot \"#{instance_uuid}\" delete \"#{@sandboxname}\"")
|
80
|
-
|
81
|
-
#Now retake the snapshot
|
82
|
-
puts "[#{boxname}] - fastforwarding sandbox"
|
83
|
-
|
84
|
-
execute("#{@vboxcmd} snapshot \"#{instance_uuid}\" take \"#{@sandboxname}\" --pause")
|
85
|
-
|
73
|
+
puts "[#{machine.name}] Not sandbox mode now"
|
86
74
|
end
|
87
|
-
|
88
75
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
puts "[#{boxname}] - this requires that sandbox mode is on."
|
76
|
+
|
77
|
+
def on(machine)
|
78
|
+
if !self.is_vm_created?(machine) then
|
79
|
+
puts "[#{machine.name}] VM is not created"
|
80
|
+
return
|
81
|
+
end
|
82
|
+
if !self.is_snapshot_mode_on?(machine) then
|
83
|
+
instance_id = machine.id
|
84
|
+
`#{@vboxcmd} snapshot "#{instance_id}" take "#{@sandboxname}" --pause`
|
99
85
|
else
|
100
|
-
|
101
|
-
|
102
|
-
puts "[#{boxname}] - powering off machine"
|
103
|
-
|
104
|
-
#Poweroff machine
|
105
|
-
execute("#{@vboxcmd} controlvm \"#{instance_uuid}\" poweroff")
|
106
|
-
|
107
|
-
#Poweroff takes a second or so to complete; Virtualbox will throw errors
|
108
|
-
#if you try to restore a snapshot before it's ready.
|
109
|
-
sleep 2
|
110
|
-
|
111
|
-
puts "[#{boxname}] - roll back machine"
|
112
|
-
|
113
|
-
#Rollback until snapshot
|
114
|
-
execute("#{@vboxcmd} snapshot \"#{instance_uuid}\" restore \"#{@sandboxname}\"")
|
115
|
-
|
116
|
-
puts "[#{boxname}] - starting the machine again"
|
117
|
-
|
118
|
-
#Startvm again
|
119
|
-
#
|
120
|
-
# Grab the boot_mode setting from the Vagrantfile
|
121
|
-
config_boot_mode="#{@vagrant_env.vms[boxname.to_sym].config.vm.boot_mode.to_s}"
|
122
|
-
|
123
|
-
case config_boot_mode
|
124
|
-
when 'vrdp'
|
125
|
-
boot_mode='headless'
|
126
|
-
when 'headless'
|
127
|
-
boot_mode='headless'
|
128
|
-
when 'gui'
|
129
|
-
boot_mode='gui'
|
130
|
-
else
|
131
|
-
puts "Vagrantfile config.vm.boot_mode=#{config_boot_mode} setting unknown - defaulting to headless"
|
132
|
-
boot_mode='headless'
|
133
|
-
end
|
134
|
-
|
135
|
-
execute("#{@vboxcmd} startvm --type #{boot_mode} \"#{instance_uuid}\" ")
|
136
|
-
|
86
|
+
puts "[#{machine.name}] Already sandbox mode"
|
137
87
|
end
|
138
|
-
|
139
88
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
|
151
|
-
|
152
|
-
if !is_snapshot_mode_on?(boxname)
|
153
|
-
puts "[#{boxname}] - this requires that sandbox mode is on."
|
89
|
+
|
90
|
+
def commit(machine)
|
91
|
+
if !self.is_vm_created?(machine) then
|
92
|
+
puts "[#{machine.name}] VM is not created"
|
93
|
+
return
|
94
|
+
end
|
95
|
+
if self.is_snapshot_mode_on?(machine) then
|
96
|
+
instance_id = machine.id
|
97
|
+
`#{@vboxcmd} snapshot "#{instance_id}" delete "#{@sandboxname}"`
|
98
|
+
`#{@vboxcmd} snapshot "#{instance_id}" take "#{@sandboxname}" --pause`
|
154
99
|
else
|
155
|
-
puts "[#{
|
156
|
-
|
157
|
-
# We might wanna check for sandbox changes or not
|
158
|
-
|
159
|
-
#Discard snapshot
|
160
|
-
execute("#{@vboxcmd} snapshot \"#{instance_uuid}\" delete \"#{@sandboxname}\" ")
|
161
|
-
|
100
|
+
puts "[#{machine.name}] Not sandbox mode now"
|
162
101
|
end
|
163
|
-
|
164
102
|
end
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
if @vagrant_env.vms[boxname.to_sym].nil?
|
175
|
-
puts "[#{boxname}] - Box name doesn't exist in the Vagrantfile"
|
176
|
-
return false
|
177
|
-
else
|
178
|
-
return !@vagrant_env.vms[boxname.to_sym].uuid.nil?
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def self.list_snapshots(boxname)
|
183
|
-
|
184
|
-
instance_uuid="#{@vagrant_env.vms[boxname.to_sym].uuid}"
|
185
|
-
snapshotlist=Array.new
|
186
|
-
output=execute("#{@vboxcmd} showvminfo --machinereadable \"#{instance_uuid}\"").join
|
187
|
-
snapshotresult=output.scan(/SnapshotName.*=(.*)/).flatten
|
188
|
-
snapshotresult.each do |result|
|
189
|
-
clean=result.gsub(/\"/,'').chomp
|
190
|
-
snapshotlist << clean
|
191
|
-
end
|
192
|
-
return snapshotlist
|
193
|
-
end
|
194
|
-
|
195
|
-
def self.is_snapshot_mode_on?(boxname)
|
196
|
-
snapshots=list_snapshots(boxname)
|
197
|
-
return snapshots.include?(@sandboxname)
|
198
|
-
end
|
199
|
-
|
200
|
-
def self.on_selected_vms(selection,&block)
|
201
|
-
|
202
|
-
if selection.nil?
|
203
|
-
#puts "no selection was done"
|
204
|
-
@vagrant_env.vms.each do |name,vm|
|
205
|
-
#puts "Processing #{name}"
|
206
|
-
if @vagrant_env.multivm?
|
207
|
-
if name.to_s!="default"
|
208
|
-
if is_vm_created?(name)
|
209
|
-
yield name
|
210
|
-
else
|
211
|
-
puts "[#{name}] - machine not created"
|
212
|
-
end
|
213
|
-
end
|
214
|
-
else
|
215
|
-
if is_vm_created?(name)
|
216
|
-
yield name
|
217
|
-
else
|
218
|
-
puts "[#{name}] - machine not created"
|
219
|
-
end
|
220
|
-
end
|
103
|
+
|
104
|
+
def rollback(machine)
|
105
|
+
if !self.is_vm_created?(machine) then
|
106
|
+
puts "[#{machine.name}] VM is not created"
|
107
|
+
return
|
108
|
+
end
|
109
|
+
if !self.is_snapshot_mode_on?(machine) then
|
110
|
+
puts "[#{machine.name}] Not sandbox mode now"
|
111
|
+
return
|
221
112
|
end
|
222
|
-
|
223
|
-
|
224
|
-
|
113
|
+
|
114
|
+
instance_id = machine.id
|
115
|
+
`#{@vboxcmd} controlvm "#{instance_id}" poweroff `
|
116
|
+
sleep 2
|
117
|
+
`#{@vboxcmd} snapshot "#{instance_id}" restore "#{@sandboxname}"`
|
118
|
+
|
119
|
+
gui_boot = machine.provider_config.gui
|
120
|
+
if gui_boot
|
121
|
+
boot_mode = "gui"
|
225
122
|
else
|
226
|
-
|
123
|
+
boot_mode = "headless"
|
227
124
|
end
|
125
|
+
# restore boot mode
|
126
|
+
`#{@vboxcmd} startvm --type #{boot_mode} "#{instance_id}" `
|
228
127
|
end
|
128
|
+
|
129
|
+
def is_vm_created?(machine)
|
130
|
+
return !machine.id.nil?
|
131
|
+
end
|
132
|
+
|
229
133
|
end
|
230
134
|
end
|
231
135
|
end
|
232
|
-
|
233
|
-
|
234
|
-
#command="#{@vboxcmd} unregistervm '#{boxname}' --delete"
|
235
|
-
#puts command
|
236
|
-
#puts "Deleting vm #{boxname}"
|
237
|
-
|
238
|
-
#Exec and system stop the execution here
|
239
|
-
#Veewee::Shell.execute("#{command}")
|
240
|
-
|
data/lib/sahara/version.rb
CHANGED
data/sahara.gemspec
CHANGED
metadata
CHANGED
@@ -1,149 +1,110 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sahara
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 13
|
10
|
-
version: 0.0.13
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Patrick Debois
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: popen4
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
version: "1.0"
|
32
|
-
prerelease: false
|
33
|
-
name: vagrant
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.2
|
36
22
|
type: :runtime
|
37
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
25
|
none: false
|
39
|
-
requirements:
|
26
|
+
requirements:
|
40
27
|
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 31
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 1
|
46
|
-
- 2
|
28
|
+
- !ruby/object:Gem::Version
|
47
29
|
version: 0.1.2
|
48
|
-
|
49
|
-
name:
|
50
|
-
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
type: :runtime
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
54
33
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
- 0
|
61
|
-
- 14
|
62
|
-
version: "0.14"
|
34
|
+
requirements:
|
35
|
+
- - ! '>'
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0.14'
|
38
|
+
type: :runtime
|
63
39
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>'
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.14'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
69
49
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
hash: 23
|
74
|
-
segments:
|
75
|
-
- 1
|
76
|
-
- 0
|
77
|
-
- 0
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
78
53
|
version: 1.0.0
|
54
|
+
type: :development
|
79
55
|
prerelease: false
|
80
|
-
|
81
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0
|
82
62
|
description: Allows you to sandbox your vagrant
|
83
|
-
email:
|
63
|
+
email:
|
84
64
|
- patrick.debois@jedi.be
|
85
65
|
executables: []
|
86
|
-
|
87
66
|
extensions: []
|
88
|
-
|
89
67
|
extra_rdoc_files: []
|
90
|
-
|
91
|
-
files:
|
68
|
+
files:
|
92
69
|
- .gitignore
|
93
|
-
- .rvmrc
|
94
70
|
- Gemfile
|
95
|
-
- Gemfile.lock
|
96
71
|
- README.md
|
97
72
|
- Rakefile
|
98
|
-
- Vagrantfile.multi
|
99
|
-
- Vagrantfile.single
|
100
73
|
- lib/sahara.rb
|
101
74
|
- lib/sahara/command/commit.rb
|
102
75
|
- lib/sahara/command/off.rb
|
103
76
|
- lib/sahara/command/on.rb
|
104
77
|
- lib/sahara/command/rollback.rb
|
105
|
-
- lib/sahara/command/
|
78
|
+
- lib/sahara/command/root.rb
|
106
79
|
- lib/sahara/command/status.rb
|
107
|
-
- lib/sahara/command/vagrant.rb
|
108
80
|
- lib/sahara/session.rb
|
109
|
-
- lib/sahara/shell.rb
|
110
81
|
- lib/sahara/version.rb
|
111
|
-
- lib/vagrant_init.rb
|
112
82
|
- sahara.gemspec
|
113
83
|
homepage: http://github.com/jedi4ever/sahara/
|
114
84
|
licenses: []
|
115
|
-
|
116
85
|
post_install_message:
|
117
86
|
rdoc_options: []
|
118
|
-
|
119
|
-
require_paths:
|
87
|
+
require_paths:
|
120
88
|
- lib
|
121
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
90
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
segments:
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
segments:
|
128
96
|
- 0
|
129
|
-
|
130
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
hash: 2159711704490986345
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
99
|
none: false
|
132
|
-
requirements:
|
133
|
-
- -
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
hash: 23
|
136
|
-
segments:
|
137
|
-
- 1
|
138
|
-
- 3
|
139
|
-
- 6
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
140
103
|
version: 1.3.6
|
141
104
|
requirements: []
|
142
|
-
|
143
105
|
rubyforge_project: sahara
|
144
|
-
rubygems_version: 1.8.
|
106
|
+
rubygems_version: 1.8.24
|
145
107
|
signing_key:
|
146
108
|
specification_version: 3
|
147
109
|
summary: Vagrant box creation
|
148
110
|
test_files: []
|
149
|
-
|
data/.rvmrc
DELETED
data/Gemfile.lock
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
sahara (0.0.13)
|
5
|
-
popen4 (~> 0.1.2)
|
6
|
-
thor (> 0.14)
|
7
|
-
vagrant (~> 1.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: http://rubygems.org/
|
11
|
-
specs:
|
12
|
-
Platform (0.4.0)
|
13
|
-
archive-tar-minitar (0.5.2)
|
14
|
-
childprocess (0.3.2)
|
15
|
-
ffi (~> 1.0.6)
|
16
|
-
erubis (2.7.0)
|
17
|
-
ffi (1.0.11)
|
18
|
-
i18n (0.6.0)
|
19
|
-
json (1.5.4)
|
20
|
-
log4r (1.1.10)
|
21
|
-
net-scp (1.0.4)
|
22
|
-
net-ssh (>= 1.99.1)
|
23
|
-
net-ssh (2.2.2)
|
24
|
-
open4 (1.3.0)
|
25
|
-
popen4 (0.1.2)
|
26
|
-
Platform (>= 0.4.0)
|
27
|
-
open4 (>= 0.4.0)
|
28
|
-
rake (0.9.2.2)
|
29
|
-
thor (0.15.2)
|
30
|
-
vagrant (1.0.3)
|
31
|
-
archive-tar-minitar (= 0.5.2)
|
32
|
-
childprocess (~> 0.3.1)
|
33
|
-
erubis (~> 2.7.0)
|
34
|
-
i18n (~> 0.6.0)
|
35
|
-
json (~> 1.5.1)
|
36
|
-
log4r (~> 1.1.9)
|
37
|
-
net-scp (~> 1.0.4)
|
38
|
-
net-ssh (~> 2.2.2)
|
39
|
-
|
40
|
-
PLATFORMS
|
41
|
-
ruby
|
42
|
-
|
43
|
-
DEPENDENCIES
|
44
|
-
rake
|
45
|
-
sahara!
|
data/Vagrantfile.multi
DELETED
data/Vagrantfile.single
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
Vagrant::Config.run do |config|
|
2
|
-
|
3
|
-
# All Vagrant configuration is done here. The most common configuration
|
4
|
-
# options are documented and commented below. For a complete reference,
|
5
|
-
# please see the online documentation at vagrantup.com.
|
6
|
-
|
7
|
-
# Every Vagrant virtual environment requires a box to build off of.
|
8
|
-
config.vm.box = "maverick64"
|
9
|
-
|
10
|
-
# Enable provisioning with chef server, specifying the chef server URL,
|
11
|
-
# and the path to the validation key (relative to this Vagrantfile).
|
12
|
-
#
|
13
|
-
# The Opscode Platform uses HTTPS. Substitute your organization for
|
14
|
-
# ORGNAME in the URL and validation key.
|
15
|
-
#
|
16
|
-
# If you have your own Chef Server, use the appropriate URL, which may be
|
17
|
-
# HTTP instead of HTTPS depending on your configuration. Also change the
|
18
|
-
# validation key to validation.pem.
|
19
|
-
#
|
20
|
-
#config.vm.provision :chef_server do |chef|
|
21
|
-
#chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
22
|
-
#chef.validation_key_path = "ORGNAME-validator.pem"
|
23
|
-
#end
|
24
|
-
#
|
25
|
-
# If you're using the Opscode platform, your validator client is
|
26
|
-
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
27
|
-
#
|
28
|
-
# IF you have your own Chef Server, the default validation client name is
|
29
|
-
# chef-validator, unless you changed the configuration.
|
30
|
-
#
|
31
|
-
# chef.validation_client_name = "ORGNAME-validator"
|
32
|
-
end
|
33
|
-
|
data/lib/sahara/shell.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#require 'open4'
|
2
|
-
|
3
|
-
module Sahara
|
4
|
-
class Shell
|
5
|
-
|
6
|
-
def self.execute(command,options = {})
|
7
|
-
STDOUT.sync = true
|
8
|
-
output=nil
|
9
|
-
result=IO.popen("#{command}") {|f| output=f.readlines}
|
10
|
-
#{ |f| print "#{f}, #{f.class}" }
|
11
|
-
# output=result.read
|
12
|
-
return output
|
13
|
-
end
|
14
|
-
|
15
|
-
#pty allows you to gradually see the output of a local command
|
16
|
-
#http://www.shanison.com/?p=415
|
17
|
-
def self.execute2(command, options = {} )
|
18
|
-
require "pty"
|
19
|
-
begin
|
20
|
-
PTY.spawn( command ) do |r, w, pid|
|
21
|
-
begin
|
22
|
-
#r.each { }
|
23
|
-
r.each { |line| print line;}
|
24
|
-
|
25
|
-
rescue Errno::EIO
|
26
|
-
end
|
27
|
-
end
|
28
|
-
rescue PTY::ChildExited => e
|
29
|
-
puts "The child process exited!"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
#occassinally fails with 'no child processes
|
34
|
-
def self.execute3(command, options = {} )
|
35
|
-
defaults= { :port => "22", :exitcode => "0", :user => "root"}
|
36
|
-
options=defaults.merge(options)
|
37
|
-
|
38
|
-
status = POpen4::popen4(command) do |stdout,stderr,stdin|
|
39
|
-
stdout.each do |line|
|
40
|
-
puts line
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
@status=status.to_i
|
45
|
-
|
46
|
-
if (@status.to_s != options[:exitcode] )
|
47
|
-
if (options[:exitcode]=="*")
|
48
|
-
#its a test so we don't need to worry
|
49
|
-
else
|
50
|
-
raise "Exitcode was not what we expected"
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end #Class
|
58
|
-
end #Module
|