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,8 +1,9 @@
1
1
  require 'date'
2
+ require 'translit'
2
3
 
3
- class InternalFunc
4
+ class InternalFunc_1
4
5
 
5
- def datetimenow()
6
+ def datetimenow_1()
6
7
  d_curr = DateTime.now
7
8
  time_zone = 'Europe/Minsk'
8
9
  # DateTime.new
@@ -11,28 +12,47 @@ class InternalFunc
11
12
  d_curr.to_s
12
13
  end
13
14
 
14
- def printer_texter_wifi(text, log_level)
15
+ def printer_texter_wifi_1(text, log_level)
15
16
  begin
16
- mess = {:datetime => datetimenow, :sdk => "freewifi", :sdk_version => Freewifi::VERSION, :message => text}
17
- p mess
17
+ if log_level == "debug" && Freewifi_1::LOGLEVEL_1 == "debug"
18
+ mess = {:datetime => datetimenow_1, :sdk => "freewifi", :sdk_version => Freewifi_1::VERSION, :message => text}
19
+ p mess
20
+ end
21
+
18
22
  rescue
19
23
  p "Failed print message"
20
24
  end
21
25
  end
22
26
 
23
- def hub_tunnelname_generator(tunnel_id, company_name)
27
+ def hub_tunnelname_generator_1(tunnel_id, company_name)
24
28
  comp_name = company_name
25
29
  "#{tunnel_id.to_s}_eoip_hub_auto_#{comp_name}"
26
30
  end
27
31
 
28
- def company_check_wifi(compname)
32
+ def company_check_wifi_1(compname)
29
33
  compname2=""
30
34
  if compname.include?(" ")
31
- compname2 = compname.gsub(" ","")
35
+ compname2 = compname.gsub(" ", "")
32
36
  else
33
37
  compname2 = compname
34
38
  end
35
39
  compname2
36
40
  end
37
41
 
38
- end
42
+ def prep_comp_name_for_config_1(company_name)
43
+ res = company_name.gsub(" ", "")
44
+ res1 = Translit.convert(res, :english)
45
+ res1.slice(0..14)
46
+ end
47
+
48
+ def prep_ssid_for_config_1(ssid)
49
+ res = ssid.gsub(" ", "_")
50
+ res1 = Translit.convert(res, :english)
51
+ res1.slice(0..14)
52
+ end
53
+
54
+ def ap_hostname_generator(company, tunnel_id)
55
+ "#{self.prep_comp_name_for_config_1(company)}_#{tunnel_id.to_s}"
56
+ end
57
+
58
+ end
@@ -0,0 +1,12 @@
1
+ class CiscoSchemesGen_1
2
+
3
+ def scheme1_fttx_config_gen_1(ap_wifi_ip, ap_wifi_gateway, ap_wifi_mask)
4
+ [
5
+ "capwap ap ip address #{ap_wifi_ip} #{ap_wifi_mask}",
6
+ "capwap ap ip default-gateway #{ap_wifi_gateway}",
7
+ "capwap ap controller ip address 172.24.211.1"
8
+ ]
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,4 @@
1
+ module Freewifi_1
2
+ LOGLEVEL_1 = "critical"
3
+ end
4
+
@@ -5,9 +5,9 @@ require 'rubygems'
5
5
  require 'freewifi/additional/additional_functions'
6
6
 
7
7
  #class for communication with mongo database for iot API
8
- class MongoWifiCl
8
+ class MongoWifiCl_1
9
9
 
10
- attr_accessor :mongo_ip, :mongo_port, :client, :mongo_database, :additional_func
10
+ attr_accessor :mongo_ip, :mongo_port, :client, :mongo_database, :additional_func_1
11
11
 
12
12
  def initialize(mongo_ip, mongo_port, mongo_database)
13
13
  @mongo_database = mongo_database
@@ -15,13 +15,14 @@ class MongoWifiCl
15
15
  @mongo_port = mongo_port
16
16
  client_host = [mongo_ip + ":" + mongo_port]
17
17
  @client = Mongo::Client.new(client_host, :database => mongo_database)
18
- @additional_func = InternalFunc.new
18
+
19
+ @additional_func_1 = InternalFunc_1.new
19
20
  end
20
21
 
21
- def audit_logger_wifi(proc_name, src_ip, input_json, output_json, real_ip, subscriber_ip)
22
+ def audit_logger_wifi_1(proc_name, src_ip, input_json, output_json, real_ip, subscriber_ip)
22
23
  out_resp = {}
23
24
  begin
24
- current = additional_func.datetimenow
25
+ current = additional_func_1.datetimenow_1
25
26
  collection = client[:audit]
26
27
  doc = {
27
28
  :proc_name => proc_name,
@@ -29,33 +30,35 @@ class MongoWifiCl
29
30
  :sender => {:src_ip => src_ip, :real_ip => real_ip, :subscriber_ip => subscriber_ip},
30
31
  :input_params => input_json,
31
32
  :output_params => output_json,
32
- :sdk_version => Freewifi::VERSION
33
+ :sdk_version => Freewifi_1::VERSION
33
34
  }
34
35
  result = collection.insert_one(doc)
35
- out_resp = {:code => 200, :result => "audit_logger: Request completed successfully", :body => result}
36
+ out_resp = {:code => 200, :result => "audit_logger_wifi_1: Request completed successfully", :body => result, :sdk => "freewifi"}
36
37
  rescue
37
- out_resp = {:code => 507, :result => "audit_logger: Unknown SDK error"}
38
+ out_resp = {:code => 507, :result => "audit_logger_wifi_1: Unknown SDK error", :sdk => "freewifi"}
38
39
  end
39
- additional_func.printer_texter_wifi(out_resp, "debug")
40
+ additional_func_1.printer_texter_wifi_1(out_resp, "debug")
40
41
  out_resp
41
42
  end
42
43
 
43
44
 
44
- def data_ap_auto_created_insert(data)
45
+ def data_ap_auto_created_insert_1(data)
45
46
  input_params = {:data => data}
46
47
  output_params = {}
47
48
  begin
48
49
  collection = client[:ap_auto_created]
49
50
  result = collection.insert_one(data)
50
- output_params = {:code => 200, :result => "data_ap_auto_created_insert: Request completed successfully", :body => result}
51
+ output_params = {:code => 200, :result => "data_ap_auto_created_insert_1: Request completed successfully", :body => result, :sdk => "freewifi"}
51
52
  rescue
52
- output_params = {:code => 500, :result => "data_ap_auto_created_insert: failed insert data to mongo"}
53
+ output_params = {:code => 500, :result => "data_ap_auto_created_insert_1: failed insert data to mongo", :sdk => "freewifi"}
53
54
  end
54
- additional_func.printer_texter_wifi({:input_params => input_params, :output_params => output_params, :procedure => "data_ap_auto_created_insert", :file => "freewifi/database/mongo/mongoconnector.rb"}, "debug")
55
+ additional_func_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "data_ap_auto_created_insert_1", :file => "freewifi/database/mongo/mongoconnector.rb", :sdk => "freewifi"}, "debug")
55
56
  output_params
56
57
  end
57
58
 
58
- def get_ap_info_sim_ip_wifi(sim_ipaddress, sim_msisdn)
59
+ def get_ap_info_sim_ip_wifi_1(sim_ipaddress, sim_msisdn)
60
+ input_params = {:sim_ipaddress => sim_ipaddress, :sim_msisdn => sim_msisdn}
61
+ output_params = {}
59
62
  begin
60
63
  result_ps = []
61
64
  collection = client[:ap_auto_created]
@@ -63,13 +66,15 @@ class MongoWifiCl
63
66
  result_ps << row
64
67
  #result_ps.append(row)
65
68
  }
66
- result_ps[0]
69
+ output_params = {:code => 200, :result => "get_ap_info_sim_ip_wifi_1: Request completed successfully", :body => {:all_mongo => result_ps, :tunnel_id => result_ps[0]["tunnel_id"] }, :sdk => "freewifi"}
67
70
  rescue
68
- []
71
+ output_params = {:code => 500, :result => "get_ap_info_sim_ip_wifi_1: failed ", :sdk => "freewifi"}
69
72
  end
73
+ additional_func_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "get_ap_info_sim_ip_wifi_1", :file => "freewifi/database/mongo/mongoconnector.rb", :sdk => "freewifi"}, "debug")
74
+ output_params
70
75
  end
71
76
 
72
- def tunnelid_remove_single_mongo(tunnel_id)
77
+ def tunnelid_remove_single_mongo_1(tunnel_id)
73
78
  out_resp = {}
74
79
  begin
75
80
  collection = client[:ap_auto_created]
@@ -78,9 +83,9 @@ class MongoWifiCl
78
83
  }
79
84
  result = collection.delete_many(doc)
80
85
  p result
81
- out_resp = {:code => 200, :result => "tunnelid_remove_single_mongo: Request completed successfully"}
86
+ out_resp = {:code => 200, :result => "tunnelid_remove_single_mongo_1: Request completed successfully", :sdk => "freewifi"}
82
87
  rescue
83
- out_resp = {:code => 507, :result => "tunnelid_remove_single_mongo: Unknown SDK error"}
88
+ out_resp = {:code => 507, :result => "tunnelid_remove_single_mongo_1: Unknown SDK error", :sdk => "freewifi"}
84
89
  end
85
90
  #internal_func.printer_texter(out_resp, "debug")
86
91
  out_resp
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'mysql2'
4
4
 
5
- class DatabaseMethodsWifi
5
+ class DatabaseMethodsWifi_1
6
6
 
7
7
  attr_accessor :database_username, :database_password, :database_host
8
8
 
@@ -0,0 +1,321 @@
1
+ require 'net/ssh'
2
+ require 'ipaddr'
3
+ require 'json'
4
+ require 'ipaddr'
5
+ require 'date'
6
+ require "freewifi/additional/additional_functions"
7
+
8
+
9
+ class NEWhubWifi_1
10
+
11
+ attr_accessor :t_id_min, :t_id_max, :additional_func_wifi_1
12
+
13
+ def initialize
14
+ @t_id_min = 10001
15
+ @t_id_max = 65535
16
+
17
+ @additional_func_wifi_1 = InternalFunc_1.new
18
+ end
19
+
20
+
21
+ def del_eoip_for_mikr_1(tunnel_id, hub1, hub2, user_hub, password_hub)
22
+
23
+ begin
24
+ Net::SSH.start(hub1, user_hub, :password => password_hub) do |ssh|
25
+ #result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
26
+ #p result
27
+ result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
28
+ regimsi = /\s+name=\"(.+)\"\s+/
29
+ m1 = regimsi.match(result)[1]
30
+ sleep 0.2
31
+ result2 = ssh.exec!("/interface bridge port remove [/interface bridge port find interface=#{m1}]")
32
+ sleep 0.2
33
+ result3 = ssh.exec!("/interface eoip remove [/interface eoip find where tunnel-id=#{tunnel_id}]")
34
+
35
+ #result2 = ssh.exec!("interface bridge port add bridge=#{bridge_name} interface=#{tunnel_name}")
36
+ end
37
+ #Net::SSH.stop
38
+ rescue
39
+ nil
40
+ end
41
+
42
+ begin
43
+ Net::SSH.start(hub2, user_hub, :password => password_hub) do |ssh|
44
+ result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
45
+ regimsi = /\s+name=\"(.+)\"\s+/
46
+ m1 = regimsi.match(result)[1]
47
+ sleep 0.2
48
+ result2 = ssh.exec!("/interface bridge port remove [/interface bridge port find interface=#{m1}]")
49
+ sleep 0.2
50
+ result3 = ssh.exec!("/interface eoip remove [/interface eoip find where tunnel-id=#{tunnel_id}]")
51
+
52
+ #result = ssh.exec!("interface eoip add remote-address=#{ap_ip_address} tunnel-id=#{tunnel_id} name=#{tunnel_name}")
53
+ #result2 = ssh.exec!("interface bridge port add bridge=#{bridge_name} interface=#{tunnel_name}")
54
+ end
55
+ #Net::SSH.stop
56
+ rescue
57
+ nil
58
+ end
59
+ end
60
+
61
+
62
+ def ap_get_info(ap_ip_address, ap_login, ap_password)
63
+ res = ""
64
+ Net::SSH.start(ap_ip_address, ap_login, :password => ap_password) do |ssh|
65
+ result = ssh.exec!("system identity print")
66
+ dff = result.to_s
67
+ res = dff.gsub!("name: ", "").gsub!("\r\n\r\n", "").gsub!(" ", "")
68
+ end
69
+ res
70
+ end
71
+
72
+ def ap_tun_rewrite(ap_ip_address, tun_id, ap_login, ap_password)
73
+ res = ""
74
+ Net::SSH.start(ap_ip_address, ap_login, :password => ap_password) do |ssh|
75
+ result = ssh.exec!("/interface eoip set tunnel_to_hab1 tunnel-id=#{tun_id} remote-address=172.24.202.145")
76
+ end
77
+ res
78
+ end
79
+
80
+ def get_tun_id(req_num_of_tunid, busy_tun_id)
81
+ all_ids=[]
82
+ i = t_id_min
83
+ while i < t_id_max
84
+ all_ids << i
85
+ i=i+1
86
+ end
87
+ p all_ids
88
+ end
89
+
90
+ #procedure for tunnel id-s selection based on all_tunids array
91
+ def get_tun_id2_1(req_num_of_tunid, busy_tun_id)
92
+ #req_num_of_tunid - integer number of necessary tun ids
93
+ #busy_tun_id - [] dictionary of currently used tun ids with integer elements
94
+ input_params = {:req_num_of_tunid => req_num_of_tunid, :busy_tun_id => busy_tun_id}
95
+ output_params = {}
96
+ all_ids = []
97
+ req_tun_ids = []
98
+ begin
99
+ available_tun_id = Freewifi_1::ALL_TUNIDS - busy_tun_id
100
+ i = 0
101
+ while i < req_num_of_tunid
102
+ req_tun_ids << available_tun_id[i]
103
+ i=i+1
104
+ end
105
+ output_params = {:code => 200, :result => "get_tun_id2_1: Request completed", :body => {:selected_tun_ids => req_tun_ids}, :sdk => "freewifi"}
106
+ rescue
107
+ output_params = {:code => 500, :result => "get_tun_id2_1: Something Wrong", :sdk => "freewifi"}
108
+ end
109
+ additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "get_tun_id2_1"}, "debug")
110
+ output_params
111
+ end
112
+
113
+ #universal procedure for get currently configured eoip tunnels
114
+ def hub_get_all_eoip_tunnels_1(hub_ip_address, hub_login, hub_password)
115
+ input_params = {:hub_ip_address => hub_ip_address, :hub_login => hub_login, :hub_password => hub_password}
116
+ output_params = {}
117
+ result = ""
118
+ busy_tunnel_ids = []
119
+ begin
120
+ ssh_connection = Net::SSH.start(hub_ip_address, hub_login, :password => hub_password) do |ssh|
121
+ result = ssh.exec!("/interface eoip print where tunnel-id>=#{t_id_min.to_s} tunnel-id<=#{t_id_max.to_s}")
122
+ end
123
+ #p ssh_connection.
124
+ reg_tunnelid = /tunnel-id=(\d+)/
125
+ m1 = result.scan(reg_tunnelid)
126
+ for a1 in m1
127
+ if a1[0] != []
128
+ s1 = a1[0].to_i
129
+ busy_tunnel_ids << s1
130
+ end
131
+ end
132
+ output_params = {:code => 200, :result => "hub_get_all_eoip_tunnels_1: Request completed", :body => {:busy_tunnel_ids => busy_tunnel_ids}, :sdk => "freewifi"}
133
+
134
+ rescue
135
+ output_params = {:code => 500, :result => "hub_get_all_eoip_tunnels_1: Something Wrong", :sdk => "freewifi"}
136
+ end
137
+
138
+ additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "hub_get_all_eoip_tunnels_1"}, "debug")
139
+ output_params
140
+
141
+ #m1 = reg_tunnelid.scan(result)
142
+ #p busy_tunnel_ids
143
+ #g = result.split("\r\n\r\n")
144
+ #p g
145
+ #result
146
+ end
147
+
148
+
149
+ def add_eoip_for_mikr_wifi_1(bridge_name, ap_ip_address, company_name, hub1, hub2, user_hub, password_hub)
150
+
151
+ input_params = {:bridge_name => bridge_name,
152
+ :ap_ip_address => ap_ip_address,
153
+ :company_name => company_name,
154
+ :hub1 => hub1,
155
+ :hub2 => hub2,
156
+ :user_hub => user_hub,
157
+ :password_hub => password_hub
158
+ }
159
+ output_params = {}
160
+ hub1_processed = ""
161
+ hub2_processed = ""
162
+
163
+ get_tun_id_answ = get_tun_id2_1(1, hub_get_all_eoip_tunnels_1(hub1, user_hub, password_hub)[:body][:busy_tunnel_ids])
164
+ eoip_tunnel_name = additional_func_wifi_1.hub_tunnelname_generator_1(get_tun_id_answ[:body][:selected_tun_ids][0], company_name)
165
+
166
+ if get_tun_id_answ[:code] == 200
167
+
168
+ begin
169
+ Net::SSH.start(hub1, user_hub, :password => password_hub) do |ssh|
170
+ result = ssh.exec!("/interface eoip add remote-address=#{ap_ip_address} tunnel-id=#{get_tun_id_answ[:body][:selected_tun_ids][0]} name=#{eoip_tunnel_name}")
171
+ result2 = ssh.exec!("/interface bridge port add bridge=#{bridge_name} interface=#{eoip_tunnel_name} unknown-multicast-flood=no unknown-unicast-flood=no")
172
+ end
173
+ hub1_processed = "Success"
174
+ rescue
175
+ hub1_processed = "Failed"
176
+ end
177
+ #Net::SSH.stop
178
+
179
+ begin
180
+ Net::SSH.start(hub2, user_hub, :password => password_hub) do |ssh|
181
+ result = ssh.exec!("/interface eoip add remote-address=#{ap_ip_address} tunnel-id=#{get_tun_id_answ[:body][:selected_tun_ids][0]} name=#{eoip_tunnel_name}")
182
+ result2 = ssh.exec!("/interface bridge port add bridge=#{bridge_name} interface=#{eoip_tunnel_name} unknown-multicast-flood=no unknown-unicast-flood=no")
183
+ end
184
+ #Net::SSH.stop
185
+ hub2_processed = "Success"
186
+ rescue
187
+ hub2_processed = "Failed"
188
+ end
189
+ output_params = {:code => 200, :result => "add_eoip_for_mikr_wifi_1: Request completed", :body => {:eoip_tunnel_id => get_tun_id_answ[:body][:selected_tun_ids][0], :eoip_tunnel_name => eoip_tunnel_name, :hub1_processed => hub1_processed, :hub2_processed => hub2_processed}}
190
+ else
191
+ output_params = {:code => 500, :result => "add_eoip_for_mikr_wifi_1: Something Wrong with empty eoip tun id", :sdk => "freewifi"}
192
+ end
193
+ additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "add_eoip_for_mikr_wifi_1", :sdk => "freewifi"}, "debug")
194
+ output_params
195
+ end
196
+
197
+
198
+ def mikr_tunnelid_gen()
199
+ t_id_min = 10001
200
+ t_id_max = 65535
201
+ end
202
+
203
+ def check_pool_range_includes_1(range, ip_addr_new)
204
+ input_params ={:range => range, :ip_addr_new => ip_addr_new}
205
+ output_params = {}
206
+
207
+ begin
208
+ res = "nothing"
209
+ gs = range.split(",")
210
+ for j in gs
211
+ if j.include?("/")
212
+ ipaddr1 = IPAddr.new ip_addr_new
213
+ x1 = j.split("/")
214
+ ipaddr2 = ipaddr1.mask(x1[1].to_i).to_s
215
+ ipaddr3 = ipaddr2.to_s
216
+ if ipaddr3 == x1[0]
217
+ res = "exists"
218
+ end
219
+ else
220
+ if j == ip_addr_new
221
+ res = "exists"
222
+ end
223
+ end
224
+ end
225
+ output_params = {:code => 200, :result => "check_pool_range_includes_1: Request processed", :body => {:result => res}}
226
+ rescue
227
+ output_params = {:code => 507, :result => "check_pool_range_includes_1: Unknown SDK error"}
228
+ end
229
+
230
+ additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "check_pool_range_includes_1", :file => "freewifi/mikrotik/newhub_mtik_ssh.rb", :sdk => "freewifi"}, "debug")
231
+ output_params
232
+ end
233
+
234
+ def capsman_set_ip_range_1(capsman1, capsman_user1, capsman_pass1, ap_ip)
235
+
236
+ end
237
+
238
+ def capsman_new_configuration_1(wifissid, capsman1, capsman_user1, capsman_pass1, ap_ip, companyname)
239
+
240
+ conf_24ghz_name = "auto_cfg_24ghz_#{companyname}_#{wifissid}"
241
+ command_conf_24ghz = "/caps-man configuration add name=#{conf_24ghz_name} ssid=#{wifissid} country=belarus mode=ap hw-retries=15 channel=24_channel_24GHz_dynamic_power22 datapath=1_datapath_MTS_Local-forwarding security=security_without_passphrase_default_FREE-WiFi"
242
+
243
+ conf_5ghz_name = "auto_cfg_5ghz_#{companyname}_#{wifissid}"
244
+ command_conf_5ghz = "/caps-man configuration add name=#{conf_5ghz_name} ssid=#{wifissid} country=belarus mode=ap hw-retries=15 channel=5_channel_5GHz_number1_power23 datapath=1_datapath_MTS_Local-forwarding security=security_without_passphrase_default_FREE-WiFi"
245
+
246
+ command_provisioning_24ghz = "/caps-man provisioning add hw-supported-modes=b,g,gn ip-address-ranges=#{ap_ip} action=create-dynamic-enabled master-configuration=#{conf_24ghz_name} name-format=identity"
247
+
248
+ command_provisioning_5ghz = "/caps-man provisioning add hw-supported-modes=a,ac,an ip-address-ranges=#{ap_ip} action=create-dynamic-enabled master-configuration=#{conf_24ghz_name} name-format=identity"
249
+
250
+ Net::SSH.start(capsman1, capsman_user1, :password => capsman_pass1) do |ssh|
251
+ result = ssh.exec!(command_conf_24ghz)
252
+ result1 = ssh.exec!(command_conf_5ghz)
253
+ result2 = ssh.exec!(command_provisioning_24ghz)
254
+ result3 = ssh.exec!(command_provisioning_5ghz)
255
+ end
256
+
257
+ end
258
+
259
+ def capsman_add_ip_to_existed_1(ap_name_list, capsman1, capsman_user1, capsman_pass1, ap_ip)
260
+ command = "/caps-man provisioning print where "
261
+
262
+ for h in ap_name_list
263
+ command = command + " or master-configuration=" + h
264
+ end
265
+ command = command.gsub("where or", "where")
266
+
267
+ final_provision_old = []
268
+
269
+ Net::SSH.start(capsman1, capsman_user1, :password => capsman_pass1) do |ssh|
270
+ result = ssh.exec!(command)
271
+ s1 = result.split("\r\n\r\n")
272
+ for a in s1
273
+ a1 = a.gsub("\r\n", "")
274
+ a2 = a1.gsub(", ", ",")
275
+ reg_addr_range = / (\d) .+ ip-address-ranges=(\d{1,3}.+\.\d{1,3}|\d{1,3}.+\.\d{1,3}\/\d{1,2})\s+/
276
+ m1 = a2.scan(reg_addr_range)
277
+ num = m1[0][0]
278
+ ip_ran = m1[0][1].gsub(" ", "")
279
+ triplet = [num, ip_ran]
280
+ final_provision_old << triplet
281
+ exists_check = self.check_pool_range_includes_1(triplet[1], ap_ip)
282
+
283
+ if exists_check[:body][:result] != "exists"
284
+ #self.capsman_set_ip_range_1(capsman1, capsman_user1, capsman_pass1, ap_ip)
285
+ #set data to capsman
286
+ rewrite_ip_command = "/caps-man provisioning set numbers=#{triplet[0]} ip-address-ranges=#{triplet[1]},#{ap_ip}"
287
+ p rewrite_ip_command
288
+
289
+ ssh.exec!(rewrite_ip_command)
290
+
291
+ end
292
+ end
293
+ end
294
+
295
+
296
+ end
297
+
298
+
299
+ def set_capsman_config_1(wifissid, capsman1, capsman_user1, capsman_pass1, ap_ip, companyname)
300
+ Net::SSH.start(capsman1, capsman_user1, :password => capsman_pass1) do |ssh|
301
+ result = ssh.exec!("/caps-man configuration print where ssid=#{wifissid}")
302
+ if result == "\r\n" || result == "" || result == nil
303
+ self.capsman_new_configuration_1(wifissid, capsman1, capsman_user1, capsman_pass1, ap_ip, companyname)
304
+ else
305
+ p result
306
+ conf_names = []
307
+ reg_config_name = /name=\"(\S+)\"/
308
+ m1 = result.scan(reg_config_name)
309
+ for a1 in m1
310
+ if a1[0] != []
311
+ s1 = a1[0]
312
+ conf_names << s1
313
+ end
314
+ end
315
+ self.capsman_add_ip_to_existed_1(conf_names, capsman1, capsman_user1, capsman_pass1, ap_ip)
316
+ end
317
+ end
318
+ end
319
+
320
+
321
+ end
@@ -0,0 +1,54 @@
1
+
2
+
3
+ class MtikSchemesGen_1
4
+
5
+
6
+ def scheme1_3g_config_gen_1(hostname, tunnel_id, hub_vip, ap_admin_password, ap_ssid, capsman)
7
+
8
+ cap_conf = "/interface wireless cap set caps-man-addresses="
9
+ for f in capsman
10
+ cap_conf = cap_conf + "," + f
11
+ end
12
+ cap_conf = cap_conf + " enabled=yes interfaces=wireless_public_interface,wlan2 bridge=bridge_tunnel"
13
+ cap_conf = cap_conf.gsub("caps-man-addresses=,", "caps-man-addresses=")
14
+
15
+
16
+ [
17
+ "/system identity set name=#{hostname}",
18
+ "/interface bridge add name=bridge_tunnel",
19
+ "/interface eoip add remote-address=#{hub_vip.to_s} tunnel-id=#{tunnel_id.to_s} name=tunnel_to_hub",
20
+ "/interface bridge port add interface=tunnel_to_hub bridge=bridge_tunnel",
21
+ "/interface bridge port add interface=wlan1 bridge=bridge_tunnel",
22
+ "/interface wireless set wlan1 mode=ap-bridge ssid=#{ap_ssid} disabled=no name=wireless_public_interface frequency=2442",
23
+ "/interface ppp-client set ppp-out1 apn=vpn pin=1111 disabled=no",
24
+ "/interface wireless set wlan2 disabled=yes",
25
+ "/system clock set time-zone-name=Europe/Minsk",
26
+ "/snmp community set numbers=0 name=\"RO2597\" addresses=172.18.25.4/32,172.17.109.3/32 security=none read-access=yes write-access=no",
27
+ "/snmp set enabled=yes trap-community=RO2597 trap-version=2",
28
+ "/system ntp client set enabled=yes primary-ntp=172.24.213.41 secondary-ntp=172.18.25.10",
29
+ cap_conf,
30
+ "/user set admin password=#{ap_admin_password}",
31
+ ]
32
+
33
+ end
34
+
35
+
36
+ def scheme1_fttx_config_gen_1(hostname, tunnel_id, hub_vip, ap_admin_password, ap_ssid, ap_wifi_ip, ap_wifi_gateway)
37
+
38
+ [
39
+ "/system identity set name=#{hostname}",
40
+ "/ip dns set servers=134.17.1.0,134.17.1.1",
41
+ "/ip address add address=#{ap_wifi_ip} interface=ether1",
42
+ "/ip route add dst-address=0.0.0.0/0 gateway=#{ap_wifi_gateway}",
43
+ "/interface bridge add name=bridge_tunnel",
44
+ "/interface eoip add remote-address=#{hub_vip.to_s} tunnel-id=#{tunnel_id.to_s} name=tunnel_to_hub",
45
+ "/interface bridge port add interface=tunnel_to_hub bridge=bridge_tunnel",
46
+ "/interface bridge port add interface=wlan1 bridge=bridge_tunnel",
47
+ "/interface wireless set wlan1 mode=ap-bridge ssid=#{ap_ssid} disabled=no name=wireless_public_interface frequency=2427",
48
+ "/user set admin password=#{ap_admin_password}",
49
+ "/interface wireless set wlan2 disabled=yes"
50
+ ]
51
+
52
+ end
53
+
54
+ end