ispunity 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README +33 -13
- data/bin/ispunity +44 -0
- data/config/settings.yml +7 -1
- data/isp_unity.gemspec +2 -1
- data/lib/isp_unity.rb +14 -7
- data/lib/isp_unity_log.rb +1 -1
- data/lib/load_balance/load_balance.rb +10 -1
- data/license +2 -0
- metadata +21 -3
data/Gemfile
CHANGED
data/README
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
1.Install rvm
|
2
|
-
|
3
|
-
|
4
|
-
source /etc/profile.d/rvm.sh
|
2
|
+
- curl -L get.rvm.io | bash -s stable
|
3
|
+
- source /etc/profile.d/rvm.sh
|
5
4
|
|
6
5
|
Find the requirements;
|
7
6
|
|
@@ -10,22 +9,43 @@ Find the requirements;
|
|
10
9
|
install the additional dependencies as mentioned.
|
11
10
|
|
12
11
|
2. Install ruby
|
13
|
-
|
12
|
+
- rvm install 1.9.3
|
13
|
+
|
14
|
+
3. Install
|
15
|
+
3.1 Install from gem
|
16
|
+
======================
|
17
|
+
1. gem install ispunity
|
18
|
+
|
19
|
+
|
20
|
+
3.2 Install from source
|
21
|
+
=======================
|
22
|
+
1. cd /opt
|
14
23
|
|
15
|
-
|
24
|
+
2. Install IspUnity ( make sure you have git installed)
|
25
|
+
- git clone git://github.com/aruntomar/isp_unity.git
|
16
26
|
|
17
|
-
|
27
|
+
3. cd /opt/isp_unity
|
18
28
|
|
19
|
-
|
29
|
+
4. bundle install
|
20
30
|
|
21
|
-
4.
|
31
|
+
4. Using configuration file
|
32
|
+
- We have provided with sample configuration file under config folder with the name configuration.json.example that must be copied under /etc folder.
|
33
|
+
- cp -v config/configuration.json.example /etc/ispunity.json
|
22
34
|
|
23
|
-
5.
|
35
|
+
5. modify the json file to suit your network.
|
24
36
|
|
25
|
-
6.
|
37
|
+
6. How to execute
|
38
|
+
- As user root execute the following command
|
39
|
+
- ispunity
|
26
40
|
|
27
|
-
7.
|
41
|
+
7. Usage
|
42
|
+
ispunity clear_rules # Clear the rules setup by the routing policy
|
43
|
+
ispunity configfile # Uses the config file provided/passed to the application
|
44
|
+
ispunity help [TASK] # Describe available tasks or one specific task
|
45
|
+
ispunity license # Displays the license
|
46
|
+
ispunity monitor # Start monitoring the isp connections.
|
47
|
+
ispunity setup # Setup the application
|
48
|
+
ispunity version # Displays the version of Ispunity
|
28
49
|
|
29
|
-
|
30
|
-
ruby setup.rb
|
50
|
+
|
31
51
|
|
data/bin/ispunity
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__),'..','lib')
|
3
|
+
require 'thor'
|
4
|
+
require 'isp_unity'
|
5
|
+
|
6
|
+
class Ispunity < Thor
|
7
|
+
desc "version","Displays the version of Ispunity"
|
8
|
+
def version
|
9
|
+
puts '0.0.2'
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "setup","Setup the application"
|
13
|
+
def setup
|
14
|
+
puts "Starting the setup application"
|
15
|
+
IspUnity.setup
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "monitor","Start monitoring the isp connections."
|
19
|
+
def monitor
|
20
|
+
puts "Starting to monitor the application"
|
21
|
+
IspUnity.monitor
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "configfile","Uses the config file provided/passed to the application"
|
25
|
+
method_option :configfile, :aliases => "-c", :desc => "Config file"
|
26
|
+
def configfile(file)
|
27
|
+
puts "Using the config file #{file}"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "clear_rules","Clear the rules setup by the routing policy"
|
31
|
+
def clear_rules
|
32
|
+
puts 'Clearing the rules.'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "license","Displays the license"
|
36
|
+
def license
|
37
|
+
File.open("../license",'r') do |f|
|
38
|
+
puts f.readlines
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
Ispunity.start
|
data/config/settings.yml
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
development:
|
2
2
|
ubuntu:
|
3
3
|
rt_table_path: '/etc/iproute2/rt_tables'
|
4
|
-
config_file_path: '
|
4
|
+
config_file_path: '/etc/ispunity.json'
|
5
5
|
|
6
6
|
test:
|
7
7
|
ubuntu:
|
8
8
|
rt_table_path: './spec/rt_tables'
|
9
9
|
config_file_path: './spec/config/configuration.json'
|
10
|
+
|
11
|
+
production:
|
12
|
+
ubuntu:
|
13
|
+
rt_table_path: '/etc/iproute2/rt_tables'
|
14
|
+
config_file_path: '/etc/ispunity.json'
|
15
|
+
|
data/isp_unity.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "isp_unity/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "ispunity"
|
7
|
-
s.version = "0.0.
|
7
|
+
s.version = "0.0.3"
|
8
8
|
s.authors = ["Pratik Shah", "Siva Gollapalli", "Arun Tomar"]
|
9
9
|
s.email = ["pratik14shah@gmail.com", "sivagollapalli@yahoo.com", "arun@solutionenterprises.co.in"]
|
10
10
|
s.homepage = "http://www.ispunity.com"
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.add_dependency("log4r", "~> 1.1.10")
|
14
14
|
s.add_dependency("i18n")
|
15
15
|
s.add_dependency("json")
|
16
|
+
s.add_dependency("thor")
|
16
17
|
|
17
18
|
|
18
19
|
s.rubyforge_project = "ispunity"
|
data/lib/isp_unity.rb
CHANGED
@@ -17,7 +17,7 @@ module IspUnity
|
|
17
17
|
config_file = File.join([File.expand_path(File.dirname(__FILE__)), '..', 'config', 'settings.yml'])
|
18
18
|
ENV['GEM_ENV'] ||= 'development'
|
19
19
|
PATH = YAML.load_file( config_file )[ENV['GEM_ENV']]['ubuntu']
|
20
|
-
ConfigFilePath = File.join(
|
20
|
+
ConfigFilePath = File.join(PATH['config_file_path'])
|
21
21
|
RoutingTablePath = PATH['rt_table_path'].to_s
|
22
22
|
|
23
23
|
class IspUnityException < Exception
|
@@ -31,18 +31,25 @@ module IspUnity
|
|
31
31
|
|
32
32
|
def setup
|
33
33
|
IspUnity.config
|
34
|
+
isp_lists = IspUnity.isp_config_list
|
34
35
|
IspUnityLog.info(I18n.t('file.write'))
|
35
|
-
Route.build_commands(
|
36
|
+
Route.build_commands(isp_lists)
|
37
|
+
route_command = Route.commands
|
36
38
|
IspUnityLog.info(I18n.t('route.build_commands'))
|
37
|
-
|
39
|
+
IspUnityLog.debug("Route Command: #{route_command}")
|
40
|
+
if SystemCall.execute(route_command)
|
38
41
|
IspUnityLog.info(I18n.t('system_call.execute.route.success'))
|
39
|
-
Rule.build_commands(
|
42
|
+
Rule.build_commands(isp_lists)
|
43
|
+
rule_command = Rule.commands
|
40
44
|
IspUnityLog.info(I18n.t('rule.build_commands'))
|
41
|
-
|
45
|
+
IspUnityLog.debug("Rule Command: #{rule_command}")
|
46
|
+
SystemCall.execute(rule_command)
|
42
47
|
IspUnityLog.info(I18n.t('system_call.execute.rule.success'))
|
43
|
-
LoadBalance.build_commands(
|
48
|
+
LoadBalance.build_commands(isp_lists)
|
49
|
+
load_balance_command = LoadBalance.commands
|
44
50
|
IspUnityLog.info(I18n.t('load_balance.build_commands'))
|
45
|
-
|
51
|
+
IspUnityLog.debug("Load Balance Command: #{load_balance_command}")
|
52
|
+
SystemCall.execute(load_balance_command)
|
46
53
|
IspUnityLog.info(I18n.t('system_call.execute.load_balance.success'))
|
47
54
|
end
|
48
55
|
end
|
data/lib/isp_unity_log.rb
CHANGED
@@ -9,5 +9,5 @@ filename = "ispunity.log"
|
|
9
9
|
IspUnityLog = Logger.new("log")
|
10
10
|
IspUnityLog.level = DEBUG
|
11
11
|
pf = PatternFormatter.new(:pattern => "%d %l %m")
|
12
|
-
IspUnityLog.outputters = FileOutputter.new("IspUnity", :filename => File.join(
|
12
|
+
IspUnityLog.outputters = FileOutputter.new("IspUnity", :filename => File.join("/var","log",filename), :formatter => pf)
|
13
13
|
|
@@ -7,11 +7,18 @@ class LoadBalance
|
|
7
7
|
@commands = []
|
8
8
|
alive_isps = []
|
9
9
|
isps.each do |isp|
|
10
|
-
|
10
|
+
if is_alive(isp)
|
11
|
+
alive_isps << isp
|
12
|
+
IspUnityLog.info("#{isp.name} is online")
|
13
|
+
else
|
14
|
+
IspUnityLog.info("#{isp.name} is offline")
|
15
|
+
end
|
11
16
|
end
|
12
17
|
if alive_isps.size == 1
|
18
|
+
IspUnityLog.info("Only 1 isp is alive")
|
13
19
|
@commands << "/sbin/ip route replace default via #{alive_isps[0].gateway} dev #{alive_isps[0].interface}"
|
14
20
|
else
|
21
|
+
IspUnityLog.info("Multiple isps are alive")
|
15
22
|
@commands << "/sbin/ip route replace default scope global "
|
16
23
|
alive_isps.each do |isp|
|
17
24
|
@commands[0] += " nexthop via #{isp.gateway} dev #{isp.interface} weight #{isp.weight} "
|
@@ -25,8 +32,10 @@ class LoadBalance
|
|
25
32
|
return false unless isp.enabled == 'true'
|
26
33
|
result = `/bin/ping -c 3 -I #{isp.ip_address} #{$ip_cluster.sample}`
|
27
34
|
if result.match("100% packet loss")
|
35
|
+
IspUnityLog.info("100% packet loss for #{isp.name}")
|
28
36
|
return false
|
29
37
|
else
|
38
|
+
IspUnityLog.info("0% packet loss for #{isp.name}")
|
30
39
|
return true
|
31
40
|
end
|
32
41
|
end
|
data/license
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
MIT License
|
2
|
+
|
1
3
|
IspUnity Copyright (C) 2012 Arun Tomar
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ispunity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-04-
|
14
|
+
date: 2012-04-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: log4r
|
@@ -61,6 +61,22 @@ dependencies:
|
|
61
61
|
- - ! '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: thor
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
64
80
|
description: With IspUnity, you can 1.Use multiple internet connections simultaneously
|
65
81
|
and get all their throughput. 2.Automatic failover on working net connection if
|
66
82
|
any on of the internet connection goes down.
|
@@ -68,7 +84,8 @@ email:
|
|
68
84
|
- pratik14shah@gmail.com
|
69
85
|
- sivagollapalli@yahoo.com
|
70
86
|
- arun@solutionenterprises.co.in
|
71
|
-
executables:
|
87
|
+
executables:
|
88
|
+
- ispunity
|
72
89
|
extensions: []
|
73
90
|
extra_rdoc_files: []
|
74
91
|
files:
|
@@ -77,6 +94,7 @@ files:
|
|
77
94
|
- Gemfile
|
78
95
|
- README
|
79
96
|
- Rakefile
|
97
|
+
- bin/ispunity
|
80
98
|
- config/configuration.json.example
|
81
99
|
- config/locale/en.yml
|
82
100
|
- config/settings.yml
|