Class: Gogetit::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gogetit/cli.rb

Instance Method Summary collapse

Instance Method Details

#create(type = nil, name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gogetit/cli.rb', line 18

def create(type=nil, name)
  case type
  when 'lxd', nil
    Gogetit.lxd.create(name)
  when 'libvirt'
    Gogetit.libvirt.create(name)
  else
    puts 'Invalid argument entered'
  end
  Gogetit.config[:default][:user] ||= ENV['USER']
  puts "ssh #{Gogetit.config[:default][:user]}@#{name}"
end

#destroy(name) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gogetit/cli.rb', line 32

def destroy(name)
  type = Gogetit.get_provider_of(name)
  if type
    case type
    when 'lxd', nil
      Gogetit.lxd.destroy(name)
    when 'libvirt'
      Gogetit.libvirt.destroy(name)
    end
  end
end

#listObject



9
10
11
12
13
14
15
# File 'lib/gogetit/cli.rb', line 9

def list
  puts "Listing LXD containers on #{Gogetit.config[:lxd][:url]}.."
  system("lxc list #{Gogetit.config[:lxd][:name]}:")
  puts ''
  puts "Listing KVM domains on #{Gogetit.config[:libvirt][:url]}.."
  system("virsh -c #{Gogetit.config[:libvirt][:url]} list --all")
end