Class: ServersController

Inherits:
MVCLI::Controller
  • Object
show all
Defined in:
app/controllers/servers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/servers_controller.rb', line 14

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: "~/.ssh/id_rsa",
    public_key_path: "~/.ssh/id_rsa.pub"
  }
  command.output.puts "--> bootstrapping server #{options[:name]}"
  #Progress bar
  server = compute.servers.create options
  command.output.puts "    done."
  return server
end

#destroyObject



34
35
36
37
38
# File 'app/controllers/servers_controller.rb', line 34

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

#indexObject



5
6
7
# File 'app/controllers/servers_controller.rb', line 5

def index
  compute.servers.all
end

#showObject



9
10
11
12
# File 'app/controllers/servers_controller.rb', line 9

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