Sha256: fc791a93ad9df53744cb487d6855898f58419bf74d868fa8b01711d0194cd8e9

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

class ServersController < MVCLI::Controller
  requires :compute

  def index
    compute.servers.all
  end

  def show
    server
  end

  def create
    options = {
      name: generate_name,
      flavor_id: 2,
      image_id: '9922a7c7-5a42-4a56-bc6a-93f857ae2346'
    }
    compute.servers.create options
  end

  def destroy
    server.tap do |s|
      s.destroy
    end
  end

  private

  def server
    index.find {|s| s.name == params[:id]} or fail Fog::Errors::NotFound
  end

  def generate_name
    'divine-reef'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rax-0.0.2 app/controllers/servers_controller.rb