Permalink
Browse files

first fix or ui element output

  • Loading branch information...
1 parent 30c4bfa commit cd37b9af5dbbfc643a02724a6bbc6bb3dc2ad99b @jedi4ever committed Sep 22, 2011
View
26 bin/veewee
@@ -4,19 +4,19 @@ require 'veewee'
env = Veewee::Environment.new
begin
- # Begin logging
- # env.logger.info("veewee")
-
- # Disable color if the proper argument was passed
- shell = ARGV.include?("--no-color") ? Thor::Shell::Basic.new : Thor::Base.shell.new
-
- # Attach the UI
- env.ui = ::Veewee::UI::Shell.new(env, shell)
- env.load!
-
- # Start the CLI
+ # Begin logging
+ env.ui.info("veewee") { "`veewee` invoked: #{ARGV.inspect}" }
+
+ # Disable color if the proper argument was passed
+ shell = ARGV.include?("--no-color") ? Thor::Shell::Basic.new : Thor::Base.shell.new
+
+ # Attach the UI
+ env.ui = ::Veewee::UI::Shell.new(env, shell)
+ env.load!
+
+ # Start the CLI
::Veewee::CLI.start(ARGV,:env => env)
-
+
rescue Veewee::Error => e
puts "#{e}"
-end
+end
View
10 lib/veewee/builder/core/box/vnc.rb
@@ -1,10 +1,10 @@
require 'net/vnc'
-module Veewee
+module Veewee
module Builder
module Core
module BoxCommand
-
+
def vnc_type(sequence,host,display=20)
counter=0
env.logger.info "Opening VNC #{host} on display #{display}"
@@ -20,7 +20,7 @@ def vnc_type(sequence,host,display=20)
if keycode==:wait
sleep 1
else
- send_vnc_keycode(vnc,keycode)
+ send_vnc_keycode(vnc,keycode)
end
end
}
@@ -109,8 +109,8 @@ def string_to_vnccode(thestring)
return keycodes
end
-
-
+
+
end #Module
end #Module
end #Module
View
4 lib/veewee/builder/vmfusion/box.rb
@@ -50,7 +50,7 @@ def destroy
env.ui.error "Error:: You tried to destroy a non-existing box '#{name}'"
exit -1
end
-
+
raw.halt if raw.state=="running"
::Fission::VM.delete(name)
# remove it from memory
@@ -75,7 +75,7 @@ def ip_address
# Type on the console
def console_type(sequence,type_options={})
-# vnc_port=raw.vnc_port
+ # vnc_port=raw.vnc_port
vnc_port=20
vnc_type(sequence,"localhost",vnc_port)
end
View
44 lib/veewee/builder/vmfusion/builder.rb
@@ -4,29 +4,29 @@ module Veewee
module Builder
module Vmfusion
class Builder < Veewee::Builder::Core::Builder
-
- def build_info
- info=super
- command="/Library/Application Support/VMware Fusion/vmrun"
- output=IO.popen("#{command.shellescape}").readlines
- info << {:filename => ".vmfusion_version",:content => output[1].split(/ /)[2..3].join.strip}
-
- end
-
- # Translate the definition ssh options to ssh options that can be passed to Net::Ssh calls
- def ssh_options(definition)
- ssh_options={
- :user => definition.ssh_user,
- :port => 22,
- :password => definition.ssh_password,
- :timeout => definition.ssh_login_timeout.to_i
- }
- return ssh_options
- end
-
-
+ def build_info
+ info=super
+ command="/Library/Application Support/VMware Fusion/vmrun"
+ output=IO.popen("#{command.shellescape}").readlines
+ info << {:filename => ".vmfusion_version",:content => output[1].split(/ /)[2..3].join.strip}
+
+ end
+
+ # Translate the definition ssh options to ssh options that can be passed to Net::Ssh calls
+ def ssh_options(definition)
+ ssh_options={
+ :user => definition.ssh_user,
+ :port => 22,
+ :password => definition.ssh_password,
+ :timeout => definition.ssh_login_timeout.to_i
+ }
+ return ssh_options
+ end
+
+
+
end #End Class
end # End Module
end # End Module
-end # End Module
+end # End Module
View
50 lib/veewee/command/kvm.rb
@@ -9,53 +9,65 @@ class Kvm< Veewee::Command::GroupBase
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "force the build"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
- method_option :auto,:type => :boolean , :default => false, :aliases => "-a", :desc => "auto answers"
+ method_option :auto,:type => :boolean , :default => false, :aliases => "-a", :desc => "auto answers"
def build(definition_name,box_name=nil)
- Veewee::Environment.new(options).config.builders["kvm"].build(definition_name,box_name,options)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.config.builders["kvm"].build(definition_name,box_name,options)
end
-
+
desc "destroy [BOXNAME]", "Destroys the virtualmachine that was build"
def destroy(box_name)
- Veewee::Environment.new(options).config.builders["kvm"].get_box(box_name).destroy
- end
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.config.builders["kvm"].get_box(box_name).destroy
+ end
desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
- method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def define(definition_name, template_name)
- Veewee::Environment.new(options).define(definition_name,template_name,options)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.define(definition_name,template_name,options)
puts "The basebox '#{definition_name}' has been succesfully created from the template '#{template_name}'"
puts "You can now edit the definition files stored in definitions/#{definition_name} or build the box with:"
puts "veewee vbox build '#{definition_name}'"
end
desc "undefine [BOXNAME]", "Removes the definition of a basebox "
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def undefine(definition_name)
- puts "Removing definition #{definition_name}"
begin
- Veewee::Environment.new(options).undefine(definition_name,options)
- puts "Definition #{definition_name} succesfully removed"
+ env.ui.info "Removing definition #{definition_name}"
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.undefine(definition_name,options)
+ venv.info "Definition #{definition_name} succesfully removed"
rescue Error => ex
- puts "#{ex}"
+ env.ui.error "#{ex}"
exit -1
end
- end
-
+ end
+
desc "templates", "List the currently available templates"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def templates
env.ui.info "The following templates are available:"
- Veewee::Environment.new(options).get_template_paths.keys.each do |name|
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.get_template_paths.keys.each do |name|
env.ui.info "veewee vbox define '<box_name>' '#{name}'"
- end
+ end
end
desc "list", "Lists all defined boxes"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def list
env.ui.info "The following local definitions are available:"
- Veewee::Environment.new(options).get_definition_paths.keys.each do |name|
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.get_definition_paths.keys.each do |name|
env.ui.info "- #{name}"
end
end
View
60 lib/veewee/command/virtualbox.rb
@@ -1,64 +1,74 @@
module Veewee
module Command
class Virtualbox< Veewee::Command::GroupBase
-
+
register "vbox", "Subcommand for virtualbox"
desc "build [TEMPLATE_NAME] [BOX_NAME]", "Build box"
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "force the build"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
method_option :auto,:type => :boolean , :default => false, :aliases => "-a", :desc => "auto answers"
def build(definition_name,box_name=nil)
- Veewee::Environment.new(options).config.builders["virtualbox"].build(definition_name,box_name,options)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.config.builders["virtualbox"].build(definition_name,box_name,options)
end
-
+
desc "destroy [BOXNAME]", "Destroys the virtualmachine that was build"
def destroy(box_name)
Veewee::Environment.new(options).config.builders["virtualbox"].get_box(box_name).destroy
- end
+ end
desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
- method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def define(definition_name, template_name)
- Veewee::Environment.new(options).define(definition_name,template_name,options)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.define(definition_name,template_name,options)
puts "The basebox '#{definition_name}' has been succesfully created from the template '#{template_name}'"
puts "You can now edit the definition files stored in definitions/#{definition_name} or build the box with:"
puts "veewee vbox build '#{definition_name}'"
end
desc "undefine [BOXNAME]", "Removes the definition of a basebox "
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def undefine(definition_name)
- puts "Removing definition #{definition_name}"
+ env.ui.info "Removing definition #{definition_name}", :prefix => false
begin
- Veewee::Environment.new(options).undefine(definition_name,options)
- puts "Definition #{definition_name} succesfully removed"
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.undefine(definition_name,options)
+ env.ui.info "Definition #{definition_name} succesfully removed" , :prefix => false
rescue Error => ex
- puts "#{ex}"
+ env.ui.error "#{ex}",:prefix => false
exit -1
end
- end
-
+ end
+
desc "templates", "List the currently available templates"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def templates
- env.ui.info "The following templates are available:"
- Veewee::Environment.new(options).get_template_paths.keys.each do |name|
- env.ui.info "veewee vbox define '<box_name>' '#{name}'"
- end
+ env.ui.info "The following templates are available:",:prefix => false
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.get_template_paths.keys.each do |name|
+ env.ui.info "veewee vbox define '<box_name>' '#{name}'",:prefix => false
+ end
end
desc "list", "Lists all defined boxes"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def list
- env.ui.info "The following local definitions are available:"
- Veewee::Environment.new(options).get_definition_paths.keys.each do |name|
- env.ui.info "- #{name}"
+ env.ui.info "The following local definitions are available:",:prefix => false
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.get_definition_paths.keys.each do |name|
+ env.ui.info "- #{name}",:prefix => false
end
end
-
+
end
end
-end
+end
View
71 lib/veewee/command/vmfusion.rb
@@ -10,65 +10,76 @@ class Vmfusion< Veewee::Command::GroupBase
method_option :auto,:type => :boolean , :default => false, :aliases => "-a", :desc => "auto answers"
def build(definition_name,box_name=nil)
venv=Veewee::Environment.new(options)
-
+ venv.ui=env.ui
venv.config.builders["vmfusion"].build(definition_name,box_name,options)
end
-
+
desc "destroy [BOXNAME]", "Destroys the virtualmachine that was build"
def destroy(box_name)
- Veewee::Environment.new(options).config.builders["vmfusion"].get_box(box_name).destroy
- end
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.config.builders["vmfusion"].get_box(box_name).destroy
+ end
desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
- method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def define(definition_name, template_name)
- Veewee::Environment.new(options).define(definition_name,template_name,options)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.define(definition_name,template_name,options)
puts "The basebox '#{definition_name}' has been succesfully created from the template '#{template_name}'"
puts "You can now edit the definition files stored in definitions/#{definition_name} or build the box with:"
puts "veewee fusion build '#{definition_name}'"
end
desc "undefine [BOXNAME]", "Removes the definition of a basebox "
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def undefine(definition_name)
- puts "Removing definition #{definition_name}"
+ env.ui.info "Removing definition #{definition_name}" , :prefix => false
begin
- Veewee::Environment.new(options).undefine(definition_name,options)
- puts "Definition #{definition_name} succesfully removed"
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.undefine(definition_name,options)
+ env.ui.info "Definition #{definition_name} succesfully removed",:prefix => false
rescue Error => ex
- puts "#{ex}"
+ env.ui.error "#{ex}" , :prefix => false
exit -1
end
- end
-
- desc "export [NAME]", "Exports the basebox to the ova format"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ end
+
+ desc "export [NAME]", "Exports the basebox to the ova format"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def export(box_name)
venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
venv.config.builders["vmfusion"].get_box(box_name).export_ova(options)
- end
-
-
+ end
+
+
desc "templates", "List the currently available templates"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def templates
- env.ui.info "The following templates are available:"
- Veewee::Environment.new(options).get_template_paths.keys.each do |name|
- env.ui.info "veewee fusion define '<box_name>' '#{name}'"
- end
+ env.ui.info "The following templates are available:",:prefix => false
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.get_template_paths.keys.each do |name|
+ env.ui.info "veewee fusion define '<box_name>' '#{name}'",:prefix => false
+ end
end
desc "list", "Lists all defined boxes"
- method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
def list
- env.ui.info "The following local definitions are available:"
- Veewee::Environment.new(options).get_definition_paths.keys.each do |name|
- env.ui.info "- #{name}"
+ env.ui.info "The following local definitions are available:",:prefix => false
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.get_definition_paths.keys.each do |name|
+ env.ui.info "- #{name}",:prefix => false
end
- end
+ end
+
-
end
end
View
2 lib/veewee/environment.rb
@@ -60,7 +60,7 @@ def initialize(options={})
options = defaults.merge(options)
logger.info("environment") { "Environment initialized (#{self})" }
-
+
# Injecting all variables of the options and assign the variables
options.each do |key, value|
instance_variable_set("@#{key}".to_sym, options[key])
View
3 lib/veewee/ui.rb
@@ -68,6 +68,7 @@ def clear_line
def format_message(message, opts=nil)
opts = { :prefix => true }.merge(opts || {})
+ opts[:prefix]=false if env.resource=="veewee"
message = "[#{env.resource}] #{message}" if opts[:prefix]
message
end
@@ -79,4 +80,4 @@ def line_reset
end
end
end
-end
+end

0 comments on commit cd37b9a

Please sign in to comment.