Class: Server

Inherits:
Thor
  • Object
show all
Defined in:
lib/cloudstack-cli/commands/server.rb

Instance Method Summary collapse

Instance Method Details

#create(name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cloudstack-cli/commands/server.rb', line 38

def create(name)
  CloudstackCli::Cli.new.bootstrap_server(
      name,
      options[:zone],
      options[:template],
      options[:offering],
      options[:networks],
      options[:port_forwarding],
      options[:project]
    )
end

#listObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cloudstack-cli/commands/server.rb', line 8

def list
  cs_cli = CloudstackCli::Helper.new(options[:config])
  if options[:project]
    project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first
    exit_now! "Project '#{options[:project]}' not found" unless project
    options[:project_id] = project['id']
    options[:account] = nil
  end
  servers = cs_cli.virtual_machines(options)
  if servers.size < 1
    puts "No servers found"
  else
    if options[:text]
      servers.each do |server|
        puts "#{server['name']} - #{server['state']} - #{server['domain']}"
      end
    else
      cs_cli.virtual_machines_table(servers)
    end
  end
end

#restart(name) ⇒ Object



61
62
63
# File 'lib/cloudstack-cli/commands/server.rb', line 61

def restart(name)
  CloudstackCli::Cli.new.reboot_server(name)
end

#start(name) ⇒ Object



56
57
58
# File 'lib/cloudstack-cli/commands/server.rb', line 56

def start(name)
  CloudstackCli::Cli.new.start_server(name)
end

#stop(name) ⇒ Object



51
52
53
# File 'lib/cloudstack-cli/commands/server.rb', line 51

def stop(name)
  CloudstackCli::Cli.new.stop_server(name)
end