Class: Server
- Inherits:
-
CloudstackCli::Base
- Object
- Thor
- CloudstackCli::Base
- Server
- Defined in:
- lib/cloudstack-cli/commands/server.rb
Instance Attribute Summary
Attributes inherited from CloudstackCli::Base
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #create(name) ⇒ Object
- #list ⇒ Object
- #restart(name) ⇒ Object
- #start(name) ⇒ Object
- #stop(name) ⇒ Object
Instance Method Details
#bootstrap ⇒ Object
55 56 57 |
# File 'lib/cloudstack-cli/commands/server.rb', line 55 def bootstrap CloudstackCli::Helper.new([:config]).bootstrap_server_interactive() end |
#create(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cloudstack-cli/commands/server.rb', line 42 def create(name) CloudstackCli::Helper.new([:config]).bootstrap_server( name, [:zone], [:template], [:offering], [:networks], [:port_forwarding], [:project] ) end |
#list ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cloudstack-cli/commands/server.rb', line 6 def list if [:project] if [:project].downcase == "all" [:project_id] = -1 else project = find_project [:project_id] = project['id'] end end servers = client.list_servers() if servers.size < 1 puts "No servers found" else table = [["Name", "State", "Offering", "Zone", [:project] ? "Project" : "Account", "IP's"]] servers.each do |server| table << [ server['name'], server['state'], server['serviceofferingname'], server['zonename'], [:project] ? server['project'] : server['account'], server['nic'].map { |nic| nic['ipaddress']}.join(' ') ] end print_table table end end |
#restart(name) ⇒ Object
72 73 74 75 |
# File 'lib/cloudstack-cli/commands/server.rb', line 72 def restart(name) client.reboot_server(name) puts end |
#start(name) ⇒ Object
66 67 68 69 |
# File 'lib/cloudstack-cli/commands/server.rb', line 66 def start(name) client.start_server(name) puts end |
#stop(name) ⇒ Object
60 61 62 63 |
# File 'lib/cloudstack-cli/commands/server.rb', line 60 def stop(name) client.stop_server(name) puts end |