class Smartdc::Cli::Machine

Public Instance Methods

add(name) click to toggle source
# File lib/smartdc/cli/machine.rb, line 26
def add(name)
  body = {name: name}.merge(options)
  output Smartdc.create_machine(body), options.merge({table: :vertical})
end
destroy(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 32
def destroy(id=nil)
  id = use_machine(id)
  output Smartdc.destroy_machine(id), options.merge(message: "Destroy [#{id}] of machine.")
end
list() click to toggle source
# File lib/smartdc/cli/machine.rb, line 12
def list
  output Smartdc.machines(options), options.merge(table: :horizontal, include: %i[
    id name state primaryIp memory disk dataset
  ])
end
reboot(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 50
def reboot(id=nil)
  id = use_machine(id)
  output Smartdc.reboot_machine(id), options.merge(message: "Reboot [#{id}] of machine.")
end
resize(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 57
def resize(id=nil)
  body = {package: options[:package]}
  id = use_machine(id)
  output Smartdc.resize_machine(id, body), options.merge(message: "Resize [#{id}] of machine.")
end
show(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 19
def show(id=nil)
  output Smartdc.machine(use_machine(id)), options.merge(table: :vertical)
end
start(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 44
def start(id=nil)
  id = use_machine(id)
  output Smartdc.start_machine(id), options.merge(message: "Start [#{id}] of machine.")
end
stop(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 38
def stop(id=nil)
  id = use_machine(id)
  output Smartdc.stop_machine(id), options.merge(message: "Stop [#{id}] of machine.")
end
use(id=nil) click to toggle source
# File lib/smartdc/cli/machine.rb, line 64
def use(id=nil)
  clicfg = Smartdc::CliConfigure.new
  sdccfg = clicfg.read
  if id.nil?
    puts "Use [#{sdccfg[:use_machine]}] of machine."
  else
    sdccfg[:use_machine] = id
    clicfg.write(sdccfg)
  end
end