imperituroard 1.1.17 → 1.1.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,4 +42,67 @@ class Qps_2
42
42
  access_interface1 = response.to_hash #[:mts_wifi_portal_get_access_int_response][:accessinterface]
43
43
  end
44
44
 
45
+ def add_avp_acl(username, acl)
46
+ message1 = {
47
+ :audit => {:id => "SOAPGW", :comment => "takih ne berut v kosmonavty"},
48
+ :networkId => username,
49
+ :newAvp => [
50
+ {:code =>"IN-ACL", :value => acl}
51
+ ]
52
+ }
53
+ response = cps_connector_client.call(:change_subscriber_avps) do
54
+ message(message1)
55
+ end
56
+ response.to_hash
57
+ end
58
+
59
+ def delete_avp_acl(username)
60
+ mess = {
61
+ :audit => {:id => 'SOAPGW', :comment => 'some procedure'},
62
+ :networkId => username,
63
+ :deletedAvp => [
64
+ {:code => 'IN-ACL'}
65
+ ]
66
+ }
67
+ response = cps_connector_client.call(:change_subscriber_avps) do
68
+ message(mess)
69
+ end
70
+ response.to_hash
71
+ end
72
+
73
+ def stop_session_username(username)
74
+ params = {
75
+ audit: { id: 'SOAPGW', comment: 'stop session procedure' },
76
+ key: {
77
+ code: 'UserIdKey',
78
+ primary: false,
79
+ key_field: { code: 'userId', value: username }
80
+ }
81
+ }
82
+ p params
83
+ xml = cps_connector_client.call(:stop_session) do
84
+ message(params)
85
+ end
86
+ code = xml.to_hash[:stop_session_response]
87
+ p code
88
+ end
89
+
90
+ def query_session_username(username)
91
+ params = {
92
+ audit: { id: 'SOAPGW', comment: 'query session procedure' },
93
+ key: {
94
+ code: 'UserIdKey',
95
+ primary: false,
96
+ key_field: { code: 'userId', value: username }
97
+ }
98
+ }
99
+ p params
100
+ xml = cps_connector_client.call(:query_session) do
101
+ message(params)
102
+ end
103
+ code = xml.to_hash[:query_session_response]
104
+ p code
105
+ end
106
+
45
107
  end
108
+
@@ -15,7 +15,7 @@ class IwagDbCache
15
15
  end
16
16
 
17
17
 
18
- def insert_new_cache()
18
+ def insert_new_cache
19
19
 
20
20
  end
21
21
 
@@ -19,7 +19,7 @@ class CSRtelnet_1
19
19
  #begin
20
20
 
21
21
  dump =""
22
- connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
22
+ connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*/ ) { |str| }
23
23
  connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
24
24
  connection.cmd("show ip dhcp binding #{ipaddress}") {
25
25
  |c|
@@ -33,7 +33,7 @@ class CSRtelnet_1
33
33
 
34
34
  ma = reer[1].to_s.upcase
35
35
  pos = ma[0]+ma[1]
36
- if pos=="01"
36
+ if pos == '01'
37
37
  subscribers_mac = ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]+":"+ma[15]+ma[16]
38
38
  else
39
39
  subscribers_mac = ma[0]+ma[1]+":"+ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]
@@ -44,7 +44,7 @@ class CSRtelnet_1
44
44
  # subscribers_mac = "unknown"
45
45
  #end
46
46
 
47
- return subscribers_mac
47
+ subscribers_mac
48
48
 
49
49
  end
50
50
 
@@ -69,7 +69,7 @@ class CSRtelnet_1
69
69
 
70
70
  dump =""
71
71
  begin
72
- connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
72
+ connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*/) {|str| print str}
73
73
  connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
74
74
  connection.cmd("show ip dhcp binding #{ipaddress}") {
75
75
  |c|
@@ -82,13 +82,13 @@ class CSRtelnet_1
82
82
  access_interface = as[4].gsub!(" ", "").split(" ").last
83
83
  return access_interface
84
84
  else
85
- answer ="false"
85
+ answer = 'false'
86
86
  return answer
87
87
  end
88
88
  rescue
89
89
  begin
90
- connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
91
- connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
90
+ connection = Net::Telnet.new('Host' => host_iwag, 'Timeout' => false, 'Prompt' => /.*/) {|str| print str}
91
+ connection.login({'Name' => username_iwag, 'Password' => password_iwag, 'LoginPrompt' => /Username:/}) {|str| print str}
92
92
  connection.cmd("show ip dhcp binding #{ipaddress}") {
93
93
  |c|
94
94
  dump << c
@@ -99,11 +99,11 @@ class CSRtelnet_1
99
99
  access_interface = as[4].gsub!(" ", "").split(" ").last
100
100
  return access_interface
101
101
  else
102
- answer ="false"
102
+ answer ='false'
103
103
  return answer
104
104
  end
105
105
  rescue
106
- return "unknown"
106
+ return 'unknown'
107
107
  end
108
108
  end
109
109
  end
@@ -1381,6 +1381,36 @@ class IotFunctions_2
1381
1381
  end
1382
1382
 
1383
1383
 
1384
+ #15
1385
+ #add service iot
1386
+ # soapgw_params = {:imei => "43563456", :imsi => "2452345", :unp => "6454127", :description => "test", :note => "test2"}
1387
+ #{"autorization"=>{"login"=>"login", "token"=>"token"}, "service"=>{"imei"=>"13412341234", "imsi"=>"5645645", "msisdn"=>"3423423", "unp"=>"4564564", "note"=>"test", "descriptiot"=>"test 2"}}
1388
+
1389
+ def spa_service_set_2(soapgw_params, real_ip, remote_ip)
1390
+ input_params = {:soapgw_params => soapgw_params, :real_ip => real_ip, :remote_ip => remote_ip}
1391
+ output_answ = {}
1392
+ begin
1393
+ output_answ = {:code => 200,
1394
+ :message => 'Request completed successfully',
1395
+ :body => {
1396
+ :to_soap_gw => {
1397
+ :code => 200,
1398
+ :result => 'Request completed successfully'
1399
+ }}}
1400
+ mongo_client.audit_spa_logger('spa_service_set_2', {:remote_ip => remote_ip, :real_ip => real_ip}, input_params, output_answ)
1401
+ rescue
1402
+ output_answ = {:code => 500,
1403
+ :message => 'Server error',
1404
+ :body => {
1405
+ :to_soap_gw => {
1406
+ :code => 500,
1407
+ :result => 'Server error'
1408
+ }}}
1409
+ end
1410
+ output_answ
1411
+ end
1412
+
1413
+
1384
1414
  ################################################
1385
1415
  ############technology procedures###############
1386
1416
  ################################################
@@ -26,9 +26,9 @@ class AdditionalFunc
26
26
  imei =0
27
27
  imsi =0
28
28
  msisdn =0
29
- description ="nil"
30
- note ="nil"
31
- type ="nil"
29
+ description = 'nil'
30
+ note = "nil"
31
+ type = "nil"
32
32
  profile ="nil"
33
33
  address ="nil"
34
34
 
@@ -34,16 +34,16 @@ class HuaIot
34
34
  def parse_token(str)
35
35
  begin
36
36
  dd = str.split(",")
37
- acc_token = ""
38
- refr_token = ""
39
- exp_in = ""
37
+ acc_token = ''
38
+ refr_token = ''
39
+ exp_in = ''
40
40
 
41
- access_token = /\"accessToken\":\"(\S+)\"/
42
- refresh_token = /\"refreshToken\":\"(.+)\"/
43
- expires_in = /\"expiresIn\":(\d+)/
41
+ access_token = /"accessToken":"(\S+)"/
42
+ refresh_token = /"refreshToken":"(.+)"/
43
+ expires_in = /"expiresIn":(\d+)/
44
44
 
45
45
  for i in dd
46
- if i.to_s.include?("accessToken")
46
+ if i.to_s.include?('accessToken')
47
47
  acc_token = access_token.match(i)
48
48
  elsif i.to_s.include?("refreshToken")
49
49
  refr_token = refresh_token.match(i)
@@ -64,7 +64,7 @@ class HuaIot
64
64
  data = {}
65
65
  url_string = ""
66
66
  begin
67
- path = "/iocm/app/sec/v1.1.0/login"
67
+ path = '/iocm/app/sec/v1.1.0/login'
68
68
  url_string = "https://" + platformip + ":" + platformport + path
69
69
  internal_func.printer_texter("get_token: start. Step2, url_string: #{url_string}", "debug")
70
70
  uri = URI.parse url_string
@@ -618,7 +618,7 @@ class HuaIot
618
618
 
619
619
  #######################################
620
620
 
621
- def test()
621
+ def test
622
622
 
623
623
  url_string = "https://134.17.93.4:8743/iocm/app/sec/v1.1.0/login"
624
624
  headers = {
@@ -4,7 +4,7 @@ require 'date'
4
4
 
5
5
  class InternalFunc
6
6
 
7
- def datetimenow()
7
+ def datetimenow
8
8
  d_curr = DateTime.now
9
9
  time_zone = 'Europe/Minsk'
10
10
  DateTime.new
@@ -63,11 +63,11 @@ class InternalFunc
63
63
  end
64
64
  end
65
65
  if is_string == 0
66
- output_params = {:code => 200, :result => "if_digit_or_string: Request processed. Its digit", :body => {:string => false}}
66
+ output_params = {:code => 200, :result => 'if_digit_or_string: Request processed. Its digit', :body => {:string => false}}
67
67
  else
68
- output_params = {:code => 200, :result => "if_digit_or_string: Request processed. Its string", :body => {:string => true}}
68
+ output_params = {:code => 200, :result => 'if_digit_or_string: Request processed. Its string', :body => {:string => true}}
69
69
  end
70
- printer_texter({:input_params => input_params, :output_params => output_params}, "debug")
70
+ printer_texter({:input_params => input_params, :output_params => output_params}, 'debug')
71
71
  output_params
72
72
 
73
73
  end
@@ -193,7 +193,7 @@ class InternalFunc
193
193
  end
194
194
 
195
195
 
196
- def test()
196
+ def test
197
197
  p "eeeeeeeeeeeeeeeeeeeeeeee"
198
198
  end
199
199
 
@@ -66,6 +66,31 @@ class MongoIot
66
66
  out_resp
67
67
  end
68
68
 
69
+ def audit_spa_logger(proc_name, url_str, input_json, output_json)
70
+ out_resp = {}
71
+ p "iiiiiiiot"
72
+ p input_json
73
+ begin
74
+ current = internal_func.datetimenow
75
+ collection = client[:audit_spa]
76
+ doc = {
77
+ :proc_name => proc_name,
78
+ :date => current,
79
+ :url => url_str,
80
+ :iot_platform_request => input_json,
81
+ :iot_platform_responce => output_json
82
+ }
83
+ p doc
84
+ result = collection.insert_one(doc)
85
+ out_resp = {:code => 200, :result => "audit_logger: Request completed successfully", :body => result}
86
+ rescue
87
+ out_resp = {:code => 507, :result => "audit_logger: Unknown SDK error"}
88
+ end
89
+ internal_func.printer_texter(out_resp, "debug")
90
+ out_resp
91
+ end
92
+
93
+
69
94
  #:code => 507, :result => "Unknown SDK error"
70
95
  #{:code => 200, :result => "Request completed successfully", :body => result_ps}
71
96
  def get_profiles_by_login(login)
@@ -210,23 +210,44 @@ class MhubFunctions_2
210
210
 
211
211
  #for bank dabrabyt
212
212
  def rec_deliv_report_2(params, ip_src, ip_real, ip_vip, crm_slice_num=2)
213
+ internal_func.printer_texter({:mess => 'started function rec_deliv_report_2'}, log_level)
213
214
  input_params = {:params => params, :ip_src => ip_src, :ip_real => ip_real, :ip_vip => ip_vip}
214
215
  output_params = {}
215
216
  hub_resp = {}
217
+ result = {}
216
218
 
219
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step1'}, log_level)
217
220
  begin
218
221
  mes_report = dabrab_connecter.delivery_report_transform(params)[:body][:report_to_recip]
219
- result = crm_connector.crm_status_2(mes_report, crm_slice_num)
220
- if result[:body][:res_body]["GetReportsResult"]==""
221
- output_params = {"code": 200, "result": "Data processed", "body": {"answer": {"code": 200, "status": "Success"}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
222
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step2'}, log_level)
223
+
224
+ begin
225
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step2.1'}, log_level)
226
+ result = crm_connector.crm_status_2(mes_report, crm_slice_num)
227
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step2.2'}, log_level)
228
+ rescue
229
+ result = {:code => 505505, :result => 'Error', :body => {:res_body => 'Error communication with crm'}}
230
+ end
231
+
232
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step3'}, log_level)
233
+ if result[:body][:res_body] == ''
234
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step4'}, log_level)
235
+ output_params = {'code': 200, 'result': 'Data processed', 'body': {'answer': {'code': 200, 'status': 'Success'}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}}
236
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step5'}, log_level)
237
+ elsif result[:code] == 505505
238
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step5.1'}, log_level)
239
+ output_params = {'code': 505, 'result': 'Data processed', 'body': {'answer': {'code': 505, 'status': 'Error communicate with dabrabyt'}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}}
240
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step5.2'}, log_level)
222
241
  else
223
- output_params = {"code": 202, "result": "CRM returned error #{result[:body][:res_body]["GetReportsResult"].to_s}", "body": {"answer": {"code": 200, "status": "Success"}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
242
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step6'}, log_level)
243
+ output_params = {'code': 202, 'result': "CRM returned error #{result[:body][:res_body]['GetReportsResult'].to_s}", 'body': {'answer': {'code': 200, 'status': 'Success'}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}}
244
+ internal_func.printer_texter({:mess => 'rec_deliv_report_2 step7'}, log_level)
224
245
  end
225
246
  rescue
226
- output_params = {"code": 500, "result": "MhubFunctions_2.rec_deliv_report_2: Unknown SDK error", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
247
+ output_params = {'code': 500, 'result': 'MhubFunctions_2.rec_deliv_report_2: Unknown SDK error', 'body': {'answer': {}, 'sender': {'ip_src': ip_src, 'ip_real': ip_real, 'ip_vip': ip_vip}}}
227
248
  telegram_connector.telegram_message(output_params)
228
249
  end
229
- internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => "Mhub_2.recieve_delivery_report"}, log_level)
250
+ internal_func.printer_texter({:input => input_params, :output => output_params, :hub_resp => hub_resp, :procedure => 'Mhub_2.recieve_delivery_report'}, log_level)
230
251
  output_params
231
252
  end
232
253
 
@@ -24,40 +24,40 @@ class Gmsgms_2
24
24
  output = {}
25
25
 
26
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"
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
51
  }
52
52
 
53
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"]}}
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
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]}}
58
+ output = {:code => 404, :result => 'Not found', :body => {'status_code': '', 'status': '', 'phone_number': '', 'message_id': gms_answer[:body][:request_message][:external_id]}}
59
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]}}
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
61
  end
62
62
  output
63
63
  end
@@ -22,11 +22,13 @@ class Crm_2
22
22
 
23
23
  begin
24
24
 
25
- internal_func.printer_texter({:input => "Start process", :procedure => "Crm_2.crm_status_2"}, log_level)
25
+ internal_func.printer_texter({:input => 'Start process', :procedure => "Crm_2.crm_status_2"}, log_level)
26
26
 
27
27
 
28
28
  thr_crm_status_2 = Thread.new do
29
29
 
30
+ internal_func.printer_texter({:input => 'Thread start', :procedure => 'Crm_2.crm_status_2'}, log_level)
31
+
30
32
  partnnn = crm_payload[:results].each_slice(slice_num).to_a
31
33
 
32
34
  partnnn.each { |one_part_reports|
@@ -37,6 +39,8 @@ class Crm_2
37
39
  uri = URI(crm_callback_url)
38
40
  #8 - client id
39
41
 
42
+ internal_func.printer_texter({:input => 'before net', :procedure => 'Crm_2.crm_status_2'}, log_level)
43
+
40
44
  https = Net::HTTP.new(uri.host, uri.port)
41
45
  https.use_ssl = true
42
46
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -54,10 +58,19 @@ class Crm_2
54
58
 
55
59
  internal_func.printer_texter({:input => "Before send request to crm", :procedure => "Crm_2.crm_status_2"}, log_level)
56
60
 
57
- res = https.request(req)
61
+ begin
62
+
63
+ res = https.request(req)
64
+ internal_func.printer_texter({:input => "After send request to crm Ok", :procedure => "Crm_2.crm_status_2"}, log_level)
65
+ internal_func.printer_texter({:input => {:res_code => res.code, :res_body => res.body.to_s}, :procedure => "Crm_2.crm_status_2"}, log_level)
66
+
67
+ rescue
68
+
69
+ res = 'dabrabyt error'
70
+ internal_func.printer_texter({:input => "After send request to crm error", :procedure => "Crm_2.crm_status_2"}, log_level)
71
+ internal_func.printer_texter({:input => {:res_code => "500", :res_body => res}, :procedure => "Crm_2.crm_status_2"}, log_level)
58
72
 
59
- internal_func.printer_texter({:input => "After send request to crm", :procedure => "Crm_2.crm_status_2"}, log_level)
60
- internal_func.printer_texter({:input => {:res_code => res.code, :res_body => res.body.to_s}, :procedure => "Crm_2.crm_status_2"}, log_level)
73
+ end
61
74
 
62
75
  }
63
76