lib/gogetit/cli.rb in gogetit-0.14.0 vs lib/gogetit/cli.rb in gogetit-0.15.0

- old
+ new

@@ -59,10 +59,12 @@ :desc => 'An alias name for a lxd image' method_option :distro, :aliases => '-d', :type => :string, \ :desc => 'A distro name with its series for libvirt provider' method_option :chef, :aliases => '-c', :type => :boolean, \ :default => false, :desc => 'Chef awareness' + method_option :zero, :aliases => '-z', :type => :boolean, \ + :default => false, :desc => 'Chef Zero awareness' method_option :vlans, :aliases => '-v', :type => :array, \ :desc => 'A list of VLAN IDs to connect to' method_option :ipaddresses, :aliases => '-i', :type => :array, \ :desc => 'A list of static IPs to assign' method_option :"no-maas", :type => :boolean, \ @@ -71,10 +73,13 @@ :desc => 'File location(only for LXD provider)' def create(name) abort("'vlans' and 'ipaddresses' can not be set together.") \ if options['vlans'] and options['ipaddresses'] + abort("'chef' and 'zero' can not be set together.") \ + if options['chef'] and options['zero'] + abort("when 'no-maas', the network configuration have to be set by 'file'.") \ if options['no-maas'] and (options['vlans'] or options['ipaddresses']) abort("'no-maas' and 'file' have to be set together.") \ if options['no-maas'] ^ !!options['file'] @@ -94,18 +99,26 @@ abort('Invalid argument entered.') end # post-tasks if options['chef'] - knife_bootstrap(name, options[:provider], config, logger) - update_databags(config, logger) + bootstrap_chef(name, options[:provider], config) + update_databags(config) + elsif options['zero'] + knife_bootstrap_zero(name, options[:provider], config) end end desc 'destroy NAME', 'Destroy either a container or KVM instance.' - method_option :chef, :type => :boolean, :desc => "Enable chef awareness." + method_option :chef, :aliases => '-c', :type => :boolean, \ + :default => false, :desc => 'Chef awareness' + method_option :zero, :aliases => '-z', :type => :boolean, \ + :default => false, :desc => 'Chef Zero awareness' def destroy(name) + abort("'chef' and 'zero' can not be set together.") \ + if options['chef'] and options['zero'] + provider = get_provider_of(name, providers) if provider case provider when 'lxd' Gogetit::CLI.result = lxd.destroy(name) @@ -115,47 +128,70 @@ abort('Invalid argument entered.') end end # post-tasks if options['chef'] - knife_remove(name) if options[:chef] + knife_remove(name, options) update_databags(config) + elsif options['zero'] + knife_remove(name, options) end end desc 'deploy NAME', 'Deploy a node existing in MAAS.' method_option :distro, :aliases => '-d', :type => :string, \ :desc => 'A distro name with its series for libvirt provider' method_option :chef, :aliases => '-c', :type => :boolean, \ :default => false, :desc => 'Chef awareness' + method_option :zero, :aliases => '-z', :type => :boolean, \ + :default => false, :desc => 'Chef Zero awareness' def deploy(name) + abort("'chef' and 'zero' can not be set together.") \ + if options['chef'] and options['zero'] + Gogetit::CLI.result = libvirt.deploy(name, options.to_hash) # post-tasks if options['chef'] - knife_bootstrap(name, options[:provider], config, logger) - update_databags(config, logger) + knife_bootstrap(name, options[:provider], config) + update_databags(config) + elsif options['zero'] + knife_bootstrap_zero(name, options[:provider], config) end end desc 'release NAME', 'Release a node in MAAS' method_option :chef, :type => :boolean, :desc => "Enable chef awareness." + method_option :chef, :aliases => '-c', :type => :boolean, \ + :default => false, :desc => 'Chef awareness' + method_option :zero, :aliases => '-z', :type => :boolean, \ + :default => false, :desc => 'Chef Zero awareness' def release(name) + abort("'chef' and 'zero' can not be set together.") \ + if options['chef'] and options['zero'] + Gogetit::CLI.result = libvirt.release(name) # post-tasks if options['chef'] - knife_remove(name) if options[:chef] + knife_remove(name, options) update_databags(config) + elsif options['zero'] + knife_remove(name, options) end end desc 'rebuild NAME', 'Destroy(or release) and create(or deploy)'\ ' either a container or a node(machine) in MAAS again.' method_option :chef, :aliases => '-c', :type => :boolean, \ :default => false, :desc => 'Chef awareness' + method_option :zero, :aliases => '-z', :type => :boolean, \ + :default => false, :desc => 'Chef Zero awareness' def rebuild(name) + abort("'chef' and 'zero' can not be set together.") \ + if options['chef'] and options['zero'] + provider = get_provider_of(name, providers) if provider case provider when 'lxd' 1.upto(100) { print '_' }; puts @@ -175,11 +211,11 @@ abort('Invalid argument entered.') end end # post-tasks if options['chef'] - knife_remove(name, logger) if options[:chef] - update_databags(config, logger) + knife_remove(name) if options[:chef] + update_databags(config) end end end end