imperituroard 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/runConfigurations/autovpn.xml +21 -0
- data/lib/imperituroard.rb +25 -0
- data/lib/imperituroard/platforms/staros/staros_automation.rb +1 -1
- data/lib/imperituroard/projects/autovpn.rb +27 -0
- data/lib/imperituroard/projects/{vpn/ezuev_fun → autovpn}/functions_ezuev.rb +0 -0
- data/lib/imperituroard/projects/autovpn/mongo_vpn.rb +56 -0
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +3 -0
- data/lib/imperituroard/projects/ukaz60.rb +4 -2
- data/lib/imperituroard/projects/ukaz60/belgim.rb +1 -1
- data/lib/imperituroard/projects/ukaz60/fortigate.rb +1 -1
- data/lib/imperituroard/projects/ukaz60/staros.rb +5 -5
- data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +50 -4
- data/lib/imperituroard/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f9c5a08701e31d0a87ce664a92db4cc736dd56a
|
4
|
+
data.tar.gz: 1f5b19a4aaf12b01b0ef9f30026541f5f63e05d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 821eec2e26448ded59f48f9a5a9564e6253fd95d302038a4f375218d0ff4215e79302adf8b5a4904aaa2b48051f37cae86657258b01f27baadf1734cf8e1d83c
|
7
|
+
data.tar.gz: 6284ef90f6d634930e5a87d6dc6fc590c4a924ba2df7168023bf82ae9c7cdab42f44a8854db3731ed8462aa1b6ea935f39f824f4a4366782c6bf2086ff01fc5a
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="autovpn" type="RubyRunConfigurationType" factoryName="Ruby">
|
3
|
+
<module name="imperituroard" />
|
4
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
5
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/imperituroard/projects" />
|
6
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
7
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
8
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
9
|
+
<envs />
|
10
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
11
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
12
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
13
|
+
<COVERAGE_PATTERN ENABLED="true">
|
14
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
15
|
+
</COVERAGE_PATTERN>
|
16
|
+
</EXTENSION>
|
17
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/lib/imperituroard/projects/autovpn.rb" />
|
18
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
19
|
+
<method />
|
20
|
+
</configuration>
|
21
|
+
</component>
|
data/lib/imperituroard.rb
CHANGED
@@ -269,6 +269,17 @@ class Iot
|
|
269
269
|
iot_connector.set_data_replace_2(soapgw_params, real_ip, remote_ip)
|
270
270
|
end
|
271
271
|
|
272
|
+
#14 integration with SPA
|
273
|
+
# add imei to correct profile
|
274
|
+
def spa_service_set(soapgw_params, real_ip, remote_ip)
|
275
|
+
#imei
|
276
|
+
#imsi
|
277
|
+
#msisdn
|
278
|
+
#unp
|
279
|
+
#note
|
280
|
+
#descriptiot
|
281
|
+
end
|
282
|
+
|
272
283
|
|
273
284
|
def logger_to_audit_database(proc_name, src_ip, input_json, output_json, real_ip)
|
274
285
|
mongo_client.audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
|
@@ -431,3 +442,17 @@ class Ukaz60Automation_2
|
|
431
442
|
end
|
432
443
|
|
433
444
|
end
|
445
|
+
|
446
|
+
|
447
|
+
class Autovpn
|
448
|
+
attr_accessor :vpn_connector
|
449
|
+
|
450
|
+
def initialize (mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
|
451
|
+
@vpn_connector = Autovpn.new(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
|
452
|
+
end
|
453
|
+
|
454
|
+
def vpn_add_msisdn_by_example(new_msisdn, example_msisdn)
|
455
|
+
vpn_connector.vpn_add_msisdn_by_example_2(new_msisdn, example_msisdn)
|
456
|
+
end
|
457
|
+
|
458
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'imperituroard/projects/autovpn/mongo_vpn'
|
2
|
+
|
3
|
+
class Autovpn
|
4
|
+
|
5
|
+
attr_accessor :mongo_client
|
6
|
+
|
7
|
+
def initialize(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
|
8
|
+
@mongo_client = MongoVpn.new(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
|
9
|
+
end
|
10
|
+
|
11
|
+
def vpn_add_msisdn_by_example_2(new_msisdn, example_msisdn)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def test
|
16
|
+
mongo_client.get_mongo_msisdn("375298766719")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
vvv = Autovpn.new("172.24.210.177",
|
23
|
+
"27017",
|
24
|
+
"autovpn"
|
25
|
+
)
|
26
|
+
|
27
|
+
vvv.test
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'rails'
|
7
|
+
|
8
|
+
require 'imperituroard/add_functions/logger/any_functions'
|
9
|
+
|
10
|
+
class MongoVpn
|
11
|
+
|
12
|
+
attr_accessor :mongo_vpn_ip, :mongo_vpn_port, :client_vpn, :mongo_vpn_database, :internal_vpn_func, :logger_any
|
13
|
+
|
14
|
+
def initialize(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
|
15
|
+
@mongo_vpn_database = mongo_vpn_database
|
16
|
+
@mongo_vpn_ip = mongo_vpn_ip
|
17
|
+
@mongo_vpn_port = mongo_vpn_port
|
18
|
+
client_vpn_host = [mongo_vpn_ip + ":" + mongo_vpn_port]
|
19
|
+
@client_vpn = Mongo::Client.new(client_vpn_host, :database => mongo_vpn_database)
|
20
|
+
@logger_any = LogAddFunctions_2.new
|
21
|
+
end
|
22
|
+
|
23
|
+
#get data by msisdn. Validate data from collection msisdn_list
|
24
|
+
def get_mongo_msisdn(msisdn)
|
25
|
+
out_resp = {}
|
26
|
+
begin
|
27
|
+
msisdn_data = []
|
28
|
+
collection = client_vpn[:msisdn_list]
|
29
|
+
collection.find({:msisdn => msisdn.to_s}).each {|row|
|
30
|
+
msisdn_data = row
|
31
|
+
}
|
32
|
+
if msisdn_data != [] && msisdn_data["msisdn"] != nil && msisdn_data["msisdn"] != ""
|
33
|
+
if msisdn_data["group_id"] != [] && msisdn_data["group_id"] != nil && msisdn_data["group_id"] != ""
|
34
|
+
if msisdn_data["profile_id"] != [] && msisdn_data["profile_id"] != nil && msisdn_data["profile_id"] != ""
|
35
|
+
out_resp = {:code => 200, :result => "get_mongo_msisdn: Request completed successfully", :body => msisdn_data}
|
36
|
+
else
|
37
|
+
out_resp = {:code => 406, :result => "get_mongo_msisdn: invalid data. profile_id not found"}
|
38
|
+
end
|
39
|
+
else
|
40
|
+
out_resp = {:code => 405, :result => "get_mongo_msisdn: invalid data. organization_id not found"}
|
41
|
+
end
|
42
|
+
else
|
43
|
+
out_resp = {:code => 404, :result => "get_mongo_msisdn: login not found in database"}
|
44
|
+
end
|
45
|
+
rescue
|
46
|
+
out_resp = {:code => 507, :result => "get_mongo_msisdn: Unknown SDK error"}
|
47
|
+
end
|
48
|
+
logger_any.printer_texter(out_resp, "debug")
|
49
|
+
out_resp
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
@@ -310,6 +310,9 @@ class HuaIot
|
|
310
310
|
request.content_type = 'application/json'
|
311
311
|
request['Authorization'] = 'Bearer ' + token
|
312
312
|
request['app_key'] = app_id
|
313
|
+
#request['node-id'] = node_id
|
314
|
+
bbb = {"nodeId": node_id, "appId": "Jy5KpoBUOScZEcrO2bRZhzfaIOUa"}.to_json
|
315
|
+
request.body = bbb
|
313
316
|
res = https.request(request)
|
314
317
|
p res.body.to_s
|
315
318
|
p res.code
|
@@ -60,7 +60,7 @@ class Ukaz60All_2
|
|
60
60
|
else
|
61
61
|
forti_answer = {:code => update_fortigate_ansible[:code], :result => update_fortigate_ansible[:result]}
|
62
62
|
end
|
63
|
-
|
63
|
+
forti_connector.clean_tmp_folders
|
64
64
|
else
|
65
65
|
forti_answer = {:code => 401, :result => "Failed for uploading data to ansible server"}
|
66
66
|
end
|
@@ -85,6 +85,8 @@ class Ukaz60All_2
|
|
85
85
|
#compare data with belgim
|
86
86
|
answ = ukaz60_add_func.staros_compare_http(staros_blocks_current, get_belgim_data)
|
87
87
|
|
88
|
+
p answ
|
89
|
+
|
88
90
|
if answ[:code] == 200
|
89
91
|
#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
92
|
output_starprocess = ukaz60_add_func.format_star_processed_answ(answ)[:body][:to_message]
|
@@ -110,7 +112,7 @@ class Ukaz60All_2
|
|
110
112
|
|
111
113
|
begin
|
112
114
|
get_belgim_data = belgim_connector.belgim_ukaz60_get
|
113
|
-
p get_belgim_data
|
115
|
+
#p get_belgim_data
|
114
116
|
|
115
117
|
if get_belgim_data[:code] == 200
|
116
118
|
|
@@ -55,7 +55,7 @@ class Belgim_2
|
|
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
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
57
|
return_from_belgim = `#{curl_belgie_command}`
|
58
|
-
p curl_belgie_command
|
58
|
+
#p curl_belgie_command
|
59
59
|
|
60
60
|
return_from_belgim = return_from_belgim.gsub!("\n", "")
|
61
61
|
|
@@ -113,7 +113,7 @@ class FortiUkaz60_2
|
|
113
113
|
p "ansible_answer: #{ansible_answer}"
|
114
114
|
|
115
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.
|
116
|
+
answ_pr = add_func_connector.ansible_answer_parse_fmg(ansible_answer)
|
117
117
|
output_data = {:code => 200, :result => "update_weburl_fortigate: Request completed", :body => answ_pr}
|
118
118
|
rescue
|
119
119
|
output_data = {:code => 507, :result => "update_weburl_fortigate: Unknown SDK error"}
|
@@ -129,13 +129,13 @@ class Ukaz60Staros_2
|
|
129
129
|
end
|
130
130
|
|
131
131
|
|
132
|
-
uu ="/fgd?ef"
|
132
|
+
#uu ="/fgd?ef"
|
133
133
|
|
134
134
|
#ggg = uu.force_encoding('ASCII-8BIT')
|
135
135
|
#puts CGI.escape ggg
|
136
|
-
p url_encode("foo/bar? baz&")
|
136
|
+
#p url_encode("foo/bar? baz&")
|
137
137
|
|
138
|
-
p URI.parse("foo/bar? baz&").to_s
|
139
|
-
p URI::encode("foo/bar? baz&")
|
138
|
+
#p URI.parse("foo/bar? baz&").to_s
|
139
|
+
#p URI::encode("foo/bar? baz&")
|
140
140
|
|
141
|
-
p URI.decode("newsx-ru.ru/by/251-potencia-spartagen-by/%3futm%20medium=251&utmcampaign=4&%20utm%20content=57849345&utm%20source=56960717")
|
141
|
+
#p URI.decode("newsx-ru.ru/by/251-potencia-spartagen-by/%3futm%20medium=251&utmcampaign=4&%20utm%20content=57849345&utm%20source=56960717")
|
@@ -154,6 +154,52 @@ class AddFuncUkaz60_2
|
|
154
154
|
end
|
155
155
|
|
156
156
|
|
157
|
+
def ansible_answer_parse_fmg(answer_string)
|
158
|
+
input_data = {:answer_string => answer_string}
|
159
|
+
output_data = {}
|
160
|
+
|
161
|
+
begin
|
162
|
+
answ_ans_parsed = answer_string.gsub("\n", " ")
|
163
|
+
result_out = {}
|
164
|
+
#result_out = []
|
165
|
+
num_ok = 0
|
166
|
+
num_failed = 0
|
167
|
+
#final_checks = /(fortimanager1)\s+:\s+ok=(\d)\s+changed=(\d)\s+unreachable=(\d)\s+failed=(\d)\s+/
|
168
|
+
final_checks = /(fortimanager1)\s+:\s+ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)\s+/
|
169
|
+
|
170
|
+
#p answ_ans_parsed
|
171
|
+
processed_data = answ_ans_parsed.scan(final_checks)
|
172
|
+
#p processed_data
|
173
|
+
if processed_data!=[] && processed_data!=""
|
174
|
+
for aaa in processed_data
|
175
|
+
begin
|
176
|
+
if aaa[1].to_i>0 && aaa[3].to_i==0 && aaa[4].to_i==0
|
177
|
+
result_out[aaa[0]] = {:ok => aaa[1], :changed => aaa[2], :unreachable => aaa[3], :failed => aaa[4], :result => "Ok"}
|
178
|
+
#result_out.push({aaa[0] => "Ok"})
|
179
|
+
num_ok = num_ok + 1
|
180
|
+
else
|
181
|
+
result_out[aaa[0]] = {:ok => aaa[1], :unreachable => aaa[3], :failed => aaa[4], :result => "Failed"}
|
182
|
+
#result_out.push({aaa[0] => "Failed"})
|
183
|
+
num_failed = num_failed + 1
|
184
|
+
end
|
185
|
+
rescue
|
186
|
+
result_out["unknown"] = aaa.to_s
|
187
|
+
#result_out.push({"unknown" => aaa.to_s})
|
188
|
+
num_failed = num_failed + 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
output_data = {:code => 200, :result => "ansible_answer_parse: Request completed successfully", :body => {:list => result_out, :num_ok => num_ok, :num_failed => num_failed}}
|
192
|
+
else
|
193
|
+
output_data = {:code => 400, :result => "ansible_answer_parse: Ansible returned empty data"}
|
194
|
+
end
|
195
|
+
rescue
|
196
|
+
output_data = {:code => 507, :result => "ansible_answer_parse: Unknown error"}
|
197
|
+
end
|
198
|
+
add_functions.printer_texter(output_data, "debug")
|
199
|
+
output_data
|
200
|
+
end
|
201
|
+
|
202
|
+
|
157
203
|
def https_to_forti_prep(domain)
|
158
204
|
f0 = domain.gsub("#", "")
|
159
205
|
f1 = f0.gsub("https://", "").split("/")
|
@@ -248,10 +294,10 @@ class AddFuncUkaz60_2
|
|
248
294
|
end
|
249
295
|
|
250
296
|
#p JSON.pretty_generate(output_answ)
|
251
|
-
p "staros_compare_http"
|
252
|
-
p output_answ
|
297
|
+
#p "staros_compare_http"
|
298
|
+
#p output_answ
|
253
299
|
|
254
|
-
p "temp data"
|
300
|
+
#p "temp data"
|
255
301
|
for i in output_answ[:body][:for_unblock][:for_unblock]["vit11asr2"]
|
256
302
|
#for i in output_answ[:body][:for_block][:not_blocked_belgim]["vit11asr2"]
|
257
303
|
p i
|
@@ -280,7 +326,7 @@ class AddFuncUkaz60_2
|
|
280
326
|
end
|
281
327
|
end
|
282
328
|
|
283
|
-
p notbl_equal
|
329
|
+
#p notbl_equal
|
284
330
|
if notbl_equal == 0
|
285
331
|
block_me = {:for_block_count => data[:body][:for_block][:notblocked_stat][compa_n_data]}
|
286
332
|
unblock_me = {:for_unblock_count => data[:body][:for_unblock][:for_unblock_stat][compa_n_data]}
|
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: 1.1.
|
4
|
+
version: 1.1.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-06-
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -186,6 +186,7 @@ extensions: []
|
|
186
186
|
extra_rdoc_files: []
|
187
187
|
files:
|
188
188
|
- ".gitignore"
|
189
|
+
- ".idea/runConfigurations/autovpn.xml"
|
189
190
|
- ".idea/runConfigurations/hua_oceanconnect_adapter.xml"
|
190
191
|
- ".idea/runConfigurations/version.xml"
|
191
192
|
- ".ruby-gemset"
|
@@ -211,6 +212,9 @@ files:
|
|
211
212
|
- lib/imperituroard/platforms/staros/staros_automation.rb
|
212
213
|
- lib/imperituroard/platforms/staros/staros_automation_fun.rb
|
213
214
|
- lib/imperituroard/platforms/staros/staros_parser.rb
|
215
|
+
- lib/imperituroard/projects/autovpn.rb
|
216
|
+
- lib/imperituroard/projects/autovpn/functions_ezuev.rb
|
217
|
+
- lib/imperituroard/projects/autovpn/mongo_vpn.rb
|
214
218
|
- lib/imperituroard/projects/dns.rb
|
215
219
|
- lib/imperituroard/projects/iot.rb
|
216
220
|
- lib/imperituroard/projects/iot/add_functions.rb
|
@@ -229,7 +233,6 @@ files:
|
|
229
233
|
- lib/imperituroard/projects/ukaz60/fortigate.rb
|
230
234
|
- lib/imperituroard/projects/ukaz60/staros.rb
|
231
235
|
- lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb
|
232
|
-
- lib/imperituroard/projects/vpn/ezuev_fun/functions_ezuev.rb
|
233
236
|
- lib/imperituroard/projects/wttx/phpipamcps.rb
|
234
237
|
- lib/imperituroard/projects/wttx/phpipamdb.rb
|
235
238
|
- lib/imperituroard/projects/wttx/updatepostcps.rb
|