imperituroard 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96222a0e0f14b7abc4ff4d1434d6c55115f07623
4
- data.tar.gz: 8d1d4264fa33fec3d27cfb5c7c900c1f293a1112
3
+ metadata.gz: dec8fb3791d83727a6bfd54fc71889481af42b42
4
+ data.tar.gz: 583739817cad732740861c08845910e849770b55
5
5
  SHA512:
6
- metadata.gz: 3c8887a0051b6fb3e7d57d3092ae7ac343f677e32d2e24a2ebaaaf8e54acd15662ad41185d4e2c588a2987001c2c7a5a8fcdc24eb7c65bad6633bdf316f7634b
7
- data.tar.gz: 98c743b8d56c5a6b637edeb8f11445664ab30af49625eae7d6d1e76f9fa04cebb9dffb07b30fa16a230b08034a86314c8eac6f93e9981476266c296f73113368
6
+ metadata.gz: 27b131265896d1793261ea994a011e436171f6d5e74bc0c11a4d2e7039545a715ca693be6faab217e321d52e41ae92a6488fb00027c9c2a3beab8fc24b4f198b
7
+ data.tar.gz: c5d72b86f1168829d5287c14120f70705a1bfb317ee896071d84b161a0a6b2ec3495a3e3c525a2e1aa2aa0a7d530c78f76c8d790dfe0a290a9c56401a7d9f71e
Binary file
Binary file
@@ -0,0 +1,95 @@
1
+ require 'net/ssh'
2
+
3
+ staros_thr_1233 = []
4
+ conf = {}
5
+
6
+ staros_hosts = {
7
+ #5700
8
+ }
9
+
10
+ def printer (config)
11
+ for gggg1 in config
12
+
13
+ p ""
14
+ p ""
15
+ p "##{gggg1[0]}"
16
+ for jjj in gggg1[1]
17
+ p jjj
18
+ end
19
+ end
20
+ end
21
+
22
+ staros_hosts.each do |ggsn|
23
+ staros_thr_1233 << Thread.new do
24
+
25
+ p ggsn
26
+
27
+ begin
28
+
29
+ conf[ggsn[0]] = []
30
+
31
+ Net::SSH.start(ggsn[1], "ывапывап", :password => "пыапыва") do |ssh|
32
+ staros_answer = ssh.exec!("show configuration context Ga | grep edr")
33
+
34
+ regexp = /file name (\S+) rotation volume (\d+) rotation time \d+ storage-limit \d+ headers edr-format-name compression gzip file-sequence-number rulebase-seq-num/
35
+
36
+ ggg = staros_answer.match(regexp)
37
+ conf[ggsn[0]].push("configure")
38
+ conf[ggsn[0]].push("context Ga")
39
+ conf[ggsn[0]].push("edr-module active-charging-service charging")
40
+ conf[ggsn[0]].push("file name #{ggg[1]} rotation volume 40000000 rotation time 600 storage-limit 536870912 headers edr-format-name compression gzip file-sequence-number rulebase-seq-num")
41
+ conf[ggsn[0]].push("end")
42
+
43
+ #config
44
+ # staros_answer1 = ssh.exec!("configure")
45
+ # p staros_answer1
46
+ # staros_answer2 = ssh.exec!("context Ga")
47
+ # p staros_answer2
48
+ # staros_answer3 = ssh.exec!("edr-module active-charging-service charging")
49
+ # p staros_answer3
50
+ # staros_answer4 = ssh.exec!("file name #{ggg[1]} rotation volume 40000000 rotation time 600 storage-limit 536870912 headers edr-format-name compression gzip file-sequence-number rulebase-seq-num")
51
+ # p staros_answer4
52
+ # staros_answer5 = ssh.exec!("end")
53
+ # p staros_answer5
54
+
55
+ #check
56
+ staros_answer7 = ssh.exec!("show configuration | grep hostname")
57
+ reggg = /system hostname (\S+)/
58
+ hostname_this = staros_answer7.match(reggg)[1]
59
+
60
+ staros_answer8 = ssh.exec!("show configuration context Ga | grep edr")
61
+ regexp2 = /file name (\S+) rotation volume (\d+) rotation time \d+ storage-limit \d+ headers edr-format-name compression gzip file-sequence-number rulebase-seq-num/
62
+
63
+ ggg2 = staros_answer8.match(regexp2)
64
+
65
+ a1 = ggg2[1].gsub("edr-", "")
66
+ #p a1
67
+ #p hostname_this
68
+ #p ggg2
69
+
70
+ if a1 != hostname_this
71
+ p "incorrect: #{hostname_this}"
72
+ end
73
+
74
+
75
+ if ggg2[2] == "40000000"
76
+ else
77
+ p "incorrect value: #{hostname_this}"
78
+ end
79
+
80
+ end
81
+
82
+ rescue
83
+
84
+ p "#{ggsn[0]} ERROR"
85
+
86
+ end
87
+
88
+ end
89
+ end
90
+ staros_thr_1233.each(&:join)
91
+
92
+ #p conf
93
+
94
+
95
+ #printer(conf)
@@ -0,0 +1,37 @@
1
+ require 'net/ssh'
2
+
3
+ class StarosAutomationFun
4
+
5
+ attr_accessor :ignore_y
6
+
7
+ def initialize
8
+ @ignore_y = 1 #1-yes, 0-no
9
+ end
10
+
11
+ def staros_massive_command(staros_hosts, staros_login, staros_password, command_array)
12
+
13
+
14
+ staros_thr_pool_222 = []
15
+
16
+ staros_hosts.each do |ggsn|
17
+ staros_thr_pool_222 << Thread.new do
18
+
19
+ Net::SSH.start(ggsn[1], staros_login, :password => staros_password) do |session|
20
+
21
+ gg = session.exec!("context AAA")
22
+ p gg
23
+ gg1 = session.exec!("show subscribers summary")
24
+ p gg1
25
+
26
+
27
+
28
+ end
29
+
30
+
31
+
32
+ end
33
+ end
34
+ staros_thr_pool_222.each(&:join)
35
+
36
+ end
37
+ end
@@ -51,6 +51,7 @@ class MhubFunctions_2
51
51
  # "notifyContentType"=>"application/json"}}
52
52
 
53
53
 
54
+ #for bank dabrabyt
54
55
  def get_send_message_2(params, ip_src, ip_real, ip_vip)
55
56
 
56
57
  input_params = {:params => params}
@@ -123,6 +124,7 @@ class MhubFunctions_2
123
124
  end
124
125
 
125
126
 
127
+ #for bank dabrabyt
126
128
  def rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
127
129
  input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip}
128
130
  output_params = {}
@@ -1,8 +1,9 @@
1
1
  require 'imperituroard/projects/iot/internal_functions'
2
+ require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
2
3
 
3
4
  class Sksk_2
4
5
 
5
- attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector
6
+ attr_accessor :sk_url, :sk_url_broadcast, :sk_login, :sk_password, :internal_func, :telegram_connector, :dabrab_add_func
6
7
 
7
8
  def initialize(sk_url, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
8
9
  @sk_url = sk_url
@@ -11,6 +12,7 @@ class Sksk_2
11
12
  @internal_func = InternalFunc.new
12
13
  @sk_url_broadcast = sk_url_broadcast
13
14
  @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
15
+ @dabrab_add_func = Dabrab.new
14
16
  end
15
17
 
16
18
 
@@ -82,50 +84,49 @@ class Sksk_2
82
84
  request_message = {}
83
85
 
84
86
  begin
85
-
86
87
  thr_sk_send_viber_one = Thread.new do
88
+ viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(text)
89
+
90
+ if viber_mess_ans[:code] == 200
91
+ uri = URI(sk_url)
92
+ #8 - client id
93
+
94
+ https = Net::HTTP.new(uri.host, uri.port)
95
+ https.use_ssl=true
96
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
97
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
98
+
99
+ req.basic_auth sk_login, sk_password
100
+
101
+ req["Content-Type"] = "application/json"
102
+ req["Accept"] = "application/json"
103
+
104
+ request_message = {
105
+ "phone_number": msisdn,
106
+ #"extra_id": "4232j4h89932kjhs",
107
+ "callback_url": callback_url,
108
+ #"start_time": "2019-08-16 09:59:10",
109
+ "tag": "Dabrab_custom_api_1",
110
+ "channels": [
111
+ "viber"
112
+ ],
113
+ "channel_options": {
114
+ "viber": viber_mess_ans[:body][:to_sk_format]
115
+ }
116
+ }
117
+ req.body = request_message.to_json
118
+ res = https.request(req)
119
+ output_params = {:code => 200,
120
+ :result => "Sksk_2.sk_send_viber_one: Request processed",
121
+ :body => {:request_message => request_message,
122
+ :res_code => res.code,
123
+ :res_body => JSON.parse(res.body.to_s)}}
124
+
125
+ else
126
+ output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_one: Something wrong with dabrabyt_text_field_parse"}
127
+ end
87
128
 
88
129
 
89
- uri = URI(sk_url)
90
- #8 - client id
91
-
92
- https = Net::HTTP.new(uri.host, uri.port)
93
- https.use_ssl=true
94
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
95
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
96
-
97
- req.basic_auth sk_login, sk_password
98
-
99
- req["Content-Type"] = "application/json"
100
- req["Accept"] = "application/json"
101
-
102
- request_message = {
103
- "phone_number": msisdn,
104
- #"extra_id": "4232j4h89932kjhs",
105
- "callback_url": callback_url,
106
- #"start_time": "2019-08-16 09:59:10",
107
- "tag": "Dabrab_custom_api_1",
108
- "channels": [
109
- "viber"
110
- ],
111
- "channel_options": {
112
- "viber": {
113
- "text": text,
114
- "ttl": 60,
115
- # "img": "http://olddogs.org/logo.png",
116
- # "caption": "Old Dogs need you!",
117
- # "action": "http://olddogs.org",
118
- },
119
- }
120
- }
121
- req.body = request_message.to_json
122
- res = https.request(req)
123
- output_params = {:code => 200,
124
- :result => "Sksk_2.sk_send_viber_one: Request processed",
125
- :body => {:request_message => request_message,
126
- :res_code => res.code,
127
- :res_body => JSON.parse(res.body.to_s)}}
128
-
129
130
  end
130
131
 
131
132
  thr_sk_send_viber_one.join
@@ -149,53 +150,54 @@ class Sksk_2
149
150
 
150
151
  thr_sk_send_viber_sms_one = Thread.new do
151
152
 
152
- uri = URI(sk_url)
153
- #8 - client id
154
-
155
- https = Net::HTTP.new(uri.host, uri.port)
156
- https.use_ssl=true
157
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
158
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
159
-
160
- req.basic_auth sk_login, sk_password
161
-
162
- req["Content-Type"] = "application/json"
163
- req["Accept"] = "application/json"
164
-
165
- request_message = {
166
- "phone_number": msisdn,
167
- #"extra_id": "4232j4h89932kjhs",
168
- "callback_url": callback_url,
169
- #"start_time": "2019-08-16 09:59:10",
170
- "tag": "Dabrab_custom_api_1",
171
- "channels": [
172
- "viber",
173
- "sms"
174
- ],
175
- "channel_options": {
176
- "sms": {
177
- "text": sms_text,
178
- "alpha_name": alphaname,
179
- "ttl": 600
180
- },
181
- "viber": {
182
- "text": viber_txt,
183
- "ttl": 60,
184
- # "img": "http://olddogs.org/logo.png",
185
- # "caption": "Old Dogs need you!",
186
- # "action": "http://olddogs.org",
187
- },
188
- }
189
- }
190
-
191
- req.body = request_message.to_json
192
- res = https.request(req)
193
-
194
- output_params = {:code => 200,
195
- :result => "Sksk_2.sk_send_viber_sms_one: Request processed",
196
- :body => {:request_message => request_message,
197
- :res_code => res.code,
198
- :res_body => JSON.parse(res.body.to_s)}}
153
+ viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_txt)
154
+
155
+ if viber_mess_ans[:code] == 200
156
+ uri = URI(sk_url)
157
+ #8 - client id
158
+
159
+ https = Net::HTTP.new(uri.host, uri.port)
160
+ https.use_ssl=true
161
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
162
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
163
+
164
+ req.basic_auth sk_login, sk_password
165
+
166
+ req["Content-Type"] = "application/json"
167
+ req["Accept"] = "application/json"
168
+
169
+ request_message = {
170
+ "phone_number": msisdn,
171
+ #"extra_id": "4232j4h89932kjhs",
172
+ "callback_url": callback_url,
173
+ #"start_time": "2019-08-16 09:59:10",
174
+ "tag": "Dabrab_custom_api_1",
175
+ "channels": [
176
+ "viber",
177
+ "sms"
178
+ ],
179
+ "channel_options": {
180
+ "sms": {
181
+ "text": sms_text,
182
+ "alpha_name": alphaname,
183
+ "ttl": 600
184
+ },
185
+ "viber": viber_mess_ans[:body][:to_sk_format]
186
+ }
187
+ }
188
+
189
+ req.body = request_message.to_json
190
+ res = https.request(req)
191
+
192
+ output_params = {:code => 200,
193
+ :result => "Sksk_2.sk_send_viber_sms_one: Request processed",
194
+ :body => {:request_message => request_message,
195
+ :res_code => res.code,
196
+ :res_body => JSON.parse(res.body.to_s)}}
197
+
198
+ else
199
+ output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_one: Something wrong with dabrabyt_text_field_parse"}
200
+ end
199
201
 
200
202
  end
201
203
 
@@ -281,44 +283,49 @@ class Sksk_2
281
283
  begin
282
284
 
283
285
  thr_sk_send_viber_list = Thread.new do
284
- uri = URI(sk_url_broadcast)
285
- #8 - client id
286
286
 
287
- https = Net::HTTP.new(uri.host, uri.port)
288
- https.use_ssl = true
289
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
290
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
287
+ viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(text)
291
288
 
292
- req["Content-Type"] = "application/json"
293
- req["Accept"] = "application/json"
289
+ if viber_mess_ans[:code] == 200
290
+ uri = URI(sk_url_broadcast)
291
+ #8 - client id
294
292
 
295
- req.basic_auth sk_login, sk_password
293
+ https = Net::HTTP.new(uri.host, uri.port)
294
+ https.use_ssl = true
295
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
296
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
296
297
 
298
+ req["Content-Type"] = "application/json"
299
+ req["Accept"] = "application/json"
297
300
 
298
- # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
299
- request_message = {
300
- "recipients": msisdn_list,
301
- "callback_url": callback_url,
302
- "tag": "Dabrab_custom_api_1",
303
- "channels": [
304
- "viber"
305
- ],
306
- "channel_options": {
307
- "viber": {
308
- "text": text,
309
- "ttl": 60
310
- }
311
- }
312
- }
301
+ req.basic_auth sk_login, sk_password
313
302
 
314
- req.body = request_message.to_json
315
- res = https.request(req)
316
303
 
317
- output_params = {:code => 200,
318
- :result => "Sksk_2.sk_send_viber_list: Request processed",
319
- :body => {:request_message => request_message,
320
- :res_code => res.code,
321
- :res_body => JSON.parse(res.body.to_s)}}
304
+ # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
305
+ request_message = {
306
+ "recipients": msisdn_list,
307
+ "callback_url": callback_url,
308
+ "tag": "Dabrab_custom_api_1",
309
+ "channels": [
310
+ "viber"
311
+ ],
312
+ "channel_options": {
313
+ "viber": viber_mess_ans[:body][:to_sk_format]
314
+ }
315
+ }
316
+
317
+ req.body = request_message.to_json
318
+ res = https.request(req)
319
+
320
+ output_params = {:code => 200,
321
+ :result => "Sksk_2.sk_send_viber_list: Request processed",
322
+ :body => {:request_message => request_message,
323
+ :res_code => res.code,
324
+ :res_body => JSON.parse(res.body.to_s)}}
325
+ else
326
+ output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_list: Something wrong with dabrabyt_text_field_parse"}
327
+ end
328
+
322
329
  end
323
330
  thr_sk_send_viber_list.join
324
331
  rescue
@@ -337,50 +344,57 @@ class Sksk_2
337
344
 
338
345
  begin
339
346
  thr_sk_send_viber_sms_list = Thread.new do
340
- uri = URI(sk_url_broadcast)
341
- #8 - client id
342
347
 
343
- https = Net::HTTP.new(uri.host, uri.port)
344
- https.use_ssl = true
345
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
346
- req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
348
+ viber_mess_ans = dabrab_add_func.dabrabyt_text_field_parse(viber_text)
347
349
 
348
- req.basic_auth sk_login, sk_password
350
+ if viber_mess_ans[:code] == 200
349
351
 
352
+ uri = URI(sk_url_broadcast)
353
+ #8 - client id
350
354
 
351
- req["Content-Type"] = "application/json"
352
- req["Accept"] = "application/json"
355
+ https = Net::HTTP.new(uri.host, uri.port)
356
+ https.use_ssl = true
357
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
358
+ req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
353
359
 
354
- # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
355
- request_message = {
356
- "recipients": msisdn_list,
357
- "callback_url": callback_url,
358
- "tag": "Dabrab_custom_api_1",
359
- "channels": [
360
- "viber",
361
- "sms"
362
- ],
363
- "channel_options": {
364
- "sms": {
365
- "alpha_name": alphaname,
366
- "text": sms_text,
367
- "ttl": 60
368
- },
369
- "viber": {
370
- "text": viber_text,
371
- "ttl": 60
372
- }
373
- }
374
- }
360
+ req.basic_auth sk_login, sk_password
375
361
 
376
- req.body = request_message.to_json
377
- res = https.request(req)
378
362
 
379
- output_params = {:code => 200,
380
- :result => "Sksk_2.sk_send_viber_sms_list: Request processed",
381
- :body => {:request_message => request_message,
382
- :res_code => res.code,
383
- :res_body => JSON.parse(res.body.to_s)}}
363
+ req["Content-Type"] = "application/json"
364
+ req["Accept"] = "application/json"
365
+
366
+ # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
367
+ request_message = {
368
+ "recipients": msisdn_list,
369
+ "callback_url": callback_url,
370
+ "tag": "Dabrab_custom_api_1",
371
+ "channels": [
372
+ "viber",
373
+ "sms"
374
+ ],
375
+ "channel_options": {
376
+ "sms": {
377
+ "alpha_name": alphaname,
378
+ "text": sms_text,
379
+ "ttl": 60
380
+ },
381
+ "viber": viber_mess_ans[:body][:to_sk_format]
382
+ }
383
+ }
384
+
385
+ req.body = request_message.to_json
386
+ res = https.request(req)
387
+
388
+ output_params = {:code => 200,
389
+ :result => "Sksk_2.sk_send_viber_sms_list: Request processed",
390
+ :body => {:request_message => request_message,
391
+ :res_code => res.code,
392
+ :res_body => JSON.parse(res.body.to_s)}}
393
+
394
+ else
395
+ output_params = {:code => 508, :result => "Sksk_2.sk_send_viber_sms_list: Something wrong with dabrabyt_text_field_parse"}
396
+ end
397
+
384
398
  end
385
399
 
386
400
  thr_sk_send_viber_sms_list.join
@@ -1,5 +1,117 @@
1
1
  class Dabrab
2
2
 
3
+ def dabrabyt_text_field_parse(stri)
4
+ button_url = ""
5
+ image = ""
6
+ button_text = ""
7
+ text = stri
8
+
9
+ #############
10
+ #0 - Text only
11
+ #1 - Text + Button
12
+ #2 - Text + Image + Button
13
+ #3 - image only
14
+ #############
15
+ scheme = 0
16
+ scheme_dic = {0 => "Text only", 1 => "Text+Button", 2 => "Text+Image+Button", 3 => "Image only"}
17
+ #############
18
+
19
+ output_answer = {}
20
+ sk_format = {}
21
+
22
+ begin
23
+
24
+ regexp_image1 = /(image:(\S+)[\s\n]?)/
25
+ button_url1 = /(button_url:(\S+)[\s\n]?)/
26
+ button_text1 = /(button_text:["']([^"]+)["'][\s\n])/
27
+
28
+ button_url_dat = stri.scan(button_url1)
29
+ button_text_dat = stri.scan(button_text1)
30
+ image_dat = stri.scan(regexp_image1)
31
+
32
+
33
+ p button_url_dat
34
+ p button_text_dat
35
+ p image_dat
36
+
37
+ begin
38
+ if button_url_dat != [] && button_url_dat != nil && button_url_dat != ""
39
+ button_url = button_url_dat[0][1]
40
+ text = text.gsub(button_url_dat[0][0], "")
41
+ end
42
+ rescue
43
+ nil
44
+ end
45
+
46
+ begin
47
+ if button_text_dat != [] && button_text_dat != nil && button_text_dat != ""
48
+ button_text = button_text_dat[0][1]
49
+ text = text.gsub(button_text_dat[0][0], "")
50
+ end
51
+ rescue
52
+ nil
53
+ end
54
+
55
+ begin
56
+ if image_dat != [] && image_dat != nil && image_dat != ""
57
+ image = image_dat[0][1]
58
+ text = text.gsub(image_dat[0][0], "")
59
+ end
60
+ rescue
61
+ nil
62
+ end
63
+ text = text.gsub(/\s+$/, '').gsub(/\n$/, '')
64
+
65
+
66
+ if button_url != "" && button_text != "" && image != "" #111
67
+ scheme = 2
68
+ elsif button_url != "" && button_text != "" && image == "" #110
69
+ scheme = 1
70
+ elsif button_url == "" && button_text == "" && image != "" #001
71
+ if text == ""
72
+ scheme = 3
73
+ else
74
+ scheme = 2
75
+ button_url = image
76
+ button_text = "Открыть"
77
+ end
78
+ elsif button_url != "" && button_text == "" && image != "" #101
79
+ scheme = 2
80
+ button_text = "Открыть"
81
+ elsif button_url == "" && button_text != "" && image != "" #011
82
+ scheme = 2
83
+ button_url = image
84
+ elsif button_url == "" && button_text != "" && image == "" #010
85
+ scheme = 0
86
+ elsif button_url != "" && button_text == "" && image == "" #100
87
+ button_text = "Открыть"
88
+ scheme = 1
89
+ else
90
+ scheme = 0
91
+ end
92
+
93
+ if scheme==0
94
+ sk_format = {"text": text, "ttl": 60}
95
+ elsif scheme==1
96
+ sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url}
97
+ elsif scheme==2
98
+ sk_format = {"text": text, "ttl": 60, "caption": button_text, "action": button_url, "img": image}
99
+ elsif scheme==3
100
+ sk_format = {"img": image, "ttl": 60}
101
+ else
102
+ nil
103
+ end
104
+
105
+ p sk_format
106
+
107
+ output_answer ={:code => 200, :result => "Success", :body => {:to_sk_format => sk_format, :button_url => button_url, :image => image, :button_text => button_text, :text => text, :scheme => scheme, :scheme_dic => scheme_dic[scheme]}}
108
+ rescue
109
+ output_answer ={:code => 507, :result => "dabrabyt_text_field_parse: Unknown error"}
110
+ end
111
+ output_answer
112
+ end
113
+
114
+
3
115
  def num_formatter(infobip_msisdn, extra_id)
4
116
  #[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}]
5
117
  # [{"phone_number": 375298766719}, {"phone_number": 375295730878}]
@@ -50,20 +162,20 @@ class Dabrab
50
162
  status1 = {}
51
163
  if a["processed"] == true && a["accepted"] == true
52
164
  status1 = {"to": {"phoneNumber": a["phone_number"]},
53
- "status": {"groupId": 1,
54
- "groupName": "PENDING",
55
- "id": 26,
56
- "name": "MESSAGE_ACCEPTED",
57
- "description": "Message sent to next instance"},
58
- "messageId": a["message_id"]}
165
+ "status": {"groupId": 1,
166
+ "groupName": "PENDING",
167
+ "id": 26,
168
+ "name": "MESSAGE_ACCEPTED",
169
+ "description": "Message sent to next instance"},
170
+ "messageId": a["message_id"]}
59
171
  else
60
172
  status1 = {"to": {"phoneNumber": a["phone_number"]},
61
- "status": {"groupId": 5,
62
- "groupName": "REJECTED",
63
- "id": 21,
64
- "name": "REJECTED_SYSTEM_ERROR",
65
- "description": "Unknown error"},
66
- "messageId": a["message_id"]}
173
+ "status": {"groupId": 5,
174
+ "groupName": "REJECTED",
175
+ "id": 21,
176
+ "name": "REJECTED_SYSTEM_ERROR",
177
+ "description": "Unknown error"},
178
+ "messageId": a["message_id"]}
67
179
  end
68
180
 
69
181
  messages_sect.append(status1)
@@ -53,13 +53,14 @@ class Ukaz60All_2
53
53
  if format_for_forti[:code] == 200
54
54
  url_uploading = forti_connector.upload_url(format_for_forti[:body][:to_fortigate])
55
55
  if url_uploading[:code] == 200
56
- update_fortigate_ansible = forti_connector.update_weburl_fortigate
56
+ #update_fortigate_ansible = forti_connector.update_weburl_fortigate
57
+ update_fortigate_ansible = forti_connector.update_weburl_fortimanager
57
58
  if update_fortigate_ansible[:code] == 200
58
59
  forti_answer = {:code => 200, :result => "Fortigate processed", :data => update_fortigate_ansible[:body][:body], :num_uploaded_to_forti => format_for_forti[:body][:num_list]}
59
60
  else
60
61
  forti_answer = {:code => update_fortigate_ansible[:code], :result => update_fortigate_ansible[:result]}
61
62
  end
62
- forti_connector.clean_tmp_folders
63
+ #forti_connector.clean_tmp_folders
63
64
  else
64
65
  forti_answer = {:code => 401, :result => "Failed for uploading data to ansible server"}
65
66
  end
@@ -109,6 +110,7 @@ class Ukaz60All_2
109
110
 
110
111
  begin
111
112
  get_belgim_data = belgim_connector.belgim_ukaz60_get
113
+ p get_belgim_data
112
114
 
113
115
  if get_belgim_data[:code] == 200
114
116
 
@@ -52,7 +52,11 @@ class Belgim_2
52
52
  results = {}
53
53
 
54
54
  # Get data from Belgim site by curl
55
- return_from_belgim = `curl -d "name=#{belgim_login}&pass=#{belgim_password}" -H "Content-Type: application/x-www-form-urlencoded" -X POST #{belgim_url}`
55
+ curl_belgie_command = "curl -d \"name=#{belgim_login}&pass=#{belgim_password}\" -H \"Content-Type: application/x-www-form-urlencoded\" -X POST #{belgim_url} --insecure"
56
+ #return_from_belgim = `curl -d "name=#{belgim_login}&pass=#{belgim_password}" -H "Content-Type: application/x-www-form-urlencoded" -X POST #{belgim_url} --insecure`
57
+ return_from_belgim = `#{curl_belgie_command}`
58
+ p curl_belgie_command
59
+
56
60
  return_from_belgim = return_from_belgim.gsub!("\n", "")
57
61
 
58
62
  #parse Belgim file by regexpression
@@ -99,6 +99,29 @@ class FortiUkaz60_2
99
99
  output_data
100
100
  end
101
101
 
102
+
103
+ #2.1 function for process data to fortigate by fortimanager by ansible
104
+ # Full ready
105
+ def update_weburl_fortimanager
106
+ output_data = {}
107
+ begin
108
+ command = "/bin/bash /scripts/temp_fortimanager_url_upload.sh"
109
+ ansible_answer = ""
110
+ Net::SSH.start(ansible_host, ansible_ssh_user, :password => ansible_ssh_password) do |ssh|
111
+ ansible_answer = ssh.exec!(command)
112
+ end
113
+ p "ansible_answer: #{ansible_answer}"
114
+
115
+ #hh = "\nPLAY [ha_master] ***************************************************************\n\nTASK [set url table] ***********************************************************\nchanged: [gom32sg1]\nchanged: [bre32sg1]\nchanged: [min32sg1]\nchanged: [vit32sg1]\nchanged: [min32sg3]\nchanged: [gro32sg1]\nchanged: [mog32sg1]\n\nTASK [check current url table] *************************************************\nok: [min32sg1]\nok: [bre32sg1]\nok: [min32sg3]\nok: [vit32sg1]\nok: [gom32sg1]\nok: [gro32sg1]\nok: [mog32sg1]\n\nTASK [debug] *******************************************************************\nok: [min32sg1] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\nok: [min32sg3] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\nok: [bre32sg1] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\nok: [vit32sg1] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\nok: [gom32sg1] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\nok: [gro32sg1] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\nok: [mog32sg1] => {\n \"msg\": \"URL loaded/in-file: [1273 / 1273]\"\n}\n\nPLAY RECAP *********************************************************************\nbre32sg1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \ngom32sg1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \ngro32sg1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \nmin32sg1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \nmin32sg3 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \nmog32sg1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \nvit32sg1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \n\n"
116
+ answ_pr = add_func_connector.ansible_answer_parse(ansible_answer)
117
+ output_data = {:code => 200, :result => "update_weburl_fortigate: Request completed", :body => answ_pr}
118
+ rescue
119
+ output_data = {:code => 507, :result => "update_weburl_fortigate: Unknown SDK error"}
120
+ end
121
+ add_functions_full.printer_texter(output_data, "debug")
122
+ output_data
123
+ end
124
+
102
125
  #3 Clean all temp files
103
126
  # Full ready
104
127
  def clean_tmp_folders
@@ -1,4 +1,7 @@
1
1
  require 'net/ssh'
2
+ require 'uri'
3
+ require "erb"
4
+ include ERB::Util
2
5
 
3
6
  require 'imperituroard/platforms/staros/get_data_ssh'
4
7
 
@@ -124,3 +127,15 @@ class Ukaz60Staros_2
124
127
  returned_data
125
128
  end
126
129
  end
130
+
131
+
132
+ uu ="/fgd?ef"
133
+
134
+ #ggg = uu.force_encoding('ASCII-8BIT')
135
+ #puts CGI.escape ggg
136
+ p url_encode("foo/bar? baz&")
137
+
138
+ p URI.parse("foo/bar? baz&").to_s
139
+ p URI::encode("foo/bar? baz&")
140
+
141
+ p URI.decode("newsx-ru.ru/by/251-potencia-spartagen-by/%3futm%20medium=251&utmcampaign=4&%20utm%20content=57849345&utm%20source=56960717")
@@ -1,4 +1,5 @@
1
1
  require 'imperituroard/add_functions/logger/any_functions'
2
+ require 'uri'
2
3
 
3
4
  class AddFuncUkaz60_2
4
5
 
@@ -209,7 +210,7 @@ class AddFuncUkaz60_2
209
210
  else
210
211
  star_dom_x = star_url_curr
211
212
  end
212
- if belg_url.include?(star_dom_x)
213
+ if belg_url.include?(star_dom_x) || belg_url.include?(URI.decode(star_dom_x))
213
214
  blocked = 1
214
215
  for_unblock_tmp[star_host[:hostname]].push(star_dom)
215
216
  end
@@ -245,6 +246,16 @@ class AddFuncUkaz60_2
245
246
  rescue
246
247
  output_answ = {:code => 507, :result => "staros_compare_http: Unknown SDK error"}
247
248
  end
249
+
250
+ #p JSON.pretty_generate(output_answ)
251
+ p "staros_compare_http"
252
+ p output_answ
253
+
254
+ p "temp data"
255
+ for i in output_answ[:body][:for_unblock][:for_unblock]["vit11asr2"]
256
+ #for i in output_answ[:body][:for_block][:not_blocked_belgim]["vit11asr2"]
257
+ p i
258
+ end
248
259
  output_answ
249
260
  end
250
261
 
@@ -289,8 +300,6 @@ class AddFuncUkaz60_2
289
300
  answ_out[:body][:to_message][:data][:unblock_me] = data[:body][:for_unblock][:for_unblock_stat]
290
301
  end
291
302
 
292
-
293
-
294
303
  answ_out
295
304
  end
296
305
 
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -202,10 +202,13 @@ files:
202
202
  - lib/imperituroard.rb
203
203
  - lib/imperituroard/.DS_Store
204
204
  - lib/imperituroard/add_functions/logger/any_functions.rb
205
+ - lib/imperituroard/platforms/cps/cps_multiple_thread_req.rb
205
206
  - lib/imperituroard/platforms/cps/qps_connector.rb
206
207
  - lib/imperituroard/platforms/cps/request_formatter.rb
207
208
  - lib/imperituroard/platforms/public/telegram.rb
208
209
  - lib/imperituroard/platforms/staros/get_data_ssh.rb
210
+ - lib/imperituroard/platforms/staros/staros_automation.rb
211
+ - lib/imperituroard/platforms/staros/staros_automation_fun.rb
209
212
  - lib/imperituroard/platforms/staros/staros_parser.rb
210
213
  - lib/imperituroard/projects/dns.rb
211
214
  - lib/imperituroard/projects/iot.rb