Skip to content
Browse files

added veewee command again

  • Loading branch information...
1 parent 7db5231 commit ce6f78691ebfcd9f34ce4b5be6fe048e91f44730 @jedi4ever committed Sep 18, 2011
View
2 bin/veewee-kvm → bin/veewee
@@ -13,7 +13,7 @@ begin
# Attach the UI
env.ui = ::Veewee::UI::Shell.new(env, shell)
env.load!
-
+
# Start the CLI
::Veewee::CLI.start(ARGV,:env => env)
View
2 lib/vagrant_init.rb
@@ -4,4 +4,6 @@
rescue LoadError
require 'rubygems'
require 'veewee/vagrant/command'
+ require 'veewee/command/kvm'
+
end
View
2 lib/veewee.rb
@@ -3,7 +3,7 @@
module Veewee
# The source root is the path to the root directory of
- # the Mccloud gem.
+ # the Veewee gem.
def self.source_root
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
end
View
6 lib/veewee/builder/core/builder.rb
@@ -1,6 +1,4 @@
-require 'veewee/builder/virtualbox/box'
-require 'veewee/builder/vmfusion/box'
-require 'veewee/builder/kvm/box'
+require 'veewee/builder/core/builder/build.rb'
module Veewee
module Builder
@@ -15,6 +13,8 @@ class Builder
attr_accessor :boxes
+ include ::Veewee::Builder::Core::BuilderCommand
+
def initialize(name,options,env)
@name=name
View
38 lib/veewee/builder/core/builder/build.rb
@@ -0,0 +1,38 @@
+module Veewee
+ module Builder
+ module Core
+ module BuilderCommand
+ def build(definition_name,box_name,options)
+
+ # If no box_name was given, let's give the box the same name as the definition
+ if box_name.nil?
+ box_name=definition_name
+ end
+
+ env.ui.info "building #{definition_name} #{box_name} #{options}"
+
+ definition=get_definition(definition_name)
+ box=get_box(box_name)
+
+ if box.exists?
+ # check if --force option was given
+ if option[:force]==true
+ box.destroy
+ else
+ env.ui.error "you need to provide --force because the box #{box_name} already exists"
+ end
+ end
+
+ # By now the box should have been gone, just checking again
+ box=get_box(box_name)
+ if box.exists?
+ env.ui.error "The box should have been deleted by now. Something went terribly wrong. Sorry"
+ end
+
+ box.assemble(definition)
+
+ end
+ end
+ end
+ end
+end
View
2 lib/veewee/builder/kvm/builder.rb
@@ -1,3 +1,5 @@
+require 'veewee/builder/core/builder'
+
module Veewee
module Builder
module Kvm
View
2 lib/veewee/builder/virtualbox/builder.rb
@@ -1,3 +1,5 @@
+require 'veewee/builder/core/builder'
+
require 'virtualbox'
#require 'virtualbox/abstract_model'
#require 'virtualbox/ext/byte_normalizer'
View
1 lib/veewee/builder/vmfusion/build.rb
@@ -2,7 +2,6 @@ module Veewee
module Builder
module Vmfusion
-
def build(build_options={})
defaults= { "force" => false, "nogui" => false }
options=defaults.merge(build_options)
View
1 lib/veewee/builder/vmfusion/builder.rb
@@ -1,3 +1,4 @@
+require 'veewee/builder/core/builder'
module Veewee
module Builder
module Vmfusion
View
15 lib/veewee/builderfactory.rb
@@ -1,15 +0,0 @@
-require 'veewee/builder/virtualbox/builder'
-require 'veewee/builder/vmfusion/builder'
-require 'veewee/builder/kvm/builder'
-
-module Veewee
-
- class BuilderFactory
- def self.instantiate(builder_type,builder_options,environment)
- classname=builder_type.to_s.capitalize
- builder_class=Object.const_get("Veewee").const_get("Builder").const_get(classname).const_get("Builder")
- return builder_class.new(builder_options,environment)
- end
- end
-
-end
View
3 lib/veewee/command.rb
@@ -9,3 +9,6 @@ module Command
# The built-in commands must always be loaded
require 'veewee/command/version'
+require 'veewee/command/kvm'
+require 'veewee/command/virtualbox'
+require 'veewee/command/vmfusion'
View
17 lib/veewee/command/init.rb
@@ -1,17 +0,0 @@
-module Mccloud
- module Command
- class InitCommand < Base
- argument :box_name, :type => :string, :optional => false, :default => nil
- argument :template_name, :type => :string, :optional => false, :default => nil
-
- register "init NAME TEMPLATE-NAME", "Creates a new Mccloud project based on a template"
-
- def execute
- env.config.templates.each do |name,template|
- env.ui.info template.to_template if template.name==template_name
- end
- end
-
- end #Class
- end #Module
-end #Module
View
14 lib/veewee/command/kvm.rb
@@ -0,0 +1,14 @@
+module Veewee
+ module Command
+ class Kvm< Veewee::Command::GroupBase
+ register "kvm", "Subcommand for kvm"
+
+ desc "build [TEMPLATE_NAME] [BOX_NAME]", "Build box"
+ def build(definition_name,box_name=nil)
+ env.config.builders["kvm"].build(definition_name,box_name,options)
+ end
+
+ end
+
+ end
+end
View
14 lib/veewee/command/virtualbox.rb
@@ -0,0 +1,14 @@
+module Veewee
+ module Command
+ class Virtualbox< Veewee::Command::GroupBase
+ register "vbox", "Subcommand for Virtualbox"
+
+ desc "build [TEMPLATE_NAME] [BOX_NAME]", "Build box"
+ def build(definition_name,box_name=nil)
+ env.config.builders["vbox"].build(definition_name,box_name,options)
+ end
+
+ end
+
+ end
+end
View
14 lib/veewee/command/vmfusion.rb
@@ -0,0 +1,14 @@
+module Veewee
+ module Command
+ class Vmfusion< Veewee::Command::GroupBase
+ register "fusion", "Subcommand for fusion"
+
+ desc "build [TEMPLATE_NAME] [BOX_NAME]", "Build box"
+ def build(definition_name,box_name=nil)
+ env.config.builders["vmfusion"].build(definition_name,box_name,options)
+ end
+
+ end
+
+ end
+end
View
23 lib/veewee/config.rb
@@ -1,6 +1,8 @@
require 'veewee/config/veewee'
require 'veewee/config/collection'
require 'veewee/config/definition'
+require 'veewee/config/builder'
+
require 'fileutils'
module Veewee
@@ -77,9 +79,26 @@ def load_veewee_config()
end
return self
end
+
+
+ # Loading the builders
+ def load_builders()
+ %w{vmfusion kvm virtualbox}.each do |name|
+ config=OpenStruct.new
+ config.env=env
+ config.builder=::Veewee::Config::Builder.new(config)
+ config.builder.define(name) do |config|
+ config.builder.name="#{name}"
+ config.builder.type="#{name}"
+ end
+ env.config.builders.merge!(config.builder.components)
-
-
+ end
+
+ end
+
+
+ # Loading the definitions directories
def load_definitions()
# Read definitions from definitionspath
env.ui.info "Loading definitions from definition path"
View
1 lib/veewee/config/builder.rb
@@ -16,7 +16,6 @@ def initialize(config)
def define(name)
# We do this for vagrant syntax
# Depending on type, we create a variable of that type
- # f.i. component_stub.vm or component_stub.lb
builder_stub=OpenStruct.new
builder_stub.builder=OpenStruct.new
View
40 lib/veewee/config/definition.rb
@@ -14,43 +14,39 @@ def initialize(config)
end
def declare(name,options)
+
+ env.logger.debug("config definition"){ "Start declaring definition"}
- # Initialize options via hash
-
+ self.define(name) do |definition|
+ # we need to inject all keys as instance variables & attr_accessors
+ options.keys.each do |key|
+ definition.send("#{key.to_s}=",options[key])
+ end
+ end
+
+ env.logger.debug("config definition"){ "End declaring definition"}
+
+ end
+
+ def define(name)
+ # Depending on type, we create a variable of that type
definition_stub=OpenStruct.new
- env.logger.debug("config definition"){ "Start declaring definition"}
builder_type="vmfusion"
begin
# Load required builder
require_path='veewee/builder/'+builder_type.to_s.downcase+"/definition.rb"
require require_path
+
# Get a real definition object from the builder
real_definition=Object.const_get("Veewee").const_get("Builder").const_get(builder_type.to_s.capitalize).const_get("Definition").new(name,env)
-
- definition_stub.definition=real_definition
-
- env.logger.debug("config definition"){ "End declaring definition #{definition_stub.definition.name}"}
-
- components[name.to_s]=definition_stub.definition
-
- # we need to inject all keys as instance variables & attr_accessors
- options.keys.each do |key|
- definition_stub.definition.send("#{key.to_s}=",options[key])
- end
-
rescue Error => e
env.ui.error "Error loading provider with #{name},#{$!}"
end
-
- end
-
- def define(name)
- # Depending on type, we create a variable of that type
- definition_stub=OpenStruct.new
- definition_stub.definition=::Veewee::Definition.new(name,env)
+
+ definition_stub.definition=real_definition
env.logger.debug("config definition"){ "Start defining definition"}
View
3 lib/veewee/environment.rb
@@ -92,7 +92,10 @@ def load!
def load_config!
@config=Config.new({:env => self}).load_veewee_config()
+
+ @config.load_builders
@config.load_definitions
+
@ui.info "Loaded #{@config.builders.length} builders + #{@config.templates.length} templates + #{@config.definitions.length} definitions "
return self
View
1 lib/veewee/ui.rb
@@ -1,4 +1,5 @@
module Veewee
+
# Vagrant UIs handle communication with the outside world (typically
# through a shell). They must respond to the typically logger methods
# of `warn`, `error`, `info`, and `confirm`.
View
211 lib/veewee/vagrant/command.rb
@@ -1,118 +1,123 @@
require 'veewee'
-require 'veewee/ui/vagrant_plugin'
+require 'veewee/vagrant/ui/vagrant_plugin'
module Veewee
+ module Vagrant
+ class Command < ::Vagrant::Command::GroupBase
+ register "basebox","Commands to manage baseboxes"
- class Command < Vagrant::Command::GroupBase
- register "basebox","Commands to manage baseboxes"
- desc "ostypes", "List the available Operating System types"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- def ostypes
- Veewee::UI::VagrantPlugin.list_ostypes(options)
- end
+ desc "ostypes", "List the available Operating System types"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ def ostypes
+ Veewee::Vagrant::UI::VagrantPlugin.list_ostypes(options)
+ end
- desc "templates", "List the currently available basebox templates"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
- def templates
- Veewee::UI::VagrantPlugin.list_templates(options)
- end
+ desc "templates", "List the currently available basebox templates"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
+ def templates
+ Veewee::Vagrant::UI::VagrantPlugin.list_templates(options)
+ end
- desc "list", "Lists all defined baseboxes"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- def list
- Veewee::UI::VagrantPlugin.list_definitions(options)
- end
+ desc "list", "Lists all defined baseboxes"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def list
+ Veewee::Vagrant::UI::VagrantPlugin.list_definitions(options)
+ end
- desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- def define(box_name, template)
- Veewee::UI::VagrantPlugin.define(box_name,template,options)
- end
+ desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ def define(box_name, template)
+ Veewee::Vagrant::UI::VagrantPlugin.define(box_name,template,options)
+ end
- desc "undefine [BOXNAME]", "Removes the definition of a basebox "
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- def undefine(box_name)
- Veewee::UI::VagrantPlugin.undefine(box_name,options)
- end
+ desc "undefine [BOXNAME]", "Removes the definition of a basebox "
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def undefine(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.undefine(box_name,options)
+ end
- desc "build [BOXNAME]", "Build the box BOXNAME"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
- method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
- method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
- method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
- method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the basebox"
- method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- method_option :temp_dir , :desc => "directory where tempory files are created"
- method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
- method_option :iso_dir , :aliases => "-i", :desc => "directory where to look/store iso images"
- method_option :box_name , :desc => "name to use for the box"
- method_option :auto_download, :type => :boolean, :default => false, :desc => "download files automatically if required"
- method_option :auto_validate, :type => :boolean, :default => false, :desc => "validate the box if build is succesfull"
- method_option :auto_export, :type => :boolean, :default => false, :desc => "export the box if build is succesfull"
- method_option :auto_destroy, :type => :boolean, :default => false, :desc => "destroy the vm after possible build,validation,export"
- method_option :auto_ssh_port, :type => :boolean, :default => false, :desc => "if there is an ssh port clash, calculate a new conflicting port"
- def build(box_name)
- Veewee::UI::VagrantPlugin.build(box_name,options)
- end
+ desc "build [BOXNAME]", "Build the box BOXNAME"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the basebox"
+ method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ method_option :temp_dir , :desc => "directory where tempory files are created"
+ method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
+ method_option :iso_dir , :aliases => "-i", :desc => "directory where to look/store iso images"
+ method_option :box_name , :desc => "name to use for the box"
+ method_option :auto_download, :type => :boolean, :default => false, :desc => "download files automatically if required"
+ method_option :auto_validate, :type => :boolean, :default => false, :desc => "validate the box if build is succesfull"
+ method_option :auto_export, :type => :boolean, :default => false, :desc => "export the box if build is succesfull"
+ method_option :auto_destroy, :type => :boolean, :default => false, :desc => "destroy the vm after possible build,validation,export"
+ method_option :auto_ssh_port, :type => :boolean, :default => false, :desc => "if there is an ssh port clash, calculate a new conflicting port"
+ def build(box_name)
+ veewee_env = Veewee::Environment.new
+ # Attach the UI
+ veewee_env.ui = env.ui
+ veewee_env.load!
+ veewee_env.config.builders["virtualbox"].build(box_name,box_name,options)
+ end
- desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
- method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
- method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
- method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
- method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- def validate(box_name)
- Veewee::UI::VagrantPlugin.validate(box_name,options)
- end
-
- desc "export [NAME]", "Exports the basebox to the vagrant box format"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
- method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
- method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
- method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
- method_option :force => :boolean, :default => false, :aliases => "-f", :desc => "force overwrite box file"
- method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- method_option :vagrant_box_name, :desc => "name of vagrant box"
- def export(box_name)
- Veewee::UI::VagrantPlugin.export(box_name,options)
- end
+ desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def validate(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.validate(box_name,options)
+ end
- desc "destroy [BOXNAME]", "Destroys the virtualmachine that was build for a basebox"
- method_option :log_level, :default => 'info', :desc => "info,warning,debug"
- method_option :log_file, :desc => "file to output log"
- method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
- method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
- method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
- method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
- method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
- method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
- def destroy(box_name)
- Veewee::UI::VagrantPlugin.destroy(box_name,options)
- end
+ desc "export [NAME]", "Exports the basebox to the vagrant box format"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :force => :boolean, :default => false, :aliases => "-f", :desc => "force overwrite box file"
+ method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ method_option :vagrant_box_name, :desc => "name of vagrant box"
+ def export(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.export(box_name,options)
+ end
- end
+ desc "destroy [BOXNAME]", "Destroys the virtualmachine that was build for a basebox"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def destroy(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.destroy(box_name,options)
+ end
+ end
+end
end
View
117 lib/veewee/vagrant/command/sub.rb
@@ -0,0 +1,117 @@
+module Bla
+ desc "ostypes", "List the available Operating System types"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ def ostypes
+ Veewee::Vagrant::UI::VagrantPlugin.list_ostypes(options)
+ end
+
+ desc "templates", "List the currently available basebox templates"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
+ def templates
+ Veewee::Vagrant::UI::VagrantPlugin.list_templates(options)
+ end
+
+ desc "list", "Lists all defined baseboxes"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def list
+ Veewee::Vagrant::UI::VagrantPlugin.list_definitions(options)
+ end
+
+ desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ def define(box_name, template)
+ Veewee::Vagrant::UI::VagrantPlugin.define(box_name,template,options)
+ end
+
+ desc "kvm [BOXNAME] [TEMPLATENAME]", "kvm stuff"
+ def kvm(definition_name,box_name=nil)
+ veewee_env = Veewee::Environment.new
+ # Attach the UI
+ veewee_env.ui = env.ui
+ veewee_env.load!
+ veewee_env.cli("kvm","build",definition_name,box_name)
+ end
+
+ desc "undefine [BOXNAME]", "Removes the definition of a basebox "
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def undefine(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.undefine(box_name,options)
+ end
+
+ desc "build [BOXNAME]", "Build the box BOXNAME"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the basebox"
+ method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ method_option :temp_dir , :desc => "directory where tempory files are created"
+ method_option :template_dir , :aliases => "-t", :desc => "directory where templates are found"
+ method_option :iso_dir , :aliases => "-i", :desc => "directory where to look/store iso images"
+ method_option :box_name , :desc => "name to use for the box"
+ method_option :auto_download, :type => :boolean, :default => false, :desc => "download files automatically if required"
+ method_option :auto_validate, :type => :boolean, :default => false, :desc => "validate the box if build is succesfull"
+ method_option :auto_export, :type => :boolean, :default => false, :desc => "export the box if build is succesfull"
+ method_option :auto_destroy, :type => :boolean, :default => false, :desc => "destroy the vm after possible build,validation,export"
+ method_option :auto_ssh_port, :type => :boolean, :default => false, :desc => "if there is an ssh port clash, calculate a new conflicting port"
+ def build(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.build(box_name,options)
+ end
+
+ desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def validate(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.validate(box_name,options)
+ end
+
+ desc "export [NAME]", "Exports the basebox to the vagrant box format"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :force => :boolean, :default => false, :aliases => "-f", :desc => "force overwrite box file"
+ method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ method_option :vagrant_box_name, :desc => "name of vagrant box"
+ def export(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.export(box_name,options)
+ end
+
+ desc "destroy [BOXNAME]", "Destroys the virtualmachine that was build for a basebox"
+ method_option :log_level, :default => 'info', :desc => "info,warning,debug"
+ method_option :log_file, :desc => "file to output log"
+ method_option :ssh_user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
+ method_option :ssh_password, :default => "vagrant", :desc => "password to login with"
+ method_option :ssh_key, :aliases => "-k", :desc => "ssh key to login with"
+ method_option :ssh_port, :aliases => "-p", :desc => "ssh port to login to"
+ method_option :box_name , :aliases => "-n", :desc => "name to use for the box"
+ method_option :definition_dir , :aliases => "-d", :desc => "directory where definitions are found"
+ def destroy(box_name)
+ Veewee::Vagrant::UI::VagrantPlugin.destroy(box_name,options)
+ end
+end
View
6 lib/veewee/vagrant/config.rb
@@ -1,5 +1,7 @@
module Veewee
- class BaseBoxConfig < Vagrant::Config::Base
- configures :basebox
+ module Vagrant
+ class BaseBoxConfig < Vagrant::Config::Base
+ configures :basebox
+ end
end
end
View
3 lib/veewee/ui/vagrant_plugin.rb → lib/veewee/vagrant/ui/vagrant_plugin.rb
@@ -1,4 +1,5 @@
module Veewee
+ module Vagrant
module UI
class VagrantPlugin
@@ -23,6 +24,7 @@ def self.list_definitions(options={})
end
end
+
def self.define(definition_name, template_name,define_options={})
begin
@@ -74,3 +76,4 @@ def self.destroy(box_name,options={})
end
end
end
+end
View
1 veewee.gemspec
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
s.add_development_dependency "bundler", ">= 1.0.0"
s.add_development_dependency('ruby-libvirt','~>0.4.0')
-
s.files = `git ls-files`.split("\n")
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
s.require_path = 'lib'

0 comments on commit ce6f786

Please sign in to comment.
Something went wrong with that request. Please try again.