Class: Tupperware::Base
- Inherits:
-
Object
- Object
- Tupperware::Base
- Defined in:
- lib/tupperware.rb
Instance Method Summary collapse
- #check_driver ⇒ Object
-
#initialize(options = {}, kitchen_config = Kitchen::Config.new) ⇒ Base
constructor
A new instance of Base.
- #package ⇒ Object
- #vagrant_finish(instance_name) ⇒ Object
Constructor Details
#initialize(options = {}, kitchen_config = Kitchen::Config.new) ⇒ Base
Returns a new instance of Base.
41 42 43 44 45 |
# File 'lib/tupperware.rb', line 41 def initialize( = {}, kitchen_config = Kitchen::Config.new) @kitchen_config = kitchen_config = @supported_drivers = {'vagrant' => VagrantVirtualBox} end |
Instance Method Details
#check_driver ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/tupperware.rb', line 47 def check_driver hash = @kitchen_config.loader.read driver = hash[:driver][:name] unless @supported_drivers.has_key?(driver) puts "#{driver} is not yet supported" exit end return @supported_drivers[driver] end |
#package ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/tupperware.rb', line 77 def package cls = check_driver instance = nil if cls == VagrantVirtualBox if [:instance] @kitchen_config.instances.each do |i| if i.name.to_s == [:instance] instance = i break end end unless instance puts "#{@options[:instance]} is not a valid kitchen instance" exit 1 end instance_name = instance.name.to_s puts "\n*** Converging #{instance_name} ***\n" instance.converge packager = VagrantVirtualBox.new(, @kitchen_config) packager.provision_local_box(instance) packager.halt(instance_name) packager.package(instance_name) instance.destroy vagrant_finish(instance_name) else packager = VagrantVirtualBox.new(, @kitchen_config) packager.kitchen_config.instances.each do |i| instance_name = i.name.to_s puts "\n*** Converging #{i.name.to_s} ***\n" i.converge packager.provision_local_box(i) packager.halt(i.name.to_s) packager.package(i.name.to_s) i.destroy vagrant_finish(instance_name) end end end end |
#vagrant_finish(instance_name) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tupperware.rb', line 57 def vagrant_finish(instance_name) done = "\n\nYour vagrant box file is named \#{instance_name}.box. Import it by\nrunning:\n\nvagrant box add --name NAME \#{instance_name}.box\n\nRun the following command for more information on importing vagrant\nboxes:\n\nvagrant box add -h\n\n\n DONE\n puts done\n\nend\n" |