Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added the export command

  • Loading branch information...
commit 96bd8bb5ce8a2184d3474e5aa2466f201dd5e8ac 1 parent c5c66ac
@jedi4ever authored
View
1  Gemfile
@@ -6,3 +6,4 @@ gem 'net-ssh'
gem 'virtualbox'
gem 'popen4'
gem 'vagrant'
+gem 'thor'
View
2  Gemfile.lock
@@ -4,6 +4,7 @@ PATH
veewee (0.1.0)
net-ssh (~> 2.1.0)
popen4 (~> 0.1.2)
+ thor (~> 0.14.6)
vagrant (~> 0.7.0)
GEM
@@ -47,6 +48,7 @@ PLATFORMS
DEPENDENCIES
net-ssh
popen4
+ thor
vagrant
veewee!
virtualbox
View
68 bin/veewee
@@ -1,2 +1,68 @@
#!/usr/bin/env ruby
-puts "detect, bootstrap, take it on both C-level and team-level, ..."
+
+require 'rubygems'
+require 'thor'
+require 'bundler'
+require 'veewee'
+
+#Setup some base variables to use
+veewee_dir= File.expand_path(File.join(File.dirname(__FILE__),".."))
+definition_dir= File.expand_path(File.join(".", "definitions"))
+lib_dir= File.expand_path(File.join(veewee_dir, "lib"))
+box_dir= File.expand_path(File.join(veewee_dir, "boxes"))
+template_dir=File.expand_path(File.join(veewee_dir, "templates"))
+
+#vbox_dir=File.expand_path(File.join(veewee_dir, "tmp"))
+tmp_dir=File.expand_path(File.join(veewee_dir, "tmp"))
+
+iso_dir=File.expand_path(File.join(veewee_dir, "iso"))
+
+#needs to be moved to the config files to be allowed override
+#ENV['VBOX_USER_HOME']=vbox_dir
+
+#Load Veewee::Session libraries
+Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f|
+ require f }
+
+#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})
+
+class VeeweeCLI < Thor
+
+ desc "init [NAME] [TEMPLATE]", "initializes a box from a template"
+ method_options :force => :boolean
+ def init(boxname=nil, template=nil)
+ if (boxname.nil?)
+ puts "please provide a boxname"
+ exit
+ end
+
+ puts "Init a new box #{boxname}, starting from template #{template}"
+ Veewee::Session.define(boxname,template)
+
+ end
+
+ desc "templates", "list the template available"
+ def templates
+ Veewee::Session.list_templates
+ end
+
+ desc "build [NAME]", "build the box defined"
+ method_options :force => :boolean
+ def build(boxname)
+ puts "Building box #{boxname}"
+ Veewee::Session.build(boxname)
+ end
+
+ desc "export [NAME]", "export the box"
+ method_options :force => :boolean
+ def export(boxname)
+ if (!boxname.nil?)
+ Veewee::Session.export_box(boxname)
+ end
+ end
+
+end
+
+VeeweeCLI.start
View
4 lib/veewee/export.rb
@@ -32,6 +32,10 @@ def self.vagrant(boxname,boxdir,definition)
end
#Vagrant requires a relative path for output of boxes
+
+ #4.0.x. not using boxes as a subdir
+ boxdir=Pathname.new(Dir.pwd)
+
full_path=File.join(boxdir,boxname+".box")
path1=Pathname.new(full_path)
path2=Pathname.new(Dir.pwd)
View
21 lib/veewee/session.rb
@@ -358,7 +358,14 @@ def self.create_disk(boxname)
##PDB: again problems with the virtualbox GEM
##VirtualBox::Global.global.max_vdi_size=1000000
#newdisk.save
- command ="#{@vboxcmd} createhd --filename '#{boxname}.#{@definition[:disk_format]}' --size '#{@definition[:disk_size].to_i}' --format #{@definition[:disk_format]}"
+
+ command="VBoxManage list systemproperties|grep '^Default machine'|cut -d ':' -f 2|sed -e 's/^[ ]*//'"
+ results=IO.popen("#{command}")
+ place=results.gets.chop
+ results.close
+
+ puts "#{command}"
+ command ="#{@vboxcmd} createhd --filename '#{place}/#{boxname}/#{boxname}.#{@definition[:disk_format]}' --size '#{@definition[:disk_size].to_i}' --format #{@definition[:disk_format]}"
Veewee::Shell.execute("#{command}")
end
@@ -381,9 +388,21 @@ def self.add_sata_controller(boxname)
def self.attach_disk(boxname)
location=boxname+"."+@definition[:disk_format].downcase
+ command="VBoxManage list systemproperties|grep '^Default machine'|cut -d ':' -f 2|sed -e 's/^[ ]*//'"
+ results=IO.popen("#{command}")
+ place=results.gets.chop
+ results.close
+
+ location="#{place}/#{boxname}/"+location
+
+ puts "location=#{location}"
+
+
#command => "${vboxcmd} storageattach '${vname}' --storagectl 'SATA Controller' --port 0 --device 0 --type hdd --medium '${vname}.vdi'",
command ="#{@vboxcmd} storageattach '#{boxname}' --storagectl 'SATA Controller' --port 0 --device 0 --type hdd --medium '#{location}'"
+ puts "#{command}"
Veewee::Shell.execute("#{command}")
+
end
def self.mount_isofile(boxname,isofile)
View
1  veewee.gemspec
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.add_dependency "vagrant", "~> 0.7.0"
s.add_dependency "net-ssh", "~> 2.1.0"
s.add_dependency "popen4", "~> 0.1.2"
+ s.add_dependency "thor", "~> 0.14.6"
s.files = `git ls-files`.split("\n")
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
Please sign in to comment.
Something went wrong with that request. Please try again.