Skip to content

Commit

Permalink
cleaned up the output during the execution + major changes to make it…
Browse files Browse the repository at this point in the history
… work on 4.x
  • Loading branch information
jedi4ever committed Feb 7, 2011
1 parent 2f5bc89 commit 61d5bb6
Show file tree
Hide file tree
Showing 16 changed files with 311 additions and 284 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source "http://rubygems.org"

gem "veewee", :path => "."

gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
#gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
32 changes: 14 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
GIT
remote: git://github.com/mitchellh/vagrant.git
revision: dc0b17583899a5cf0096f7e50fc80eb286977946
specs:
vagrant (0.7.2.dev)
archive-tar-minitar (= 0.5.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
json (~> 1.5.1)
mario (~> 0.0.6)
net-scp (~> 1.0.4)
net-ssh (~> 2.1.0)
thor (~> 0.14.6)
virtualbox (~> 0.8.3)

PATH
remote: .
specs:
veewee (0.1.0a)
veewee (0.1.1)
highline (~> 1.6.1)
net-ssh (~> 2.1.0)
popen4 (~> 0.1.2)
progressbar
thor (~> 0.14.6)
vagrant (~> 0.7.0)

Expand All @@ -35,7 +21,7 @@ GEM
rake (>= 0.8.7)
highline (1.6.1)
i18n (0.5.0)
json (1.5.1)
json (1.4.6)
mario (0.0.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
Expand All @@ -44,14 +30,24 @@ GEM
popen4 (0.1.2)
Platform (>= 0.4.0)
open4 (>= 0.4.0)
progressbar (0.9.0)
rake (0.8.7)
thor (0.14.6)
vagrant (0.7.1)
archive-tar-minitar (= 0.5.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
json (~> 1.4.6)
mario (~> 0.0.6)
net-scp (~> 1.0.4)
net-ssh (~> 2.1.0)
thor (~> 0.14.6)
virtualbox (~> 0.8.3)
virtualbox (0.8.3)
ffi (~> 0.6.3)

PLATFORMS
ruby

DEPENDENCIES
vagrant!
veewee!
78 changes: 34 additions & 44 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,40 @@
# Veewee is currently broken due to changes in Virtualbox 4.x
# We will fix them soon and move veewee to a plugin for vagrant


VeeWee: the tool to easily build vagrant base boxes
===================================================
**VeeWee:** the tool to easily build vagrant base boxes
Vagrant is a great tool to test new things or changes in a virtual machine(Virtualbox) using either chef or puppet.
The first step is to download an existing 'base box'. I believe this scares a lot of people as they don't know who or how this box was build. Therefore lots of people end up first building their own base box to use with vagrant.

Veewee tries to automate this and to share the knowledge and sources you need to create a basebox. Instead of creating custom ISO's from your favorite distribution, it leverages the 'keyboardputscancode' command of Virtualbox so send the actual 'boot prompt' keysequence to boot an existing iso.

Before we can actually build the boxes, we need to take care of the minimal things to install:
- Currently this is still a very much 'it works on my machine only' code
- Have Virtualbox 4.x installed -> download it from http://download.virtualbox.org/virtualbox/
- Have ruby and rubygems working
- Have the rake gem installed -> gem install rake

ALPHA CODE: -> you're on your own....

### WILL UPDATE SOON ####

ALPHA CODE: -> you're on your own....

1)Installation: (from source)
===========================
## Installation: (from source)
**from source **
$ git clone https://github.com/jedi4ever/veewee.git
$ cd veewee
$ gem install bundler
$ bundle install

Installation: (as a gem)
========================
coming soon

List all templates
===================
$ rake templates
the following templates are available:
use rake define['<boxname>','CentOS-4.8-i386']
use rake define['<boxname>','CentOS-5.5-i386']
use rake define['<boxname>','ubuntu-10.04.1-server-i386']
use rake define['<boxname>','ubuntu-10.10-server-i386']

3) Define a new box (ex. Ubuntu 10.10 server i386) - this is essentially making a copy based on the templates provided above.
$ rake define['myubuntubox','ubuntu-10.10-server-i386']
$ bundle install

**as a gem**
$ gem install veewee


## List all templates
$ vagrant basebox templates

## Define a new box (ex. Ubuntu 10.10 server i386)

this is essentially making a copy based on the templates provided above.
$ vagrant basebox define 'myubuntubox' 'ubuntu-10.10-server-i386'
template successfully copied

-> This copies over the files in templates/ubuntu-10.10-server-i386 to definition/myubuntubox
-> This copies over the templates/ubuntu-10.10-server-i386 to definition/myubuntubox
$ ls definitions/myubuntubox
definition.rb postinstall.sh postinstall2.sh preseed.cfg

4) Optionally modify the definition.rb , postinstall.sh or preseed.cfg
## Optionally modify the definition.rb , postinstall.sh or preseed.cfg
Veewee::Session.declare( {
:cpu_count => '1', :memory_size=> '256',
:disk_size => '10140', :disk_format => 'VDI',:disk_size => '10240' ,
Expand Down Expand Up @@ -78,13 +64,14 @@ Veewee::Session.declare( {

If you need to change values in the templates, be sure to run the rake undefine, the rake define again to copy the changes across.

5) Put your isofile inside the $VEEWEE/iso directory or if you don't run
$ rake build['myubuntubox]
## Put your isofile inside the $VEEWEE/iso directory or if you don't run
$ vagrant basebox build 'myubuntubox'

-> This will show you the iso to download
-> the build assumes your iso files are in 'currentdir'/iso
-> if it can not find it will suggest to download the iso for you

6) Build the new box:
$ rake build['myubuntubox]
$ vagrant basebox build 'myubuntubox'

-> This will create a machine + disk according to the definition.rb
-> Note: :os_type_id = The internal Name Virtualbox uses for that Distribution
Expand All @@ -95,23 +82,26 @@ $ rake build['myubuntubox]
-> Wait for ssh login to work with :ssh_user , :ssh_password
-> Sudo execute the :postinstall_files

7) Export the box into the boxes directory
$ rake export['myubuntubox']
## Export the vm to a .box file
$ vagrant basebox export 'myubuntubox'

this is actually calling - vagrant package --base 'myubuntubox' --output 'boxes/myubuntubox.box'

vagrant package --base 'myubuntubox' --output 'boxes/myubuntubox.box'
vagrant box add 'myubuntubox' 'boxes/myubuntubox.box'
this will result in a myubuntubox.box

-> This will show you the vagrant command to export and to add it your vagrant boxset
## Add the box as one of your boxes
vagrant box add 'myubuntubox' 'myubuntubox.box'

8) Start vagrant init in another window (as we have set the Virtualbox env to tmp before)
## Use it in vagrant
Start vagrant init in another window (as we have set the Virtualbox env to tmp before)
$ To import it into vagrant type:

To use it:
vagrant init 'myubuntubox'
vagrant up
vagrant ssh

9) If you have a setup working, share your 'definition' with me. That would be fun!
## If you have a setup working, share your 'definition' with me. That would be fun!

IDEAS:
- Now you integrate this with your CI build to create a daily basebox
Expand Down
9 changes: 6 additions & 3 deletions bin/veewee
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f|
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir,
:template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir})



class VeeweeCLI < Thor

desc "init [NAME] [TEMPLATE]", "initializes a box from a template"
Expand Down Expand Up @@ -67,10 +69,11 @@ class VeeweeCLI < Thor

end



version=VirtualBox.version
if (version.match(/^4./))
VeeweeCLI.start
VeeweeCLI.start
else
puts "veewee only supports VirtualBox 4.x"
puts "veewee only supports VirtualBox 4.x"
end

3 changes: 1 addition & 2 deletions lib/vagrant_init.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
require 'veewee'
puts "here we are"
require 'veewee'
13 changes: 0 additions & 13 deletions lib/veewee.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
require 'vagrant'
#require 'veewee/config'
require 'veewee/command'
#require 'veewee/middleware'


#basebox = Vagrant::Action::Builder.new do
#use BaseBoxMiddleware
#end

#Vagrant::Action.register :basebox, basebox

# Add our custom translations to the load path
I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)

75 changes: 55 additions & 20 deletions lib/veewee/command.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
require 'veewee/session'

#Load Veewee::Session libraries
lib_dir= File.expand_path(File.join(File.dirname(__FILE__),"..","..", "lib"))
Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f| require f }

#Setup some base variables to use
template_dir=File.expand_path(File.join(lib_dir,"..", "templates"))

veewee_dir="."
definition_dir= File.expand_path(File.join(veewee_dir, "definitions"))
tmp_dir=File.expand_path(File.join(veewee_dir, "tmp"))
iso_dir=File.expand_path(File.join(veewee_dir, "iso"))
box_dir=File.expand_path(File.join(veewee_dir, "boxes"))

#Initialize
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir,
:template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir})

module Veewee
class Command < Vagrant::Command::Base
register "bla", "Run a rake task inside the VM environment"
#argument :rake_command, :type => :array, :required => false, :desc => "The command to run on the VM via Rake"
#class_option :cwd, :type => :string, :default => nil

# Executes the given rake command on the VMs that are represented
# by this environment.
def execute
command = (rake_command || []).join(" ")
target_vms.each { |vm| execute_on_vm(vm, command) }
end

protected

# Executes a command on a specific VM.
def execute_on_vm(vm, command)
vm.env.actions.run(:rake,
"rake.command" => command,
"rake.cwd" => options[:cwd])
end
class Command < Vagrant::Command::GroupBase
register "basebox","Commands to manage baseboxes"

desc "templates", "List the currently available box templates"
def templates
Veewee::Session.list_templates
end

desc "define BOXNAME TEMPLATE", "Define a new box starting from a template"
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
def define(boxname, template)
Veewee::Session.define(boxname,template,options)
end

desc "build BOXNAME", "Build the box BOXNAME"
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the basebox"
def build(boxname)
Veewee::Session.build(boxname,options)
end

desc "ostypes", "List the available Operating System types"
def ostypes
Veewee::Session.list_ostypes
end

desc "destroy", "Destroy the virtualmachine of a basebox"
def destroy(boxname)
puts Veewee::Session.destroy_vm(boxname)
end

desc "list", "Lists all defined boxes"
def list
Veewee::Session.list_definitions
end

end

end
66 changes: 0 additions & 66 deletions lib/veewee/command2.rb

This file was deleted.

10 changes: 0 additions & 10 deletions lib/veewee/middleware.rb

This file was deleted.

Loading

0 comments on commit 61d5bb6

Please sign in to comment.