Class: Proxy::DHCP::RemoteISC::SubnetServiceInitializer
- Inherits:
-
Object
- Object
- Proxy::DHCP::RemoteISC::SubnetServiceInitializer
- Includes:
- CommonISC::IscSubnetServiceInitialization, Log
- Defined in:
- lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#leases_path ⇒ Object
readonly
Returns the value of attribute leases_path.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #hosts_and_leases_from_config(subnet_service, config_file) ⇒ Object
- #hosts_and_leases_from_leases(subnet_service, path) ⇒ Object
-
#initialize(config_file, leases_file_path, isc_config_file_parser, subnet_service) ⇒ SubnetServiceInitializer
constructor
A new instance of SubnetServiceInitializer.
- #initialized_subnet_service ⇒ Object
- #load_subnets ⇒ Object
Constructor Details
#initialize(config_file, leases_file_path, isc_config_file_parser, subnet_service) ⇒ SubnetServiceInitializer
Returns a new instance of SubnetServiceInitializer.
10 11 12 13 14 15 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 10 def initialize(config_file, leases_file_path, isc_config_file_parser, subnet_service) @config_file = config_file @leases_path = leases_file_path @parser = isc_config_file_parser @service = subnet_service end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
8 9 10 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 8 def config_file @config_file end |
#leases_path ⇒ Object (readonly)
Returns the value of attribute leases_path.
8 9 10 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 8 def leases_path @leases_path end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
8 9 10 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 8 def parser @parser end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
8 9 10 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 8 def service @service end |
Instance Method Details
#hosts_and_leases_from_config(subnet_service, config_file) ⇒ Object
30 31 32 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 30 def hosts_and_leases_from_config(subnet_service, config_file) parser.parse_config_and_leases_for_records(subnet_service, config_file.read) end |
#hosts_and_leases_from_leases(subnet_service, path) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 34 def hosts_and_leases_from_leases(subnet_service, path) fd = File.open(File.(path), "r") parser.parse_config_and_leases_for_records(subnet_service, fd.read) ensure fd.close unless fd.nil? end |
#initialized_subnet_service ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 17 def initialized_subnet_service load_subnets update_subnet_service_with_dhcp_records(hosts_and_leases_from_config(service, config_file)) update_subnet_service_with_dhcp_records(hosts_and_leases_from_leases(service, leases_path)) service end |
#load_subnets ⇒ Object
26 27 28 |
# File 'lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb', line 26 def load_subnets service.add_subnets(*config_file.subnets) end |