imperituroard 0.5.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/imperituroard.gemspec +3 -0
- data/lib/.DS_Store +0 -0
- data/lib/imperituroard.rb +103 -72
- data/lib/imperituroard/.DS_Store +0 -0
- data/lib/imperituroard/platforms/cps/cps_multiple_thread_req.rb +0 -0
- data/lib/imperituroard/platforms/staros/get_data_ssh.rb +54 -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/platforms/staros/staros_parser.rb +141 -0
- data/lib/imperituroard/projects/dns.rb +1 -1
- data/lib/imperituroard/projects/iot.rb +189 -30
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +22 -8
- data/lib/imperituroard/projects/iot/mongoconnector.rb +177 -2
- data/lib/imperituroard/projects/mhub.rb +2 -0
- data/lib/imperituroard/projects/mhub/infobip.rb +1 -1
- 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 +140 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/belgim.rb +48 -9
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns.rb +0 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns_update.rb +2 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/fortigate.rb +43 -4
- data/lib/imperituroard/projects/ukaz60/staros.rb +141 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/ukaz60_add_func.rb +159 -4
- data/lib/imperituroard/version.rb +1 -1
- metadata +28 -8
- data/lib/imperituroard/projects/dns/ukaz60.rb +0 -85
@@ -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)
|
@@ -0,0 +1,140 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../projects/ukaz60", __dir__)
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require 'imperituroard/projects/ukaz60/belgim'
|
6
|
+
require 'imperituroard/projects/ukaz60/fortigate'
|
7
|
+
require 'imperituroard/projects/ukaz60/staros'
|
8
|
+
|
9
|
+
class Ukaz60All_2
|
10
|
+
|
11
|
+
attr_accessor :telegram_messanger,
|
12
|
+
:belgim_login,
|
13
|
+
:belgim_password,
|
14
|
+
:belgim_url,
|
15
|
+
:ukaz60_add_func,
|
16
|
+
:belgim_connector,
|
17
|
+
:forti_connector,
|
18
|
+
:staros_connector
|
19
|
+
|
20
|
+
def initialize(telegram_api_url,
|
21
|
+
telegram_chat_id,
|
22
|
+
belgim_login,
|
23
|
+
belgim_password,
|
24
|
+
belgim_url,
|
25
|
+
ansible_tmp_folder,
|
26
|
+
local_tmp_directory,
|
27
|
+
ansible_ssh_user,
|
28
|
+
ansible_ssh_password,
|
29
|
+
ansible_host,
|
30
|
+
url_backup_dir,
|
31
|
+
staros_login,
|
32
|
+
staros_password,
|
33
|
+
ukaz60_http_groups,
|
34
|
+
ukaz60_https_groups,
|
35
|
+
staros_hosts
|
36
|
+
|
37
|
+
)
|
38
|
+
@telegram_messanger = Telegram_2.new(telegram_api_url, telegram_chat_id)
|
39
|
+
@belgim_login = belgim_login
|
40
|
+
@belgim_password = belgim_password
|
41
|
+
@belgim_url = belgim_url
|
42
|
+
@ukaz60_add_func = AddFuncUkaz60_2.new
|
43
|
+
@belgim_connector = Belgim_2.new(telegram_api_url, telegram_chat_id, belgim_login, belgim_password, belgim_url)
|
44
|
+
@forti_connector = FortiUkaz60_2.new(ansible_tmp_folder, local_tmp_directory, ansible_ssh_user, ansible_ssh_password, ansible_host, url_backup_dir)
|
45
|
+
@staros_connector = Ukaz60Staros_2.new(staros_login, staros_password, ukaz60_http_groups, ukaz60_https_groups, staros_hosts)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def forti_process(get_belgim_data)
|
50
|
+
forti_answer = {}
|
51
|
+
begin
|
52
|
+
format_for_forti = forti_connector.prepare_url_config_fortigate(get_belgim_data)
|
53
|
+
if format_for_forti[:code] == 200
|
54
|
+
url_uploading = forti_connector.upload_url(format_for_forti[:body][:to_fortigate])
|
55
|
+
if url_uploading[:code] == 200
|
56
|
+
#update_fortigate_ansible = forti_connector.update_weburl_fortigate
|
57
|
+
update_fortigate_ansible = forti_connector.update_weburl_fortimanager
|
58
|
+
if update_fortigate_ansible[:code] == 200
|
59
|
+
forti_answer = {:code => 200, :result => "Fortigate processed", :data => update_fortigate_ansible[:body][:body], :num_uploaded_to_forti => format_for_forti[:body][:num_list]}
|
60
|
+
else
|
61
|
+
forti_answer = {:code => update_fortigate_ansible[:code], :result => update_fortigate_ansible[:result]}
|
62
|
+
end
|
63
|
+
#forti_connector.clean_tmp_folders
|
64
|
+
else
|
65
|
+
forti_answer = {:code => 401, :result => "Failed for uploading data to ansible server"}
|
66
|
+
end
|
67
|
+
else
|
68
|
+
forti_answer = {:code => 400, :result => "Error while processing data"}
|
69
|
+
end
|
70
|
+
rescue
|
71
|
+
forti_answer = {:code => 507, :result => "Unknown error with Forti"}
|
72
|
+
end
|
73
|
+
forti_answer
|
74
|
+
end
|
75
|
+
|
76
|
+
def staros_process(get_belgim_data)
|
77
|
+
|
78
|
+
output_starprocess = {}
|
79
|
+
|
80
|
+
begin
|
81
|
+
#get data from staros
|
82
|
+
staros_blocks_current = staros_connector.get_all_staros_ukaz60
|
83
|
+
|
84
|
+
if staros_blocks_current[:code] == 200
|
85
|
+
#compare data with belgim
|
86
|
+
answ = ukaz60_add_func.staros_compare_http(staros_blocks_current, get_belgim_data)
|
87
|
+
|
88
|
+
if answ[:code] == 200
|
89
|
+
#output_starprocess = {:code => 200, :result => "Staros processed", :data => {:block_me => answ[:body][:for_block][:notblocked_stat], :unblock_me =>answ[:body][:for_unblock][:for_unblock_stat]}}
|
90
|
+
output_starprocess = ukaz60_add_func.format_star_processed_answ(answ)[:body][:to_message]
|
91
|
+
else
|
92
|
+
output_starprocess = answ
|
93
|
+
end
|
94
|
+
|
95
|
+
else
|
96
|
+
output_starprocess = staros_blocks_current
|
97
|
+
end
|
98
|
+
rescue
|
99
|
+
output_starprocess = {:code => 507, :result => "staros_process: Something wrong"}
|
100
|
+
end
|
101
|
+
|
102
|
+
output_starprocess
|
103
|
+
end
|
104
|
+
|
105
|
+
def no_pasaran
|
106
|
+
|
107
|
+
answer_output = {}
|
108
|
+
forti_answer = {}
|
109
|
+
staros_answer = {}
|
110
|
+
|
111
|
+
begin
|
112
|
+
get_belgim_data = belgim_connector.belgim_ukaz60_get
|
113
|
+
p get_belgim_data
|
114
|
+
|
115
|
+
if get_belgim_data[:code] == 200
|
116
|
+
|
117
|
+
thr_forti = Thread.new do
|
118
|
+
forti_answer = self.forti_process(get_belgim_data)
|
119
|
+
end
|
120
|
+
|
121
|
+
thr_staros = Thread.new do
|
122
|
+
staros_answer = staros_process(get_belgim_data)
|
123
|
+
end
|
124
|
+
|
125
|
+
thr_staros.join
|
126
|
+
thr_forti.join
|
127
|
+
|
128
|
+
answer_output = {:code => 200, :result => "No pasaran", :fortigate => forti_answer, :staros => staros_answer, :info_belgim => get_belgim_data[:number]}
|
129
|
+
else
|
130
|
+
answer_output = {:code => 404, :result => "Failed to receive data from Belgim"}
|
131
|
+
end
|
132
|
+
|
133
|
+
rescue
|
134
|
+
answer_output = {:code => 507, :result => "no_pasaran: Unknown SDK error"}
|
135
|
+
end
|
136
|
+
telegram_messanger.telegram_message(JSON.pretty_generate(answer_output))
|
137
|
+
answer_output
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'imperituroard/platforms/public/telegram'
|
2
|
-
require 'imperituroard/projects/
|
2
|
+
require 'imperituroard/projects/ukaz60/ukaz60_add_func'
|
3
3
|
|
4
4
|
require 'simpleidn'
|
5
5
|
|
@@ -45,12 +45,18 @@ class Belgim_2
|
|
45
45
|
url_parsed = []
|
46
46
|
ipv4_parsed = []
|
47
47
|
ipv6_parsed = []
|
48
|
+
https_parsed = []
|
49
|
+
url_all = []
|
48
50
|
|
49
51
|
f2 =[]
|
50
52
|
results = {}
|
51
53
|
|
52
54
|
# Get data from Belgim site by curl
|
53
|
-
|
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
|
+
|
54
60
|
return_from_belgim = return_from_belgim.gsub!("\n", "")
|
55
61
|
|
56
62
|
#parse Belgim file by regexpression
|
@@ -99,7 +105,7 @@ class Belgim_2
|
|
99
105
|
processed_url = func_processed[:domain_only]
|
100
106
|
processed_domain_in_url = func_processed[:processed_domain_in_url]
|
101
107
|
|
102
|
-
if func_processed[:type] == "domain"
|
108
|
+
if func_processed[:type] == "domain"
|
103
109
|
domain_parsed.push(processed_url)
|
104
110
|
check_if_www = processed_url[0]+processed_url[1]+processed_url[2]+processed_url[3]
|
105
111
|
|
@@ -126,6 +132,17 @@ class Belgim_2
|
|
126
132
|
gar1url = processed_domain_in_url[4..processed_domain_in_url.length]
|
127
133
|
url_parsed.push(func_processed[:protocol] + "://" + gar1url)
|
128
134
|
end
|
135
|
+
elsif func_processed[:protocol] == "https"
|
136
|
+
#additional section for https urls
|
137
|
+
https_parsed.push(func_processed[:protocol] + "://" + processed_domain_in_url)
|
138
|
+
check_if_www2https = processed_domain_in_url[0]+processed_domain_in_url[1]+processed_domain_in_url[2]+processed_domain_in_url[3]
|
139
|
+
if check_if_www2https != "www."
|
140
|
+
https_parsed.push(func_processed[:protocol] + "://" + "www."+processed_domain_in_url)
|
141
|
+
end
|
142
|
+
if check_if_www2https == "www."
|
143
|
+
gar1url_https = processed_domain_in_url[4..processed_domain_in_url.length]
|
144
|
+
https_parsed.push(func_processed[:protocol] + "://" + gar1url_https)
|
145
|
+
end
|
129
146
|
end
|
130
147
|
end
|
131
148
|
end
|
@@ -154,22 +171,44 @@ class Belgim_2
|
|
154
171
|
url_parsed = url_parsed.uniq
|
155
172
|
ipv6_parsed = ipv6_parsed.uniq
|
156
173
|
ipv4_parsed = ipv4_parsed.uniq
|
174
|
+
https_parsed = https_parsed.uniq
|
175
|
+
|
176
|
+
https_parsed_tmmp = []
|
177
|
+
https_parsed.each do |tmp_tmp|
|
178
|
+
https_parsed_tmmp.push(tmp_tmp.gsub("https://", "http://"))
|
179
|
+
end
|
180
|
+
url_all = https_parsed_tmmp + url_parsed
|
181
|
+
url_all = url_all.uniq
|
182
|
+
url_all_num = url_all.length
|
183
|
+
|
157
184
|
|
158
185
|
dns_num = domain_parsed.length
|
159
186
|
ipv4_num = ipv4_parsed.length
|
160
187
|
ipv6_num = ipv6_parsed.length
|
161
188
|
url_num = url_parsed.length
|
189
|
+
https_num = https_parsed.length
|
190
|
+
|
191
|
+
all_num = dns_num + ipv4_num + ipv6_num + url_num + https_num
|
192
|
+
|
193
|
+
|
162
194
|
|
163
|
-
output_data = {:code => 200,
|
164
|
-
:
|
165
|
-
|
166
|
-
|
167
|
-
|
195
|
+
output_data = {:code => 200,
|
196
|
+
:result => "Request completed successfully",
|
197
|
+
:number => {:domain_num => dns_num,
|
198
|
+
:url_http_num => url_num,
|
199
|
+
:ipv4_num => ipv4_num,
|
200
|
+
:ipv6_num => ipv6_num,
|
201
|
+
:url_https_num => https_num,
|
202
|
+
:url_all_num => url_all_num,
|
203
|
+
:all_num => all_num
|
168
204
|
},
|
169
205
|
:domains_for_block => domain_parsed,
|
170
206
|
:url_for_block => url_parsed,
|
171
207
|
:ipv6_parsed => ipv6_parsed,
|
172
|
-
:ipv4_parsed => ipv4_parsed
|
208
|
+
:ipv4_parsed => ipv4_parsed,
|
209
|
+
:https_parsed => https_parsed,
|
210
|
+
:url_all => url_all
|
211
|
+
}
|
173
212
|
|
174
213
|
rescue
|
175
214
|
output_data = {:code => 507, :result => "belgim_ukaz60_get: Unknown error"}
|
File without changes
|
@@ -54,6 +54,7 @@ class Ukaz60Dns_2
|
|
54
54
|
@unblo = 0
|
55
55
|
end
|
56
56
|
|
57
|
+
=begin
|
57
58
|
|
58
59
|
|
59
60
|
def gen_mem_script()
|
@@ -267,6 +268,7 @@ class Ukaz60Dns_2
|
|
267
268
|
|
268
269
|
telegram_messanger.telegram_message(results.to_s)
|
269
270
|
|
271
|
+
=end
|
270
272
|
|
271
273
|
#File.delete("blocked.conf") if File.exist?("blocked.conf")
|
272
274
|
#File.delete("blocked_old.conf") if File.exist?("blocked_old.conf")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'net/scp'
|
2
2
|
require 'date'
|
3
3
|
|
4
|
-
require 'imperituroard/projects/
|
4
|
+
require 'imperituroard/projects/ukaz60/ukaz60_add_func'
|
5
5
|
|
6
6
|
|
7
7
|
class FortiUkaz60_2
|
@@ -16,7 +16,12 @@ class FortiUkaz60_2
|
|
16
16
|
:url_backup_dir
|
17
17
|
|
18
18
|
|
19
|
-
def initialize(ansible_tmp_folder,
|
19
|
+
def initialize(ansible_tmp_folder,
|
20
|
+
local_tmp_directory,
|
21
|
+
ansible_ssh_user,
|
22
|
+
ansible_ssh_password,
|
23
|
+
ansible_host,
|
24
|
+
url_backup_dir)
|
20
25
|
@ansible_tmp_folder = ansible_tmp_folder
|
21
26
|
@local_tmp_directory = local_tmp_directory
|
22
27
|
@ansible_ssh_user = ansible_ssh_user
|
@@ -82,6 +87,31 @@ class FortiUkaz60_2
|
|
82
87
|
Net::SSH.start(ansible_host, ansible_ssh_user, :password => ansible_ssh_password) do |ssh|
|
83
88
|
ansible_answer = ssh.exec!(command)
|
84
89
|
end
|
90
|
+
p "ansible_answer: #{ansible_answer}"
|
91
|
+
|
92
|
+
#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"
|
93
|
+
answ_pr = add_func_connector.ansible_answer_parse(ansible_answer)
|
94
|
+
output_data = {:code => 200, :result => "update_weburl_fortigate: Request completed", :body => answ_pr}
|
95
|
+
rescue
|
96
|
+
output_data = {:code => 507, :result => "update_weburl_fortigate: Unknown SDK error"}
|
97
|
+
end
|
98
|
+
add_functions_full.printer_texter(output_data, "debug")
|
99
|
+
output_data
|
100
|
+
end
|
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
|
+
|
85
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"
|
86
116
|
answ_pr = add_func_connector.ansible_answer_parse(ansible_answer)
|
87
117
|
output_data = {:code => 200, :result => "update_weburl_fortigate: Request completed", :body => answ_pr}
|
@@ -147,10 +177,19 @@ class FortiUkaz60_2
|
|
147
177
|
})
|
148
178
|
end
|
149
179
|
|
180
|
+
#for url in data_belgim[:url_for_block]
|
150
181
|
for url in data_belgim[:url_for_block]
|
151
|
-
|
182
|
+
format_url1 = add_func_connector.http_to_forti_prep(url)
|
183
|
+
to_fortigate.push({
|
184
|
+
"url" => format_url1,
|
185
|
+
"action" => "block"
|
186
|
+
})
|
187
|
+
end
|
188
|
+
|
189
|
+
for https in data_belgim[:https_parsed]
|
190
|
+
format_url2 = add_func_connector.https_to_forti_prep(https)
|
152
191
|
to_fortigate.push({
|
153
|
-
"url" =>
|
192
|
+
"url" => format_url2,
|
154
193
|
"action" => "block"
|
155
194
|
})
|
156
195
|
end
|