Sha256: 10653b88b0b231944bb2077c489796e15574fa1229d6775be28b06165f8b3b50

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

#!/usr/bin/env ruby
# vim: filetype=ruby

require 'conoha'
require 'pp'

subcommand = ARGV.shift

Conoha.init!

def server_id(server_id_or_index)
  if server_id_or_index.length == '01234567-89ab-cdef-0123-456789abcdef'.length
    server_id_or_index
  else
    Conoha.vps_list[server_id_or_index.to_i]
  end
end

case subcommand
when 'authenticate'
  Conoha.authenticate!
  puts 'Succeeded!'
when 'vpslist'
  pp Conoha.vps_list
when 'ipaddress'
  exit 1 if ARGV.size != 1
  pp Conoha.ip_address_of server_id(ARGV.first)
when 'create'
  pp Conoha.create *ARGV
when 'delete'
  exit 1 if ARGV.size != 1
  puts Conoha.delete server_id(ARGV.first)
when 'boot'
  exit 1 if ARGV.size != 1
  puts Conoha.boot server_id(ARGV.first)
when 'shutdown'
  exit 1 if ARGV.size != 1
  puts Conoha.shutdown server_id(ARGV.first)
when 'imagelist'
  pp Conoha.images
when 'imagecreate'
  exit 1 if ARGV.size != 2
  name = ARGV[1]
  puts Conoha.create_image server_id(ARGV[0]), name
when 'imagedelete'
  exit 1 if ARGV.size != 1
  image_ref = ARGV.first
  puts Conoha.delete_image image_ref
when 'createfromimage'
  exit 1 if ARGV.size != 2
  image_ref = ARGV[0]
  ram = ARGV[1]
  puts Conoha.create_from_image image_ref, ram
else
  STDERR.puts 'Error'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conoha-0.0.2 exe/conoha
conoha-0.0.1 bin/conoha