diff --git a/README.md b/README.md
index ad0e22b..42a86d7 100644
--- a/README.md
+++ b/README.md
@@ -6,13 +6,16 @@ smart proxy.
## Installation
+The foreman_dhcp_browser plugin is available both via RPM/DEB.
+
+eg; yum install tfm-rubygem-foreman_dhcp_browser
+
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
for how to install Foreman plugins
-The gem name is "foreman_dhcp_browser".
-
## Latest code
+The gem name is "foreman_dhcp_browser".
You can get the master branch of the plugin by specifying your Gemfile in this way:
gem 'foreman_dhcp_browser', :git => "https://github.com/theforeman/foreman_dhcp_browser.git"
diff --git a/Rakefile b/Rakefile
index 8f263bc..5d34666 100644
--- a/Rakefile
+++ b/Rakefile
@@ -31,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
t.verbose = false
end
-
-task :default => :test
+task default: :test
diff --git a/app/controllers/dhcp_controller.rb b/app/controllers/dhcp_controller.rb
index f82c7dd..b21743d 100644
--- a/app/controllers/dhcp_controller.rb
+++ b/app/controllers/dhcp_controller.rb
@@ -1,58 +1,54 @@
class DhcpController < ApplicationController
- before_filter :find_proxy
- before_filter :find_record, :only => [:show, :edit, :update, :destroy]
+ before_action :find_proxy
+ before_action :find_record, only: %i[show edit update destroy]
- def index
- end
+ def index; end
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'
+ # 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
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 })
+ process_success(success_redirect: subnet_dhcp_index_path(@subnet), object_name: @record.to_s)
else
- process_error({ :redirect => subnet_dhcp_index_path(@subnet) })
+ 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
+ process_error error_msg: error_msg
end
- def show
- end
+ def show; end
- def edit
- end
+ def edit; end
def update
- #TODO
+ # TODO
end
def destroy
if @record.destroy
- process_success({ :success_redirect => subnet_dhcp_index_path(@subnet), :object_name => @record.to_s })
+ process_success(success_redirect: subnet_dhcp_index_path(@subnet), object_name: @record.to_s)
else
- process_error({ :redirect => subnet_dhcp_index_path(@subnet) })
+ process_error(redirect: subnet_dhcp_index_path(@subnet))
end
end
private
def find_proxy
- return not_found unless params[:subnet_id].present?
+ return not_found if params[:subnet_id].blank?
@subnet = ::Subnet.find(params[:subnet_id])
return not_found unless @subnet.try(:dhcp?)
- @entries = DhcpEntries.new(:subnet => @subnet)
+ @entries = DhcpEntries.new(subnet: @subnet)
end
def find_record
@record = @entries.find(params[:id])
end
-
end
diff --git a/app/models/dhcp_entries.rb b/app/models/dhcp_entries.rb
index 45b35a1..c2952df 100644
--- a/app/models/dhcp_entries.rb
+++ b/app/models/dhcp_entries.rb
@@ -1,5 +1,5 @@
class DhcpEntries
- delegate :dhcp_proxy, :to => :subnet
+ delegate :dhcp_proxy, to: :subnet
alias_attribute :proxy, :dhcp_proxy
def initialize(opts = {})
@@ -12,7 +12,7 @@ def all
def reservations
@reservations ||= all['reservations'].map do |reservation|
- Net::DHCP::Record.new reservation.merge(:proxy => proxy, :network => subnet.network)
+ Net::DHCP::Record.new reservation.merge(proxy: proxy, network: subnet.network)
end
rescue ProxyAPI::ProxyException => e
[]
@@ -27,6 +27,6 @@ def find(mac)
end
private
- attr_reader :subnet
-end
\ No newline at end of file
+ attr_reader :subnet
+end
diff --git a/app/models/foreman_dhcp_browser/concerns/net_record_extension.rb b/app/models/foreman_dhcp_browser/concerns/net_record_extension.rb
index d42b09b..74f1384 100644
--- a/app/models/foreman_dhcp_browser/concerns/net_record_extension.rb
+++ b/app/models/foreman_dhcp_browser/concerns/net_record_extension.rb
@@ -16,7 +16,7 @@ def persisted?
end
def subnet_id=(id)
- subnet = ::Subnet.find_by_id(id) || return
+ subnet = ::Subnet.find_by(id: id) || return
@network = subnet.network
@proxy = subnet.dhcp_proxy
end
diff --git a/app/overrides/add_link_to_dhcp_entries.rb b/app/overrides/add_link_to_dhcp_entries.rb
index d7ef4b2..c635427 100644
--- a/app/overrides/add_link_to_dhcp_entries.rb
+++ b/app/overrides/add_link_to_dhcp_entries.rb
@@ -1,4 +1,4 @@
-Deface::Override.new(:virtual_path => 'subnets/index',
- :name => 'add_subnets_dhcp',
- :insert_top => 'td:last',
- :text => "<%= link_to 'DHCP',subnet_dhcp_index_path(subnet), :class => 'btn btn-default btn-sm', :disabled => !subnet.dhcp? %>")
+Deface::Override.new(virtual_path: 'subnets/index',
+ name: 'add_subnets_dhcp',
+ insert_top: 'td:last',
+ text: "<%= link_to 'DHCP',subnet_dhcp_index_path(subnet), :class => 'btn btn-default btn-sm', :disabled => !subnet.dhcp? %>")
diff --git a/app/views/dhcp/index.html.erb b/app/views/dhcp/index.html.erb
index 52336f0..8580b1b 100644
--- a/app/views/dhcp/index.html.erb
+++ b/app/views/dhcp/index.html.erb
@@ -1,6 +1,6 @@
<% title "DHCP Reservations for #{@subnet}" %>
-<% title_actions button_group(link_to_if_authorized _('New DHCP Record'), hash_for_new_subnet_dhcp_path(params[:subnet_id])) %>
-
+<% title_actions button_group(link_to_if_authorized _('New DHCP Record'), hash_for_new_subnet_dhcp_path(params[:subnet_id]), :class => 'btn btn-primary') %>
+
Name |
IP |
diff --git a/app/views/dhcp/show.html.erb b/app/views/dhcp/show.html.erb
index a6b541c..fd6b154 100644
--- a/app/views/dhcp/show.html.erb
+++ b/app/views/dhcp/show.html.erb
@@ -1,4 +1,4 @@
-
+
<% @record.attrs.keys.each do |header| %>
<%= header %>
<% end %>
diff --git a/foreman_dhcp_browser.gemspec b/foreman_dhcp_browser.gemspec
index dab51f7..58ffe30 100644
--- a/foreman_dhcp_browser.gemspec
+++ b/foreman_dhcp_browser.gemspec
@@ -1,4 +1,4 @@
-$:.push File.expand_path('../lib', __FILE__)
+$LOAD_PATH.push File.expand_path('../lib', __FILE__)
# Maintain your gem's version:
require 'foreman_dhcp_browser/version'
@@ -7,15 +7,15 @@ require 'foreman_dhcp_browser/version'
Gem::Specification.new do |s|
s.name = 'foreman_dhcp_browser'
s.version = ForemanDhcpBrowser::VERSION
+ s.license = 'GPL-3.0'
s.authors = ['Ohad Levy']
- s.email = %q{ohadlevy@gmail.com}
- s.homepage = %q{https://github.com/theforeman/foreman_dhcp_browser}
- s.summary = %q{DHCP browser plugin for Foreman}
- s.description = %q{Plugin for Foreman to browse and add/edit/delete DHCP leases independent of Foreman's host creation}
+ s.email = 'ohadlevy@gmail.com'
+ s.homepage = 'https://github.com/theforeman/foreman_dhcp_browser'
+ s.summary = 'DHCP browser plugin for Foreman'
+ s.description = "Plugin for Foreman to browse and add/edit/delete DHCP leases independent of Foreman's host creation"
s.files = Dir['{app,config,db,lib}/**/*'] + ['LICENSE', 'Rakefile', 'README.md']
s.test_files = Dir['test/**/*']
- s.add_dependency 'deface', '< 2.0'
-
+ s.add_dependency 'deface'
end
diff --git a/lib/foreman_dhcp_browser/engine.rb b/lib/foreman_dhcp_browser/engine.rb
index 9411d1e..f5aeb43 100644
--- a/lib/foreman_dhcp_browser/engine.rb
+++ b/lib/foreman_dhcp_browser/engine.rb
@@ -1,16 +1,16 @@
require 'deface'
module ForemanDhcpBrowser
class Engine < ::Rails::Engine
- initializer 'foreman_dhcp_browser.register_plugin', :after=> :finisher_hook do |app|
+ initializer 'foreman_dhcp_browser.register_plugin', before: :finisher_hook do |_app|
Foreman::Plugin.register :foreman_dhcp_browser do
end
end
config.to_prepare do
- ::Net::Record.send :include, ::ActiveModel::AttributeMethods
- ::Net::Record.send :include, ::ActiveModel::Conversion
- ::Net::Record.send :extend, ::ActiveModel::Naming
- ::Net::Record.send :include, ForemanDhcpBrowser::Concerns::NetRecordExtension
- end
+ ::Net::Record.send :include, ::ActiveModel::AttributeMethods
+ ::Net::Record.send :include, ::ActiveModel::Conversion
+ ::Net::Record.send :extend, ::ActiveModel::Naming
+ ::Net::Record.send :include, ForemanDhcpBrowser::Concerns::NetRecordExtension
+ end
end
end
diff --git a/lib/foreman_dhcp_browser/version.rb b/lib/foreman_dhcp_browser/version.rb
index 7fc6743..1ef3d1f 100644
--- a/lib/foreman_dhcp_browser/version.rb
+++ b/lib/foreman_dhcp_browser/version.rb
@@ -1,3 +1,3 @@
module ForemanDhcpBrowser
- VERSION = '0.0.7'
+ VERSION = '0.0.8'.freeze
end
|