lib/gogetit/cli.rb in gogetit-0.7.0 vs lib/gogetit/cli.rb in gogetit-0.8.0
- old
+ new
@@ -18,11 +18,13 @@
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 :alias, :aliases => '-a', :type => :string, \
- :default => '', :desc => 'An alias name for a lxd image'
+ :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 :vlans, :aliases => '-v', :type => :array, \
:desc => 'A list of VLAN IDs to connect to'
method_option :ipaddresses, :aliases => '-i', :type => :array, \
@@ -39,10 +41,16 @@
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']
+ abort("'distro' has to be set with libvirt provider.") \
+ if options['distro'] and options['provider'] == 'lxd'
+
+ abort("'alias' has to be set with lxd provider.") \
+ if options['alias'] and options['provider'] == 'libvirt'
+
case options['provider']
when 'lxd'
Gogetit.lxd.create(name, options.to_hash)
when 'libvirt'
Gogetit.libvirt.create(name, options.to_hash)
@@ -55,20 +63,42 @@
knife_bootstrap(name, options[:provider], Gogetit.config, Gogetit.logger)
update_databags(Gogetit.config, Gogetit.logger)
end
end
- desc 'destroy NAME', 'Destroy either a container or KVM domain.'
+ desc 'destroy NAME', 'Destroy either a container or KVM instance.'
method_option :chef, :type => :boolean, :desc => "Enable chef awareness."
def destroy(name)
# 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
+ abort('Invalid argument entered.')
+ end
+ end
+ # post-tasks
+ if options['chef']
+ knife_remove(name, Gogetit.logger) if options[:chef]
+ update_databags(Gogetit.config, Gogetit.logger)
+ end
+ end
+
+ desc 'release NAME', 'Release a node in MAAS'
+ method_option :chef, :type => :boolean, :desc => "Enable chef awareness."
+ def release(name)
+ # Let Gogetit recognize the provider.
+ provider = Gogetit.get_provider_of(name)
+ if provider
+ case provider
+ when 'lxd'
+ abort('This method is not available for LXD container.')
+ when 'libvirt'
+ Gogetit.libvirt.release(name)
else
abort('Invalid argument entered.')
end
end
# post-tasks