foreman_dhcp_browser 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -2
- data/app/controllers/dhcp_controller.rb +16 -20
- data/app/models/dhcp_entries.rb +4 -4
- data/app/models/foreman_dhcp_browser/concerns/net_record_extension.rb +1 -1
- data/app/overrides/add_link_to_dhcp_entries.rb +4 -4
- data/lib/foreman_dhcp_browser/engine.rb +6 -6
- data/lib/foreman_dhcp_browser/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 472bfadb4dcc78e34f7f9a09e2d90042aceb7ca1
|
4
|
+
data.tar.gz: 03cf35804684e3ef9493cd59164f0aae36c07683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77aedddc41e01118954f6ae5a30998d8019115d84c1b3800f15e96dab31f9bbc6f0abfc0dbdfb82ed8ece7798b75d09bb01fdede747ec6c8c2c0d32508b163c0
|
7
|
+
data.tar.gz: bafc5387624b2388f734e7a79c00dc6a3365fbee3c15d6fefadedf924e7fe74124ff65c8b3bc1254ecdd9413f3fc9b2c79c67ee6476cc2590aafeada644cb463
|
data/Rakefile
CHANGED
@@ -1,58 +1,54 @@
|
|
1
1
|
class DhcpController < ApplicationController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :find_proxy
|
3
|
+
before_action :find_record, only: %i[show edit update destroy]
|
4
4
|
|
5
|
-
def index
|
6
|
-
end
|
5
|
+
def index; end
|
7
6
|
|
8
7
|
def new
|
9
|
-
#
|
10
|
-
@record = Net::DHCP::Record.new :
|
11
|
-
:
|
8
|
+
# HACK: hack hack, need to fix foreman core to validate on create/save instead of init
|
9
|
+
@record = Net::DHCP::Record.new proxy: @subnet.dhcp_proxy, hostname: 'dummy', mac: 'aa:bb:cc:dd:ee:ff',
|
10
|
+
network: @subnet.network, ip: '1.2.3.4'
|
12
11
|
@record.hostname = @record.mac = @record.ip = nil
|
13
12
|
end
|
14
13
|
|
15
14
|
def create
|
16
15
|
@record = Net::DHCP::Record.new(params[:net_dhcp_record])
|
17
16
|
if @record.create
|
18
|
-
process_success(
|
17
|
+
process_success(success_redirect: subnet_dhcp_index_path(@subnet), object_name: @record.to_s)
|
19
18
|
else
|
20
|
-
process_error(
|
19
|
+
process_error(redirect: subnet_dhcp_index_path(@subnet))
|
21
20
|
end
|
22
21
|
rescue ProxyAPI::ProxyException => e
|
23
22
|
error_msg = (e.try(:wrapped_exception).try(:response) || e).to_s
|
24
|
-
process_error :
|
23
|
+
process_error error_msg: error_msg
|
25
24
|
end
|
26
25
|
|
27
|
-
def show
|
28
|
-
end
|
26
|
+
def show; end
|
29
27
|
|
30
|
-
def edit
|
31
|
-
end
|
28
|
+
def edit; end
|
32
29
|
|
33
30
|
def update
|
34
|
-
#TODO
|
31
|
+
# TODO
|
35
32
|
end
|
36
33
|
|
37
34
|
def destroy
|
38
35
|
if @record.destroy
|
39
|
-
process_success(
|
36
|
+
process_success(success_redirect: subnet_dhcp_index_path(@subnet), object_name: @record.to_s)
|
40
37
|
else
|
41
|
-
process_error(
|
38
|
+
process_error(redirect: subnet_dhcp_index_path(@subnet))
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
45
42
|
private
|
46
43
|
|
47
44
|
def find_proxy
|
48
|
-
return not_found
|
45
|
+
return not_found if params[:subnet_id].blank?
|
49
46
|
@subnet = ::Subnet.find(params[:subnet_id])
|
50
47
|
return not_found unless @subnet.try(:dhcp?)
|
51
|
-
@entries = DhcpEntries.new(:
|
48
|
+
@entries = DhcpEntries.new(subnet: @subnet)
|
52
49
|
end
|
53
50
|
|
54
51
|
def find_record
|
55
52
|
@record = @entries.find(params[:id])
|
56
53
|
end
|
57
|
-
|
58
54
|
end
|
data/app/models/dhcp_entries.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class DhcpEntries
|
2
|
-
delegate :dhcp_proxy, :
|
2
|
+
delegate :dhcp_proxy, to: :subnet
|
3
3
|
alias_attribute :proxy, :dhcp_proxy
|
4
4
|
|
5
5
|
def initialize(opts = {})
|
@@ -12,7 +12,7 @@ class DhcpEntries
|
|
12
12
|
|
13
13
|
def reservations
|
14
14
|
@reservations ||= all['reservations'].map do |reservation|
|
15
|
-
Net::DHCP::Record.new reservation.merge(:
|
15
|
+
Net::DHCP::Record.new reservation.merge(proxy: proxy, network: subnet.network)
|
16
16
|
end
|
17
17
|
rescue ProxyAPI::ProxyException => e
|
18
18
|
[]
|
@@ -27,6 +27,6 @@ class DhcpEntries
|
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
|
-
attr_reader :subnet
|
31
30
|
|
32
|
-
|
31
|
+
attr_reader :subnet
|
32
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Deface::Override.new(:
|
2
|
-
:
|
3
|
-
:
|
4
|
-
:
|
1
|
+
Deface::Override.new(virtual_path: 'subnets/index',
|
2
|
+
name: 'add_subnets_dhcp',
|
3
|
+
insert_top: 'td:last',
|
4
|
+
text: "<%= link_to 'DHCP',subnet_dhcp_index_path(subnet), :class => 'btn btn-default btn-sm', :disabled => !subnet.dhcp? %>")
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'deface'
|
2
2
|
module ForemanDhcpBrowser
|
3
3
|
class Engine < ::Rails::Engine
|
4
|
-
initializer 'foreman_dhcp_browser.register_plugin', :
|
4
|
+
initializer 'foreman_dhcp_browser.register_plugin', before: :finisher_hook do |_app|
|
5
5
|
Foreman::Plugin.register :foreman_dhcp_browser do
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
config.to_prepare do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
::Net::Record.send :include, ::ActiveModel::AttributeMethods
|
11
|
+
::Net::Record.send :include, ::ActiveModel::Conversion
|
12
|
+
::Net::Record.send :extend, ::ActiveModel::Naming
|
13
|
+
::Net::Record.send :include, ForemanDhcpBrowser::Concerns::NetRecordExtension
|
14
|
+
end
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_dhcp_browser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ohad Levy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
description: Plugin for Foreman to browse and add/edit/delete DHCP leases independent
|
28
28
|
of Foreman's host creation
|
29
29
|
email: ohadlevy@gmail.com
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.6.8
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: DHCP browser plugin for Foreman
|