Class: Api::V2::ContainersController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::V2::ContainersController
- Defined in:
- app/controllers/api/v2/containers_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'app/controllers/api/v2/containers_controller.rb', line 71 def create @container = Service::Containers.new.start_container!(set_wizard_state) set_container_taxonomies process_response @container.save rescue ActiveModel::MassAssignmentSecurity::Error => e render :json => { :error => _("Wrong attributes: %s") % e. }, :status => :unprocessable_entity end |
#destroy ⇒ Object
86 87 88 |
# File 'app/controllers/api/v2/containers_controller.rb', line 86 def destroy process_response @container.destroy end |
#index ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/api/v2/containers_controller.rb', line 19 def index if params[:compute_resource_id].present? scoped = Container.where(:compute_resource_id => params[:compute_resource_id]) else scoped = Container.scoped end @containers = scoped.search_for(params[:search], :order => params[:order]) .paginate(:page => params[:page]) end |
#logs ⇒ Object
99 100 101 102 103 104 |
# File 'app/controllers/api/v2/containers_controller.rb', line 99 def logs render :json => { :logs => Docker::Container.get(@container.uuid) .logs(:stdout => (params[:stdout] || true), :stderr => (params[:stderr] || false), :tail => (params[:tail] || 100)) } end |
#power ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/controllers/api/v2/containers_controller.rb', line 115 def power power_actions = %(start stop status) if power_actions.include? params[:power_action] response = if params[:power_action] == 'status' { :running => @container.in_fog.ready? } else { :running => @container.in_fog.send(params[:power_action]) } end render :json => response else render :json => { :error => _("Unknown method: available power operations are %s") % power_actions.join(', ') }, :status => :unprocessable_entity end end |
#show ⇒ Object
35 36 |
# File 'app/controllers/api/v2/containers_controller.rb', line 35 def show end |