imperituroard 0.5.7 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/imperituroard.gemspec +2 -2
- data/lib/.DS_Store +0 -0
- data/lib/imperituroard.rb +63 -55
- data/lib/imperituroard/.DS_Store +0 -0
- data/lib/imperituroard/platforms/cps/cps_multiple_thread_req.rb +0 -0
- data/lib/imperituroard/platforms/staros/staros_automation.rb +95 -0
- data/lib/imperituroard/platforms/staros/staros_automation_fun.rb +37 -0
- data/lib/imperituroard/projects/iot.rb +190 -29
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +51 -16
- data/lib/imperituroard/projects/iot/mongoconnector.rb +177 -2
- data/lib/imperituroard/projects/mhub.rb +2 -0
- data/lib/imperituroard/projects/mhub/sk.rb +171 -157
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +124 -12
- data/lib/imperituroard/projects/ukaz60.rb +4 -2
- data/lib/imperituroard/projects/ukaz60/belgim.rb +5 -1
- data/lib/imperituroard/projects/ukaz60/fortigate.rb +23 -0
- data/lib/imperituroard/projects/ukaz60/staros.rb +15 -0
- data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +12 -3
- data/lib/imperituroard/version.rb +1 -1
- metadata +8 -5
@@ -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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
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
|
|
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.
|
4
|
+
version: 1.0.2
|
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-
|
11
|
+
date: 2020-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - '='
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 5.
|
173
|
+
version: 5.0.7.2
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - '='
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 5.
|
180
|
+
version: 5.0.7.2
|
181
181
|
description: Gem from imperituroard for different actions
|
182
182
|
email:
|
183
183
|
- imperituro.ard@gmail.com
|
@@ -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
|
@@ -246,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
246
249
|
requirements:
|
247
250
|
- - ">="
|
248
251
|
- !ruby/object:Gem::Version
|
249
|
-
version: 2.
|
252
|
+
version: 2.3.0
|
250
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
254
|
requirements:
|
252
255
|
- - ">="
|