Sha256: 8b94d918aa41f45308af0b8d73d50938a7874f83677d759f60470e431c4e640d

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

class ServersController < MVCLI::Controller
  requires :compute
  requires :command

  def index
    compute.servers.all
  end

  def show
    #What if you have two or more servers with the same name?
    server
  end

  def create
    template = Servers::CreateForm
    argv = MVCLI::Argv.new command.argv
    form = template.new argv.options
    form.validate!
    #Add personalization
    options = {
      name: form.name,
      flavor_id: form.flavor_id,
      image_id: form.image_id,
      private_key_path: form.ssh_private, #"~/.ssh/id_rsa"
      public_key_path: form.ssh_public #"~/.ssh/id_rsa.pub"
    }
    command.output.puts "--> bootstrapping server #{options[:name]}"
    #Progress bar
    server = compute.servers.bootstrap options
    command.output.puts "    done."
    return server
  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

  def ssh
    test = server
    ip_address = test.ipv4_address
    exec "ssh root@#{ip_address} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rumm-0.0.23 app/controllers/servers_controller.rb
rumm-0.0.22 app/controllers/servers_controller.rb
rumm-0.0.21 app/controllers/servers_controller.rb
rumm-0.0.20 app/controllers/servers_controller.rb
rumm-0.0.19 app/controllers/servers_controller.rb
rumm-0.0.18 app/controllers/servers_controller.rb
rumm-0.0.17 app/controllers/servers_controller.rb
rumm-0.0.16 app/controllers/servers_controller.rb