Skip to content

Commit

Permalink
OS types are now verified and added rake list_ostypes to give a list
Browse files Browse the repository at this point in the history
  • Loading branch information
jedi4ever committed Nov 13, 2010
1 parent 5552984 commit 136de45
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Rakefile
Expand Up @@ -101,6 +101,11 @@ task :remove_box, [:boxname] do |t,args|
Veewee::Session.remove_box(args.boxname)
end

desc 'List ostypes available'
task :list_ostypes do |t,args|
Veewee::Session.list_ostypes
end

desc 'Clean all unfinished builds'
task :clean do
Veewee::Session.clean
Expand Down
29 changes: 28 additions & 1 deletion lib/veewee/session.rb
Expand Up @@ -120,8 +120,9 @@ def self.verify_iso(filename)
puts "curl -C - -L '#{@definition[:iso_src]}' -o '#{rel_path}'"
puts "md5 '#{rel_path}' "
puts
exit
end
exit

end

def self.export_box(boxname)
Expand Down Expand Up @@ -243,8 +244,21 @@ def self.create_vm(boxname)
vm.destroy
end

#Verifying the os.id with the :os_type_id specified
matchfound=false
VirtualBox::Global.global.lib.virtualbox.guest_os_types.collect { |os|
if @definition[:os_type_id] == os.id
matchfound=true
end
}
unless matchfound
puts "The ostype: #{@definition[:os_type_id]} is not available in your Virtualbox version"
exit
end

#TODO One day ruby-virtualbox will be able to handle this creation
#Box does not exist, we can start to create it

command="#{@vboxcmd} createvm --name '#{boxname}' --ostype '#{@definition[:os_type_id]}' --register"
#Exec and system stop the execution here
Veewee::Shell.execute("#{command}")
Expand Down Expand Up @@ -360,6 +374,19 @@ def self.transaction(boxname,name,checksum_params, &block)
end
end

#VirtualBox::Global.global.lib.virtualbox.version

def self.list_ostypes
puts
puts "Available os types:"
VirtualBox::Global.global.lib.virtualbox.guest_os_types.collect { |os|
puts "#{os.id}: #{os.description}"
}

puts

end

def transaction2(boxname,name,checksum_params, &block)

if @provider.snapshot_exists(@vmname,name+"-"+options[:checksum])
Expand Down

0 comments on commit 136de45

Please sign in to comment.