Permalink
Browse files

allow tag for validation to be specified

  • Loading branch information...
1 parent dec691f commit de1f9befc36b88928f1eb06d00ba53ad44cbd127 @jedi4ever committed Sep 4, 2012
@@ -81,6 +81,7 @@ def undefine(definition_name)
desc "validate [NAME]", "Validates a box against vmfusion compliancy rules"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :tags, :type => :array , :default => %w{vmfusion puppet chef}, :aliases => "-t", :desc => "tags to validate"
def validate(box_name)
venv=Veewee::Environment.new(options)
venv.ui=env.ui
@@ -82,6 +82,7 @@ def undefine(definition_name)
desc "validate [NAME]", "Validates a box against kvm compliancy rules"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :tags,:type => :array , :default => %w{kvm puppet chef}, :aliases => "-t", :desc => "tags to validate"
def validate(box_name)
venv=Veewee::Environment.new(options)
venv.ui=env.ui
@@ -79,6 +79,7 @@ def undefine(definition_name)
desc "validate [NAME]", "Validates a box against parallels compliancy rules"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :tags,:type => :array, :default => %w{parallels puppet chef}, :aliases => "-t", :desc => "tags to validate"
def validate(box_name)
venv=Veewee::Environment.new(options)
venv.ui=env.ui
@@ -16,8 +16,8 @@ def execute
options['debug'] = d
end
- opts.on("-f", "--force", "force overwrite") do |f|
- options['force'] = f
+ opts.on("-t", "--tags vagrant,puppet,chef", Array, "tags to validate") do |t|
+ options['tags'] = t
end
end
@@ -114,6 +114,7 @@ def list
desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ method_option :tags, :type => :array , :default => %w{vagrant virtualbox puppet chef}, :aliases => "-t", :desc => "tags to validate"
def validate(box_name)
begin
venv=Veewee::Environment.new(options)
@@ -13,6 +13,7 @@
require 'veewee/provider/core/box/ssh'
require 'veewee/provider/core/box/issh'
require 'veewee/provider/core/box/floppy'
+require 'veewee/provider/core/box/validate_tags'
module Veewee
module Provider
@@ -0,0 +1,52 @@
+module Veewee
+ module Provider
+ module Core
+ module BoxCommand
+
+ def validate_tags(tags,options)
+ unless self.running?
+ ui.error "Error:: You tried to validate box '#{name}' but it is not running"
+ exit -1
+ end
+
+ require 'cucumber'
+
+ require 'cucumber/rspec/disable_option_parser'
+ require 'cucumber/cli/main'
+
+ # Passing ssh options via ENV varialbles to cucumber
+ # VEEWEE_SSH_USER, VEEWEE_SSH_PASSWORD ,VEEWEE_SSH_PORT
+ cucumber_vars=ssh_options
+ cucumber_vars.each do |key,value|
+ ENV['VEEWEE_'+key.to_s.upcase]=cucumber_vars[key].to_s
+ end
+
+ # Pass the name of the box
+ ENV['VEEWEE_BOXNAME']=@name
+ ENV['VEEWEE_PROVIDER']=@provider.name
+
+ feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation","veewee.feature")
+
+ features=Array.new
+ features[0]=feature_path
+ features << "--tags"
+ features << tags.map {|t| "@#{t}"}.join(',')
+
+ begin
+ # The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
+ failure = Cucumber::Cli::Main.execute(features.dup)
+ Kernel.exit(failure ? 1 : 0)
+ rescue SystemExit => e
+ Kernel.exit(e.status)
+ rescue Exception => e
+ ui.error("#{e.message} (#{e.class})")
+ ui.error(e.backtrace.join("\n"))
+ Kernel.exit(1)
+ end
+
+ end
+ end #Module
+
+ end #Module
+ end #Module
+end #Module
@@ -4,40 +4,8 @@ module Kvm
module BoxCommand
def validate_kvm(options)
- require 'cucumber'
- require 'cucumber/rspec/disable_option_parser'
- require 'cucumber/cli/main'
-
- # Passing ssh options via ENV varialbles to cucumber
- # VEEWEE_SSH_USER, VEEWEE_SSH_PASSWORD ,VEEWEE_SSH_PORT
- cucumber_vars=ssh_options
- cucumber_vars.each do |key,value|
- ENV['VEEWEE_'+key.to_s.upcase]=cucumber_vars[key].to_s
- end
-
- # Pass the name of the box
- ENV['VEEWEE_BOXNAME']=@name
- ENV['VEEWEE_PROVIDER']="kvm"
-
- feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation","veewee.feature")
-
- features=Array.new
- features[0]=feature_path
- features[1]="--tags"
- features[2]="@kvm"
-
- begin
- # The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
- failure = Cucumber::Cli::Main.execute(features.dup)
- Kernel.exit(failure ? 1 : 0)
- rescue SystemExit => e
- Kernel.exit(e.status)
- rescue Exception => e
- ui.error("#{e.message} (#{e.class})")
- ui.error(e.backtrace.join("\n"))
- Kernel.exit(1)
- end
+ validate_tags( [ 'vbox', 'puppet', 'chef'],options)
end
end #Module
@@ -4,41 +4,7 @@ module Parallels
module BoxCommand
def validate_parallels(options)
- require 'cucumber'
-
- require 'cucumber/rspec/disable_option_parser'
- require 'cucumber/cli/main'
-
- # Passing ssh options via ENV varialbles to cucumber
- # VEEWEE_SSH_USER, VEEWEE_SSH_PASSWORD ,VEEWEE_SSH_PORT
- cucumber_vars=ssh_options
- cucumber_vars.each do |key,value|
- ENV['VEEWEE_'+key.to_s.upcase]=cucumber_vars[key].to_s
- end
-
- # Pass the name of the box
- ENV['VEEWEE_BOXNAME']=@name
- ENV['VEEWEE_PROVIDER']="parallels"
-
- feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation","veewee.feature")
-
- features=Array.new
- features[0]=feature_path
- features[1]="--tags"
- features[2]="@parallels"
-
- begin
- # The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
- failure = Cucumber::Cli::Main.execute(features.dup)
- Kernel.exit(failure ? 1 : 0)
- rescue SystemExit => e
- Kernel.exit(e.status)
- rescue Exception => e
- ui.error("#{e.message} (#{e.class})")
- ui.error(e.backtrace.join("\n"))
- Kernel.exit(1)
- end
-
+ validate_tags([ 'parallels','puppet','chef'],options)
end
end #Module
@@ -4,47 +4,7 @@ module Virtualbox
module BoxCommand
def validate_vagrant(options = {})
-
- unless self.running?
- ui.error "Error:: You tried to validate box '#{name}' but it is not running"
- exit -1
- end
-
- require 'cucumber'
-
- require 'cucumber/rspec/disable_option_parser'
- require 'cucumber/cli/main'
-
- # Passing ssh options via ENV varialbles to cucumber
- # VEEWEE_SSH_USER, VEEWEE_SSH_PASSWORD ,VEEWEE_SSH_PORT
- cucumber_vars=self.ssh_options
- cucumber_vars.each do |key,value|
- ENV['VEEWEE_'+key.to_s.upcase]=cucumber_vars[key].to_s
- end
-
- # Pass the name of the box
- ENV['VEEWEE_BOXNAME']=@name
- ENV['VEEWEE_PROVIDER']="virtualbox"
-
- feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation","veewee.feature")
-
- features=Array.new
- features[0]=feature_path
- features[1]="--tags"
- features[2]="@vagrant,@virtualbox"
-
- begin
- # The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
- failure = Cucumber::Cli::Main.execute(features.dup)
- Kernel.exit(failure ? 1 : 0)
- rescue SystemExit => e
- Kernel.exit(e.status)
- rescue Exception => e
- ui.error("#{e.message} (#{e.class})")
- ui.error(e.backtrace.join("\n"))
- Kernel.exit(1)
- end
-
+ validate_tags( ['virtualbox','vagrant','puppet','chef'],options)
end
end #Module
@@ -4,41 +4,7 @@ module Vmfusion
module BoxCommand
def validate_vmfusion(options)
- require 'cucumber'
-
- require 'cucumber/rspec/disable_option_parser'
- require 'cucumber/cli/main'
-
- # Passing ssh options via ENV varialbles to cucumber
- # VEEWEE_SSH_USER, VEEWEE_SSH_PASSWORD ,VEEWEE_SSH_PORT
- cucumber_vars=ssh_options
- cucumber_vars.each do |key,value|
- ENV['VEEWEE_'+key.to_s.upcase]=cucumber_vars[key].to_s
- end
-
- # Pass the name of the box
- ENV['VEEWEE_BOXNAME']=@name
- ENV['VEEWEE_PROVIDER']="vmfusion"
-
- feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation","veewee.feature")
-
- features=Array.new
- features[0]=feature_path
- features[1]="--tags"
- features[2]="@vmfusion"
-
- begin
- # The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
- failure = Cucumber::Cli::Main.execute(features.dup)
- Kernel.exit(failure ? 1 : 0)
- rescue SystemExit => e
- Kernel.exit(e.status)
- rescue Exception => e
- env.ui.error("#{e.message} (#{e.class})")
- env.ui.error(e.backtrace.join("\n"))
- Kernel.exit(1)
- end
-
+ validate_tags( options['tags'],options)
end
end #Module
View
@@ -2,37 +2,37 @@ Feature: veewee box validation
As a valid veewee box
I need to comply to a set of rules
- @vmfusion @virtualbox @kvm
+ @vmfusion @virtualbox @kvm @parallels
Scenario: Valid definition
Given a veeweebox was build
And I run "whoami" over ssh
Then I should see the provided username in the output
- @vmfusion @virtualbox @kvm
+ @vmfusion @virtualbox @kvm @parallels
Scenario: Checking sudo
Given a veeweebox was build
And I sudorun "whoami" over ssh
Then I should see "root" in the output
- @vmfusion @virtualbox @kvm
+ @vmfusion @virtualbox @kvm @parallels
Scenario: Checking ruby
Given a veeweebox was build
And I run ". /etc/profile ;ruby --version 2> /dev/null 1> /dev/null; echo $?" over ssh
Then I should see "0" in the output
- @vmfusion @virtualbox @kvm
+ @vmfusion @virtualbox @kvm @parallels
Scenario: Checking gem
Given a veeweebox was build
And I run ". /etc/profile; gem --version 2> /dev/null 1> /dev/null ; echo $?" over ssh
Then I should see "0" in the output
- @vmfusion @virtualbox @kvm
+ @chef
Scenario: Checking chef
Given a veeweebox was build
And I run ". /etc/profile ;chef-client --version 2> /dev/null 1>/dev/null; echo $?" over ssh
Then I should see "0" in the output
- @vmfusion @virtualbox @kvm
+ @puppet
Scenario: Checking puppet
Given a veeweebox was build
And I run ". /etc/profile ; puppet --version 2> /dev/null 1>/dev/null; echo $?" over ssh

0 comments on commit de1f9be

Please sign in to comment.