imperituroard 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/imperituroard.rb CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__)
2
2
  $LOAD_PATH.unshift File.expand_path("../projects/wttx", __dir__)
3
3
  $LOAD_PATH.unshift File.expand_path("../projects/mhub", __dir__)
4
4
  $LOAD_PATH.unshift File.expand_path("../projects/mhub/subs/dabrab", __dir__)
5
-
5
+ $LOAD_PATH.unshift File.expand_path("../platforms/cps", __dir__)
6
6
 
7
7
  require "imperituroard/version"
8
8
  require "imperituroard/phpipamdb"
@@ -15,6 +15,8 @@ require 'imperituroard/projects/mhub/infobip'
15
15
  require 'imperituroard/projects/mhub/sk'
16
16
  require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced'
17
17
  require 'imperituroard/projects/mhub/subs/dabrab/dabrab_platform'
18
+ require 'imperituroard/iot'
19
+ require 'imperituroard/platforms/cps/qps_connector'
18
20
  require 'json'
19
21
  require 'ipaddr'
20
22
  require 'date'
@@ -109,7 +111,8 @@ class Iot
109
111
  :real_ip, #real ip address of procedure caller
110
112
  :remote_ip, #ip address of balancer
111
113
  :hua_aceanconnect_connector,
112
- :internal_func
114
+ :internal_func,
115
+ :iot_connector
113
116
 
114
117
  def initialize(mongoip, mongoport, iotip, mongo_database,
115
118
  iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id, real_ip, remote_ip)
@@ -127,6 +130,8 @@ class Iot
127
130
  @remote_ip = remote_ip
128
131
  @hua_aceanconnect_connector = HuaIot.new(iotplatform_ip, iotplatform_port, cert_path, key_path)
129
132
  @internal_func = InternalFunc.new
133
+ @iot_connector = IotFunctions_2.new(mongoip, mongoport, iotip, mongo_database,
134
+ iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id, real_ip, remote_ip)
130
135
  end
131
136
 
132
137
  #error list
@@ -134,7 +139,6 @@ class Iot
134
139
  #:code => 507, :result => "Unknown SDK error"
135
140
  #{:code => 200, :result => "Request completed successfully", :body => result_ps}
136
141
 
137
-
138
142
  #!!1. Add device to profile (only for new device)
139
143
  #login - login for client identification
140
144
  #profile - profile for device
@@ -145,108 +149,7 @@ class Iot
145
149
  #+++
146
150
  #iot logic added
147
151
  def add_device_to_profile(login, imei_list)
148
- input_json = {:login => login, :imei_list => imei_list}
149
- resp_out = {}
150
- begin
151
-
152
- thr1 = Thread.new do
153
- if add_functions_connector.check_input_1(login, imei_list)[:code]==200
154
-
155
- imei = []
156
- list1 = {}
157
- for_insert = []
158
- not_processed_list = []
159
- processed_list = []
160
-
161
- for ii in imei_list
162
- list1[ii["imei"]] = ii
163
- imei.append(ii["imei"])
164
- end
165
- list_checked = mongo_client.check_imei_exists(imei)
166
- for ss in list_checked[:body][:exists]
167
- not_processed_list.append({:imei => ss, :error => "Device exists in database"})
168
- end
169
-
170
- for jj in list_checked[:body][:not_exists]
171
- begin
172
- get_login_info = mongo_client.check_login_prof_perm_id_one(login, list1[jj]["profile"])[:code]
173
- if get_login_info==200
174
- for_insert.append(list1[jj])
175
- else
176
- not_processed_list.append({:imei => list1[jj], :error => "Permission denied for this profile"})
177
- end
178
- rescue
179
- not_processed_list.append({:imei => list1[jj], :error => "Unknown error"})
180
- end
181
- end
182
-
183
- begin
184
- added_on_iot_platf = []
185
- if for_insert!=[]
186
- ##Logic for IOT Platform connection###
187
-
188
- credentials = mongo_client.get_iot_oceanconnect_credent(login)
189
-
190
- if credentials[:code]==200
191
- for aaa in for_insert
192
- begin
193
- dev_name = aaa["imei"].to_s
194
-
195
- #get {"model"=>"BGT_PPMC", "ManufacturerID"=>"unknown", "ManufacturerNAME"=>"unknown", "device_type"=>"unknown"}
196
- #from database
197
- model_data = mongo_client.get_device_type_info_by_model(aaa["device_type"])
198
- resss = hua_aceanconnect_connector.add_new_device_on_huawei(credentials[:body][:app_id],
199
- credentials[:body][:secret],
200
- aaa["imei"],
201
- dev_name,
202
- aaa["description"],
203
- model_data[:body]["device_type"],
204
- aaa["profile"],
205
- model_data[:body]["ManufacturerID"],
206
- model_data[:body]["ManufacturerNAME"],
207
- model_data[:body]["model"]
208
- )
209
- if resss[:code]=="200"
210
- s1 = aaa
211
- s1[:huadata] = resss
212
- s1[:created] = DateTime.now
213
- added_on_iot_platf.append(s1)
214
- else
215
- not_processed_list.append({:imei => aaa["imei"], :error => resss})
216
- end
217
- rescue
218
- not_processed_list.append({:imei => aaa["imei"], :error => "Unknown error with insertion imei on IOT platform"})
219
- end
220
- end
221
-
222
- #########end iot platform logic#######
223
-
224
- mongo_client.imei_insert_list(added_on_iot_platf)
225
- resp_out = {:code => 200, :result => "Data processed", :body => {:imei_processed => added_on_iot_platf, :error_list => not_processed_list}}
226
- else
227
- resp_out = {:code => 400, :result => "IOT platform credentials not found"}
228
- end
229
-
230
-
231
- else
232
- resp_out = {:code => 202, :result => "Nothing for insertion", :body => {:imei_processed => added_on_iot_platf, :error_list => not_processed_list}}
233
-
234
- end
235
- rescue
236
- resp_out = {:code => 505, :result => "Error with database communication"}
237
- end
238
-
239
- else
240
- resp_out = {:code => 509, :result => "Input data invalid"}
241
- end
242
- end
243
- rescue
244
- resp_out = {:code => 507, :result => "Unknown SDK error"}
245
- end
246
- thr1.join
247
-
248
- mongo_client.audit_logger("add_device_to_profile", remote_ip, input_json, resp_out, real_ip)
249
- resp_out
152
+ iot_connector.add_device_to_prof_2(login, imei_list)
250
153
  end
251
154
 
252
155
 
@@ -258,55 +161,7 @@ class Iot
258
161
  # imei_list =[41234,23452345,132412]
259
162
  #++
260
163
  def device_find(login, imei_list)
261
- input_json = {:login => login, :imei_list => imei_list}
262
- ime_list_approved = []
263
- ime_list_notapproved = []
264
- resp_out = {}
265
- begin
266
- thr2 = Thread.new do
267
- if add_functions_connector.check_input_2(login, imei_list)[:code]==200
268
-
269
- for t in imei_list
270
- prof_name1 = mongo_client.get_profile_name_from_imei(t)
271
- if prof_name1[:code]==200
272
- begin
273
- permiss1 = mongo_client.check_login_profile_permiss(login, prof_name1[:body]["profile"])
274
- p "permiss1"
275
- p permiss1
276
- if permiss1[:code]==200
277
- ime_list_approved.append(t)
278
- else
279
- ime_list_notapproved.append({:imei => t, :error => permiss1})
280
- end
281
- rescue
282
- ime_list_notapproved.append({:imei => t, :error => {:code => 405, :result => "Unknown error when check_login_profile_permiss imei #{t.to_s}"}})
283
- end
284
- else
285
- ime_list_notapproved.append({:imei => t, :error => prof_name1})
286
- end
287
- end
288
- begin
289
- if ime_list_approved != []
290
- data = mongo_client.get_imei_info_from_db(ime_list_approved)
291
-
292
- resp_out = {:code => 200, :result => "Request completed successfully", :data => {:approved_list => data, :unapproved_list => ime_list_notapproved}}
293
-
294
- else
295
- resp_out = {:code => 404, :result => "Invalidate data", :data => {:approved_list => [], :unapproved_list => ime_list_notapproved}}
296
- end
297
- rescue
298
- resp_out = {:code => 504, :result => "Unsuccessfully data transfer"}
299
- end
300
- else
301
- resp_out = {:code => 509, :result => "Input data invalid"}
302
- end
303
- end
304
- rescue
305
- resp_out = {:code => 507, :result => "Unknown SDK error"}
306
- end
307
- thr2.join
308
- mongo_client.audit_logger("device_find", remote_ip, input_json, resp_out, real_ip)
309
- resp_out
164
+ iot_connector.device_find_2(login, imei_list)
310
165
  end
311
166
 
312
167
  #!3 device modify, change imei
@@ -317,160 +172,9 @@ class Iot
317
172
  #im_list = [{"imei_old"=>7967843245667, "imei_new"=>7967843245665}]
318
173
  #++
319
174
  def imei_replace(login, im_list)
320
- input_json = {:login => login, :imei_list => im_list}
321
- resp_out = {}
322
-
323
- begin
324
-
325
- thr3 = Thread.new do
326
-
327
- if add_functions_connector.check_input_3(login, im_list)[:code]==200
328
-
329
- li_new_imei = []
330
- list1 = {}
331
-
332
- #dictionary for imeis which not processed. Final dictionary
333
- not_processed_list = []
334
-
335
- #dictionary for devices which was processed correctly
336
- processed_list = []
337
-
338
- #array for translations from old imei to new
339
- old_new_translation = {}
340
-
341
- approved_list = []
342
-
343
-
344
- #old_imei_list for query to iot platform for data request
345
- step1_approved_dict_old=[]
346
-
347
- #form dictionary for processing
348
- for pr1 in im_list
349
- li_new_imei.append(pr1["imei_new"])
350
- list1[pr1["imei_new"]]=pr1["imei_old"]
351
- old_new_translation[pr1["imei_old"]]=pr1["imei_new"]
352
- end
353
-
354
- #check if imei_new exists in database. If exists - not process this imei
355
- list_checked = mongo_client.check_imei_exists(li_new_imei)
356
-
357
- internal_func.printer_texter({:function => "imei_replace Step1", :list_checked => list_checked}, "debug")
358
-
359
- #add already exists new IMEI in error dictionary
360
- for ss in list_checked[:body][:exists]
361
- not_processed_list.append({:record => {:imei_old => list1[ss], :imei_new => ss}, :error => "New IMEI exists in database"})
362
- end
363
-
364
- #new_imei list which processed step1
365
- step2_list = list_checked[:body][:not_exists]
366
-
367
- internal_func.printer_texter({:function => "imei_replace Step2", :step2_list => step2_list}, "debug")
368
-
369
-
370
- for a in step2_list
371
- begin
372
-
373
- #step3 checking permission for writing for imei list
374
- prof_name1 = mongo_client.get_profile_name_from_imei(list1[a])
375
-
376
- internal_func.printer_texter({:function => "imei_replace Step3", :prof_name1 => prof_name1}, "debug")
377
-
378
- if prof_name1[:code]==200
379
- permiss1 = mongo_client.check_login_profile_permiss(login, prof_name1[:body]["profile"])[:code]
380
- internal_func.printer_texter({:function => "imei_replace Step4", :permiss1 => permiss1, :input => prof_name1[:body]["profile"]}, "debug")
381
- if permiss1==200
382
-
383
- approved_list.append({:imei_old => list1[a], :imei_new => a})
384
- step1_approved_dict_old.append(list1[a])
385
-
386
- else
387
- not_processed_list.append({:record => {:imei_old => list1[a], :imei_new => a}, :error => "Old IMEI modification denied"})
388
- end
389
- else
390
- not_processed_list.append({:record => {:imei_old => list1[a], :imei_new => a}, :error => "Old IMEI not exists in database"})
391
- end
392
- rescue
393
- not_processed_list.append({:record => {:imei_old => list1[a], :imei_new => a}, :error => "Unknown error"})
394
- end
395
- end
396
-
397
- internal_func.printer_texter({:function => "imei_replace Step5", :not_processed_list => not_processed_list, :input => list1, :approved_list => approved_list, :step1_approved_dict_old => step1_approved_dict_old}, "debug")
398
-
399
-
400
- ##Logic for IOT Platform connection###
401
-
402
- list_from_iot = self.get_info_by_imeilist_from_iot(login, step1_approved_dict_old)
403
-
404
- internal_func.printer_texter({:function => "imei_replace Step6", :list_from_iot => list_from_iot, :description => "data from iot platform by old imei"}, "debug")
405
-
406
- #processing data. modifying data on iot platform and mongoDB
407
- if list_from_iot[:code]=="200"
408
-
409
- for ard in list_from_iot[:body]["devices"]
410
- p ard
411
- new_data_cur_dev = {}
412
- mongo_answer = {}
413
- current_old_dev = ard["deviceInfo"]["nodeId"]
414
- current_device_id = ard["deviceId"]
415
- new_data_cur_dev = ard["deviceInfo"]
416
- new_data_cur_dev["nodeId"] = old_new_translation[current_old_dev.to_i].to_s
417
-
418
- credentials = mongo_client.get_iot_oceanconnect_credent(login)
419
-
420
- if credentials[:code]==200
421
- flag_remove=0
422
- flag_create=0
423
- remove_answer = hua_aceanconnect_connector.remove_one_device_from_iot(credentials[:body][:app_id], credentials[:body][:secret], current_device_id)
424
- create_answer = hua_aceanconnect_connector.add_new_device_on_huawei2(credentials[:body][:app_id], credentials[:body][:secret], new_data_cur_dev)
425
-
426
- if remove_answer[:code]=="204" || remove_answer[:code]=="200"
427
- flag_remove=1
428
- end
429
- if create_answer[:code]=="200"
430
- flag_create=1
431
- end
432
- if flag_remove==1 && flag_create==1
433
- mongo_answer = mongo_client.device_modify_any_attr_mongo(current_old_dev.to_i, {:imei => old_new_translation[current_old_dev.to_i], :huadata => {:body => create_answer[:body]}, :updated => DateTime.now})
434
- processed_list.append({:imei_old => current_old_dev.to_i, :imei_new => old_new_translation[current_old_dev.to_i]})
435
- else
436
- not_processed_list.append({:record => {:imei_old => current_old_dev.to_i, :imei_new => old_new_translation[current_old_dev.to_i]}, :error => "Failed for provisioning to IOT platform"})
437
- end
438
-
439
- internal_func.printer_texter({:function => "imei_replace Step7", :remove_answer => remove_answer, :create_answer => create_answer, :mongo_answer => mongo_answer, :description => "processing imei #{current_old_dev.to_s}"}, "debug")
440
-
441
- else
442
- approved_list=[]
443
- end
444
- end
445
-
446
- else
447
- approved_list=[]
448
- end
449
-
450
- if approved_list!=[]
451
- resp_out = {:code => 200, :result => "Request completed successfully", :data => {:approved_list => processed_list, :unapproved_list => not_processed_list}}
452
- else
453
- resp_out = {:code => 202, :result => "Nothing to do", :data => {:approved_list => processed_list, :unapproved_list => not_processed_list}}
454
- end
455
-
456
- else
457
- resp_out = {:code => 509, :result => "Input data invalid"}
458
- end
459
-
460
- end
461
-
462
- rescue
463
- resp_out = {:code => 507, :result => "Unknown SDK error"}
464
- end
465
-
466
- thr3.join
467
- mongo_client.audit_logger("imei_replace", remote_ip, input_json, resp_out, real_ip)
468
-
469
- resp_out
470
-
175
+ iot_connector.imei_replace_2(login, im_list)
471
176
  end
472
177
 
473
-
474
178
  #!!4 remove device
475
179
  #login
476
180
  #imei
@@ -480,69 +184,10 @@ class Iot
480
184
  #+++
481
185
  #IOT logic added
482
186
  def device_remove(login, imei)
187
+ iot_connector.device_remove_2(login, imei)
188
+ end
483
189
 
484
- input_json = {:login => login, :imei_list => imei}
485
- resp_out = {}
486
190
 
487
- begin
488
- thr4 = Thread.new do
489
-
490
- if add_functions_connector.check_input_4(login, imei)[:code]==200
491
-
492
- prof_name = mongo_client.get_profile_name_from_imei(imei)
493
- if prof_name[:code]==200
494
- permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
495
- if permiss[:code]==200
496
-
497
- ##Logic for IOT Platform connection###
498
-
499
- credentials = mongo_client.get_iot_oceanconnect_credent(login)
500
- resp = {}
501
-
502
- if credentials[:code]==200
503
-
504
- imei_data = mongo_client.get_imei_info_from_db([imei])
505
- if imei_data[:body]!=[]
506
- ans = hua_aceanconnect_connector.remove_one_device_from_iot(credentials[:body][:app_id], credentials[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
507
- p ans
508
- if ans[:code]=="204" or ans[:code]=="200"
509
- resp = mongo_client.device_remove_single_mongo(imei)
510
- else
511
- resp = {:code => 500, :result => "Unknown IOT platform error", :body => ans}
512
- end
513
- else
514
- resp_out = {:code => 404, :result => "Data not found"}
515
- end
516
-
517
- #########end iot platform logic#######
518
-
519
- if resp[:code]==200
520
- resp_out = {:code => 200, :result => "Request completed successfully"}
521
- else
522
- resp_out=resp
523
- end
524
- else
525
- resp_out = {:code => 400, :result => "IOT platform credentials not found"}
526
- end
527
- else
528
- resp_out=permiss
529
- end
530
- else
531
- resp_out=prof_name
532
- end
533
- else
534
- resp_out = {:code => 509, :result => "Input data invalid"}
535
- end
536
-
537
- end
538
-
539
- rescue
540
- resp_out = {:code => 507, :result => "Unknown SDK error"}
541
- end
542
- thr4.join
543
- mongo_client.audit_logger("device_remove", remote_ip, input_json, resp_out, real_ip)
544
- resp_out
545
- end
546
191
 
547
192
 
548
193
  #!5 add address to device
@@ -553,72 +198,9 @@ class Iot
553
198
  #+++
554
199
  #iot platform integration completed
555
200
  def device_add_address(login, newdevice_list)
556
- #add_functions_connector.telegram_message(newdevice_list.to_s)
557
- p newdevice_list
558
- p "gas"
559
- p MyJSON.valid?(newdevice_list[0].to_s)
560
- p "sdfsdfgs"
561
- input_json = {:login => login, :devices => newdevice_list}
562
- resp_out = {}
563
- not_processed = []
564
- processed = []
565
- begin
566
- thr5 = Thread.new do
567
- if add_functions_connector.check_input_5(login, newdevice_list)[:code]==200
568
-
569
- for p in newdevice_list
570
- prof_name = mongo_client.get_profile_name_from_imei(p[:imei])
571
-
572
- if prof_name[:code]==200
573
- permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
574
- if permiss[:code]==200
575
-
576
- ##Logic for IOT Platform connection###
577
- credentials = mongo_client.get_iot_oceanconnect_credent(login)
578
- resp = {}
579
-
580
- if credentials[:code]==200
581
- imei_data = mongo_client.get_imei_info_from_db([p[:imei]])
582
- if imei_data[:body]!=[]
583
- ans =hua_aceanconnect_connector.modify_location_iot(credentials[:body][:app_id], credentials[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"], p[:address])
584
-
585
- internal_func.printer_texter({:function => "device_add_address Step2", :ans => ans, :descrition => "answer from hua IOT", :input => {:did => imei_data[:body][0]["huadata"]["body"]["deviceId"], :appid => credentials[:body][:app_id], :secret => credentials[:body][:secret], :address => p[:address]}}, "debug")
586
- end
587
-
588
- end
589
-
590
- #########end iot platform logic#######
591
-
592
- resp = mongo_client.device_modify_attr_mongo(p[:imei], p[:address])
593
- if resp[:code]==200
594
- processed.append({:imei => p[:imei]})
595
- end
596
- else
597
- not_processed.append({:imei => p[:imei], :address => p[:address], :error => permiss})
598
- end
599
- else
600
- not_processed.append({:imei => p[:imei], :address => p[:address], :error => prof_name})
601
- end
602
- end
603
-
604
- if processed!=[]
605
- resp_out = {:code => 200, :result => "Request completed successfully", :body => {:imei_processed => processed, :error_list => not_processed}}
606
- else
607
- resp_out = {:code => 202, :result => "Nothing processed", :body => {:imei_processed => processed, :error_list => not_processed}}
608
- end
609
- else
610
- resp_out = {:code => 509, :result => "Input data invalid"}
611
- end
612
- end
613
- rescue
614
- resp_out = {:code => 507, :result => "Unknown SDK error"}
615
- end
616
- thr5.join
617
- mongo_client.audit_logger("device_add_address", remote_ip, input_json, resp_out, real_ip)
618
- resp_out
201
+ iot_connector.device_add_address_2(login, newdevice_list)
619
202
  end
620
203
 
621
-
622
204
  #6 add service by SPA
623
205
  #imei
624
206
  #profile
@@ -627,115 +209,37 @@ class Iot
627
209
  #newdevice_list=[{:imei=>7967843245665, :attributes=>{:address=>"Golubeva51", :profile=>"wqeqcqeqwev", :msisdn=>375298766719, :imsi=>25702858586756875}}]
628
210
  #+
629
211
  def add_service(login, device_list)
630
- resp_out = {}
631
- not_processed = []
632
- processed = []
633
-
634
- input_json = {:login => login, :devices => device_list}
635
-
636
- begin
637
-
638
- thr6 = Thread.new do
639
-
640
- if add_functions_connector.check_input_5(login, device_list)[:code]==200
641
-
642
- for g in device_list
643
-
644
- prof_name1 = mongo_client.get_profile_name_from_imei(g["imei"])
645
-
646
- if prof_name1[:code]==200
647
- permiss1 = mongo_client.check_login_profile_permiss(login, prof_name1[:body]["profile"])
648
- if permiss1[:code]==200
649
-
650
- if g["attributes"].key?("profile")
651
- permiss2 = mongo_client.check_login_profile_permiss(login, g["attributes"]["profile"])[:code]
652
-
653
- if permiss2==200
654
-
655
- attr = g["attributes"]
656
- #mod_attr = {}
657
-
658
- if attr.key?("profile")
659
- if attr["profile"].is_a? Integer
660
- p "Ok"
661
- else
662
- p new = mongo_client.get_profile_id_by_name(attr["profile"])
663
- attr["profile"] = new["profile_id"]
664
- end
665
- end
666
- mongo_client.device_modify_any_attr_mongo(g["imei"], attr)
667
- processed.append(g["imei"])
668
- else
669
- not_processed.append({:imei => g["imei"], :description => "New profile permission error", :error => permiss2})
670
- end
671
-
672
- else
673
- attr = g["attributes"]
674
- mongo_client.device_modify_any_attr_mongo(g["imei"], attr)
675
- processed.append(g["imei"])
676
- end
677
- else
678
- not_processed.append({:imei => g["imei"], :description => "Old profile permission error", :error => permiss1})
679
- end
680
-
681
- else
682
- not_processed.append({:imei => g["imei"], :error => prof_name1})
683
- end
684
-
685
- end
686
- resp_out = {:code => 200, :result => "Request completed successfully", :body => {:imei_processed => processed, :error_list => not_processed}}
687
- else
688
- resp_out = {:code => 509, :result => "Input data invalid"}
689
- end
690
-
691
- end
692
-
693
- rescue
694
- resp_out = {:code => 507, :result => "Unknown SDK error"}
695
- end
696
- thr6.join
697
- mongo_client.audit_logger("device_remove", remote_ip, input_json, resp_out, real_ip)
698
- resp_out
212
+ iot_connector.add_service_2(login, device_list)
699
213
  end
700
214
 
701
215
 
702
216
  #7 procedure for subscriber autorization
703
217
  def autorize_subscriber(login, password)
704
- input_json = {:login => login, :password => password}
705
- resp_out = {}
706
- thr7 = Thread.new do
707
- begin
708
- login_inform = mongo_client.get_login_info(login)
709
- if login_inform[:code]==200
710
- pass_mongo = login_inform[:body]["password"]
711
- if pass_mongo == password
712
- resp_out = {:code => 200, :result => "Access granted"}
713
- else
714
- resp_out = {:code => 400, :result => "Access denied"}
715
- end
716
- else
717
- resp_out = {:code => 401, :result => "Access denied. Incorrect login"}
718
- end
719
- rescue
720
- resp_out = {:code => 507, :result => "Unknown SDK error"}
721
- end
722
- end
723
- thr7.join
724
- mongo_client.audit_logger("autorize_subscriber", remote_ip, input_json, resp_out, real_ip)
725
- resp_out
218
+ iot_connector.autorize_subscriber_2(login, password)
726
219
  end
727
220
 
728
- def get_available_profiles(login)
729
221
 
222
+ #8 get available profiles for login
223
+ def get_available_profiles(login)
224
+ iot_connector.get_available_prof_2(login)
730
225
  end
731
226
 
227
+
228
+ #9 get available types for login
732
229
  def get_available_types(login)
230
+ iot_connector.get_available_types_2(login)
231
+ end
733
232
 
233
+
234
+ #10 get info for device type
235
+ def get_info_data_type(type)
236
+ iot_connector.get_info_data_type_2(type)
734
237
  end
735
238
 
736
239
 
737
- def answ_dev_query_format_process(dev_list)
738
- add_functions_connector.answ_dev_query_format_process(dev_list)
240
+ #11 get info for profile
241
+ def get_info_data_profile(profile)
242
+ iot_connector.get_info_data_profile_2(profile)
739
243
  end
740
244
 
741
245
 
@@ -743,6 +247,8 @@ class Iot
743
247
  mongo_client.audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
744
248
  end
745
249
 
250
+
251
+
746
252
  #additional procedure for checking status on iot platform
747
253
  def get_info_by_imeilist_from_iot(login, imei_list)
748
254
  resp_out={}
@@ -934,4 +440,25 @@ class Mhub_2
934
440
  hh.test
935
441
  end
936
442
 
443
+ end
444
+
445
+
446
+ class CpsFunctions_2
447
+
448
+ attr_accessor :qps_connector
449
+
450
+ def initialize(cps_wsdl, cps_endpoint, cps_namespace)
451
+ @qps_connector = Qps_2.new(cps_wsdl, cps_endpoint, cps_namespace)
452
+ end
453
+
454
+ def recreate_cps_profile(msisdn)
455
+ p gettt = qps_connector.get_subscriber_msisdn(msisdn)
456
+ p qps_connector.delete_subscriber(msisdn)
457
+ p qps_connector.recreate_subscriber(gettt)
458
+ end
459
+
460
+ def get_subscriber_profile(msisdn)
461
+ qps_connector.get_subscriber_msisdn(msisdn)
462
+ end
463
+
937
464
  end