vbox 0.0.4

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 (131) hide show
  1. data/.gitignore +14 -0
  2. data/Gemfile +5 -0
  3. data/Gemfile.lock +68 -0
  4. data/README.md +5 -0
  5. data/Rakefile +91 -0
  6. data/bin/vbox +73 -0
  7. data/lib/java/README.txt +5 -0
  8. data/lib/java/dir2floppy.jar +0 -0
  9. data/lib/java/dir2floppy.java +134 -0
  10. data/lib/vagrant_init.rb +6 -0
  11. data/lib/vbox.rb +2 -0
  12. data/lib/vbox/command.rb +82 -0
  13. data/lib/vbox/config.rb +5 -0
  14. data/lib/vbox/export.rb +65 -0
  15. data/lib/vbox/scancode.rb +208 -0
  16. data/lib/vbox/session.rb +893 -0
  17. data/lib/vbox/shell.rb +54 -0
  18. data/lib/vbox/ssh.rb +193 -0
  19. data/lib/vbox/transaction.rb +122 -0
  20. data/lib/vbox/utils.rb +26 -0
  21. data/lib/vbox/version.rb +3 -0
  22. data/lib/vbox/web.rb +48 -0
  23. data/templates/CentOS-5.7-i386-netboot/definition.rb +16 -0
  24. data/templates/CentOS-5.7-i386-netboot/ks.cfg +45 -0
  25. data/templates/CentOS-5.7-i386-netboot/postinstall.sh +53 -0
  26. data/templates/CentOS-5.7-x86_64-netboot/definition.rb +16 -0
  27. data/templates/CentOS-5.7-x86_64-netboot/ks.cfg +45 -0
  28. data/templates/CentOS-5.7-x86_64-netboot/postinstall.sh +60 -0
  29. data/templates/CentOS-6.0-i386-netboot/definition.rb +16 -0
  30. data/templates/CentOS-6.0-i386-netboot/ks.cfg +52 -0
  31. data/templates/CentOS-6.0-i386-netboot/postinstall.sh +30 -0
  32. data/templates/CentOS-6.0-i386/definition.rb +17 -0
  33. data/templates/CentOS-6.0-i386/ks.cfg +47 -0
  34. data/templates/CentOS-6.0-i386/postinstall.sh +48 -0
  35. data/templates/CentOS-6.0-x86_64-netboot/definition.rb +16 -0
  36. data/templates/CentOS-6.0-x86_64-netboot/ks.cfg +52 -0
  37. data/templates/CentOS-6.0-x86_64-netboot/postinstall.sh +30 -0
  38. data/templates/CentOS-6.0-x86_64/definition.rb +17 -0
  39. data/templates/CentOS-6.0-x86_64/ks.cfg +47 -0
  40. data/templates/CentOS-6.0-x86_64/postinstall.sh +48 -0
  41. data/templates/Debian-6.0.3-amd64-netboot/definition.rb +42 -0
  42. data/templates/Debian-6.0.3-amd64-netboot/postinstall.sh +80 -0
  43. data/templates/Debian-6.0.3-amd64-netboot/preseed.cfg +42 -0
  44. data/templates/Debian-6.0.3-i386-netboot/definition.rb +44 -0
  45. data/templates/Debian-6.0.3-i386-netboot/postinstall.sh +80 -0
  46. data/templates/Debian-6.0.3-i386-netboot/preseed.cfg +42 -0
  47. data/templates/Fedora-15-i386-netboot/definition.rb +17 -0
  48. data/templates/Fedora-15-i386-netboot/ks.cfg +82 -0
  49. data/templates/Fedora-15-i386-netboot/postinstall.sh +18 -0
  50. data/templates/Fedora-15-i386/definition.rb +17 -0
  51. data/templates/Fedora-15-i386/ks.cfg +64 -0
  52. data/templates/Fedora-15-i386/postinstall.sh +33 -0
  53. data/templates/Fedora-15-x86_64-netboot/definition.rb +29 -0
  54. data/templates/Fedora-15-x86_64-netboot/ks.cfg +64 -0
  55. data/templates/Fedora-15-x86_64-netboot/postinstall.sh +33 -0
  56. data/templates/Fedora-15-x86_64/definition.rb +17 -0
  57. data/templates/Fedora-15-x86_64/ks.cfg +64 -0
  58. data/templates/Fedora-15-x86_64/postinstall.sh +33 -0
  59. data/templates/Sysrescuecd-2.0.0-experimental/autorun0 +3 -0
  60. data/templates/Sysrescuecd-2.0.0-experimental/definition.rb +20 -0
  61. data/templates/archlinux-i386-netboot/aif.cfg +34 -0
  62. data/templates/archlinux-i386-netboot/definition.rb +29 -0
  63. data/templates/archlinux-i386-netboot/postinstall.sh +87 -0
  64. data/templates/archlinux-i386-netboot/postinstall2.sh +28 -0
  65. data/templates/archlinux-i386/aif.cfg +33 -0
  66. data/templates/archlinux-i386/definition.rb +29 -0
  67. data/templates/archlinux-i386/postinstall.sh +106 -0
  68. data/templates/archlinux-x86_64-netboot/aif.cfg +34 -0
  69. data/templates/archlinux-x86_64-netboot/definition.rb +29 -0
  70. data/templates/archlinux-x86_64-netboot/postinstall.sh +90 -0
  71. data/templates/archlinux-x86_64-netboot/postinstall2.sh +28 -0
  72. data/templates/archlinux-x86_64/aif.cfg +33 -0
  73. data/templates/archlinux-x86_64/definition.rb +29 -0
  74. data/templates/archlinux-x86_64/postinstall.sh +90 -0
  75. data/templates/archlinux-x86_64/postinstall2.sh +38 -0
  76. data/templates/freebsd-8.2-experimental/definition.rb +19 -0
  77. data/templates/freebsd-8.2-experimental/postinstall.sh +191 -0
  78. data/templates/freebsd-8.2-pcbsd-i386-netboot/definition.rb +35 -0
  79. data/templates/freebsd-8.2-pcbsd-i386-netboot/pcinstall.fbg.cfg +58 -0
  80. data/templates/freebsd-8.2-pcbsd-i386-netboot/postinstall.sh +93 -0
  81. data/templates/freebsd-8.2-pcbsd-i386/definition.rb +31 -0
  82. data/templates/freebsd-8.2-pcbsd-i386/pcinstall.fbg.cfg +57 -0
  83. data/templates/freebsd-8.2-pcbsd-i386/postinstall.sh +93 -0
  84. data/templates/gentoo-latest-i386-experimental/definition.rb +29 -0
  85. data/templates/gentoo-latest-i386-experimental/postinstall.sh +184 -0
  86. data/templates/openSUSE-11.4-DVD-i586/autoinst_de.xml +1284 -0
  87. data/templates/openSUSE-11.4-DVD-i586/autoinst_en.xml +1284 -0
  88. data/templates/openSUSE-11.4-DVD-i586/definition.rb +28 -0
  89. data/templates/openSUSE-11.4-DVD-i586/postinstall.sh +43 -0
  90. data/templates/openSUSE-11.4-DVD-x86_64/autoinst_de.xml +1459 -0
  91. data/templates/openSUSE-11.4-DVD-x86_64/autoinst_en.xml +1459 -0
  92. data/templates/openSUSE-11.4-DVD-x86_64/definition.rb +28 -0
  93. data/templates/openSUSE-11.4-DVD-x86_64/postinstall.sh +43 -0
  94. data/templates/openSUSE-11.4-NET-i586/autoinst_de.xml +1278 -0
  95. data/templates/openSUSE-11.4-NET-i586/autoinst_en.xml +1278 -0
  96. data/templates/openSUSE-11.4-NET-i586/definition.rb +28 -0
  97. data/templates/openSUSE-11.4-NET-i586/postinstall.sh +43 -0
  98. data/templates/openSUSE-11.4-NET-x86_64/autoinst_de.xml +1453 -0
  99. data/templates/openSUSE-11.4-NET-x86_64/autoinst_en.xml +1453 -0
  100. data/templates/openSUSE-11.4-NET-x86_64/definition.rb +28 -0
  101. data/templates/openSUSE-11.4-NET-x86_64/postinstall.sh +43 -0
  102. data/templates/solaris-11-express-i386/auto_install/ai.dtd +58 -0
  103. data/templates/solaris-11-express-i386/auto_install/ai_manifest.xml +241 -0
  104. data/templates/solaris-11-express-i386/auto_install/configuration.dtd +44 -0
  105. data/templates/solaris-11-express-i386/auto_install/default.xml +124 -0
  106. data/templates/solaris-11-express-i386/auto_install/default.xml.orig +124 -0
  107. data/templates/solaris-11-express-i386/auto_install/sc_profiles/static_network.xml +105 -0
  108. data/templates/solaris-11-express-i386/auto_install/software.dtd +105 -0
  109. data/templates/solaris-11-express-i386/auto_install/target.dtd +196 -0
  110. data/templates/solaris-11-express-i386/default.xml +121 -0
  111. data/templates/solaris-11-express-i386/definition.rb +65 -0
  112. data/templates/solaris-11-express-i386/postinstall.sh +98 -0
  113. data/templates/ubuntu-10.04.3-server-amd64/definition.rb +54 -0
  114. data/templates/ubuntu-10.04.3-server-amd64/postinstall.sh +90 -0
  115. data/templates/ubuntu-10.04.3-server-amd64/preseed.cfg +87 -0
  116. data/templates/ubuntu-10.04.3-server-i386/definition.rb +24 -0
  117. data/templates/ubuntu-10.04.3-server-i386/postinstall.sh +91 -0
  118. data/templates/ubuntu-10.04.3-server-i386/preseed.cfg +87 -0
  119. data/templates/ubuntu-11.10-server-amd64/definition.rb +35 -0
  120. data/templates/ubuntu-11.10-server-amd64/postinstall.sh +90 -0
  121. data/templates/ubuntu-11.10-server-amd64/preseed.cfg +87 -0
  122. data/templates/ubuntu-11.10-server-i386/definition.rb +35 -0
  123. data/templates/ubuntu-11.10-server-i386/postinstall.sh +90 -0
  124. data/templates/ubuntu-11.10-server-i386/preseed.cfg +87 -0
  125. data/validation/features/steps/ssh_steps.rb +169 -0
  126. data/validation/support/env.rb +1 -0
  127. data/validation/vagrant-private.key +27 -0
  128. data/validation/vagrant.feature +52 -0
  129. data/validation/vagrant.pub +1 -0
  130. data/vbox.gemspec +32 -0
  131. metadata +338 -0
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.box
2
+ *.gem
3
+ .DS_Store
4
+ .vagrant
5
+ boxes/*
6
+ cookbooks/*
7
+ definitions/*
8
+ gems/*
9
+ iso/*
10
+ manifests/*
11
+ pkg/*
12
+ tmp/*
13
+ Vagrantfile
14
+ virtualfloppy.vfd
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "vbox", :path => "."
4
+
5
+ #gem "vagrant", :git => "git://github.com/minihub/vbox.git"
data/Gemfile.lock ADDED
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vbox (0.0.4)
5
+ cucumber (~> 1.0.2)
6
+ highline (~> 1.6.1)
7
+ net-ssh (~> 2.1.0)
8
+ popen4 (~> 0.1.2)
9
+ progressbar
10
+ rspec (~> 2.5.0)
11
+ thor (~> 0.14.6)
12
+ vagrant (~> 0.8.2)
13
+
14
+ GEM
15
+ remote: http://rubygems.org/
16
+ specs:
17
+ Platform (0.4.0)
18
+ archive-tar-minitar (0.5.2)
19
+ builder (3.0.0)
20
+ cucumber (1.0.2)
21
+ builder (>= 2.1.2)
22
+ diff-lcs (>= 1.1.2)
23
+ gherkin (~> 2.4.5)
24
+ json (>= 1.4.6)
25
+ term-ansicolor (>= 1.0.5)
26
+ diff-lcs (1.1.3)
27
+ erubis (2.7.0)
28
+ ffi (1.0.11)
29
+ gherkin (2.4.21)
30
+ json (>= 1.4.6)
31
+ highline (1.6.8)
32
+ i18n (0.6.0)
33
+ json (1.5.3)
34
+ net-scp (1.0.4)
35
+ net-ssh (>= 1.99.1)
36
+ net-ssh (2.1.4)
37
+ open4 (1.3.0)
38
+ popen4 (0.1.2)
39
+ Platform (>= 0.4.0)
40
+ open4 (>= 0.4.0)
41
+ progressbar (0.9.2)
42
+ rspec (2.5.0)
43
+ rspec-core (~> 2.5.0)
44
+ rspec-expectations (~> 2.5.0)
45
+ rspec-mocks (~> 2.5.0)
46
+ rspec-core (2.5.2)
47
+ rspec-expectations (2.5.0)
48
+ diff-lcs (~> 1.1.2)
49
+ rspec-mocks (2.5.0)
50
+ term-ansicolor (1.0.7)
51
+ thor (0.14.6)
52
+ vagrant (0.8.7)
53
+ archive-tar-minitar (= 0.5.2)
54
+ erubis (~> 2.7.0)
55
+ i18n (~> 0.6.0)
56
+ json (~> 1.5.1)
57
+ net-scp (~> 1.0.4)
58
+ net-ssh (~> 2.1.4)
59
+ thor (~> 0.14.6)
60
+ virtualbox (~> 0.9.1)
61
+ virtualbox (0.9.2)
62
+ ffi (~> 1.0.9)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ vbox!
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ **VBox:** the tool to easily build vagrant base boxes
2
+
3
+ Vagrant is a great tool to test new things or changes in a virtual machine using either chef or puppet.
4
+ VBox extends vagrant to earily build those Virtual Machines based on tested templates.
5
+
data/Rakefile ADDED
@@ -0,0 +1,91 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'bundler/setup'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ #Setup some base variables to use
7
+ vbox_dir= "."
8
+ definition_dir= File.expand_path(File.join(vbox_dir, "definitions"))
9
+ lib_dir= File.expand_path(File.join(vbox_dir, "lib"))
10
+ box_dir= File.expand_path(File.join(vbox_dir, "boxes"))
11
+ template_dir=File.expand_path(File.join(vbox_dir, "templates"))
12
+ vbox_dir=File.expand_path(File.join(vbox_dir, "tmp"))
13
+ tmp_dir=File.expand_path(File.join(vbox_dir, "tmp"))
14
+ iso_dir=File.expand_path(File.join(vbox_dir, "iso"))
15
+
16
+ #Load vbox::Session libraries
17
+ Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f|
18
+ require f }
19
+
20
+ #Initialize
21
+ vbox::Session.setenv({:vbox_dir => vbox_dir, :definition_dir => definition_dir,
22
+ :template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir})
23
+
24
+ desc 'Default: list templates'
25
+ task :default => [:templates]
26
+
27
+ desc 'List templates'
28
+ task :templates do
29
+ vbox::Session.list_templates
30
+ end
31
+
32
+ desc 'Define box'
33
+ task :define, [:boxname,:template_name] do |t,args|
34
+ if args.to_hash.size!=2
35
+ puts "needs two arguments: rake define['boxname','template_name']"
36
+ exit
37
+ end
38
+ vbox::Session.define(args.boxname,args.template_name)
39
+ end
40
+
41
+ desc 'Undefine box'
42
+ task :undefine, [:boxname] do |t,args|
43
+ if args.to_hash.size!=1
44
+ puts "needs one arguments: rake undefine[\"yourname\"]"
45
+ exit
46
+ end
47
+ vbox::Session.undefine(args.boxname)
48
+ end
49
+
50
+ desc 'List Definitions'
51
+ task :definitions do
52
+ vbox::Session.list_definitions
53
+ end
54
+
55
+ desc 'Build box'
56
+ task :build, [:boxname] do |t,args|
57
+ if args.to_hash.size!=1
58
+ puts "needs one arguments: rake build['boxname']"
59
+ exit
60
+ end
61
+ vbox::Session.build(args.boxname)
62
+ end
63
+
64
+ desc 'List boxes'
65
+ task :boxes do
66
+ vbox::Session.list_boxes
67
+ end
68
+
69
+ desc 'Export box'
70
+ task :export, [:boxname] do |t,args|
71
+ if args.to_hash.size!=1
72
+ puts "needs one arguments: rake export['boxname']"
73
+ exit
74
+ end
75
+ vbox::Session.export_box(args.boxname)
76
+ end
77
+
78
+ desc 'Remove box'
79
+ task :remove_box, [:boxname] do |t,args|
80
+ vbox::Session.remove_box(args.boxname)
81
+ end
82
+
83
+ desc 'List ostypes available'
84
+ task :list_ostypes do |t,args|
85
+ vbox::Session.list_ostypes
86
+ end
87
+
88
+ desc 'Clean all unfinished builds'
89
+ task :clean do
90
+ vbox::Session.clean
91
+ end
data/bin/vbox ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'bundler'
6
+ require 'virtualbox'
7
+ require 'vbox'
8
+
9
+ #Setup some base variables to use
10
+ vbox_dir= File.expand_path(File.join(File.dirname(__FILE__),".."))
11
+ definition_dir= File.expand_path(File.join(".", "definitions"))
12
+ lib_dir= File.expand_path(File.join(vbox_dir, "lib"))
13
+ box_dir= File.expand_path(File.join(vbox_dir, "boxes"))
14
+ template_dir=File.expand_path(File.join(vbox_dir, "templates"))
15
+ tmp_dir=File.expand_path(File.join(vbox_dir, "tmp"))
16
+ iso_dir=File.expand_path(File.join(vbox_dir, "iso"))
17
+
18
+ #Load Vbox::Session libraries
19
+ Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f|
20
+ require f }
21
+
22
+ #Initialize
23
+ Vbox::Session.setenv({
24
+ :vbox_dir => vbox_dir,
25
+ :definition_dir => definition_dir,
26
+ :template_dir => template_dir,
27
+ :iso_dir => iso_dir,
28
+ :box_dir => box_dir,
29
+ :tmp_dir => tmp_dir})
30
+
31
+ class VboxCLI < Thor
32
+
33
+ desc "init [NAME] [TEMPLATE]", "initializes a vbox from a template"
34
+ method_options :force => :boolean
35
+ def init(boxname=nil, template=nil)
36
+ if (boxname.nil?)
37
+ puts "please provide a boxname"
38
+ exit
39
+ end
40
+
41
+ puts "Init a new box #{boxname}, starting from template #{template}"
42
+ Vbox::Session.define(boxname,template)
43
+
44
+ end
45
+
46
+ desc "templates", "list the template available"
47
+ def templates
48
+ Vbox::Session.list_templates
49
+ end
50
+
51
+ desc "build [NAME]", "build the box defined"
52
+ method_options :force => :boolean
53
+ def build(boxname)
54
+ puts "Building box #{boxname}"
55
+ Vbox::Session.build(boxname)
56
+ end
57
+
58
+ desc "export [NAME]", "export the box"
59
+ method_options :force => :boolean
60
+ def export(boxname)
61
+ if (!boxname.nil?)
62
+ Vbox::Session.export_box(boxname)
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+ version=VirtualBox.version
69
+ if (version.match(/^4./))
70
+ VboxCLI.start
71
+ else
72
+ puts "Vbox only supports VirtualBox 4.x"
73
+ end
@@ -0,0 +1,5 @@
1
+ $ java -jar dir2floppy.jar
2
+ Usage: java -jar dir2floppy.jar <sourcedir> <floppyfile>
3
+
4
+ This uses the http://code.google.com/p/fat32-lib library
5
+ http://code.google.com/p/fat32-lib/wiki/Tutorial
Binary file
@@ -0,0 +1,134 @@
1
+ package be.jedi.dir2floppy;
2
+
3
+ import java.io.File;
4
+ import java.io.FileInputStream;
5
+ import java.io.IOException;
6
+ import java.nio.ByteBuffer;
7
+ import java.nio.channels.FileChannel;
8
+
9
+ import de.waldheinz.fs.FileSystem;
10
+ import de.waldheinz.fs.FsDirectoryEntry;
11
+ import de.waldheinz.fs.FsFile;
12
+ import de.waldheinz.fs.fat.SuperFloppyFormatter;
13
+ import de.waldheinz.fs.util.FileDisk;
14
+
15
+ /**
16
+ * Hello world!
17
+ *
18
+ */
19
+ public class Dir2Floppy {
20
+ public static void main(String[] args) {
21
+ if (args.length < 2) {
22
+ System.out
23
+ .println("Usage: java -jar dir2floppy.jar <sourcedir> <floppyfile>");
24
+ System.exit(-1);
25
+ }
26
+
27
+ FileDisk device = null;
28
+
29
+ // Create the floppy
30
+ try {
31
+ device = FileDisk.create(new File(args[1]), (long) 1440 * 1024);
32
+ } catch (IOException e) {
33
+ // TODO Auto-generated catch block
34
+ e.printStackTrace();
35
+ System.exit(-1);
36
+ }
37
+
38
+ // Format the floppy
39
+ FileSystem fs = null;
40
+ try {
41
+ fs = SuperFloppyFormatter.get(device).format();
42
+
43
+ } catch (IOException e) {
44
+ // TODO Auto-generated catch block
45
+ e.printStackTrace();
46
+ System.exit(-1);
47
+
48
+ }
49
+
50
+ // Iterate of directories
51
+ File dir = new File(args[0]);
52
+
53
+ String[] children = dir.list();
54
+ if (children == null) {
55
+ // Either dir does not exist or is not a directory
56
+ System.out.println("Error. does the directory exist?");
57
+ System.exit(-1);
58
+ } else {
59
+ for (int i = 0; i < children.length; i++) {
60
+ // Get filename of file or directory
61
+ File aFile = new File(dir.getAbsolutePath()
62
+ + System.getProperty("file.separator") + children[i]);
63
+
64
+ try {
65
+ // Create the entry on the floppy
66
+ FsDirectoryEntry floppyEntry = fs.getRoot().addFile(
67
+ children[i]);
68
+ // floppyEntry.setName(children[i]);
69
+ System.out.print("- Processing file: " + children[i] + " ");
70
+
71
+ FsFile floppyfile = floppyEntry.getFile();
72
+
73
+ // Copy the file over
74
+ if (aFile.isFile()) {
75
+ FileInputStream fis = new FileInputStream(aFile);
76
+
77
+ FileChannel fci = fis.getChannel();
78
+ ByteBuffer buffer = ByteBuffer.allocate(1024);
79
+
80
+ long counter = 0;
81
+ int len;
82
+
83
+ // http://www.kodejava.org/examples/49.html
84
+ // Here we start to read the source file and write it
85
+ // to the destination file. We repeat this process
86
+ // until the read method of input stream channel return
87
+ // nothing (-1).
88
+ while (true) {
89
+ // read a block of data and put it in the buffer
90
+ int read = fci.read(buffer);
91
+
92
+ // did we reach the end of the channel? if yes
93
+ // jump out the while-loop
94
+ if (read == -1)
95
+ break;
96
+
97
+ // flip the buffer
98
+ buffer.flip();
99
+
100
+ // write to the destination channel
101
+ System.out.print(".");
102
+ floppyfile.write(counter * 1024, buffer);
103
+ counter++;
104
+
105
+ // clear the buffer and user it for the next read
106
+ // process
107
+ buffer.clear();
108
+ }
109
+ System.out.println();
110
+
111
+ floppyfile.flush();
112
+
113
+ fis.close();
114
+ }
115
+ } catch (IOException e) {
116
+ // TODO Auto-generated catch block
117
+ e.printStackTrace();
118
+
119
+ }
120
+
121
+ }
122
+ }
123
+
124
+ try {
125
+ fs.close();
126
+ } catch (IOException e) {
127
+ // TODO Auto-generated catch block
128
+ e.printStackTrace();
129
+ }
130
+
131
+ System.out.println("Done");
132
+ }
133
+
134
+ }
@@ -0,0 +1,6 @@
1
+ begin
2
+ require 'vbox'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'vbox'
6
+ end
data/lib/vbox.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'vagrant'
2
+ require 'vbox/command'
@@ -0,0 +1,82 @@
1
+ require 'vbox/session'
2
+
3
+ #Load Vbox::Session libraries
4
+ lib_dir= File.expand_path(File.join(File.dirname(__FILE__),"..","..", "lib"))
5
+ Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f| require f }
6
+
7
+ #Setup some base variables to use
8
+ template_dir=File.expand_path(File.join(lib_dir,"..", "templates"))
9
+
10
+ vbox_dir="."
11
+ definition_dir= File.expand_path(File.join(vbox_dir, "definitions"))
12
+ tmp_dir=File.expand_path(File.join(vbox_dir, "tmp"))
13
+ iso_dir=File.expand_path(File.join(vbox_dir, "iso"))
14
+ box_dir=File.expand_path(File.join(vbox_dir, "boxes"))
15
+ validation_dir=File.expand_path(File.join(lib_dir, "..","validation"))
16
+
17
+ #Initialize
18
+ Vbox::Session.setenv({:vbox_dir => vbox_dir, :definition_dir => definition_dir,
19
+ :template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir, :validation_dir => validation_dir})
20
+
21
+ module Vbox
22
+ class Command < Vagrant::Command::GroupBase
23
+ register "vboxes","Commands to manage vboxes"
24
+
25
+ desc "templates", "List the currently available basebox templates"
26
+ def templates
27
+ Vbox::Session.list_templates
28
+ end
29
+
30
+ desc "define BOXNAME TEMPLATE", "Define a new vbox starting from a template"
31
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
32
+ def define(boxname, template)
33
+ Vbox::Session.define(boxname,template,options)
34
+ end
35
+
36
+ desc "undefine BOXNAME", "Removes the definition of a vbox "
37
+ def undefine(boxname)
38
+ Vbox::Session.undefine(boxname)
39
+ end
40
+
41
+ desc "build BOXNAME", "Build the box BOXNAME"
42
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the vbox"
43
+ method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
44
+
45
+ def build(boxname)
46
+ Vbox::Session.build(boxname,options)
47
+ end
48
+
49
+ desc "ostypes", "List the available Operating System types"
50
+ def ostypes
51
+ Vbox::Session.list_ostypes
52
+ end
53
+
54
+ desc "destroy BOXNAME", "Destroys the virtualmachine that was build for a vbox"
55
+ def destroy(boxname)
56
+ Vbox::Session.destroy_vm(boxname)
57
+ end
58
+
59
+ desc "list", "Lists all defined vbox"
60
+ def list
61
+ Vbox::Session.list_definitions
62
+ end
63
+
64
+ desc "export [NAME]", "Exports the vbox to the vagrant box format"
65
+ method_options :force => :boolean
66
+ def export(boxname)
67
+ if (!boxname.nil?)
68
+ Vbox::Session.export_box(boxname)
69
+ end
70
+ end
71
+
72
+ desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
73
+ method_option :user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
74
+ def validate(boxname)
75
+ if (!boxname.nil?)
76
+ Vbox::Session.validate_box(boxname,options)
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+ end