lib/gogetit/cli.rb in gogetit-0.5.0 vs lib/gogetit/cli.rb in gogetit-0.5.1

- old
+ new

@@ -14,11 +14,11 @@ puts '' puts "Listing KVM domains on #{Gogetit.config[:libvirt][:url]}.." system("virsh -c #{Gogetit.config[:libvirt][:url]} list --all") end - desc 'create (TYPE) NAME', 'Create either a container or KVM domain.' + desc 'create NAME', 'Create either a container or KVM domain.' method_option :provider, :aliases => '-p', :type => :string, \ :default => 'lxd', :desc => 'A provider such as lxd and libvirt' method_option :chef, :aliases => '-c', :type => :boolean, \ :default => false, :desc => 'Chef awareness' @@ -39,23 +39,24 @@ abort('Invalid argument entered.') end # post-tasks if options[:chef] - knife_bootstrap(name, type, Gogetit.config, Gogetit.logger) + knife_bootstrap(name, options[:provider], Gogetit.config, Gogetit.logger) update_vault(Gogetit.config, Gogetit.logger) end Gogetit.config[:default][:user] ||= ENV['USER'] puts "ssh #{Gogetit.config[:default][:user]}@#{name}" end desc 'destroy NAME', 'Destroy either a container or KVM domain.' method_option :chef, :type => :boolean, :desc => "Enable chef awareness." def destroy(name) - type = Gogetit.get_provider_of(name) - if type - case type + # Let Gogetit recognize the provider. + provider = Gogetit.get_provider_of(name) + if provider + case provider when 'lxd' Gogetit.lxd.destroy(name) when 'libvirt' Gogetit.libvirt.destroy(name) else @@ -67,12 +68,13 @@ knife_remove(name, Gogetit.logger) if options[:chef] update_vault(Gogetit.config, Gogetit.logger) end end - desc 'rebuild NAME', 'Destroy and create either a container or KVM domain again.' - def rebuild(type=nil, name) - invoke :destroy, [name] - invoke :create, [type, name] - end + # This feature is broken and might be deprecated in the future. + # desc 'rebuild NAME', 'Destroy and create either a container or KVM domain again.' + # def rebuild(type=nil, name) + # invoke :destroy, [name] + # invoke :create, [type, name] + # end end end