Class: InstancesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- InstancesController
- Defined in:
- app/controllers/instances_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #index ⇒ Object
- #list ⇒ Object
- #reboot ⇒ Object
- #show ⇒ Object
- #terminate ⇒ Object
- #total ⇒ Object
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/instances_controller.rb', line 7 def create data = { :image_id => params[:image_id], :instance_spec_id => params[:instance_spec_id], :host_pool_id => params[:host_pool_id], :host_name => params[:host_name], :user_data => params[:user_data], :nf_group => params[:nf_group], :ssh_key => params[:ssh_key] } instance = DcmgrResource::Instance.create(params) render :json => instance end |
#index ⇒ Object
4 5 |
# File 'app/controllers/instances_controller.rb', line 4 def index end |
#list ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/instances_controller.rb', line 21 def list data = { :start => params[:start].to_i - 1, :limit => params[:limit] } instances = DcmgrResource::Instance.list(data) respond_with(instances[0],:to => [:json]) end |
#reboot ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/controllers/instances_controller.rb', line 45 def reboot instance_ids = params[:ids] response = [] instance_ids.each do |instance_id| response << DcmgrResource::Instance.reboot(instance_id) end render :json => response end |
#show ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/instances_controller.rb', line 30 def show instance_id = params[:id] detail = DcmgrResource::Instance.show(instance_id) respond_with(detail,:to => [:json]) end |
#terminate ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/controllers/instances_controller.rb', line 36 def terminate instance_ids = params[:ids] response = [] instance_ids.each do |instance_id| response << DcmgrResource::Instance.destroy(instance_id) end render :json => response end |
#total ⇒ Object
54 55 56 57 |
# File 'app/controllers/instances_controller.rb', line 54 def total total_resource = DcmgrResource::Instance.total_resource render :json => total_resource end |