Module: IspUnity
- Defined in:
- lib/isp_unity.rb,
lib/isp_unity/version.rb,
lib/isp_unity/routing_table.rb
Defined Under Namespace
Classes: IspUnityException
Constant Summary
collapse
- PATH =
YAML.load_file( config_file )[ENV['GEM_ENV']
- ConfigFilePath =
File.join(PATH['config_file_path'])
- RoutingTablePath =
PATH['rt_table_path'].to_s
- VERSION =
"0.0.5"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.isp_config_list ⇒ Object
Returns the value of attribute isp_config_list.
10
11
12
|
# File 'lib/isp_unity/routing_table.rb', line 10
def isp_config_list
@isp_config_list
end
|
Class Method Details
.config ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/isp_unity/routing_table.rb', line 12
def config
if File.exist?(ConfigFilePath)
begin
configurations = JSON.parse(File.read(ConfigFilePath))
IspUnityLog.info(I18n.t('file.read.success'))
rescue Exception => e
IspUnityLog.debug("#{e}")
IspUnityLog.error(I18n.t('file.read.error'))
raise IspUnityException.new(I18n.t('file.read.error'))
end
@isp_config_list = []
isp_list = configurations['isp']
$ip_cluster = configurations['public_dns']
$skip_sticky_session = configurations['skip_sticky_session']
$priority_for_sticky = configurations['priority_for_sticky'].split(',') if configurations['priority_for_sticky']
if isp_list
isp_list.each do|data|
if data['enabled'] == 'true'
ip_addr = SystemCall.get_ip(data['interface'].to_s)
if ip_addr
data['ip_address'] = SystemCall.get_ip(data['interface'])
@isp_config_list.push(Isp.new(data))
else
puts I18n.t('no_ip_addr') + data['name']
IspUnityLog.error(I18n.t('no_ip_addr') + data['name'] )
end
end
end
IspUnityLog.info('Isp Object succesfully created!')
else
raise IspUnityException.new(I18n.t('file.enter_isp'))
IspUnityLog.error(I18n.t('file.read.no_isp_found'))
end
routing_table = File.read(RoutingTablePath)
IspUnityLog.info(I18n.t('routing_table.read.success'))
begin
@isp_config_list.each do|isp_list|
unless routing_table.include?(isp_list.name)
File.open(RoutingTablePath, 'a') {|f| f.write("#{rand(100)} #{isp_list.name} \n")}
end
IspUnityLog.info(I18n.t('isp.created'))
end
rescue Exception => e
IspUnityLog.debug("#{e}")
IspUnityLog.error(I18n.t('routing_table.read.error'))
raise IspUnityException.new(I18n.t('routing_table.read.error'))
end
else
@isp_config_list = []
puts "Please make ensure that configuration file has copied on /etc dir"
IspUnityLog.error('Please make ensure that configuration file has copied on /etc dir')
end
end
|