Class: ForemanDatacenter::DeviceInterfaceConnectionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch, Controller::Parameters::DeviceInterfaceConnection
Defined in:
app/controllers/foreman_datacenter/device_interface_connections_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#action_permission, #controller_permission, #find_resource, #not_found, #resource_class, #resource_class_for, #resource_finder, #resource_name, #resource_scope, #scope_for

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 = ForemanDatacenter::DeviceInterfaceConnection.new(device_interface_connection_params.merge(interface_a: params[:device_interface_id]))
  @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



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

def index
  @device_interface_connections = resource_base_search_and_page.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 = ForemanDatacenter::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 = ForemanDatacenter::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