Permalink
Browse files

Again, a massive chunk of restructuring current behavior

  • Loading branch information...
1 parent 953965d commit d27979d8401e4f8d7a47add7cad8cee52ef64cb5 @jedi4ever committed Jul 28, 2011
Showing with 785 additions and 462 deletions.
  1. +3 −1 Gemfile.lock
  2. +34 −34 README.md
  3. +21 −14 Rakefile
  4. +12 −12 bin/veewee
  5. +0 −4 lib/veewee/builder/box.rb
  6. +27 −0 lib/veewee/builder/core/box.rb
  7. +38 −0 lib/veewee/builder/core/builder.rb
  8. +2 −4 lib/veewee/builder/core/{ → helper}/iso.rb
  9. 0 lib/veewee/builder/core/{ → helper}/transaction.rb
  10. +0 −61 lib/veewee/builder/virtualbox.rb
  11. +22 −21 lib/veewee/builder/virtualbox/{util/create.rb → assemble.rb}
  12. +66 −0 lib/veewee/builder/virtualbox/box.rb
  13. +16 −25 lib/veewee/builder/virtualbox/build.rb
  14. +19 −0 lib/veewee/builder/virtualbox/builder.rb
  15. +0 −11 lib/veewee/builder/virtualbox/console_type.rb
  16. +5 −5 lib/veewee/builder/virtualbox/destroy.rb
  17. +14 −14 lib/veewee/builder/virtualbox/export_vagrant.rb
  18. +9 −7 lib/veewee/builder/virtualbox/{util/scancode.rb → helper/console_type.rb}
  19. 0 lib/veewee/builder/virtualbox/{util → helper}/snapshots.rb
  20. 0 lib/veewee/builder/virtualbox/{ → helper}/ssh.rb
  21. +3 −3 lib/veewee/builder/virtualbox/{util → helper}/transaction.rb
  22. +34 −0 lib/veewee/builder/virtualbox/validate_vagrant.rb
  23. +7 −13 lib/veewee/builderfactory.rb
  24. +20 −8 lib/veewee/definition.rb
  25. +183 −113 lib/veewee/environment.rb
  26. +12 −0 lib/veewee/error.rb
  27. +11 −2 lib/veewee/session.rb
  28. 0 lib/veewee/ui/vagrant.rb
  29. +76 −0 lib/veewee/ui/vagrant_plugin.rb
  30. +2 −2 lib/veewee/util/checksums.rb
  31. +103 −63 lib/veewee/vagrant/command.rb
  32. +1 −1 templates/CentOS-4.8-i386/definition.rb
  33. +1 −1 templates/CentOS-5.6-i386-netboot/definition.rb
  34. +1 −1 templates/CentOS-5.6-i386/definition.rb
  35. +1 −1 templates/CentOS-5.6-x86_64-netboot/definition.rb
  36. +1 −1 templates/CentOS-6.0-i386-netboot/definition.rb
  37. +1 −1 templates/CentOS-6.0-i386/definition.rb
  38. +1 −1 templates/CentOS-6.0-x86_64-netboot/definition.rb
  39. +1 −1 templates/CentOS-6.0-x86_64/definition.rb
  40. +1 −1 templates/Debian-5.0.8-amd64-netboot/definition.rb
  41. +1 −1 templates/Debian-5.0.8-i386-netboot/definition.rb
  42. +1 −1 templates/Debian-6.0.2-amd64-netboot/definition.rb
  43. +1 −1 templates/Debian-6.0.2-i386-netboot/definition.rb
  44. +1 −1 templates/Fedora-14-amd64-netboot/definition.rb
  45. +1 −1 templates/Fedora-14-amd64/definition.rb
  46. +1 −1 templates/Fedora-14-i386-netboot/definition.rb
  47. +1 −1 templates/Fedora-14-i386/definition.rb
  48. +1 −1 templates/Fedora-15-i386-netboot/definition.rb
  49. +1 −1 templates/Fedora-15-i386/definition.rb
  50. +1 −1 templates/Sysrescuecd-2.0.0-experimental/definition.rb
  51. +1 −1 templates/archlinux-i386/definition.rb
  52. +1 −1 templates/archlinux-x86_64/definition.rb
  53. +1 −1 templates/freebsd-8.2-experimental/definition.rb
  54. +1 −1 templates/freebsd-8.2-pcbsd-i386-netboot/definition.rb
  55. +1 −1 templates/freebsd-8.2-pcbsd-i386/definition.rb
  56. +1 −1 templates/gentoo-latest-i386-experimental/definition.rb
  57. +1 −1 templates/openindiana-148-ai-x86/definition.rb
  58. +1 −1 templates/opensuse-11.4-i386-experimental/definition.rb
  59. +1 −1 templates/solaris-11-express-i386/definition.rb
  60. +1 −1 templates/ubuntu-10.04.2-amd64-netboot/definition.rb
  61. +1 −1 templates/ubuntu-10.04.2-server-amd64-alt/definition.rb
  62. +1 −1 templates/ubuntu-10.04.2-server-amd64/definition.rb
  63. +1 −1 templates/ubuntu-10.04.2-server-i386-netboot/definition.rb
  64. +1 −1 templates/ubuntu-10.04.2-server-i386/definition.rb
  65. +1 −1 templates/ubuntu-10.04.3-server-amd64/definition.rb
  66. +1 −1 templates/ubuntu-10.10-server-amd64-netboot/definition.rb
  67. +1 −1 templates/ubuntu-10.10-server-amd64/definition.rb
  68. +1 −1 templates/ubuntu-10.10-server-i386-netboot/definition.rb
  69. +1 −1 templates/ubuntu-10.10-server-i386/definition.rb
  70. +1 −1 templates/ubuntu-11.04-server-amd64/definition.rb
  71. +1 −1 templates/ubuntu-11.04-server-i386/definition.rb
  72. +1 −1 templates/ubuntu-8.04.4-server-amd64/definition.rb
  73. +1 −1 templates/ubuntu-8.04.4-server-i386/definition.rb
  74. +1 −1 templates/windows-2008R2-amd64/definition.rb
  75. +1 −1 test/definitions/test_definition/definition.rb
  76. +1 −1 validation/features/steps/ssh_steps.rb
  77. +1 −0 veewee.gemspec
View
@@ -2,6 +2,7 @@ PATH
remote: .
specs:
veewee (0.2.0)
+ ansi (~> 1.3.0)
cucumber (~> 1.0.2)
highline (~> 1.6.1)
net-ssh (~> 2.1.0)
@@ -15,6 +16,7 @@ GEM
remote: http://rubygems.org/
specs:
Platform (0.4.0)
+ ansi (1.3.0)
archive-tar-minitar (0.5.2)
builder (3.0.0)
cucumber (1.0.2)
@@ -39,7 +41,7 @@ GEM
Platform (>= 0.4.0)
open4 (>= 0.4.0)
progressbar (0.9.1)
- rake (0.8.7)
+ rake (0.9.2)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
View
@@ -32,39 +32,39 @@ If you don't use rvm, be sure to execute vagrant through bundle exec
$ vagrant basebox templates
The following templates are available:
- vagrant basebox define '<boxname>' 'ubuntu-10.10-server-i386-netboot'
- vagrant basebox define '<boxname>' 'ubuntu-10.10-server-amd64-netboot'
- vagrant basebox define '<boxname>' 'solaris-11-express-i386'
- vagrant basebox define '<boxname>' 'freebsd-8.2-pcbsd-i386-netboot'
- vagrant basebox define '<boxname>' 'Fedora-14-amd64-netboot'
- vagrant basebox define '<boxname>' 'ubuntu-11.04-server-amd64'
- vagrant basebox define '<boxname>' 'freebsd-8.2-experimental'
- vagrant basebox define '<boxname>' 'archlinux-i686'
- vagrant basebox define '<boxname>' 'CentOS-5.6-i386-netboot'
- vagrant basebox define '<boxname>' 'openindiana-148-ai-x86'
- vagrant basebox define '<boxname>' 'ubuntu-10.10-server-i386'
- vagrant basebox define '<boxname>' 'ubuntu-10.04.2-server-i386'
- vagrant basebox define '<boxname>' 'ubuntu-10.04.2-amd64-netboot'
- vagrant basebox define '<boxname>' 'Sysrescuecd-2.0.0-experimental'
- vagrant basebox define '<boxname>' 'Debian-6.0.1a-amd64-netboot'
- vagrant basebox define '<boxname>' 'freebsd-8.2-pcbsd-i386'
- vagrant basebox define '<boxname>' 'Fedora-14-i386'
- vagrant basebox define '<boxname>' 'Fedora-14-amd64'
- vagrant basebox define '<boxname>' 'ubuntu-10.04.2-server-i386-netboot'
- vagrant basebox define '<boxname>' 'opensuse-11.4-i386-experimental'
- vagrant basebox define '<boxname>' 'CentOS-4.8-i386'
- vagrant basebox define '<boxname>' 'ubuntu-10.04.2-server-amd64'
- vagrant basebox define '<boxname>' 'ubuntu-8.04.4-server-amd64'
- vagrant basebox define '<boxname>' 'gentoo-latest-i386-experimental'
- vagrant basebox define '<boxname>' 'ubuntu-8.04.4-server-i386'
- vagrant basebox define '<boxname>' 'windows-2008R2-amd64'
- vagrant basebox define '<boxname>' 'Fedora-14-i386-netboot'
- vagrant basebox define '<boxname>' 'archlinux-64-experimental'
- vagrant basebox define '<boxname>' 'Debian-6.0.1a-i386-netboot'
- vagrant basebox define '<boxname>' 'ubuntu-10.10-server-amd64'
- vagrant basebox define '<boxname>' 'archlinux-64-aif-experimental'
- vagrant basebox define '<boxname>' 'ubuntu-11.04-server-i386'
- vagrant basebox define '<boxname>' 'CentOS-5.6-i386'
+ vagrant basebox define '<box_name>' 'ubuntu-10.10-server-i386-netboot'
+ vagrant basebox define '<box_name>' 'ubuntu-10.10-server-amd64-netboot'
+ vagrant basebox define '<box_name>' 'solaris-11-express-i386'
+ vagrant basebox define '<box_name>' 'freebsd-8.2-pcbsd-i386-netboot'
+ vagrant basebox define '<box_name>' 'Fedora-14-amd64-netboot'
+ vagrant basebox define '<box_name>' 'ubuntu-11.04-server-amd64'
+ vagrant basebox define '<box_name>' 'freebsd-8.2-experimental'
+ vagrant basebox define '<box_name>' 'archlinux-i686'
+ vagrant basebox define '<box_name>' 'CentOS-5.6-i386-netboot'
+ vagrant basebox define '<box_name>' 'openindiana-148-ai-x86'
+ vagrant basebox define '<box_name>' 'ubuntu-10.10-server-i386'
+ vagrant basebox define '<box_name>' 'ubuntu-10.04.2-server-i386'
+ vagrant basebox define '<box_name>' 'ubuntu-10.04.2-amd64-netboot'
+ vagrant basebox define '<box_name>' 'Sysrescuecd-2.0.0-experimental'
+ vagrant basebox define '<box_name>' 'Debian-6.0.1a-amd64-netboot'
+ vagrant basebox define '<box_name>' 'freebsd-8.2-pcbsd-i386'
+ vagrant basebox define '<box_name>' 'Fedora-14-i386'
+ vagrant basebox define '<box_name>' 'Fedora-14-amd64'
+ vagrant basebox define '<box_name>' 'ubuntu-10.04.2-server-i386-netboot'
+ vagrant basebox define '<box_name>' 'opensuse-11.4-i386-experimental'
+ vagrant basebox define '<box_name>' 'CentOS-4.8-i386'
+ vagrant basebox define '<box_name>' 'ubuntu-10.04.2-server-amd64'
+ vagrant basebox define '<box_name>' 'ubuntu-8.04.4-server-amd64'
+ vagrant basebox define '<box_name>' 'gentoo-latest-i386-experimental'
+ vagrant basebox define '<box_name>' 'ubuntu-8.04.4-server-i386'
+ vagrant basebox define '<box_name>' 'windows-2008R2-amd64'
+ vagrant basebox define '<box_name>' 'Fedora-14-i386-netboot'
+ vagrant basebox define '<box_name>' 'archlinux-64-experimental'
+ vagrant basebox define '<box_name>' 'Debian-6.0.1a-i386-netboot'
+ vagrant basebox define '<box_name>' 'ubuntu-10.10-server-amd64'
+ vagrant basebox define '<box_name>' 'archlinux-64-aif-experimental'
+ vagrant basebox define '<box_name>' 'ubuntu-11.04-server-i386'
+ vagrant basebox define '<box_name>' 'CentOS-5.6-i386'
## Define a new box
@@ -84,7 +84,7 @@ this is essentially making a copy based on the templates provided above.
## Optionally modify the definition.rb , postinstall.sh or preseed.cfg
- Veewee::Environment.declare( {
+ Veewee::Definition.declare( {
:cpu_count => '1', :memory_size=> '256',
:disk_size => '10140', :disk_format => 'VDI',
:os_type_id => 'Ubuntu',
View
@@ -9,33 +9,40 @@ task :default => :test
require 'rake/testtask'
Bundler::GemHelper.install_tasks
-
+desc 'Tests not requiring an real box'
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = 'test/**/*_test.rb'
end
+desc 'Tests requiring an real box'
+Rake::TestTask.new do |t|
+ t.name="realtest"
+ t.libs << "test"
+ t.pattern = 'test/**/*_realtest.rb'
+end
+
desc 'List templates'
task :templates do
Veewee::Environment.list_templates
end
desc 'Define box'
-task :define, [:boxname,:template_name] do |t,args|
+task :define, [:box_name,:template_name] do |t,args|
if args.to_hash.size!=2
- puts "needs two arguments: rake define['boxname','template_name']"
+ puts "needs two arguments: rake define['box_name','template_name']"
exit
end
- Veewee::Environment.define(args.boxname,args.template_name)
+ Veewee::Environment.define(args.box_name,args.template_name)
end
desc 'Undefine box'
-task :undefine, [:boxname] do |t,args|
+task :undefine, [:box_name] do |t,args|
if args.to_hash.size!=1
puts "needs one arguments: rake undefine[\"yourname\"]"
exit
end
- Veewee::Environment.undefine(args.boxname)
+ Veewee::Environment.undefine(args.box_name)
end
desc 'List Definitions'
@@ -44,12 +51,12 @@ task :definitions do
end
desc 'Build box'
-task :build, [:boxname] do |t,args|
+task :build, [:box_name] do |t,args|
if args.to_hash.size!=1
- puts "needs one arguments: rake build['boxname']"
+ puts "needs one arguments: rake build['box_name']"
exit
end
- Veewee::Environment.build(args.boxname)
+ Veewee::Environment.build(args.box_name)
end
desc 'List boxes'
@@ -58,17 +65,17 @@ task :boxes do
end
desc 'Export box'
-task :export, [:boxname] do |t,args|
+task :export, [:box_name] do |t,args|
if args.to_hash.size!=1
- puts "needs one arguments: rake export['boxname']"
+ puts "needs one arguments: rake export['box_name']"
exit
end
- Veewee::Environment.export_box(args.boxname)
+ Veewee::Environment.export_box(args.box_name)
end
desc 'Remove box'
-task :remove_box, [:boxname] do |t,args|
- Veewee::Environment.remove_box(args.boxname)
+task :remove_box, [:box_name] do |t,args|
+ Veewee::Environment.remove_box(args.box_name)
end
desc 'List ostypes available'
View
@@ -12,15 +12,15 @@ class VeeweeCLI < Thor
desc "define [NAME] [TEMPLATE]", "initializes a box from a template"
method_options :force => :boolean
- def define(boxname=nil, template=nil)
+ def define(box_name=nil, template=nil)
- if (boxname.nil?)
- puts "please provide a boxname"
+ if (box_name.nil?)
+ puts "please provide a box_name"
exit
end
- puts "Init a new box #{boxname}, starting from template #{template}"
- Veewee::Environment.define(boxname,template)
+ puts "Init a new box #{box_name}, starting from template #{template}"
+ Veewee::Environment.define(box_name,template)
end
@@ -31,18 +31,18 @@ class VeeweeCLI < Thor
desc "build [NAME]", "build the box defined"
method_options :force => :boolean
- def build(boxname)
- puts "Building box #{boxname}"
+ def build(box_name)
+ puts "Building box #{box_name}"
vs=Veewee::Environment.new(options)
- vd=vs.get_definition(boxname)
- vs.build(boxname,vd)
+ vd=vs.get_definition(box_name)
+ vs.build(box_name,vd)
end
desc "export [NAME]", "export the box"
method_options :force => :boolean
- def export(boxname)
- if (!boxname.nil?)
- Veewee::Environment.export_box(boxname)
+ def export(box_name)
+ if (!box_name.nil?)
+ Veewee::Environment.export_box(box_name)
end
end
@@ -1,4 +0,0 @@
-module Veewee
- class Box
- end
-end
@@ -0,0 +1,27 @@
+require 'veewee/builder/core/helper/iso'
+
+module Veewee
+ module Builder
+ module Core
+ class Box
+ attr_accessor :definition
+ attr_accessor :environment
+ attr_accessor :box_name
+ attr_accessor :options
+
+
+ def initialize(environment,box_name,definition_name,box_options)
+ @environment=environment
+ @options=box_options
+ @box_name=box_name
+ @definition=@environment.get_definition(definition_name)
+ end
+
+ def set_definition(definition_name)
+ @definition=@environment.get_definition(definition_name)
+ end
+
+ end #End Class
+ end # End Module
+ end # End Module
+end # End Module
@@ -0,0 +1,38 @@
+require 'veewee/builder/virtualbox/box'
+
+module Veewee
+ module Builder
+ module Core
+ class Builder
+
+ attr_accessor :environment
+ attr_accessor :options
+ attr_accessor :type
+
+ # This is a generic class that will be implemeted by each boxbuilder
+ # It passes the options builder_options and links the environment to its
+ def initialize(builder_options,environment)
+ @environment=environment
+ @options=builder_options
+ type=self.class.to_s
+ # Strip out the module path Veewee::Builder::Virtualbox::Builder
+ type['Veewee::Builder::']=''
+ type['::Builder']=''
+ @type=type
+ end
+
+ # This function asks a builder to initialize a box,with a name and definition
+ def get_box(box_name,definition_name=nil,box_options={})
+ if definition_name.nil?
+ definition_name=box_name
+ end
+ box_class=Object.const_get("Veewee").const_get("Builder").const_get(@type).const_get('Box')
+ box=box_class.new(@environment,box_name,definition_name,box_options)
+ return box
+ end
+
+ end #End Class
+
+ end #End Module
+ end #End Module
+end #End Module
@@ -1,14 +1,12 @@
module Veewee
module Builder
module Core
-
+
require 'open-uri'
require 'progressbar'
require 'highline/import'
require 'digest/md5'
-
- #TODO move to veewee definition?
-
+
def download_progress(url,localfile)
pbar = nil
URI.parse(url).open(
@@ -1,61 +0,0 @@
-require 'veewee/builder/virtualbox/build'
-require 'veewee/builder/virtualbox/destroy'
-require 'veewee/builder/virtualbox/ssh'
-require 'veewee/builder/virtualbox/console_type'
-
-require 'veewee/builder/core/iso'
-require 'veewee/builder/box'
-
-require 'virtualbox'
-
-module Veewee
- class Virtualbox < Box
- include Veewee::Builder::Core
- include Veewee::Builder::Virtualbox
-
- def initialize(boxname,definition,environment,builder_options={})
- @vboxcmd=determine_vboxcmd
- @definition=definition
- @boxname=boxname
- @environment=environment
- end
-
-
- def determine_vboxcmd
- return "VBoxManage"
- end
-
- def suppress_messages
- #Setting this annoying messages to register
- VirtualBox::ExtraData.global["GUI/RegistrationData"]="triesLeft=0"
- VirtualBox::ExtraData.global["GUI/UpdateDate"]="1 d, 2009-09-20"
- VirtualBox::ExtraData.global["GUI/SuppressMessages"]="confirmInputCapture,remindAboutAutoCapture,remindAboutMouseIntegrationOff"
- VirtualBox::ExtraData.global["GUI/UpdateCheckCount"]="60"
- update_date=Time.now+86400
- VirtualBox::ExtraData.global["GUI/UpdateDate"]="1 d, #{update_date.year}-#{update_date.month}-#{update_date.day}, stable"
- VirtualBox::ExtraData.global.save
- end
-
- def add_ssh_nat_mapping
- vm=VirtualBox::VM.find(@boxname)
- #Map SSH Ports
- # command => "${vboxcmd} modifyvm '${vname}' --natpf1 'guestssh,tcp,,${hostsshport},,${guestsshport}'",
- port = VirtualBox::NATForwardedPort.new
- port.name = "guestssh"
- port.guestport = @definition.ssh_guest_port.to_i
- port.hostport = @definition.ssh_host_port.to_i
- vm.network_adapters[0].nat_driver.forwarded_ports << port
- port.save
- vm.save
- end
-
-# def self.list_ostypes
-# puts
-# puts "Available os types:"
-# VirtualBox::Global.global.lib.virtualbox.guest_os_types.collect { |os|
-# puts "#{os.id}: #{os.description}"
-# }
-# end
-
- end
-end
Oops, something went wrong.

0 comments on commit d27979d

Please sign in to comment.