Class: Router
  
  
  
  Constant Summary
  
  
  CloudstackCli::Helper::ASYNC_STATES
  Instance Attribute Summary
  
  
  #config
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  exit_on_failure?, start
  
  
  
  
  
  
  
  
  
  #resolve_account, #resolve_cluster, #resolve_compute_offering, #resolve_disk_offering, #resolve_domain, #resolve_host, #resolve_ip_network_list, #resolve_iso, #resolve_iso_for_vm_deployment, #resolve_networks, #resolve_project, #resolve_snapshot, #resolve_template, #resolve_virtual_machine, #resolve_zone, #vm_options_to_params
  
  
  
  
  
  
  
  
  
  #ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #get_server_default_nic, #pf_rule_to_object, #print_job_status, #print_options, #run_background_jobs, #update_job_status, #update_jobs, #watch_jobs
  
  
  
  
  
  
  
  
  
  Methods inherited from Thor
  banner, basename2, old_subcommand, subcommand
  
    Instance Method Details
    
      
  
  
    #destroy(*names)  ⇒ Object 
  
  
  
  
    | 
117
118
119
120
121
122
123
124
125
126 | # File 'lib/cloudstack-cli/commands/router.rb', line 117
def destroy(*names)
  routers = names.map {|name| get_router(name)}
  print_routers(routers)
  exit unless options[:force] || yes?("\nDestroy router(s) above? [y/N]:", :magenta)
  jobs = routers.map do |router|
    {id: client.destroy_router({id: router['id']}, {sync: true})['jobid'], name: "Destroy router #{router['name']}"}
  end
  puts
  watch_jobs(jobs)
end | 
 
    
      
  
  
    #list  ⇒ Object 
  
  
  
  
    | 
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | # File 'lib/cloudstack-cli/commands/router.rb', line 21
def list
  resolve_project
  resolve_zone
  resolve_account
  routers = client.list_routers(options)
    if !options[:project] && !options[:account]
    client.list_projects(listall: true).each do |project|
      routers = routers + client.list_routers(
        options.merge(projectid: project['id'])
      )
    end
  end
  options[:listall] = true
  print_routers(routers, options)
  execute_router_commands(options[:command].downcase, routers) if options[:command]
end | 
 
    
      
  
  
    #list_from_file(file)  ⇒ Object 
  
  
  
  
    | 
49
50
51
52
53 | # File 'lib/cloudstack-cli/commands/router.rb', line 49
def list_from_file(file)
  routers = parse_file(file)["routers"]
  print_routers(routers, options)
  execute_router_commands(options[:command].downcase, routers) if options[:command]
end | 
 
    
      
  
  
    #reboot(*names)  ⇒ Object 
  
  
  
  
    | 
83
84
85
86
87
88
89
90
91
92 | # File 'lib/cloudstack-cli/commands/router.rb', line 83
def reboot(*names)
  routers = names.map {|name| client.list_routers(name: name).first}
  print_routers(routers)
  exit unless options[:force] || yes?("\nReboot router(s) above? [y/N]:", :magenta)
  jobs = routers.map do |router|
    {id: client.reboot_router({id: router['id']}, {sync: true})['jobid'], name: "Reboot router #{router['name']}"}
  end
  puts
  watch_jobs(jobs)
end | 
 
    
      
  
  
    #show(*names)  ⇒ Object 
  
  
  
  
    | 
130
131
132
133
134
135
136
137
138
139
140 | # File 'lib/cloudstack-cli/commands/router.rb', line 130
def show(*names)
  routers = names.map {|name| get_router(name)}
  table = []
  routers.each do |router|
    router.each do |key, value|
      table << [ set_color("#{key}:", :yellow), "#{value}" ]
    end
    table << [ "-" * 20 ] unless router == routers[-1]
  end
  print_table table
end | 
 
    
      
  
  
    #start(*names)  ⇒ Object 
  
  
  
  
    | 
70
71
72
73
74
75
76
77
78
79 | # File 'lib/cloudstack-cli/commands/router.rb', line 70
def start(*names)
  routers = names.map {|name| get_router(name)}
  print_routers(routers)
  exit unless options[:force] || yes?("\nStart router(s) above? [y/N]:", :magenta)
  jobs = routers.map do |router|
    {id: client.start_router({id: router['id']}, {sync: true})['jobid'], name: "Start router #{router['name']}"}
  end
  puts
  watch_jobs(jobs)
end | 
 
    
      
  
  
    #stop(*names)  ⇒ Object 
  
  
  
  
    | 
57
58
59
60
61
62
63
64
65
66 | # File 'lib/cloudstack-cli/commands/router.rb', line 57
def stop(*names)
  routers = names.map {|name| get_router(name)}
  print_routers(routers)
  exit unless options[:force] || yes?("\nStop router(s) above? [y/N]:", :magenta)
  jobs = routers.map do |router|
    {id: client.stop_router({id: router['id']}, {sync: true})['jobid'], name: "Stop router #{router['name']}"}
  end
  puts
  watch_jobs(jobs)
end | 
 
    
      
  
  
    #stop_start(*names)  ⇒ Object 
  
  
  
  
    | 
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 | # File 'lib/cloudstack-cli/commands/router.rb', line 96
def stop_start(*names)
  routers = names.map {|name| get_router(name)}
  print_routers(routers)
  exit unless options[:force] || yes?("\nRestart router(s) above? [y/N]:", :magenta)
  jobs = routers.map do |router|
    {id: client.stop_router({id: router['id']}, {sync: true})['jobid'], name: "Stop router #{router['name']}"}
  end
  puts
  watch_jobs(jobs)
  jobs = routers.map do |router|
    {id: client.start_router({id: router['id']}, {sync: true})['jobid'], name: "Start router #{router['name']}"}
  end
  puts
  watch_jobs(jobs)
  say "Finished.", :green
end |