imperituroard 0.5.1 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/imperituroard.gemspec +27 -14
- data/lib/imperituroard.rb +49 -19
- data/lib/imperituroard/add_functions/logger/any_functions.rb +22 -0
- data/lib/imperituroard/platforms/staros/get_data_ssh.rb +54 -0
- data/lib/imperituroard/platforms/staros/staros_parser.rb +141 -0
- data/lib/imperituroard/projects/dns.rb +1 -1
- data/lib/imperituroard/projects/iot.rb +66 -4
- data/lib/imperituroard/projects/iot/add_functions.rb +27 -27
- data/lib/imperituroard/projects/mhub.rb +12 -6
- data/lib/imperituroard/projects/mhub/infobip.rb +1 -1
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb +2 -0
- data/lib/imperituroard/projects/ukaz60.rb +138 -0
- data/lib/imperituroard/projects/ukaz60/belgim.rb +217 -0
- data/lib/imperituroard/projects/ukaz60/dns.rb +18 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns_update.rb +2 -134
- data/lib/imperituroard/projects/ukaz60/fortigate.rb +187 -0
- data/lib/imperituroard/projects/ukaz60/staros.rb +126 -0
- data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +297 -0
- data/lib/imperituroard/projects/vpn/ezuev_fun/functions_ezuev.rb +29 -0
- data/lib/imperituroard/version.rb +1 -1
- metadata +39 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96222a0e0f14b7abc4ff4d1434d6c55115f07623
|
4
|
+
data.tar.gz: 8d1d4264fa33fec3d27cfb5c7c900c1f293a1112
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c8887a0051b6fb3e7d57d3092ae7ac343f677e32d2e24a2ebaaaf8e54acd15662ad41185d4e2c588a2987001c2c7a5a8fcdc24eb7c65bad6633bdf316f7634b
|
7
|
+
data.tar.gz: 98c743b8d56c5a6b637edeb8f11445664ab30af49625eae7d6d1e76f9fa04cebb9dffb07b30fa16a230b08034a86314c8eac6f93e9981476266c296f73113368
|
data/imperituroard.gemspec
CHANGED
@@ -10,7 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = %q{Gem from imperituroard for different actions}
|
11
11
|
spec.homepage = "https://rubygems.org/"
|
12
12
|
spec.license = "MIT"
|
13
|
-
|
13
|
+
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
14
15
|
|
15
16
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
16
17
|
|
@@ -27,18 +28,30 @@ Gem::Specification.new do |spec|
|
|
27
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
29
|
spec.require_paths = ["lib"]
|
29
30
|
|
30
|
-
spec.add_development_dependency "bundler", "2.1.4"
|
31
|
-
spec.add_development_dependency "rake", "13.0.1"
|
32
|
-
spec.add_development_dependency "net-ssh", '4.0.1'
|
33
|
-
spec.add_development_dependency "mysql2", "0.4.10"
|
34
|
-
spec.add_development_dependency "savon", "2.12.0"
|
35
|
-
spec.add_development_dependency "json", "2.3.0"
|
36
|
-
spec.add_development_dependency "mongo", "2.11.4"
|
37
|
-
spec.add_development_dependency "nokogiri", "1.10.9"
|
38
|
-
spec.add_development_dependency "ipaddr", "1.2.2"
|
39
|
-
spec.add_development_dependency "simpleidn", "0.1.1"
|
40
|
-
spec.add_development_dependency "net-scp", "3.0.0"
|
41
|
-
|
42
|
-
|
31
|
+
# spec.add_development_dependency "bundler", "2.1.4"
|
32
|
+
# spec.add_development_dependency "rake", "13.0.1"
|
33
|
+
# spec.add_development_dependency "net-ssh", '4.0.1'
|
34
|
+
# spec.add_development_dependency "mysql2", "0.4.10"
|
35
|
+
# spec.add_development_dependency "savon", "2.12.0"
|
36
|
+
# spec.add_development_dependency "json", "2.3.0"
|
37
|
+
# spec.add_development_dependency "mongo", "2.11.4"
|
38
|
+
# spec.add_development_dependency "nokogiri", "1.10.9"
|
39
|
+
# spec.add_development_dependency "ipaddr", "1.2.2"
|
40
|
+
# spec.add_development_dependency "simpleidn", "0.1.1"
|
41
|
+
# spec.add_development_dependency "net-scp", "3.0.0"
|
42
|
+
|
43
|
+
spec.add_dependency "bundler", "2.1.4"
|
44
|
+
spec.add_dependency "rake", "13.0.1"
|
45
|
+
spec.add_dependency "net-ssh", '4.0.1'
|
46
|
+
spec.add_dependency "mysql2", "0.4.10"
|
47
|
+
spec.add_dependency "savon", "2.12.0"
|
48
|
+
spec.add_dependency "json", "2.3.0"
|
49
|
+
spec.add_dependency "mongo", "2.11.4"
|
50
|
+
spec.add_dependency "nokogiri", "1.10.9"
|
51
|
+
spec.add_dependency "ipaddr", "1.2.2"
|
52
|
+
spec.add_dependency "simpleidn", "0.1.1"
|
53
|
+
spec.add_dependency "net-scp", "3.0.0"
|
54
|
+
|
55
|
+
spec.add_dependency "rails", "5.2.4.2"
|
43
56
|
|
44
57
|
end
|
data/lib/imperituroard.rb
CHANGED
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift File.expand_path("../projects/mhub/subs/dabrab", __dir__)
|
|
5
5
|
$LOAD_PATH.unshift File.expand_path("../platforms/cps", __dir__)
|
6
6
|
$LOAD_PATH.unshift File.expand_path("../platforms/public", __dir__)
|
7
7
|
$LOAD_PATH.unshift File.expand_path("../projects", __dir__)
|
8
|
+
$LOAD_PATH.unshift File.expand_path("../projects/dns", __dir__)
|
8
9
|
|
9
10
|
|
10
11
|
require "imperituroard/version"
|
@@ -23,6 +24,8 @@ require 'imperituroard/projects/iot'
|
|
23
24
|
require 'imperituroard/projects/dns'
|
24
25
|
require 'imperituroard/platforms/cps/qps_connector'
|
25
26
|
require 'imperituroard/platforms/public/telegram'
|
27
|
+
require 'imperituroard/projects/ukaz60'
|
28
|
+
|
26
29
|
require 'json'
|
27
30
|
require 'ipaddr'
|
28
31
|
require 'date'
|
@@ -194,8 +197,6 @@ class Iot
|
|
194
197
|
end
|
195
198
|
|
196
199
|
|
197
|
-
|
198
|
-
|
199
200
|
#!5 add address to device
|
200
201
|
#login
|
201
202
|
#imei = newdevice_list
|
@@ -254,7 +255,7 @@ class Iot
|
|
254
255
|
end
|
255
256
|
|
256
257
|
def test111
|
257
|
-
iot_connector.
|
258
|
+
iot_connector.test1278493
|
258
259
|
end
|
259
260
|
|
260
261
|
|
@@ -272,7 +273,7 @@ class Mhub_2
|
|
272
273
|
:static_callback,
|
273
274
|
:crm_connector
|
274
275
|
|
275
|
-
def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password)
|
276
|
+
def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname)
|
276
277
|
@sk_url = sk_url_simple
|
277
278
|
@sk_login = sk_login
|
278
279
|
@sk_password = sk_password
|
@@ -280,13 +281,11 @@ class Mhub_2
|
|
280
281
|
@mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
|
281
282
|
@internal_func = InternalFunc.new
|
282
283
|
@dabrab_connecter = Dabrab.new
|
283
|
-
|
284
284
|
@static_callback = static_callback
|
285
285
|
@crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
|
286
|
-
@mhub_connector = MhubFunctions_2.new(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password)
|
286
|
+
@mhub_connector = MhubFunctions_2.new(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname)
|
287
287
|
end
|
288
288
|
|
289
|
-
|
290
289
|
#{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}],
|
291
290
|
# "scenarioKey"=>"1", "viber"=>nil, "sms"=>{"text"=>"карточка готова"},
|
292
291
|
# "sendAt"=>"2019-08-15T08:40:00.000", "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports",
|
@@ -296,18 +295,14 @@ class Mhub_2
|
|
296
295
|
# "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports",
|
297
296
|
# "notifyContentType"=>"application/json"}}
|
298
297
|
|
299
|
-
|
300
298
|
def get_send_message(params, ip_src, ip_real, ip_vip)
|
301
299
|
mhub_connector.get_send_message_2(params, ip_src, ip_real, ip_vip)
|
302
300
|
end
|
303
301
|
|
304
|
-
|
305
302
|
def recieve_delivery_report(params, ip_src, ip_real, ip_vip)
|
306
303
|
mhub_connector.rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
|
307
304
|
end
|
308
305
|
|
309
|
-
|
310
|
-
|
311
306
|
end
|
312
307
|
|
313
308
|
|
@@ -334,7 +329,8 @@ end
|
|
334
329
|
|
335
330
|
class Ukaz60Automation_2
|
336
331
|
|
337
|
-
attr_accessor :dns
|
332
|
+
attr_accessor :dns,
|
333
|
+
:ukaz60_func
|
338
334
|
|
339
335
|
def initialize(telegram_api_url,
|
340
336
|
telegram_chat_id,
|
@@ -348,7 +344,26 @@ class Ukaz60Automation_2
|
|
348
344
|
dns_password,
|
349
345
|
belgim_login,
|
350
346
|
belgim_password,
|
351
|
-
belgim_url
|
347
|
+
belgim_url,
|
348
|
+
|
349
|
+
###########for fortigate############
|
350
|
+
ansible_tmp_folder, #folder on fortigate ansible server where url list uploaded
|
351
|
+
local_tmp_directory, #folder on local mashin where script work
|
352
|
+
ansible_ssh_user,
|
353
|
+
ansible_ssh_password,
|
354
|
+
ansible_host, #fortigate ansible server
|
355
|
+
url_backup_dir,
|
356
|
+
####################################
|
357
|
+
|
358
|
+
#########for STAROS#############
|
359
|
+
staros_login,
|
360
|
+
staros_password,
|
361
|
+
ukaz60_http_groups,
|
362
|
+
ukaz60_https_groups,
|
363
|
+
staros_hosts
|
364
|
+
|
365
|
+
)
|
366
|
+
=begin
|
352
367
|
@ukaz69_dns_func = Dns_2.new(telegram_api_url,
|
353
368
|
telegram_chat_id,
|
354
369
|
work_directory,
|
@@ -362,14 +377,29 @@ class Ukaz60Automation_2
|
|
362
377
|
belgim_login,
|
363
378
|
belgim_password,
|
364
379
|
belgim_url)
|
380
|
+
=end
|
381
|
+
|
382
|
+
@ukaz60_func = Ukaz60All_2.new(telegram_api_url,
|
383
|
+
telegram_chat_id,
|
384
|
+
belgim_login,
|
385
|
+
belgim_password,
|
386
|
+
belgim_url,
|
387
|
+
ansible_tmp_folder,
|
388
|
+
local_tmp_directory,
|
389
|
+
ansible_ssh_user,
|
390
|
+
ansible_ssh_password,
|
391
|
+
ansible_host,
|
392
|
+
url_backup_dir,
|
393
|
+
staros_login,
|
394
|
+
staros_password,
|
395
|
+
ukaz60_http_groups,
|
396
|
+
ukaz60_https_groups,
|
397
|
+
staros_hosts)
|
365
398
|
end
|
366
399
|
|
367
|
-
|
368
|
-
def
|
369
|
-
|
400
|
+
#1 block all devices by belgim list
|
401
|
+
def no_pasaran
|
402
|
+
ukaz60_func.no_pasaran
|
370
403
|
end
|
371
404
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
405
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'json'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
|
7
|
+
class LogAddFunctions_2
|
8
|
+
|
9
|
+
|
10
|
+
def datetimenow()
|
11
|
+
d_curr = DateTime.now
|
12
|
+
time_zone = 'Europe/Minsk'
|
13
|
+
DateTime.now.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
def printer_texter(text, log_level)
|
17
|
+
mess = {:datetime => datetimenow, :sdk => "imperituroard", :sdk_version => Imperituroard::VERSION, :message => text}
|
18
|
+
p mess
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
|
3
|
+
require 'imperituroard/platforms/staros/staros_parser'
|
4
|
+
|
5
|
+
class StarosGet_2
|
6
|
+
|
7
|
+
attr_accessor :staros_parser, :staros_login, :staros_password
|
8
|
+
|
9
|
+
def initialize(staros_login, staros_password)
|
10
|
+
@staros_parser = StarosParser_2.new
|
11
|
+
@staros_login = staros_login
|
12
|
+
@staros_password = staros_password
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
#get all active-charging data
|
17
|
+
#host - staros device IP address
|
18
|
+
#return parsed ECS configuration in JSON
|
19
|
+
def get_all_active_charging(host_ip)
|
20
|
+
|
21
|
+
input_data = {:host_ip => host_ip}
|
22
|
+
out_data = {}
|
23
|
+
config_all = []
|
24
|
+
|
25
|
+
begin
|
26
|
+
|
27
|
+
Net::SSH.start(host_ip, staros_login, :password => staros_password) do |ssh|
|
28
|
+
staros_answer = ssh.exec!("show configuration active-charging service all")
|
29
|
+
staros_answer = staros_answer.gsub("#exit", "exit")
|
30
|
+
#staros_answer = staros_answer.gsub("\n", " ")
|
31
|
+
#p staros_answer
|
32
|
+
#host_pool_regexp = /(host-pool.+\s+exit)/
|
33
|
+
#fff = staros_answer.scan(host_pool_regexp)
|
34
|
+
#p fff
|
35
|
+
|
36
|
+
staros_answer = staros_answer.split("\n")
|
37
|
+
for ttt in staros_answer
|
38
|
+
regexp_full_command = /\s+(.+)/
|
39
|
+
group_ruled_ukaz60_9 = ttt.match(regexp_full_command)
|
40
|
+
if group_ruled_ukaz60_9 != nil
|
41
|
+
config_all.push(group_ruled_ukaz60_9[1])
|
42
|
+
else
|
43
|
+
config_all.push(ttt)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
staros_json = staros_parser.ecs_config_parser(config_all)
|
48
|
+
out_data = {:code => 200, :result => "Successfully completed", :parsed_data => staros_json}
|
49
|
+
rescue
|
50
|
+
out_data = {:code => 507, :result => "get_all_active_charging: Unknown SDK error"}
|
51
|
+
end
|
52
|
+
out_data
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
class StarosParser_2
|
2
|
+
|
3
|
+
|
4
|
+
#parser for staros ECS configuration
|
5
|
+
def ecs_config_parser(config_string_array)
|
6
|
+
|
7
|
+
out_ans = {}
|
8
|
+
parsed_config = {"config" => {"active-charging service" => []}}
|
9
|
+
config_string_array.shift
|
10
|
+
|
11
|
+
# {"config" => {"active-charging service" => [{"ECS-SVC" => {"root" => [], "host-pool"=>{"1b1.nekurims.top"=>["ip 185.59.101.182/32"]}, "ruledef"=>{"VKONTAKTE_CDN_b"=>[]}}}}]}
|
12
|
+
|
13
|
+
flag_inter_ecs_name = 0
|
14
|
+
current_ecs_name = ""
|
15
|
+
current_section = "root"
|
16
|
+
current_section_name = ""
|
17
|
+
section_flag = 0
|
18
|
+
section_deep = 0
|
19
|
+
ecs_number = 0
|
20
|
+
for aaa in config_string_array
|
21
|
+
if section_deep == 0 && aaa[0..22] == "active-charging service" #&& flag_inter_ecs_name == 0
|
22
|
+
ecs_name_regexp = /active-charging service (\S+)/
|
23
|
+
current_ecs_name = aaa.match(ecs_name_regexp)[1]
|
24
|
+
#p current_ecs_name
|
25
|
+
parsed_config["config"]["active-charging service"].push({current_ecs_name => {"root" => [],
|
26
|
+
"host-pool" => {},
|
27
|
+
"port-map" => {},
|
28
|
+
"ruledef" => {},
|
29
|
+
"access-ruledef" => {},
|
30
|
+
"group-of-ruledefs" => {},
|
31
|
+
"packet-filter" => {},
|
32
|
+
"edr-format" => {},
|
33
|
+
"xheader-format" => {},
|
34
|
+
"charging-action" => {},
|
35
|
+
"rulebase" => {},
|
36
|
+
"fw-and-nat policy" => {}
|
37
|
+
}})
|
38
|
+
flag_inter_ecs_name = 1
|
39
|
+
section_deep = 1
|
40
|
+
current_section = "root"
|
41
|
+
else
|
42
|
+
if aaa == "exit" && section_deep == 2
|
43
|
+
section_flag = 0
|
44
|
+
section_deep = section_deep - 1
|
45
|
+
current_section = "root"
|
46
|
+
elsif aaa[0..9] == "host-pool " && section_flag == 0 && section_deep == 1
|
47
|
+
current_section = "host-pool"
|
48
|
+
ecs_hostpool_regexp = /host-pool\s+(.+)/
|
49
|
+
current_section_name = aaa.match(ecs_hostpool_regexp)[1]
|
50
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
51
|
+
section_flag = 1
|
52
|
+
section_deep = section_deep + 1
|
53
|
+
elsif aaa[0..8] == "port-map " && section_flag == 0 && section_deep == 1
|
54
|
+
current_section = "port-map"
|
55
|
+
ecs_portmap_regexp = /port-map\s+(.+)/
|
56
|
+
current_section_name = aaa.match(ecs_portmap_regexp)[1]
|
57
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
58
|
+
section_flag = 1
|
59
|
+
section_deep = section_deep + 1
|
60
|
+
elsif aaa[0..7] == "ruledef " && section_flag == 0 && section_deep == 1
|
61
|
+
current_section = "ruledef"
|
62
|
+
ecs_ruldef_regexp = /ruledef\s+(.+)/
|
63
|
+
current_section_name = aaa.match(ecs_ruldef_regexp)[1]
|
64
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
65
|
+
section_flag = 1
|
66
|
+
section_deep = section_deep + 1
|
67
|
+
elsif aaa[0..14] == "access-ruledef " && section_flag == 0 && section_deep == 1
|
68
|
+
current_section = "access-ruledef"
|
69
|
+
ecs_accruldef_regexp = /access-ruledef\s+(.+)/
|
70
|
+
current_section_name = aaa.match(ecs_accruldef_regexp)[1]
|
71
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
72
|
+
section_flag = 1
|
73
|
+
section_deep = section_deep + 1
|
74
|
+
elsif aaa[0..17] == "group-of-ruledefs " && section_flag == 0 && section_deep == 1
|
75
|
+
current_section = "group-of-ruledefs"
|
76
|
+
ecs_grruldef_regexp = /group-of-ruledefs\s+(.+)/
|
77
|
+
current_section_name = aaa.match(ecs_grruldef_regexp)[1]
|
78
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
79
|
+
section_flag = 1
|
80
|
+
section_deep = section_deep + 1
|
81
|
+
elsif aaa[0..13] == "packet-filter " && section_flag == 0 && section_deep == 1
|
82
|
+
current_section = "packet-filter"
|
83
|
+
ecs_packfil_regexp = /packet-filter\s+(.+)/
|
84
|
+
current_section_name = aaa.match(ecs_packfil_regexp)[1]
|
85
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
86
|
+
section_flag = 1
|
87
|
+
section_deep = section_deep + 1
|
88
|
+
elsif aaa[0..10] == "edr-format " && section_flag == 0 && section_deep == 1
|
89
|
+
current_section = "edr-format"
|
90
|
+
ecs_edrformat_regexp = /edr-format\s+(.+)/
|
91
|
+
current_section_name = aaa.match(ecs_edrformat_regexp)[1]
|
92
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
93
|
+
section_flag = 1
|
94
|
+
section_deep = section_deep + 1
|
95
|
+
elsif aaa[0..14] == "xheader-format " && section_flag == 0 && section_deep == 1
|
96
|
+
current_section = "xheader-format"
|
97
|
+
ecs_xheader_regexp = /xheader-format\s+(.+)/
|
98
|
+
current_section_name = aaa.match(ecs_xheader_regexp)[1]
|
99
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
100
|
+
section_flag = 1
|
101
|
+
section_deep = section_deep + 1
|
102
|
+
elsif aaa[0..15] == "charging-action " && section_flag == 0 && section_deep == 1
|
103
|
+
current_section = "charging-action"
|
104
|
+
ecs_xheader_regexp = /charging-action\s+(.+)/
|
105
|
+
current_section_name = aaa.match(ecs_xheader_regexp)[1]
|
106
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
107
|
+
section_flag = 1
|
108
|
+
section_deep = section_deep + 1
|
109
|
+
elsif aaa[0..8] == "rulebase " && section_flag == 0 && section_deep == 1
|
110
|
+
current_section = "rulebase"
|
111
|
+
ecs_xheader_regexp = /rulebase\s+(.+)/
|
112
|
+
current_section_name = aaa.match(ecs_xheader_regexp)[1]
|
113
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
114
|
+
section_flag = 1
|
115
|
+
section_deep = section_deep + 1
|
116
|
+
elsif aaa[0..17] == "fw-and-nat policy " && section_flag == 0 && section_deep == 1
|
117
|
+
current_section = "fw-and-nat policy"
|
118
|
+
ecs_xheader_regexp = /fw-and-nat policy\s+(.+)/
|
119
|
+
current_section_name = aaa.match(ecs_xheader_regexp)[1]
|
120
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name] = []
|
121
|
+
section_flag = 1
|
122
|
+
section_deep = section_deep + 1
|
123
|
+
elsif section_flag == 1 && current_section != "root" && current_section != "end" && section_deep == 2
|
124
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name][current_section][current_section_name].push(aaa)
|
125
|
+
elsif current_section == "root" && section_deep == 1 && aaa != "end"
|
126
|
+
parsed_config["config"]["active-charging service"][ecs_number][current_ecs_name]["root"].push(aaa)
|
127
|
+
elsif aaa == "end"
|
128
|
+
section_flag = 0
|
129
|
+
section_deep = 0
|
130
|
+
current_section = "end"
|
131
|
+
p "end"
|
132
|
+
else
|
133
|
+
p aaa
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
parsed_config
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
@@ -86,6 +86,9 @@ class IotFunctions_2
|
|
86
86
|
|
87
87
|
for ss in list_checked[:body][:exists]
|
88
88
|
not_processed_list.append({:imei => ss, :error => "Device exists in database"})
|
89
|
+
p ss
|
90
|
+
p "ss"
|
91
|
+
p list_checked
|
89
92
|
end
|
90
93
|
|
91
94
|
for jj in list_checked[:body][:not_exists]
|
@@ -686,6 +689,7 @@ class IotFunctions_2
|
|
686
689
|
|
687
690
|
|
688
691
|
#7 procedure for subscriber autorization
|
692
|
+
# save data to mongodb
|
689
693
|
def autorize_subscriber_2(login, password)
|
690
694
|
input_json = {:login => login, :password => password}
|
691
695
|
resp_out = {}
|
@@ -717,6 +721,7 @@ class IotFunctions_2
|
|
717
721
|
end
|
718
722
|
|
719
723
|
|
724
|
+
#8 get available profiles by login
|
720
725
|
def get_available_prof_2(login)
|
721
726
|
|
722
727
|
input_params = {:login => login}
|
@@ -767,7 +772,7 @@ class IotFunctions_2
|
|
767
772
|
resp_out
|
768
773
|
end
|
769
774
|
|
770
|
-
|
775
|
+
#9 get available device types by login
|
771
776
|
def get_available_types_2(login)
|
772
777
|
|
773
778
|
input_params = {:login => login}
|
@@ -824,7 +829,64 @@ class IotFunctions_2
|
|
824
829
|
end
|
825
830
|
|
826
831
|
|
827
|
-
#10 get
|
832
|
+
#10 get available device types by login and profile. procedure update
|
833
|
+
def get_available_types2_2(login, profile)
|
834
|
+
|
835
|
+
input_params = {:login => login}
|
836
|
+
resp_out = {}
|
837
|
+
|
838
|
+
begin
|
839
|
+
data_processed = []
|
840
|
+
data_soapgw = []
|
841
|
+
login_info = mongo_client.get_login_inf2_select(login)
|
842
|
+
if login_info[:code]==200
|
843
|
+
|
844
|
+
permit_profiles = login_info[:body]["permit_profiles"]
|
845
|
+
permit_types = login_info[:body]["permit_types"]
|
846
|
+
|
847
|
+
data_from_mongo = mongo_client.get_type_list_by_id(permit_types)
|
848
|
+
|
849
|
+
for ff in data_from_mongo
|
850
|
+
data_processed.append({:type_id => ff["type_id"],
|
851
|
+
:description => ff["description"],
|
852
|
+
:note => ff["note"],
|
853
|
+
:form => ff["form"],
|
854
|
+
:ManufacturerID => ff["ManufacturerID"],
|
855
|
+
:ManufacturerNAME => ff["ManufacturerNAME"],
|
856
|
+
:device_type => ff["device_type"],
|
857
|
+
:model => ff["model"],
|
858
|
+
:info => ff["info"]
|
859
|
+
})
|
860
|
+
data_soapgw.append({:name => ff["model"], :form => ff["form"], :description => ff["description"], :type_id => ff["type_id"]})
|
861
|
+
end
|
862
|
+
|
863
|
+
tosoapgw = {:code => 200,
|
864
|
+
:result => "Request completed successfully",
|
865
|
+
:types => data_soapgw
|
866
|
+
}
|
867
|
+
|
868
|
+
resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
|
869
|
+
else
|
870
|
+
tosoapgw = {:code => login_info[:code],
|
871
|
+
:result => login_info[:result],
|
872
|
+
:types => data_soapgw
|
873
|
+
}
|
874
|
+
resp_out = {:code => login_info[:code], :result => login_info[:result], :body => {:tosoapgw => tosoapgw}}
|
875
|
+
end
|
876
|
+
|
877
|
+
rescue
|
878
|
+
tosoapgw = {:code => 507,
|
879
|
+
:result => "Unknown SDK error",
|
880
|
+
:types => data_soapgw
|
881
|
+
}
|
882
|
+
resp_out = {:code => 507, :result => "Unknown SDK error", :body => {:tosoapgw => tosoapgw}}
|
883
|
+
end
|
884
|
+
mongo_client.audit_logger("get_available_types_2", remote_ip, input_params, resp_out, real_ip)
|
885
|
+
resp_out
|
886
|
+
end
|
887
|
+
|
888
|
+
|
889
|
+
#11 get info for device type
|
828
890
|
def get_info_data_type_2(type)
|
829
891
|
|
830
892
|
input_params = {:type => type}
|
@@ -854,7 +916,7 @@ class IotFunctions_2
|
|
854
916
|
end
|
855
917
|
|
856
918
|
|
857
|
-
#
|
919
|
+
#12 get info for profile
|
858
920
|
def get_info_data_profile_2(profile)
|
859
921
|
|
860
922
|
input_params = {:profile => profile}
|
@@ -975,7 +1037,7 @@ class IotFunctions_2
|
|
975
1037
|
end
|
976
1038
|
|
977
1039
|
|
978
|
-
def
|
1040
|
+
def test1278493
|
979
1041
|
#ddd = MongoIot.new(mongoip, mongoport, mongo_database)
|
980
1042
|
#ddd.get_profiles_by_login("test")
|
981
1043
|
|