Sha256: e78eeb3fb502ea3e231cac9ba8833c1af2a682ad58a803e74dd509c6a8d96b70

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'thor'
require 'gogetit'

module Gogetit
  class CLI < Thor
    package_name 'Gogetit'

    desc 'list', 'List containers and instances, running currently.'
    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

    desc 'create (TYPE) NAME', 'Create either a container or KVM domain.'
    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

    desc 'destroy NAME', 'Destroy either a container or KVM domain.'
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gogetit-0.1.16 lib/gogetit/cli.rb