Class: InstancesController
Instance Method Summary
collapse
#dispatch, #get_locales, #is_dcmgr?, #set_application, #set_locale
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],
:security_groups => params[:security_groups],
: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]
res = []
instance_ids.each do |instance_id|
res << DcmgrResource::Instance.reboot(instance_id)
end
render :json => res
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
|
#start ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/controllers/instances_controller.rb', line 54
def start
instance_ids = params[:ids]
res = []
instance_ids.each do |instance_id|
res << DcmgrResource::Instance.start(instance_id)
end
render :json => res
end
|
#stop ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'app/controllers/instances_controller.rb', line 63
def stop
instance_ids = params[:ids]
res = []
instance_ids.each do |instance_id|
res << DcmgrResource::Instance.stop(instance_id)
end
render :json => res
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]
res = []
instance_ids.each do |instance_id|
res << DcmgrResource::Instance.destroy(instance_id)
end
render :json => res
end
|