Class: DhcpController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @record = Net::DHCP::Record.new(params[:net_dhcp_record])
  if @record.create
    process_success(success_redirect: subnet_dhcp_index_path(@subnet), object_name: @record.to_s)
  else
    process_error(redirect: subnet_dhcp_index_path(@subnet))
  end
rescue ProxyAPI::ProxyException => e
  error_msg = (e.try(:wrapped_exception).try(:response) || e).to_s
  process_error error_msg: error_msg
end

#destroyObject



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

def destroy
  if @record.destroy
    process_success(success_redirect: subnet_dhcp_index_path(@subnet), object_name: @record.to_s)
  else
    process_error(redirect: subnet_dhcp_index_path(@subnet))
  end
end

#editObject



28
# File 'app/controllers/dhcp_controller.rb', line 28

def edit; end

#indexObject



5
# File 'app/controllers/dhcp_controller.rb', line 5

def index; end

#newObject



7
8
9
10
11
12
# File 'app/controllers/dhcp_controller.rb', line 7

def new
  # HACK: hack hack, need to fix foreman core to validate on create/save instead of init
  @record = Net::DHCP::Record.new proxy: @subnet.dhcp_proxy, hostname: 'dummy', mac: 'aa:bb:cc:dd:ee:ff',
                                  network: @subnet.network, ip: '1.2.3.4'
  @record.hostname = @record.mac = @record.ip = nil
end

#showObject



26
# File 'app/controllers/dhcp_controller.rb', line 26

def show; end

#updateObject



30
31
32
# File 'app/controllers/dhcp_controller.rb', line 30

def update
  # TODO
end