imperituroard 1.1.3 → 1.1.9

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: 44204f257643647687e7d62d06c363274cad09f3
4
- data.tar.gz: 710581ba122cda979fd1989107dd981f028c456e
3
+ metadata.gz: 629626efbfcfa0108c2b1646a42d25856e6f3135
4
+ data.tar.gz: 8a3a7f5357873aa432d9058a2a54d933e6177c7d
5
5
  SHA512:
6
- metadata.gz: fd5089b028b66fb283f57a0f5a870113ba4ad0c183c056937c2440b09c38c27d5166cb4d8670b95aa8da4f083cb6abcbe981b61a0474eb6cc1a8caeeda44a133
7
- data.tar.gz: c5a0e5737f947b4dfcd360170309cf8bf2c955532b35e3f93e84280d1ee39c8a0751cf7009dbcff36c9da2afcc73fd351e8531135aed8612572966d6184ec63a
6
+ metadata.gz: 61e4e034d6b705161bc67e7c270406cbb62a0306ca18c17a619b04b6cf78af4bd802c0f59517e5856101ec75be031be38086872e68893de159412ef241aaaf53
7
+ data.tar.gz: 87151a1bbfa092b6d77fef7279cf114446dba7540ca949b897cad0a8f77270afe3833d7d49678f7e46476fb144be849a805d2bc493c2c625b3a185630f1e96ad
@@ -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>
@@ -51,7 +51,7 @@ Gem::Specification.new do |spec|
51
51
  spec.add_dependency "ipaddr", "1.2.2"
52
52
  spec.add_dependency "simpleidn", "0.1.1"
53
53
  spec.add_dependency "net-scp", "3.0.0"
54
-
55
54
  spec.add_dependency "rails", "5.0.7.2"
56
55
 
56
+
57
57
  end
@@ -25,6 +25,7 @@ require 'imperituroard/projects/dns'
25
25
  require 'imperituroard/platforms/cps/qps_connector'
26
26
  require 'imperituroard/platforms/public/telegram'
27
27
  require 'imperituroard/projects/ukaz60'
28
+ require 'imperituroard/projects/mhub/gms'
28
29
 
29
30
  require 'json'
30
31
  require 'ipaddr'
@@ -269,6 +270,17 @@ class Iot
269
270
  iot_connector.set_data_replace_2(soapgw_params, real_ip, remote_ip)
270
271
  end
271
272
 
273
+ #14 integration with SPA
274
+ # add imei to correct profile
275
+ def spa_service_set(soapgw_params, real_ip, remote_ip)
276
+ #imei
277
+ #imsi
278
+ #msisdn
279
+ #unp
280
+ #note
281
+ #descriptiot
282
+ end
283
+
272
284
 
273
285
  def logger_to_audit_database(proc_name, src_ip, input_json, output_json, real_ip)
274
286
  mongo_client.audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
@@ -334,6 +346,26 @@ class Mhub_2
334
346
  end
335
347
 
336
348
 
349
+ #2020.09.02 function for some procedure for get message status
350
+ class GmsFunctions_2
351
+
352
+ attr_accessor :gms_func
353
+
354
+ def initialize(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
355
+ @gms_func = Gmsgms_2.new(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
356
+ end
357
+
358
+ def get_t_status_external(external_id)
359
+ gms_func.get_t_status_external_2(external_id)
360
+ end
361
+
362
+ def get_r_status_external(external_id)
363
+ gms_func.get_r_status_external_2(external_id)
364
+ end
365
+
366
+ end
367
+
368
+
337
369
  class CpsFunctions_2
338
370
 
339
371
  attr_accessor :qps_connector
@@ -431,3 +463,17 @@ class Ukaz60Automation_2
431
463
  end
432
464
 
433
465
  end
466
+
467
+
468
+ class Autovpn
469
+ attr_accessor :vpn_connector
470
+
471
+ def initialize (mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
472
+ @vpn_connector = Autovpn.new(mongo_vpn_ip, mongo_vpn_port, mongo_vpn_database)
473
+ end
474
+
475
+ def vpn_add_msisdn_by_example(new_msisdn, example_msisdn)
476
+ vpn_connector.vpn_add_msisdn_by_example_2(new_msisdn, example_msisdn)
477
+ end
478
+
479
+ end
@@ -22,7 +22,7 @@ end
22
22
  staros_hosts.each do |ggsn|
23
23
  staros_thr_1233 << Thread.new do
24
24
 
25
- p ggsn
25
+ #p ggsn
26
26
 
27
27
  begin
28
28
 
@@ -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
@@ -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
+
@@ -214,7 +214,6 @@ class IotFunctions_2
214
214
  end
215
215
 
216
216
 
217
-
218
217
  def add_device_to_prof2_2(request_full, real_ip, remote_ip)
219
218
 
220
219
  #{"autorization"=>{"login"=>"test", "token"=>"tE3aFvs27"}, "devlist"=>[{"devices"=>{"imei"=>123419520034999, "type"=>"1000002", "profile"=>0}}]}
@@ -229,6 +228,7 @@ class IotFunctions_2
229
228
  imei_list = im_li
230
229
 
231
230
  input_json = {:request_full => request_full}
231
+ input_json22 = {:login => login, :imei_list => imei_list}
232
232
  resp_out = {}
233
233
  begin
234
234
 
@@ -368,7 +368,7 @@ class IotFunctions_2
368
368
  end
369
369
  thr1.join
370
370
 
371
- resp_out[:body][:tosoapgw] = internal_func.iot_create_dev_soapgw_answer(input_json, resp_out)
371
+ resp_out[:body][:tosoapgw] = internal_func.iot_create_dev_soapgw_answer(input_json22, resp_out)
372
372
  mongo_client.audit_logger("add_device_to_profile", remote_ip, input_json, resp_out, real_ip, {})
373
373
  resp_out
374
374
  end
@@ -1381,10 +1381,6 @@ class IotFunctions_2
1381
1381
  end
1382
1382
 
1383
1383
 
1384
-
1385
-
1386
-
1387
-
1388
1384
  ################################################
1389
1385
  ############technology procedures###############
1390
1386
  ################################################
@@ -1404,8 +1400,6 @@ class IotFunctions_2
1404
1400
  end
1405
1401
 
1406
1402
 
1407
-
1408
-
1409
1403
  #for internal use. Add new device model
1410
1404
  def add_model_to_mongo(model, manufacture_id, manufacture_name, device_type, description, note)
1411
1405
  model = {
@@ -1433,6 +1427,6 @@ class IotFunctions_2
1433
1427
  p "yyyyy"
1434
1428
 
1435
1429
  #fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
1436
- p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123456789876543")
1430
+ p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123412341284999")
1437
1431
  end
1438
1432
  end
@@ -55,8 +55,8 @@ class AdditionalFunc
55
55
  note=i["note"]
56
56
  end
57
57
  end
58
- if i.key?("type")
59
- type=i["type"]
58
+ if i.key?("device_type")
59
+ type=i["device_type"]
60
60
  end
61
61
  if i.key?("profile")
62
62
  profile=i["profile"]
@@ -82,6 +82,7 @@ class HuaIot
82
82
  request.content_type = 'application/x-www-form-urlencoded'
83
83
  request.body = URI.encode_www_form(data)
84
84
  res = https.request(request)
85
+ p "get_token"
85
86
  p res.code
86
87
  p res.message
87
88
  p res.body.to_s
@@ -293,27 +294,30 @@ class HuaIot
293
294
 
294
295
  #2.2.44 Querying the Device ID
295
296
  def querying_device_id(app_id, secret, node_id)
296
- token = get_token(app_id, secret)[:body]["accessToken"]
297
- p token
298
- path = "/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&appId=Jy5KpoBUOScZEcrO2bRZhzfaIOUa"
299
- p path
300
- p path
301
- url_string = "https://" + platformip + ":" + platformport + path
302
- p url_string
303
- uri = URI.parse url_string
304
- https = Net::HTTP.new(uri.host, uri.port)
305
- https.use_ssl = true
306
- https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
307
- https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
308
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
309
- request = Net::HTTP::Get.new(uri.path)
310
- request.content_type = 'application/json'
311
- request['Authorization'] = 'Bearer ' + token
312
- request['app_key'] = app_id
313
- res = https.request(request)
314
- p res.body.to_s
315
- p res.code
316
- {:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
297
+ get_token_data = get_token(app_id, secret)
298
+ if get_token_data[:code]=="200"
299
+ token = get_token_data[:body]["accessToken"]
300
+ uri1 = URI("https://134.17.93.4:8743/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&" + app_id)
301
+ https = Net::HTTP.new(uri1.host, uri1.port)
302
+ https.use_ssl = true
303
+ https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
304
+ https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
305
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
306
+ request = Net::HTTP::Get.new(uri1)
307
+ request.content_type = 'application/json'
308
+ request['app_key'] = app_id
309
+ request['Authorization'] = 'Bearer ' + token
310
+ #request.set_form_data( params )
311
+ #request['node-id'] = node_id
312
+ bbb = {"nodeId": node_id, "appId": "Jy5KpoBUOScZEcrO2bRZhzfaIOUa"}.to_json
313
+ #request.body = bbb
314
+ res = https.request(request)
315
+ #p res.body.to_s
316
+ #p res.code
317
+ {:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
318
+ else
319
+ {:code => "500", :message => "Something wrong", :body => {}}
320
+ end
317
321
  end
318
322
 
319
323
  #2.2.14 Querying Device Activation Status
@@ -507,6 +507,7 @@ class MongoIot
507
507
  #function for get iot platform credentials from profile
508
508
  #universal procedure. use profile or profile id
509
509
  def get_iot_oceanconn_credent_2(profile)
510
+ input_in = {:profile => profile}
510
511
  out_resp = {}
511
512
  begin
512
513
  result_ps = []
@@ -528,7 +529,7 @@ class MongoIot
528
529
  rescue
529
530
  out_resp = {:code => 500, :result => "get_iot_oceanconn_credent_2: Process failed"}
530
531
  end
531
- internal_func.printer_texter(out_resp, "debug")
532
+ internal_func.printer_texter({:input_in => input_in, :out_resp => out_resp, :fun => "get_iot_oceanconn_credent_2"}, "debug")
532
533
  out_resp
533
534
  end
534
535
 
@@ -596,6 +597,7 @@ class MongoIot
596
597
 
597
598
 
598
599
  def compare_profiles(profile1, profile2)
600
+ input_inf = {:profile1 => profile1, :profile2 => profile2}
599
601
  out_answ = {}
600
602
  ch1 = internal_func.if_digit_or_string(profile1)
601
603
  ch2 = internal_func.if_digit_or_string(profile2)
@@ -632,10 +634,12 @@ class MongoIot
632
634
  out_answ = {:code => 200, :result => "compare_profiles: profiles are different", :is_the_same => false, :data_type => "different"}
633
635
  end
634
636
  end
637
+ internal_func.printer_texter({:input_inf => input_inf, :out => out_answ, :fun => "compare_profiles"}, "debug")
635
638
  out_answ
636
639
  end
637
640
 
638
641
  def compare_device_types(type1, type2)
642
+ input_inf = {:type1 => type1, :type2 => type2}
639
643
  out_answ = {}
640
644
  tp1 = internal_func.if_digit_or_string(type1)
641
645
  tp2 = internal_func.if_digit_or_string(type2)
@@ -682,6 +686,7 @@ class MongoIot
682
686
  out_answ = {:code => 200, :result => "compare_device_types: profiles are different", :is_the_same => false, :data_type => "different"}
683
687
  end
684
688
  end
689
+ internal_func.printer_texter({:input_inf => input_inf, :out => out_answ, :fun => "compare_device_types"}, "debug")
685
690
  out_answ
686
691
  end
687
692
 
@@ -146,11 +146,12 @@ class MhubFunctions_2
146
146
  output_params
147
147
  end
148
148
 
149
-
150
149
  def test2
151
150
  hh = Infobip_1.new
152
151
  hh.test
153
152
  end
154
153
 
155
154
 
156
- end
155
+ end
156
+
157
+
@@ -0,0 +1,96 @@
1
+ require 'imperituroard/projects/mhub/subs/evrotorg/gms_connector'
2
+
3
+
4
+ class Gmsgms_2
5
+
6
+ attr_accessor :gms_t_login, :gms_t_password, :gms_r_login, :gms_r_password, :gms_t_connector, :gms_r_connector
7
+
8
+
9
+ def initialize(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
10
+ @gms_t_login = gms_t_login
11
+ @gms_t_password = gms_t_password
12
+ @gms_r_login = gms_r_login
13
+ @gms_r_password = gms_r_password
14
+
15
+ @gms_t_connector = Gms_2.new(gms_t_login, gms_t_password, telegram_api_url, telegram_chat_id)
16
+ @gms_r_connector = Gms_2.new(gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
17
+
18
+ @internal_func = InternalFunc.new
19
+ @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
20
+
21
+ end
22
+
23
+ def gms_parsing(gms_answer)
24
+ output = {}
25
+
26
+ status_dic = {
27
+ 12033 => "Sent to Viber",
28
+ 36013 => "Viber internal failure",
29
+ 36023 => "Viber invalid service id",
30
+ 36033 => "Viber invalid data",
31
+ 36043 => "Viber blocked message type",
32
+ 36053 => "Viber bad message type",
33
+ 36063 => "Viber bad parameters",
34
+ 36073 => "Viber timeout",
35
+ 36083 => "Viber user blocked",
36
+ 36093 => "Viber not viber user",
37
+ 36103 => "Viber no suitable device",
38
+ 36113 => "Viber unauthorized ip",
39
+ 36123 => "Viber already sent",
40
+ 36133 => "Viber not permitted",
41
+ 36143 => "Viber billing failure",
42
+ 36153 => "Viber word in black list",
43
+ 36163 => "Viber internal process error",
44
+ 36173 => "Viber wrong or missing Label",
45
+ 36183 => "Viber invalid TTL value",
46
+ 23033 => "Viber delivered",
47
+ 35015 => "Viber expired",
48
+ 24013 => "Viber delivered(seen)",
49
+ 28013 => "Viber delivered(overdue)",
50
+ -1 => "in progress"
51
+ }
52
+
53
+ if gms_answer[:code] == 200
54
+ dt1 = gms_answer[:body][:res_body]["reports"][0]
55
+ hyber_status = dt1["hyber_status"]
56
+ output = {:code => 200, :result => "Processed", :body => {"status_code": hyber_status, "status": status_dic[hyber_status], "phone_number": dt1["phone_number"], "message_id": dt1["extra_id"]}}
57
+ elsif gms_answer[:code] == 404
58
+ output = {:code => 404, :result => "Not found", :body => {"status_code": "", "status": "", "phone_number": "", "message_id": gms_answer[:body][:request_message][:external_id]}}
59
+ else
60
+ output = {:code => gms_answer[:code], :result => gms_answer[:result], :body => {"status_code": "", "status": "", "phone_number": "", "message_id": gms_answer[:body][:request_message][:external_id]}}
61
+ end
62
+ output
63
+ end
64
+
65
+
66
+ def get_t_status_external_2(external_id)
67
+ output = {}
68
+ begin
69
+ ans = gms_t_connector.get_advanced_by_external(external_id)
70
+ parsed = gms_parsing(ans)
71
+ output = {:gms_answer => ans, :parsed_answer => parsed}
72
+ rescue
73
+ pars = {:code => "505", :result => "Failed", :body => {"status_code": "", "status": "", "phone_number": "", "message_id": ""}}
74
+ output = {:gms_answer => ans, :parsed_answer => pars}
75
+ end
76
+ output
77
+ end
78
+
79
+
80
+ def get_r_status_external_2(external_id)
81
+ output = {}
82
+ begin
83
+ ans = gms_r_connector.get_advanced_by_external(external_id)
84
+ parsed = gms_parsing(ans)
85
+ output = {:gms_answer => ans, :parsed_answer => parsed}
86
+ rescue
87
+ pars = {:code => "505", :result => "Failed", :body => {"status_code": "", "status": "", "phone_number": "", "message_id": ""}}
88
+ output = {:gms_answer => ans, :parsed_answer => pars}
89
+ end
90
+ output
91
+ end
92
+
93
+ end
94
+
95
+
96
+
@@ -0,0 +1,69 @@
1
+ require 'net/https'
2
+
3
+ require 'json'
4
+
5
+ require 'uri'
6
+ require 'net/http'
7
+ require 'rubygems'
8
+ require 'nokogiri'
9
+ require 'rails'
10
+
11
+ require 'imperituroard/projects/iot/internal_functions'
12
+
13
+
14
+ class Gms_2
15
+
16
+ attr_accessor :gms_login, :gms_password, :telegram_connector, :internal_func
17
+
18
+ def initialize(gms_login, gms_password, telegram_api_url, telegram_chat_id)
19
+ @gms_login = gms_login
20
+ @gms_password = gms_password
21
+ @internal_func = InternalFunc.new
22
+ @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
23
+ end
24
+
25
+ def get_advanced_by_external(external_id)
26
+
27
+ input_params = {:external_id => external_id}
28
+ output_params = {}
29
+ thr1_get_advanced_by_external = Thread.new do
30
+ begin
31
+ uri = URI("https://dr-v2.hyber.im/2160/api/dr/external/" + external_id + "/advanced")
32
+ https = Net::HTTP.new(uri.host, uri.port)
33
+ https.use_ssl = true
34
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
35
+ req = Net::HTTP::Get.new(uri.path, initheader = {:"Content-Type" => 'application/json'})
36
+ req.basic_auth gms_login, gms_password
37
+ req["Content-Type"] = "application/json"
38
+ res = https.request(req)
39
+
40
+ p res.code
41
+ p res.body
42
+ if res.code == "200"
43
+ output_params = {:code => 200,
44
+ :result => "Gms_2.get_advanced_by_external: Request processed",
45
+ :body => {:request_message => input_params,
46
+ :res_code => res.code,
47
+ :res_body => JSON.parse(res.body.to_s)}}
48
+ else
49
+ output_params = {:code => res.code.to_i,
50
+ :result => "Gms_2.get_advanced_by_external: Request processed",
51
+ :body => {:request_message => input_params,
52
+ :res_code => res.code,
53
+ :res_body => res.body.to_s}}
54
+ end
55
+ rescue
56
+ output_params = {:code => 500, :result => "Gms_2.get_advanced_by_external: Something wrong", :body => {:request_message => input_params}}
57
+ end
58
+ end
59
+ thr1_get_advanced_by_external.join
60
+
61
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Gms_2.get_advanced_by_external"}, "debug")
62
+ output_params
63
+
64
+ end
65
+
66
+
67
+
68
+
69
+ end
@@ -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
- #forti_connector.clean_tmp_folders
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.ansible_answer_parse(ansible_answer)
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]}
@@ -1,4 +1,4 @@
1
1
  module Imperituroard
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.9"
3
3
  end
4
4
 
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.3
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-09-01 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
@@ -218,10 +222,12 @@ files:
218
222
  - lib/imperituroard/projects/iot/internal_functions.rb
219
223
  - lib/imperituroard/projects/iot/mongoconnector.rb
220
224
  - lib/imperituroard/projects/mhub.rb
225
+ - lib/imperituroard/projects/mhub/gms.rb
221
226
  - lib/imperituroard/projects/mhub/infobip.rb
222
227
  - lib/imperituroard/projects/mhub/sk.rb
223
228
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb
224
229
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb
230
+ - lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb
225
231
  - lib/imperituroard/projects/ukaz60.rb
226
232
  - lib/imperituroard/projects/ukaz60/belgim.rb
227
233
  - lib/imperituroard/projects/ukaz60/dns.rb
@@ -229,7 +235,6 @@ files:
229
235
  - lib/imperituroard/projects/ukaz60/fortigate.rb
230
236
  - lib/imperituroard/projects/ukaz60/staros.rb
231
237
  - lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb
232
- - lib/imperituroard/projects/vpn/ezuev_fun/functions_ezuev.rb
233
238
  - lib/imperituroard/projects/wttx/phpipamcps.rb
234
239
  - lib/imperituroard/projects/wttx/phpipamdb.rb
235
240
  - lib/imperituroard/projects/wttx/updatepostcps.rb
@@ -242,7 +247,7 @@ metadata:
242
247
  homepage_uri: https://rubygems.org/
243
248
  source_code_uri: https://github.com/imperituroard/imperituroard
244
249
  changelog_uri: https://rubygems.org/
245
- post_install_message:
250
+ post_install_message:
246
251
  rdoc_options: []
247
252
  require_paths:
248
253
  - lib
@@ -257,9 +262,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
262
  - !ruby/object:Gem::Version
258
263
  version: '0'
259
264
  requirements: []
260
- rubyforge_project:
265
+ rubyforge_project:
261
266
  rubygems_version: 2.6.14
262
- signing_key:
267
+ signing_key:
263
268
  specification_version: 4
264
269
  summary: imperituroard gem
265
270
  test_files: []