freewifi 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
- module Freewifi
2
- VERSION = "0.1.4"
1
+ module Freewifi_1
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/freewifi.rb CHANGED
@@ -5,44 +5,63 @@ $LOAD_PATH.unshift File.expand_path("../database/mongo", __dir__)
5
5
  $LOAD_PATH.unshift File.expand_path("../additional", __dir__)
6
6
 
7
7
  require "freewifi/version"
8
- require 'freewifi/mikrotik/hewhub_mtik_ssh'
8
+ require "freewifi/params"
9
+ require "freewifi/config"
10
+ require 'freewifi/mikrotik/newhub_mtik_ssh'
11
+ require 'freewifi/mikrotik/schemes_conf_gen'
9
12
  require 'freewifi/database/mysql/database_methods_wifi'
10
13
  require 'freewifi/database/mongo/mongoconnector'
11
14
  require 'date'
15
+ require 'json'
12
16
 
13
17
  #eoip tunnel ids generates between 10001 - 65535
18
+ #frewifi SDK with SDK id = 1
14
19
 
15
-
16
- module Freewifi
20
+ module Freewifi_1
17
21
  attr_accessor :mtik_hub1_ip,
18
22
  :mtik_hub2_ip,
19
23
  :user_hub,
20
24
  :password_hub,
21
25
  :cps_class,
22
26
  :db_mysql,
23
- :additional_func_wifi,
24
- :ssh_mikrotik_connector,
25
- :mongo_connector_wifi,
27
+ :additional_func_wifi_1,
28
+ :ssh_mikrotik_connector_1,
29
+ :mongo_connector_wifi_1,
26
30
  :remote_ip,
27
31
  :real_ip,
28
- :subscriber_ip
32
+ :subscriber_ip,
33
+ :capsman_ip_man,
34
+ :capsman_user,
35
+ :capsman_password,
36
+ :mtik_config_gen_1,
37
+ :hub_vip,
38
+ :ap_admin_password,
39
+ :capsman_ip_wifi
40
+
29
41
 
30
- def initialize(hub1ip, hub2ip, username_hub, password_hub, database_username, database_password, database_host, mongo_ip, mongo_port, mongo_database, remote_ip, real_ip, subscriber_ip)
42
+ def initialize(hub1ip, hub2ip, username_hub, password_hub, database_username, database_password, database_host, mongo_ip, mongo_port, mongo_database, remote_ip, real_ip, subscriber_ip, capsman_ip, capsman_user, capsman_password, hub_vip, ap_admin_password, capsman_ip_wifi)
31
43
  @mtik_hub1_ip = hub1ip
32
44
  @mtik_hub2_ip = hub2ip
33
45
  @user_hub = username_hub
34
46
  @password_hub = password_hub
35
- @db_mysql = DatabaseMethodsWifi.new(database_username, database_password, database_host)
36
- @additional_func_wifi = InternalFunc.new
37
- @ssh_mikrotik_connector = NEWhubWifi.new
38
- @mongo_connector_wifi = MongoWifiCl.new(mongo_ip, mongo_port, mongo_database)
47
+ @db_mysql = DatabaseMethodsWifi_1.new(database_username, database_password, database_host)
48
+ @additional_func_wifi_1 = InternalFunc_1.new
49
+ @ssh_mikrotik_connector_1 = NEWhubWifi_1.new
50
+ @mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
39
51
  @remote_ip = remote_ip
40
52
  @real_ip = real_ip
41
53
  @subscriber_ip = subscriber_ip
54
+ @capsman_ip = capsman_ip
55
+ @capsman_user = capsman_user
56
+ @capsman_password = capsman_password
57
+ @mtik_config_gen_1 = MtikSchemesGen_1.new
58
+ @hub_vip = hub_vip
59
+ @ap_admin_password = ap_admin_password
60
+ @capsman_ip_wifi = capsman_ip_wifi
42
61
  end
43
62
 
44
63
 
45
- def add_mikrotik_ap_mobile(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
64
+ def add_mikrotik_ap_mobile_1(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
46
65
 
47
66
  input_params = {:sim_ipaddress => sim_ipaddress,
48
67
  :sim_msisdn => sim_msisdn,
@@ -62,18 +81,18 @@ module Freewifi
62
81
 
63
82
  begin
64
83
 
65
- processed_comp_name = additional_func_wifi.company_check_wifi(company_name)
84
+ processed_comp_name = additional_func_wifi_1.company_check_wifi_1(company_name)
66
85
  #p ap_state = db_mysql.check_mikrotik_ap_exists(sim_ipaddress, sim_msisdn).to_s
67
- ap_state = mongo_connector_wifi.get_ap_info_sim_ip_wifi(sim_ipaddress, sim_msisdn).to_s
86
+ ap_state = mongo_connector_wifi_1.get_ap_info_sim_ip_wifi_1(sim_ipaddress, sim_msisdn)[:body]
68
87
 
69
- if ap_state == "" || ap_state == nil || ap_state == "[]" || ap_state == "fttx"
70
- tunnel_addition = ssh_mikrotik_connector.add_eoip_for_mikr_wifi(bridge_name_hub,
71
- sim_ipaddress,
72
- processed_comp_name,
73
- mtik_hub1_ip,
74
- mtik_hub2_ip,
75
- user_hub,
76
- password_hub)
88
+ if ap_state[:all_mongo].to_s == "" || ap_state[:all_mongo].to_s == nil || ap_state[:all_mongo].to_s == "[]" || ap_state[:all_mongo].to_s == "fttx"
89
+ tunnel_addition = ssh_mikrotik_connector_1.add_eoip_for_mikr_wifi_1(bridge_name_hub,
90
+ sim_ipaddress,
91
+ processed_comp_name,
92
+ mtik_hub1_ip,
93
+ mtik_hub2_ip,
94
+ user_hub,
95
+ password_hub)
77
96
 
78
97
 
79
98
  if tunnel_addition[:code] == 200
@@ -97,8 +116,18 @@ module Freewifi
97
116
  :created_date => DateTime.now
98
117
  }
99
118
 
100
- mongo_response = mongo_connector_wifi.data_ap_auto_created_insert(data)
119
+ mongo_response = mongo_connector_wifi_1.data_ap_auto_created_insert_1(data)
101
120
  if mongo_response[:code]==200
121
+ newcapsman1 = NEWhubWifi_1.new
122
+
123
+ threads = []
124
+ capsman_ip.each do |capsman|
125
+ threads << Thread.new do
126
+ newcapsman1.set_capsman_config_1(additional_func_wifi_1.prep_ssid_for_config_1(wifi_ssid), capsman, capsman_user, capsman_password, sim_ipaddress, additional_func_wifi_1.prep_comp_name_for_config_1(company_name))
127
+ end
128
+ end
129
+ threads.each(&:join)
130
+
102
131
  output_params = {:code => 200, :result => "Request completed successfully", :body => {:tunnel_id => tunnel_addition[:body][:eoip_tunnel_id], :tunnel_name => tunnel_addition[:body][:eoip_tunnel_name]}}
103
132
  else
104
133
  output_params = {:code => 400, :result => "Something wrong with insertion to mongo"}
@@ -107,45 +136,92 @@ module Freewifi
107
136
  output_params = {:code => 401, :result => tunnel_addition[:result]}
108
137
  end
109
138
  else
110
- output_params = {:code => 202, :result => "AP exists"}
139
+ output_params = {:code => 202, :result => "AP exists", :body => {:tunnel_id => ap_state[:tunnel_id].to_s}}
111
140
  end
112
141
  rescue
113
142
  output_params = {:code => 507, :result => "Unknown SDK error"}
114
143
  end
115
- mongo_connector_wifi.audit_logger_wifi("add_mikrotik_ap_mobile", remote_ip, input_params, output_params, real_ip, subscriber_ip)
144
+ mongo_connector_wifi_1.audit_logger_wifi_1("add_mikrotik_ap_mobile", remote_ip, input_params, output_params, real_ip, subscriber_ip)
116
145
  #additional_func.printer_texter({:input_params => input_params, :output_params => output_params, :procedure => "add_mikrotik_ap_mobile", :file => "freewifi.rb"}, "info")
117
146
  output_params
118
147
  end
119
148
 
120
149
 
150
+ def mtik_sch1_config_gen_1(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
151
+ input_params = {:sim_ipaddress => sim_ipaddress,
152
+ :sim_msisdn => sim_msisdn,
153
+ :bridge_name_hub => bridge_name_hub,
154
+ :company_name => company_name,
155
+ :subscribers_address => subscribers_address,
156
+ :subscribers_region => subscribers_region,
157
+ :subscribers_contacts => subscribers_contacts,
158
+ :wifi_ssid => wifi_ssid,
159
+ :portalstyle => portalstyle,
160
+ :ap_serial_number => ap_serial_number,
161
+ :ap_model => ap_model,
162
+ :description => description,
163
+ :note => note
164
+ }
165
+ output_params = {}
166
+
167
+ begin
168
+
169
+ res = self.add_mikrotik_ap_mobile_1(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
170
+ tun_id = res[:body][:tunnel_id]
171
+ hostname = additional_func_wifi_1.ap_hostname_generator(company_name, tun_id)
172
+ conf_1 = mtik_config_gen_1.scheme1_3g_config_gen_1(hostname, tun_id, hub_vip, ap_admin_password, wifi_ssid, capsman_ip_wifi)
173
+ output_params = {:code => 200, :result => "Request completed successfully", :body => {:ap_configuration => conf_1}}
174
+
175
+ rescue
176
+ output_params = {:code => 507, :result => "Unknown SDK error"}
177
+ end
178
+ mongo_connector_wifi_1.audit_logger_wifi_1("mtik_sch1_config_gen_1", remote_ip, input_params, conf_1, real_ip, subscriber_ip)
179
+ output_params
180
+ end
181
+
182
+
121
183
  def add_eoip_for_mikr_hub(bridge_name, ap_ip_address, tunnel_name)
122
- newhub = NEWhubWifi.new
123
- newhub.add_eoip_for_mikr_wifi(bridge_name,
124
- ap_ip_address,
125
- tunnel_name,
126
- mtik_hub1_ip,
127
- mtik_hub2_ip,
128
- user_hub,
129
- password_hub)
184
+ newhub_1 = NEWhubWifi_1.new
185
+ newhub_1.add_eoip_for_mikr_wifi_1(bridge_name,
186
+ ap_ip_address,
187
+ tunnel_name,
188
+ mtik_hub1_ip,
189
+ mtik_hub2_ip,
190
+ user_hub,
191
+ password_hub)
130
192
  end
131
193
 
132
- def del_one_eoip_from_mikr_hub(tunnel_id)
133
- newhub1 = NEWhubWifi.new
134
- newhub1.del_eoip_for_mikr(tunnel_id, mtik_hub1_ip, mtik_hub2_ip, user_hub, password_hub)
194
+ def del_one_eoip_from_mikr_hub_1(tunnel_id)
195
+ newhub1 = NEWhubWifi_1.new
196
+ newhub1.del_eoip_for_mikr_1(tunnel_id, mtik_hub1_ip, mtik_hub2_ip, user_hub, password_hub)
135
197
  p tid = tunnel_id.to_i
136
- mongo_connector_wifi.tunnelid_remove_single_mongo(tid)
198
+ mongo_connector_wifi_1.tunnelid_remove_single_mongo_1(tid)
199
+ end
200
+
201
+ def cellular_mtik_ap_conf_gen_1(scheme_number)
202
+
137
203
  end
138
204
 
139
205
  def test()
140
- #newhub1 = NEWhub.new
141
- #newhub1.hub_get_all_eoip_tunnels("172.24.223.132", "soapgw", "fr8Hn3Ed2k0Im4gWmav2Nh7Y1qAm8KlmRh3Dcu2Wcok5gBdm")
142
- mongo_connector_wifi.data_ap_auto_created_insert(:test => "test")
206
+ newcapsman1 = NEWhubWifi_1.new
207
+
208
+ threads = []
209
+ capsman_ip.each do |capsman|
210
+ threads << Thread.new do
211
+ newcapsman1.set_capsman_config_1("test_ss", capsman, capsman_user, capsman_password, "172.25.208.14", "test_company")
212
+ end
213
+ end
214
+ threads.each(&:join)
215
+
216
+ #newhub1.hub_get_all_eoip_tunnels_1("172.24.223.132", "soapgw", "fr8Hn3Ed2k0Im4gWmav2Nh7Y1qAm8KlmRh3Dcu2Wcok5gBdm")
217
+ #mongo_connector_wifi_1.data_ap_auto_created_insert_1(:test => "test")
143
218
  end
219
+
144
220
  end
145
221
 
146
222
 
147
- class Fwifi
148
- include Freewifi
223
+ class Fwifi_1
224
+ include Freewifi_1
149
225
  end
150
226
 
151
227
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freewifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.11.4
139
+ - !ruby/object:Gem::Dependency
140
+ name: translit
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.1.5
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.1.5
139
153
  description: description for my gem
140
154
  email:
141
155
  - imperituro.ard@gmail.com
@@ -161,10 +175,14 @@ files:
161
175
  - freewifi.gemspec
162
176
  - lib/freewifi.rb
163
177
  - lib/freewifi/additional/additional_functions.rb
178
+ - lib/freewifi/cisco/cisco_schemes_conf_gen.rb
179
+ - lib/freewifi/config.rb
164
180
  - lib/freewifi/database/mongo/mongoconnector.rb
165
181
  - lib/freewifi/database/mysql/database_methods_wifi.rb
166
182
  - lib/freewifi/mikrotik/getsubscribermikrotik.rb
167
- - lib/freewifi/mikrotik/hewhub_mtik_ssh.rb
183
+ - lib/freewifi/mikrotik/newhub_mtik_ssh.rb
184
+ - lib/freewifi/mikrotik/schemes_conf_gen.rb
185
+ - lib/freewifi/params.rb
168
186
  - lib/freewifi/version.rb
169
187
  homepage: https://rubygems.org/gems/freewifi
170
188
  licenses: