smart_proxy_dhcp_remote_isc 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 791ed53caa083fc063689c010c4cb947b7848f15
4
- data.tar.gz: 7b07573e49911d84b203f37249f34228e085bc29
3
+ metadata.gz: 021abeb56914c9d2e1fd5e3775067d992ed9ca09
4
+ data.tar.gz: bcfdd528255e0d59306a3132361bfcae0bdf6d17
5
5
  SHA512:
6
- metadata.gz: 5a3579fa011f5c5e6fc335e59f5f2eb918c185636d4b446092304f8814833c844c7a5c70cd521f7992edfca46d0c414587d22533b90c32985755d7c3e5edbbf8
7
- data.tar.gz: 34e2fffd46cc104689fbe71a9987833f142d408615237da64c9fb1c89221e119d180e3cf0ea3c9ea42bbf4f05d3275645951dac819e2f5c6cfc0e688641e23bf
6
+ metadata.gz: 3615316ed7c67220e18de8d94f53377e6ee3681987b75061a60e976efd050d8bc600c238033b5aaf39b9ddded25e30b8b18701b6293fac463b307a6fb4ad8a02
7
+ data.tar.gz: d0693ee71b6c372f928410e93b2c1c63600d7d8a1e9c28981ca9032c82a9214afc56e01c27d27f8325df18cfb82588aee170d200d8183a02ac3ac5201943aecd
@@ -1,2 +1,4 @@
1
+ group :dhcp_remote_isc do
2
+ gem 'rsec'
3
+ end
1
4
  gem 'smart_proxy_dhcp_remote_isc'
2
-
@@ -2,7 +2,7 @@ module Proxy::DHCP::RemoteISC
2
2
  class Plugin < ::Proxy::Provider
3
3
  plugin :dhcp_remote_isc, ::Proxy::DHCP::RemoteISC::VERSION
4
4
 
5
- requires :dhcp, '>= 1.15'
5
+ requires :dhcp, '>= 1.16'
6
6
  default_settings :config => '/etc/dhcp/dhcpd.conf', :leases => '/var/lib/dhcpd/dhcpd.leases',
7
7
  :omapi_port => '7911'
8
8
 
@@ -7,10 +7,9 @@ module Proxy::DHCP::RemoteISC
7
7
  container.get_dependency(:memory_store), container.get_dependency(:memory_store),
8
8
  container.get_dependency(:memory_store), container.get_dependency(:memory_store))
9
9
  end)
10
- container.dependency :parser, lambda {::Proxy::DHCP::RemoteISC::IscFileParser.new}
11
- container.dependency :config_file, lambda {::Proxy::DHCP::CommonISC::IscConfigurationFile.new(settings[:config], container.get_dependency(:parser))}
10
+ container.dependency :parser, lambda {::Proxy::DHCP::CommonISC::ConfigurationParser.new}
12
11
  container.dependency :subnet_service_initializer, (lambda do
13
- ::Proxy::DHCP::RemoteISC::SubnetServiceInitializer.new(container.get_dependency(:config_file), settings[:leases],
12
+ ::Proxy::DHCP::RemoteISC::SubnetServiceInitializer.new(settings[:config], settings[:leases],
14
13
  container.get_dependency(:parser), container.get_dependency(:subnet_service))
15
14
  end)
16
15
  container.dependency :initialized_subnet_service, lambda {container.get_dependency(:subnet_service_initializer).initialized_subnet_service }
@@ -25,8 +24,8 @@ module Proxy::DHCP::RemoteISC
25
24
  def load_classes
26
25
  require 'dhcp_common/subnet_service'
27
26
  require 'dhcp_common/isc/omapi_provider'
28
- require 'dhcp_common/isc/configuration_file'
29
- require 'smart_proxy_dhcp_remote_isc/file_parser'
27
+ require 'dhcp_common/isc/configuration_parser'
28
+ require 'dhcp_common/isc/subnet_service_initialization'
30
29
  require 'smart_proxy_dhcp_remote_isc/subnet_service_initializer'
31
30
  end
32
31
  end
@@ -1,41 +1,29 @@
1
1
  require 'dhcp_common/isc/subnet_service_initialization'
2
2
 
3
3
  module Proxy::DHCP::RemoteISC
4
- class SubnetServiceInitializer
5
- include ::Proxy::DHCP::CommonISC::IscSubnetServiceInitialization
4
+ class SubnetServiceInitializer < ::Proxy::DHCP::CommonISC::IscSubnetServiceInitialization
6
5
  include Proxy::Log
7
6
 
8
- attr_reader :config_file, :leases_path, :parser, :service
7
+ attr_reader :config_file_path, :leases_file_path
9
8
 
10
- def initialize(config_file, leases_file_path, isc_config_file_parser, subnet_service)
11
- @config_file = config_file
12
- @leases_path = leases_file_path
13
- @parser = isc_config_file_parser
14
- @service = subnet_service
9
+ def initialize(config_file_path, leases_file_path, parser, subnet_service)
10
+ @config_file_path = config_file_path
11
+ @leases_file_path = leases_file_path
12
+ super(subnet_service, parser)
15
13
  end
16
14
 
17
15
  def initialized_subnet_service
18
- load_subnets
19
-
20
- update_subnet_service_with_dhcp_records(hosts_and_leases_from_config(service, config_file))
21
- update_subnet_service_with_dhcp_records(hosts_and_leases_from_leases(service, leases_path))
22
-
23
- service
24
- end
25
-
26
- def load_subnets
27
- service.add_subnets(*config_file.subnets)
16
+ load_configuration_file(read_config_file, config_file_path)
17
+ load_leases_file(read_leases_file, leases_file_path)
18
+ subnet_service
28
19
  end
29
20
 
30
- def hosts_and_leases_from_config(subnet_service, config_file)
31
- parser.parse_config_and_leases_for_records(subnet_service, config_file.read)
21
+ def read_leases_file
22
+ File.read(File.expand_path(leases_file_path))
32
23
  end
33
24
 
34
- def hosts_and_leases_from_leases(subnet_service, path)
35
- fd = File.open(File.expand_path(path), "r")
36
- parser.parse_config_and_leases_for_records(subnet_service, fd.read)
37
- ensure
38
- fd.close unless fd.nil?
25
+ def read_config_file
26
+ File.read(File.expand_path(config_file_path))
39
27
  end
40
28
  end
41
29
  end
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module DHCP
3
3
  module RemoteISC
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
  end
7
7
  end
@@ -5,8 +5,9 @@ require 'smart_proxy_dhcp_remote_isc/plugin_configuration'
5
5
  require 'smart_proxy_dhcp_remote_isc/dhcp_remote_isc_plugin'
6
6
  require 'dhcp_common/subnet_service'
7
7
  require 'dhcp_common/isc/omapi_provider'
8
- require 'dhcp_common/isc/configuration_file'
9
- require 'smart_proxy_dhcp_remote_isc/file_parser'
8
+ require 'rsec'
9
+ require 'dhcp_common/isc/configuration_parser'
10
+ require 'dhcp_common/isc/subnet_service_initialization'
10
11
  require 'smart_proxy_dhcp_remote_isc/subnet_service_initializer'
11
12
 
12
13
  class ConfigurationTest < ::Test::Unit::TestCase
@@ -38,13 +39,6 @@ class ProductionDiWiringsTest < Test::Unit::TestCase
38
39
  assert_equal ::Proxy::DHCP::SubnetService, provider.service.class
39
40
  end
40
41
 
41
- def test_config_file_initialization
42
- config_file = @container.get_dependency(:config_file)
43
-
44
- assert_equal @settings[:config], config_file.path
45
- assert config_file.parser
46
- end
47
-
48
42
  def test_parser_initialization
49
43
  assert @container.get_dependency(:parser)
50
44
  end
@@ -53,10 +47,10 @@ class ProductionDiWiringsTest < Test::Unit::TestCase
53
47
  service_initializer = @container.get_dependency(:subnet_service_initializer)
54
48
 
55
49
  assert service_initializer
56
- assert_equal ::Proxy::DHCP::SubnetService, service_initializer.service.class
57
- assert_equal ::Proxy::DHCP::RemoteISC::IscFileParser, service_initializer.parser.class
58
- assert_equal ::Proxy::DHCP::CommonISC::IscConfigurationFile, service_initializer.config_file.class
59
- assert_equal @settings[:leases], service_initializer.leases_path
50
+ assert_equal ::Proxy::DHCP::SubnetService, service_initializer.subnet_service.class
51
+ assert_equal ::Proxy::DHCP::CommonISC::ConfigurationParser, service_initializer.parser.class
52
+ assert_equal @settings[:config], service_initializer.config_file_path
53
+ assert_equal @settings[:leases], service_initializer.leases_file_path
60
54
  end
61
55
 
62
56
  def test_initialized_subnet_service
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dhcp_remote_isc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitri Dolguikh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-27 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rsec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Smart-Proxy dhcp module provider for NFS-accessible ISC dhcpd installations
14
28
  email:
15
29
  - dmitri@appliedlogic.ca
@@ -23,7 +37,6 @@ files:
23
37
  - config/dhcp_remote_isc.yml.example
24
38
  - lib/smart_proxy_dhcp_remote_isc.rb
25
39
  - lib/smart_proxy_dhcp_remote_isc/dhcp_remote_isc_plugin.rb
26
- - lib/smart_proxy_dhcp_remote_isc/file_parser.rb
27
40
  - lib/smart_proxy_dhcp_remote_isc/plugin_configuration.rb
28
41
  - lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb
29
42
  - lib/smart_proxy_dhcp_remote_isc/version.rb
@@ -49,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
62
  version: '0'
50
63
  requirements: []
51
64
  rubyforge_project:
52
- rubygems_version: 2.5.1
65
+ rubygems_version: 2.6.10
53
66
  signing_key:
54
67
  specification_version: 4
55
68
  summary: Smart-Proxy dhcp module provider for NFS-accessible ISC dhcpd installations
@@ -1,14 +0,0 @@
1
- require 'dhcp_common/isc/file_parser'
2
-
3
- module ::Proxy::DHCP::RemoteISC
4
- class IscFileParser < ::Proxy::DHCP::CommonISC::IscFileParser
5
- def initialize
6
- super(nil)
7
- end
8
-
9
- def parse_config_and_leases_for_records(subnet_service, conf)
10
- @service = subnet_service
11
- super(conf)
12
- end
13
- end
14
- end