foreman_dhcp_browser 0.0.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +5 -2
- data/Rakefile +2 -3
- data/app/controllers/dhcp_controller.rb +17 -21
- data/app/models/dhcp_entries.rb +5 -5
- data/app/models/foreman_dhcp_browser/concerns/net_record_extension.rb +2 -2
- data/app/overrides/add_link_to_dhcp_entries.rb +4 -4
- data/app/views/dhcp/index.html.erb +2 -2
- data/app/views/dhcp/show.html.erb +1 -1
- data/lib/foreman_dhcp_browser/engine.rb +13 -8
- data/lib/foreman_dhcp_browser/version.rb +2 -2
- data/lib/foreman_dhcp_browser.rb +1 -1
- data/lib/tasks/foreman_dhcp_browser.rake +21 -0
- metadata +10 -13
- data/app/helpers/dhcp_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02ae35213d36cf1c734f151070ddb46a4f25ef5659510a8c0f92b38281155fa8
|
4
|
+
data.tar.gz: aa1e85ddbf55feaa4594708c87b566e45ce2e02e0360940cd81b5d948a872fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3dacdf1b797aa0d31ebce5e8cd6750f16cd5eaaba97887fef56b11b937f6b7a211d4d8f9d194272e0017da330a09f81501b71d3f3c029b0e3e7cb2ffa57c767
|
7
|
+
data.tar.gz: 4f1c67b029c07f0da80d1a9195fca0c2f5c7efdc58e771ceff5713940aaa8b1bb7d19badbbbd65ab0710efdd8fcc32949ccc39b0bdfa454898750229e700fcee
|
data/README.md
CHANGED
@@ -6,13 +6,16 @@ smart proxy.
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
+
The foreman_dhcp_browser plugin is available both via RPM/DEB.
|
10
|
+
|
11
|
+
eg; yum install tfm-rubygem-foreman_dhcp_browser
|
12
|
+
|
9
13
|
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
10
14
|
for how to install Foreman plugins
|
11
15
|
|
12
|
-
The gem name is "foreman_dhcp_browser".
|
13
|
-
|
14
16
|
## Latest code
|
15
17
|
|
18
|
+
The gem name is "foreman_dhcp_browser".
|
16
19
|
You can get the master branch of the plugin by specifying your Gemfile in this way:
|
17
20
|
|
18
21
|
gem 'foreman_dhcp_browser', :git => "https://github.com/theforeman/foreman_dhcp_browser.git"
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
RDoc::Task.new(:rdoc) do |rdoc|
|
16
16
|
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = '
|
17
|
+
rdoc.title = 'ForemanDHCPBrowser'
|
18
18
|
rdoc.options << '--line-numbers'
|
19
19
|
rdoc.rdoc_files.include('README.rdoc')
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
@@ -31,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
|
|
31
31
|
t.verbose = false
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
task :default => :test
|
34
|
+
task default: :test
|
@@ -1,58 +1,54 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
|
1
|
+
class DHCPController < ApplicationController
|
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 =
|
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
|
-
class
|
2
|
-
delegate :dhcp_proxy, :
|
1
|
+
class DHCPEntries
|
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
|
-
module
|
1
|
+
module ForemanDHCPBrowser::Concerns::NetRecordExtension
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
@@ -16,7 +16,7 @@ module ForemanDhcpBrowser::Concerns::NetRecordExtension
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def subnet_id=(id)
|
19
|
-
subnet = ::Subnet.
|
19
|
+
subnet = ::Subnet.find_by(id: id) || return
|
20
20
|
@network = subnet.network
|
21
21
|
@proxy = subnet.dhcp_proxy
|
22
22
|
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,6 +1,6 @@
|
|
1
1
|
<% title "DHCP Reservations for #{@subnet}" %>
|
2
|
-
<% title_actions button_group(link_to_if_authorized _('New DHCP Record'), hash_for_new_subnet_dhcp_path(params[:subnet_id])) %>
|
3
|
-
<table class="
|
2
|
+
<% title_actions button_group(link_to_if_authorized _('New DHCP Record'), hash_for_new_subnet_dhcp_path(params[:subnet_id]), :class => 'btn btn-primary') %>
|
3
|
+
<table class="<%= table_css_classes 'table-condensed' %>" data-table="inline">
|
4
4
|
<thead>
|
5
5
|
<th>Name</th>
|
6
6
|
<th>IP</th>
|
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'deface'
|
2
|
-
module
|
2
|
+
module ForemanDHCPBrowser
|
3
3
|
class Engine < ::Rails::Engine
|
4
|
-
|
5
|
-
|
4
|
+
engine_name 'foreman_dhcp_browser'
|
5
|
+
|
6
|
+
initializer 'foreman_dhcp_browser.register_plugin', before: :finisher_hook do |app|
|
7
|
+
app.reloader.to_prepare do
|
8
|
+
Foreman::Plugin.register :foreman_dhcp_browser do
|
9
|
+
requires_foreman '>= 3.14.0'
|
10
|
+
end
|
6
11
|
end
|
7
12
|
end
|
8
13
|
|
9
14
|
config.to_prepare do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
::Net::Record.include ::ActiveModel::AttributeMethods
|
16
|
+
::Net::Record.include ::ActiveModel::Conversion
|
17
|
+
::Net::Record.extend ::ActiveModel::Naming
|
18
|
+
::Net::Record.include ForemanDHCPBrowser::Concerns::NetRecordExtension
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '0.
|
1
|
+
module ForemanDHCPBrowser
|
2
|
+
VERSION = '0.1.1'.freeze
|
3
3
|
end
|
data/lib/foreman_dhcp_browser.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
# Tests
|
4
|
+
namespace :test do
|
5
|
+
desc 'Test ForemanDHCPBrowser'
|
6
|
+
Rake::TestTask.new(:foreman_dhcp_browser) do |t|
|
7
|
+
test_dir = File.expand_path('../../test', __dir__)
|
8
|
+
t.libs << 'test'
|
9
|
+
t.libs << test_dir
|
10
|
+
t.pattern = "#{test_dir}/**/*_test.rb"
|
11
|
+
t.verbose = true
|
12
|
+
t.warning = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Rake::Task[:test].enhance ['test:foreman_dhcp_browser']
|
17
|
+
|
18
|
+
load 'tasks/jenkins.rake'
|
19
|
+
if Rake::Task.task_defined?(:'jenkins:unit')
|
20
|
+
Rake::Task['jenkins:unit'].enhance ['test:foreman_dhcp_browser']
|
21
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_dhcp_browser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ohad Levy
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: deface
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '0'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '0'
|
27
26
|
description: Plugin for Foreman to browse and add/edit/delete DHCP leases independent
|
28
27
|
of Foreman's host creation
|
29
28
|
email: ohadlevy@gmail.com
|
@@ -35,7 +34,6 @@ files:
|
|
35
34
|
- README.md
|
36
35
|
- Rakefile
|
37
36
|
- app/controllers/dhcp_controller.rb
|
38
|
-
- app/helpers/dhcp_helper.rb
|
39
37
|
- app/models/dhcp_entries.rb
|
40
38
|
- app/models/foreman_dhcp_browser/concerns/net_record_extension.rb
|
41
39
|
- app/overrides/add_link_to_dhcp_entries.rb
|
@@ -48,10 +46,11 @@ files:
|
|
48
46
|
- lib/foreman_dhcp_browser.rb
|
49
47
|
- lib/foreman_dhcp_browser/engine.rb
|
50
48
|
- lib/foreman_dhcp_browser/version.rb
|
49
|
+
- lib/tasks/foreman_dhcp_browser.rake
|
51
50
|
homepage: https://github.com/theforeman/foreman_dhcp_browser
|
52
|
-
licenses:
|
51
|
+
licenses:
|
52
|
+
- GPL-3.0
|
53
53
|
metadata: {}
|
54
|
-
post_install_message:
|
55
54
|
rdoc_options: []
|
56
55
|
require_paths:
|
57
56
|
- lib
|
@@ -66,9 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
65
|
- !ruby/object:Gem::Version
|
67
66
|
version: '0'
|
68
67
|
requirements: []
|
69
|
-
|
70
|
-
rubygems_version: 2.2.2
|
71
|
-
signing_key:
|
68
|
+
rubygems_version: 3.6.2
|
72
69
|
specification_version: 4
|
73
70
|
summary: DHCP browser plugin for Foreman
|
74
71
|
test_files: []
|
data/app/helpers/dhcp_helper.rb
DELETED