Class: ForemanDatacenter::PowerOutletsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_datacenter/power_outlets_controller.rb

Instance Method Summary collapse

Instance Method Details

#connectObject



46
47
48
49
50
51
52
53
54
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 46

def connect
  power_port = PowerPort.find(params[:power_port][:id])
  power_port.connect(
    @power_outlet,
    params[:power_port][:connection_status]
  )
  redirect_to device_url(id: @power_outlet.device_id),
              notice: 'Power outlet was successfully connected.'
end

#createObject



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 14

def create
  @power_outlet = PowerOutlet.new(power_outlet_params)

  if @power_outlet.save
    redirect_to device_url(id: @power_outlet.device_id),
                notice: 'Power outlet was successfully created.'
  else
    process_error object: @power_outlet
  end
end

#destroyObject



34
35
36
37
38
39
40
41
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 34

def destroy
  if @power_outlet.destroy
    redirect_to device_url(id: @power_outlet.device_id),
                notice: 'Power outlet was successfully destroyed.'
  else
    process_error object: @power_outlet
  end
end

#disconnectObject



56
57
58
59
60
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 56

def disconnect
  @power_outlet.power_port.disconnect
  redirect_to device_url(id: @power_outlet.device_id),
              notice: 'Power outlet was successfully disconnected.'
end

#editObject



11
12
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 11

def edit
end

#for_deviceObject



62
63
64
65
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 62

def for_device
  @device = Device.find(params[:device_id])
  render partial: 'for_device'
end

#newObject



6
7
8
9
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 6

def new
  device = Device.find(params[:device_id])
  @power_outlet = PowerOutlet.new(device: device)
end

#new_connectionObject



43
44
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 43

def new_connection
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/foreman_datacenter/power_outlets_controller.rb', line 25

def update
  if @power_outlet.update(power_outlet_params)
    redirect_to device_url(id: @power_outlet.device_id),
                notice: 'Power outlet was successfully updated.'
  else
    process_error object: @power_outlet
  end
end