Class: ForemanDatacenter::DeviceInterfaceConnectionsController

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

Instance Method Summary collapse

Instance Method Details

#connectedObject



40
41
42
43
# File 'app/controllers/foreman_datacenter/device_interface_connections_controller.rb', line 40

def connected
  @device_interface_connection.connected!
  head :ok
end

#createObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/foreman_datacenter/device_interface_connections_controller.rb', line 18

def create
  @device_interface_connection = DeviceInterfaceConnection.new(device_interface_connection_params)
  @device_interface_connection.first_interface = get_device_interface

  if @device_interface_connection.save
    redirect_to device_url(@device_interface_connection.first_interface.device),
                notice: 'Connection was successfully created.'
  else
    process_error object: @device_interface_connection
  end
end

#destroyObject



30
31
32
33
# File 'app/controllers/foreman_datacenter/device_interface_connections_controller.rb', line 30

def destroy
  @device_interface_connection.destroy
  head :ok
end

#indexObject



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

def index
  @device_interface_connections = DeviceInterfaceConnection.includes(
    :second_interface, first_interface: [:device]
  )
end

#interfacesObject



45
46
47
48
# File 'app/controllers/foreman_datacenter/device_interface_connections_controller.rb', line 45

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

#newObject



12
13
14
15
16
# File 'app/controllers/foreman_datacenter/device_interface_connections_controller.rb', line 12

def new
  @device_interface_connection = DeviceInterfaceConnection.connected.new(
    first_interface: get_device_interface
  )
end

#plannedObject



35
36
37
38
# File 'app/controllers/foreman_datacenter/device_interface_connections_controller.rb', line 35

def planned
  @device_interface_connection.planned!
  head :ok
end