imperituroard 0.2.5 → 0.2.7

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: 162e6e937083e7f1307a970dde31e6f1e32361cc
4
- data.tar.gz: 2cbd8b609bc29adee176e4f655c32884b470bb06
3
+ metadata.gz: 82ccb8c3495b39d57508a73c4a7d8fbdb773dda8
4
+ data.tar.gz: b9b50d62346f67480c4f25529cc05bc3857c467e
5
5
  SHA512:
6
- metadata.gz: 67208ee0587648aca3539642c80cff0bc3588a3dae78e9ee6cc4f58d6f2228e2c9044f1b45e89263f6090becc65f860fab664eda5862e650ea5634577994b9ed
7
- data.tar.gz: 833d138815a513d483ad4a154d13a168fe17f1e993f87fdf6a5b2d0278c024c2cbe6972f8504e538855c48cab12b46a882e5a318cda181d7ea2ba928dc481dad
6
+ metadata.gz: 7a1c07bf801f14556025427da6b5cc9de7fc72fa138735da13442314ec2ed185eb234b826e4cf0032d975c3d18f1dba1a31f95bf37447ec6b35ec212c93478b8
7
+ data.tar.gz: 2a0eddeb80e167ccfe33b1d2b25dd1281cbea7f5fda5f02da99cc714e830bb7d044efcb5d74237bd4b1259fd28716ec4881f2e9e77658fd3a61d624977ccd909
@@ -10,6 +10,7 @@ class AdditionalFunc
10
10
  def initialize(telegram_api_url, telegram_chat_id)
11
11
  @telegram_api_url = telegram_api_url
12
12
  @telegram_chat_id = telegram_chat_id
13
+
13
14
  end
14
15
 
15
16
  #procedure for send log to telegram chat
@@ -113,4 +114,6 @@ class AdditionalFunc
113
114
  end
114
115
 
115
116
  end
117
+
118
+
116
119
  end
@@ -11,11 +11,10 @@ class HuaIot
11
11
 
12
12
  attr_accessor :platformip, :platformport, :client, :database, :cert_file, :key_file
13
13
 
14
- def initialize(platformip, platformport, iotip, database, cert_file, key_file)
14
+ def initialize(platformip, platformport, cert_file, key_file)
15
15
  @database = database
16
16
  @platformip = platformip
17
17
  @platformport = platformport
18
- @iotip = iotip
19
18
  @cert_file = cert_file
20
19
  @key_file = key_file
21
20
  #client_host = [mongoip + ":" + mongoport]
@@ -89,10 +88,33 @@ class HuaIot
89
88
  {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
90
89
  end
91
90
 
91
+ #2.2.4 Registering a Directly Connected Device (Password Mode) (V2)
92
+ def dev_register_passw_code_mode2(app_id, secret, node_id, name_p, description_p, device_type, profile)
93
+ token = get_token(app_id, secret)[:body]["accessToken"]
94
+ path = "/iocm/app/reg/v2.0.0/deviceCredentials?appId=" + app_id
95
+ url_string = "https://" + platformip + ":" + platformport + path
96
+ uri = URI.parse url_string
97
+ https = Net::HTTP.new(uri.host, uri.port)
98
+ https.use_ssl = true
99
+ https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
100
+ https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
101
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
102
+ request = Net::HTTP::Post.new(uri.path)
103
+ request.content_type = 'application/json'
104
+ request['Authorization'] = 'Bearer ' + token
105
+ request['app_key'] = app_id
106
+ request.body = {deviceInfo: {nodeId: node_id, name: name_p, description: description_p, deviceType: device_type}}.to_json
107
+ res = https.request(request)
108
+ p res.body.to_s
109
+ {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
110
+ end
111
+
112
+
92
113
 
93
- def dev_delete(app_id, secret, node_id)
114
+ #2.2.12 Deleting a Directly Connected Device
115
+ def dev_delete(app_id, secret, dev_id)
94
116
  token = get_token(app_id, secret)[:body]["accessToken"]
95
- path = "/iocm/app/dm/v1.1.0/devices/" + node_id + "?app_Id=" + app_id + "&cascade=true"
117
+ path = "/iocm/app/dm/v1.1.0/devices/" + dev_id + "?app_Id=" + app_id + "&cascade=true"
96
118
  url_string = "https://" + platformip + ":" + platformport + path
97
119
  uri = URI.parse url_string
98
120
  https = Net::HTTP.new(uri.host, uri.port)
@@ -105,13 +127,21 @@ class HuaIot
105
127
  request['Authorization'] = 'Bearer ' + token
106
128
  request['app_key'] = app_id
107
129
  res = https.request(request)
108
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
130
+ p res.code
131
+ p res.body
132
+ if res.body != nil
133
+ {:code => res.code, :message => res.message, :body => {:answ => JSON.parse(res.body.to_s)}}
134
+ else
135
+ {:code => res.code, :message => res.message, :body => {:answ => "no data"}}
136
+ end
137
+
109
138
  end
110
139
 
111
140
 
112
141
  #2.2.44 Querying the Device ID
113
142
  def querying_device_id(app_id, secret, node_id)
114
143
  token = get_token(app_id, secret)[:body]["accessToken"]
144
+ p token
115
145
  path = "/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id
116
146
  p path
117
147
  p path
@@ -127,9 +157,9 @@ class HuaIot
127
157
  request.content_type = 'application/json'
128
158
  request['Authorization'] = 'Bearer ' + token
129
159
  request['app_key'] = app_id
130
- p request.body
131
160
  res = https.request(request)
132
161
  p res.body.to_s
162
+ p res.code
133
163
  {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
134
164
  end
135
165
 
@@ -216,8 +246,10 @@ class HuaIot
216
246
  #2.9.6 Querying Directly Connected Devices and Their Mounted Devices in Batches
217
247
  def quer_dev_direct_conn_batches(app_id, secret, dev_list)
218
248
  token = get_token(app_id, secret)[:body]["accessToken"]
249
+ p token
219
250
  path = "/iocm/app/dm/v1.1.0/queryDevicesByIds"
220
251
  url_string = "https://" + platformip + ":" + platformport + path
252
+ p url_string
221
253
  uri = URI.parse url_string
222
254
  https = Net::HTTP.new(uri.host, uri.port)
223
255
  https.use_ssl = true
@@ -235,6 +267,25 @@ class HuaIot
235
267
 
236
268
 
237
269
 
270
+ ##2.10.7 Adding Members to a Device Group
271
+
272
+
273
+ ##############################################################3
274
+
275
+
276
+ ########final procedures###############
277
+ def add_new_device_on_huawei(app_id, secret, node_id, name_p, description_p, device_type, profile)
278
+ dev_register_passw_code_mode2(app_id, secret, node_id, name_p, description_p, device_type, profile)
279
+ end
280
+
281
+
282
+ def remove_one_device_from_iot(app_id, secret, dev_id)
283
+ dev_delete(app_id, secret, dev_id)
284
+ end
285
+
286
+
287
+ #######################################
288
+
238
289
  def test()
239
290
 
240
291
  url_string = "https://134.17.93.4:8743/iocm/app/sec/v1.1.0/login"
@@ -18,7 +18,7 @@ class MongoIot
18
18
  @client = Mongo::Client.new(client_host, :database => mongo_database)
19
19
  end
20
20
 
21
- def audit_logger(proc_name, src_ip, input_json, output_json)
21
+ def audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
22
22
  begin
23
23
  d = DateTime.now
24
24
  current = d.strftime("%d/%m/%Y %H:%M:%S")
@@ -26,7 +26,7 @@ class MongoIot
26
26
  doc = {
27
27
  :proc_name => proc_name,
28
28
  :date => current,
29
- :sender => {:src_ip => src_ip},
29
+ :sender => {:src_ip => src_ip, :real_ip => real_ip},
30
30
  :input_params => input_json,
31
31
  :output_params => output_json
32
32
  }
@@ -207,8 +207,32 @@ class MongoIot
207
207
  for l in imei_list
208
208
  doc = {
209
209
  imei: l,
210
- imsi: "",
211
- msisdn: "",
210
+ imsi: "unknown",
211
+ msisdn: "unknown",
212
+ description: "test imei",
213
+ note: "second description",
214
+ profile: 0,
215
+ type: 0,
216
+ address: "unknown"
217
+ }
218
+ result = collection.insert_one(l)
219
+ p result
220
+ end
221
+ rescue
222
+ continue
223
+ end
224
+ end
225
+
226
+
227
+ def imei_insert_list2(imei_list)
228
+ begin
229
+ collection = client[:device_imei]
230
+ p imei_list
231
+ for l in imei_list
232
+ doc = {
233
+ imei: l,
234
+ imsi: "unknown",
235
+ msisdn: "unknown",
212
236
  description: "test imei",
213
237
  note: "second description",
214
238
  profile: 0,
@@ -308,6 +332,24 @@ class MongoIot
308
332
  end
309
333
 
310
334
 
335
+ def get_iot_oceanconnect_credent(login)
336
+ begin
337
+ result_ps = []
338
+ collection = client[:users]
339
+ collection.find({"login" => login}).each {|row|
340
+ result_ps.append(row)
341
+ }
342
+ p result_ps[0]
343
+ app_id = result_ps[0][:iot_data][:app_id]
344
+ secret = result_ps[0][:iot_data][:secret]
345
+ return {:code => 200, :result => "get_iot_oceanconnect_credent: Request completed successfully", :body => {:app_id => app_id, :secret => secret}}
346
+ rescue
347
+ {:code => 500, :result => "get_iot_oceanconnect_credent: Process failed"}
348
+ end
349
+
350
+ end
351
+
352
+
311
353
  def ttt
312
354
  p "111111"
313
355
  begin
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.7"
3
3
  end
data/lib/imperituroard.rb CHANGED
@@ -88,17 +88,19 @@ class Iot
88
88
  attr_accessor :mongoip,
89
89
  :mongoport,
90
90
  :iotip,
91
- :iottoken,
92
91
  :mongo_database,
93
92
  :iotplatform_ip,
94
93
  :iotplatform_port,
95
94
  :cert_path,
96
95
  :key_path,
97
96
  :mongo_client,
98
- :add_functions_connector
97
+ :add_functions_connector,
98
+ :real_ip, #real ip address of procedure caller
99
+ :remote_ip, #ip address of balancer
100
+ :hua_aceanconnect_connector
99
101
 
100
102
  def initialize(mongoip, mongoport, iotip, mongo_database,
101
- iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id)
103
+ iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id, real_ip, remote_ip)
102
104
  @mongoip = mongoip
103
105
  @mongoport = mongoport
104
106
  @iotip = iotip
@@ -109,6 +111,9 @@ class Iot
109
111
  @key_path = key_path
110
112
  @mongo_client = MongoIot.new(mongoip, mongoport, mongo_database)
111
113
  @add_functions_connector = AdditionalFunc.new(telegram_api_url, telegram_chat_id)
114
+ @real_ip = real_ip
115
+ @remote_ip = remote_ip
116
+ @hua_aceanconnect_connector = HuaIot.new(iotplatform_ip, iotplatform_port, cert_path, key_path)
112
117
  end
113
118
 
114
119
  #error list
@@ -117,15 +122,16 @@ class Iot
117
122
  #{:code => 200, :result => "Request completed successfully", :body => result_ps}
118
123
 
119
124
 
120
- #!1. Add device to profile (only for new device)
125
+ #!!1. Add device to profile (only for new device)
121
126
  #login - login for client identification
122
127
  #profile - profile for device
123
128
  #imei_list - device identificator
124
- #imei_list = [{"imei" => 131234123412341233, "description" => "dfdsf", "note"=>"second description", "profile"=>0},
129
+ #imei_list = [{"imei" => 131234123412341233, "description" => "dfdsf", "note"=>"second description", "profile"=>0, "device_type"=>"phone"},
125
130
  #{"imei" => 56213126347645784, "description" => "dfdsf", "note"=>"second description", "profile"=>0}]
126
131
  #massive commands
127
- #++
128
- def add_device_to_profile(login, imei_list, remote_ip)
132
+ #+++
133
+ #iot logic added
134
+ def add_device_to_profile(login, imei_list)
129
135
  input_json = {:login => login, :imei_list => imei_list}
130
136
  resp_out = {}
131
137
  begin
@@ -150,8 +156,6 @@ class Iot
150
156
  begin
151
157
  get_login_info = mongo_client.check_login_prof_perm_id_one(login, list1[jj]["profile"])[:code]
152
158
  if get_login_info==200
153
-
154
-
155
159
  for_insert.append(list1[jj])
156
160
  else
157
161
  not_processed_list.append({:imei => list1[jj], :error => "Permission denied for this profile"})
@@ -162,15 +166,40 @@ class Iot
162
166
  end
163
167
 
164
168
  begin
169
+ added_on_iot_platf = []
165
170
  if for_insert!=[]
166
171
  ##Logic for IOT Platform connection###
167
172
 
168
- #########end iot platform logic#######
173
+ credentials = mongo_client.get_iot_oceanconnect_credent(login)
174
+
175
+ if credentials[:code]==200
176
+ for aaa in for_insert
177
+ begin
178
+ dev_name = aaa["imei"].to_s
179
+ resss = hua_aceanconnect_connector.add_new_device_on_huawei(credentials[:body][:app_id], credentials[:body][:secret], aaa["imei"], dev_name, aaa["description"], aaa["device_type"], aaa["profile"])
180
+ if resss[:code]=="200"
181
+ s1 = aaa
182
+ s1[:huadata] = resss
183
+ added_on_iot_platf.append(s1)
184
+ else
185
+ not_processed_list.append({:imei => aaa["imei"], :error => resss})
186
+ end
187
+ rescue
188
+ not_processed_list.append({:imei => aaa["imei"], :error => "Unknown error with insertion imei on IOT platform"})
189
+ end
190
+ end
191
+
192
+ #########end iot platform logic#######
193
+
194
+ mongo_client.imei_insert_list(added_on_iot_platf)
195
+ resp_out = {:code => 200, :result => "Data processed", :body => {:imei_processed => added_on_iot_platf, :error_list => not_processed_list}}
196
+ else
197
+ resp_out = {:code => 400, :result => "IOT platform credentials not found"}
198
+ end
199
+
169
200
 
170
- mongo_client.imei_insert_list(for_insert)
171
- resp_out = {:code => 200, :result => "Data processed", :body => {:imei_processed => for_insert, :error_list => not_processed_list}}
172
201
  else
173
- resp_out = {:code => 202, :result => "Nothing for insertion", :body => {:imei_processed => for_insert, :error_list => not_processed_list}}
202
+ resp_out = {:code => 202, :result => "Nothing for insertion", :body => {:imei_processed => added_on_iot_platf, :error_list => not_processed_list}}
174
203
 
175
204
  end
176
205
  rescue
@@ -181,19 +210,19 @@ class Iot
181
210
  resp_out = {:code => 507, :result => "Unknown SDK error"}
182
211
  end
183
212
  thr1.join
184
- mongo_client.audit_logger("add_device_to_profile", remote_ip, input_json, resp_out)
213
+ mongo_client.audit_logger("add_device_to_profile", remote_ip, input_json, resp_out, real_ip)
185
214
  resp_out
186
215
  end
187
216
 
188
217
 
189
- #!2 Find device (only mongo datebase. IOT platform not need)
218
+ #!!2 Find device (only mongo datebase. IOT platform not need)
190
219
  # procedure for data selection from mongo database.
191
220
  # for this function IOT platform not need
192
221
  # login
193
222
  # imei
194
223
  # imei_list =[41234,23452345,132412]
195
224
  #++
196
- def device_find(login, imei_list, remote_ip)
225
+ def device_find(login, imei_list)
197
226
  input_json = {:login => login, :imei_list => imei_list}
198
227
  ime_list_approved = []
199
228
  ime_list_notapproved = []
@@ -236,7 +265,7 @@ class Iot
236
265
  resp = {:code => 507, :result => "Unknown SDK error"}
237
266
  end
238
267
  thr2.join
239
- mongo_client.audit_logger("device_find", remote_ip, input_json, resp)
268
+ mongo_client.audit_logger("device_find", remote_ip, input_json, resp, real_ip)
240
269
  resp
241
270
  end
242
271
 
@@ -247,7 +276,7 @@ class Iot
247
276
  #massive commands
248
277
  #im_list = [{"imei_old"=>7967843245667, "imei_new"=>7967843245665}]
249
278
  #++
250
- def imei_replace(login, im_list, remote_ip)
279
+ def imei_replace(login, im_list)
251
280
  input_json = {:login => login, :imei_list => im_list}
252
281
 
253
282
  li_new_imei = []
@@ -296,6 +325,8 @@ class Iot
296
325
 
297
326
  ##Logic for IOT Platform connection###
298
327
 
328
+ remove_one_device_from_iot(app_id, secret, dev_id)
329
+
299
330
  #########end iot platform logic#######
300
331
 
301
332
  mongo_client.device_modify_any_attr_mongo(list1[a], {:imei => a})
@@ -328,56 +359,79 @@ class Iot
328
359
  end
329
360
 
330
361
  thr3.join
331
- mongo_client.audit_logger("imei_replace", remote_ip, input_json, resp_out)
362
+ mongo_client.audit_logger("imei_replace", remote_ip, input_json, resp_out, real_ip)
332
363
 
333
364
  resp_out
334
365
 
335
366
  end
336
367
 
337
368
 
338
- #!4 remove device
369
+ #!!4 remove device
339
370
  #login
340
371
  #imei
341
372
  # not massive commands
342
373
  #imei=11341341234
343
374
  #login="test"
344
- #++
345
- def device_remove(login, imei, remote_ip)
375
+ #+++
376
+ #IOT logic added
377
+ def device_remove(login, imei)
346
378
 
347
379
  input_json = {:login => login, :imei_list => imei}
348
380
  resp_out = {}
349
381
 
350
382
  begin
351
383
  thr4 = Thread.new do
352
- prof_name = mongo_client.get_profile_name_from_imei(imei)
353
- if prof_name[:code]==200
354
- permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
355
- if permiss[:code]==200
384
+ prof_name = mongo_client.get_profile_name_from_imei(imei)
385
+ if prof_name[:code]==200
386
+ permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
387
+ if permiss[:code]==200
388
+
389
+ ##Logic for IOT Platform connection###
390
+
391
+
392
+ credentials = mongo_client.get_iot_oceanconnect_credent(login)
393
+ resp = {}
356
394
 
357
- ##Logic for IOT Platform connection###
395
+ if credentials[:code]==200
358
396
 
359
- #########end iot platform logic#######
397
+ imei_data = mongo_client.get_imei_info_from_db([imei])
398
+ if imei_data[:body]!=[]
399
+ ans = hua_aceanconnect_connector.remove_one_device_from_iot(credentials[:body][:app_id], credentials[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
400
+ p ans
401
+ if ans[:code]=="204" or ans[:code]=="200"
402
+ resp = mongo_client.device_remove_single_mongo(imei)
403
+ else
404
+ resp = {:code => 500, :result => "Unknown IOT platform error", :body => ans}
405
+ end
406
+ else
407
+ resp_out = {:code => 404, :result => "Data not found"}
408
+ end
360
409
 
361
- resp = mongo_client.device_remove_single_mongo(imei)
410
+ #########end iot platform logic#######
411
+
412
+ if resp[:code]==200
413
+ resp_out = {:code => 200, :result => "Request completed successfully"}
414
+ else
415
+ resp_out=resp
416
+ end
417
+
418
+ else
419
+ resp_out = {:code => 400, :result => "IOT platform credentials not found"}
420
+ end
362
421
 
363
- if resp[:code]==200
364
- resp_out = {:code => 200, :result => "Request completed successfully"}
365
422
  else
366
- resp_out=resp
423
+ resp_out=permiss
367
424
  end
368
425
  else
369
- resp_out=permiss
426
+ resp_out=prof_name
370
427
  end
371
- else
372
- resp_out=prof_name
373
- end
374
428
  end
375
429
 
376
430
  rescue
377
431
  resp_out = {:code => 507, :result => "Unknown SDK error"}
378
432
  end
379
433
  thr4.join
380
- mongo_client.audit_logger("device_remove", remote_ip, input_json, resp_out)
434
+ mongo_client.audit_logger("device_remove", remote_ip, input_json, resp_out, real_ip)
381
435
  resp_out
382
436
  end
383
437
 
@@ -388,7 +442,7 @@ class Iot
388
442
  #address = newdevice_list
389
443
  #newdevice_list=[{:imei=>7967843245665, :address=>"Golubeva51"}]
390
444
  #++
391
- def device_add_address(login, newdevice_list, remote_ip)
445
+ def device_add_address(login, newdevice_list)
392
446
  #add_functions_connector.telegram_message(newdevice_list.to_s)
393
447
  p newdevice_list
394
448
  p "gas"
@@ -400,43 +454,43 @@ class Iot
400
454
  processed = []
401
455
  begin
402
456
  thr5 = Thread.new do
403
- for p in newdevice_list
404
- prof_name = mongo_client.get_profile_name_from_imei(p[:imei])
457
+ for p in newdevice_list
458
+ prof_name = mongo_client.get_profile_name_from_imei(p[:imei])
405
459
 
406
- if prof_name[:code]==200
407
- p "prof_name"
408
- p prof_name
409
- permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
410
- if permiss[:code]==200
460
+ if prof_name[:code]==200
461
+ p "prof_name"
462
+ p prof_name
463
+ permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
464
+ if permiss[:code]==200
411
465
 
412
- ##Logic for IOT Platform connection###
466
+ ##Logic for IOT Platform connection###
413
467
 
414
- #########end iot platform logic#######
468
+ #########end iot platform logic#######
415
469
 
416
470
 
417
- resp = mongo_client.device_modify_attr_mongo(p[:imei], p[:address])
418
- if resp[:code]==200
419
- processed.append({:imei=>p[:imei]})
471
+ resp = mongo_client.device_modify_attr_mongo(p[:imei], p[:address])
472
+ if resp[:code]==200
473
+ processed.append({:imei => p[:imei]})
474
+ end
475
+ else
476
+ not_processed.append({:imei => p[:imei], :address => p[:address], :error => permiss})
420
477
  end
421
478
  else
422
- not_processed.append({:imei=>p[:imei], :address=>p[:address], :error=>permiss})
479
+ not_processed.append({:imei => p[:imei], :address => p[:address], :error => prof_name})
423
480
  end
424
- else
425
- not_processed.append({:imei=>p[:imei], :address=>p[:address], :error=>prof_name})
426
481
  end
427
- end
428
482
 
429
- if processed!=[]
430
- resp_out = {:code => 200, :result => "Request completed successfully", :body => {:imei_processed => processed, :error_list => not_processed}}
431
- else
432
- resp_out = {:code => 202, :result => "Nothing processed", :body => {:imei_processed => processed, :error_list => not_processed}}
433
- end
483
+ if processed!=[]
484
+ resp_out = {:code => 200, :result => "Request completed successfully", :body => {:imei_processed => processed, :error_list => not_processed}}
485
+ else
486
+ resp_out = {:code => 202, :result => "Nothing processed", :body => {:imei_processed => processed, :error_list => not_processed}}
487
+ end
434
488
  end
435
489
  rescue
436
490
  resp_out = {:code => 507, :result => "Unknown SDK error"}
437
491
  end
438
492
  thr5.join
439
- mongo_client.audit_logger("device_add_address", remote_ip, input_json, resp_out)
493
+ mongo_client.audit_logger("device_add_address", remote_ip, input_json, resp_out, real_ip)
440
494
  resp_out
441
495
  end
442
496
 
@@ -448,7 +502,7 @@ class Iot
448
502
  #msisdn
449
503
  #newdevice_list=[{:imei=>7967843245665, :attributes=>{:address=>"Golubeva51", :profile=>"wqeqcqeqwev", :msisdn=>375298766719, :imsi=>25702858586756875}}]
450
504
  #+
451
- def add_service(login, device_list, remote_ip)
505
+ def add_service(login, device_list)
452
506
  resp_out = {}
453
507
  not_processed = []
454
508
  processed = []
@@ -493,7 +547,7 @@ class Iot
493
547
  processed.append(g["imei"])
494
548
 
495
549
  else
496
- not_processed.append({:imei=>g["imei"], :description=> "New profile permission error", :error=>permiss2 })
550
+ not_processed.append({:imei => g["imei"], :description => "New profile permission error", :error => permiss2})
497
551
  end
498
552
 
499
553
  else
@@ -503,14 +557,12 @@ class Iot
503
557
  processed.append(g["imei"])
504
558
 
505
559
  end
506
-
507
-
508
560
  else
509
- not_processed.append({:imei=>g["imei"], :description=> "Old profile permission error", :error=>permiss1 })
561
+ not_processed.append({:imei => g["imei"], :description => "Old profile permission error", :error => permiss1})
510
562
  end
511
563
 
512
564
  else
513
- not_processed.append({:imei=>g["imei"],:error=>prof_name1})
565
+ not_processed.append({:imei => g["imei"], :error => prof_name1})
514
566
  end
515
567
 
516
568
  end
@@ -519,7 +571,7 @@ class Iot
519
571
  rescue
520
572
  resp_out = {:code => 507, :result => "Unknown SDK error"}
521
573
  end
522
- mongo_client.audit_logger("device_remove", remote_ip, input_json, resp_out)
574
+ mongo_client.audit_logger("device_remove", remote_ip, input_json, resp_out, real_ip)
523
575
  resp_out
524
576
  end
525
577
 
@@ -529,8 +581,8 @@ class Iot
529
581
  end
530
582
 
531
583
 
532
- def logger_to_audit_database(proc_name, src_ip, input_json, output_json)
533
- mongo_client.audit_logger(proc_name, src_ip, input_json, output_json)
584
+ def logger_to_audit_database(proc_name, src_ip, input_json, output_json, real_ip)
585
+ mongo_client.audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
534
586
  end
535
587
 
536
588
 
@@ -541,14 +593,15 @@ class Iot
541
593
  ff = [131234123412341233, 131234123127341233]
542
594
  #ddd.get_imsi_info_from_db(ff)
543
595
 
544
- p ddd.get_profile_id_by_name("1341241")
596
+ #p ddd.get_profile_id_by_name("1341241")
597
+ p ddd.get_iot_oceanconnect_credent("test")
545
598
  end
546
599
 
547
600
 
548
601
  def testhua()
549
602
  cert_file = cert_path
550
603
  key_file = key_path
551
- ddd1 = HuaIot.new(iotplatform_ip, iotplatform_port, "", "", cert_file, key_file)
604
+ ddd1 = HuaIot.new(iotplatform_ip, iotplatform_port, cert_file, key_file)
552
605
  #p ddd1.dev_register_verif_code_mode("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "7521234165452")
553
606
  #ddd1.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "a8834c5e-4b4d-4f0f-ad87-14e916f3d0bb")
554
607
  #ddd1.querying_device_activ_status("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "7521234165452")
@@ -556,14 +609,16 @@ class Iot
556
609
  list = ["41c0ba82-d771-4669-b766-fcbfbedc17f4", "7521234165452", "feb9c4d1-4944-4b04-a717-df87dfde30f7", "9868e121-c309-4f4f-8ab3-0aa69072caff", "b3b82f35-0723-4a83-90af-d4ea40017194"]
557
610
  #p ddd1.querying_device_direct_conn("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", list)
558
611
  #p ddd1.querying_device_type_list("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa")
559
- #p ddd1.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "7521234165452")
560
- #p ddd1.dev_register_verif_code_mode("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "12321234545345")
561
-
562
- p ddd1.quer_dev_direct_conn_batches("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", ["62c5f5ef-dead-48bf-9f09-292ca5e41577", "4c763ea1-be51-4eff-81db-863bc04791bb"])
612
+ # ddd1.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "7521234165452")
613
+ #p ddd1.dev_register_verif_code_mode("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "45324523452345")
563
614
 
564
- #ddd1.querying_device_info("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "c6e0dfb1-8042-472a-a35d-e984f118d2a6")
615
+ p devtestid = ddd1.dev_register_passw_code_mode2("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "24235455", "test", "test", "phone", "0")
616
+ p ddd1.quer_dev_direct_conn_batches("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", [devtestid[:body]["deviceId"], "4c763ea1-be51-4eff-81db-863bc04791bb"])
565
617
 
566
- #ddd1.dev_delete("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "484114f6-a49c-4bab-88e6-4ddaf1cc1c8f")
618
+ #p ddd1.querying_device_info("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "c6e0dfb1-8042-472a-a35d-e984f118d2a6")
619
+ p "delete start"
620
+ p ddd1.dev_delete("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", devtestid[:body]["deviceId"])
621
+ #p ddd1.dev_delete("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "2881a9cc-cb2a-4b59-8fac-de3aace2324d")
567
622
  end
568
623
 
569
624
 
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: 0.2.5
4
+ version: 0.2.7
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-04-15 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler