lib/imperituroard.rb in imperituroard-0.5.9 vs lib/imperituroard.rb in imperituroard-1.0.0
- old
+ new
@@ -105,46 +105,51 @@
include PhpipamModule
end
class Iot
- attr_accessor :mongoip,
- :mongoport,
- :iotip,
- :mongo_database,
- :iotplatform_ip,
- :iotplatform_port,
- :cert_path,
- :key_path,
+ attr_accessor :param_all,
:mongo_client,
:add_functions_connector,
- :real_ip, #real ip address of procedure caller
- :remote_ip, #ip address of balancer
+ #:real_ip, #real ip address of procedure caller
+ #:remote_ip, #ip address of balancer
:hua_aceanconnect_connector,
:internal_func,
:iot_connector
- def initialize(mongoip, mongoport, iotip, mongo_database,
- iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id, real_ip, remote_ip)
- @mongoip = mongoip
- @mongoport = mongoport
- @iotip = iotip
- @mongo_database = mongo_database
- @iotplatform_ip = iotplatform_ip
- @iotplatform_port = iotplatform_port
- @cert_path = cert_path
- @key_path = key_path
- @mongo_client = MongoIot.new(mongoip, mongoport, mongo_database)
+ def initialize(mongoip,
+ mongoport,
+ iotip,
+ mongo_database,
+ iotplatform_ip,
+ iotplatform_port,
+ cert_path,
+ key_path,
+ telegram_api_url,
+ telegram_chat_id
+ #real_ip,
+ #remote_ip
+ )
+ @param_all = {:mongoip => mongoip,
+ :mongoport => mongoport,
+ :iotip => iotip,
+ :mongo_database => mongo_database,
+ :iotplatform_ip => iotplatform_ip,
+ :cert_path => cert_path,
+ :key_path => key_path
+ }
+ @mongo_client = MongoIot.new(param_all[:mongoip], param_all[:mongoport], param_all[:mongo_database])
@add_functions_connector = AdditionalFunc.new(telegram_api_url, telegram_chat_id)
- @real_ip = real_ip
- @remote_ip = remote_ip
- @hua_aceanconnect_connector = HuaIot.new(iotplatform_ip, iotplatform_port, cert_path, key_path)
+ #@real_ip = real_ip
+ #@remote_ip = remote_ip
+ @hua_aceanconnect_connector = HuaIot.new(iotplatform_ip, iotplatform_port, cert_path, key_path, param_all[:mongoip], param_all[:mongoport], param_all[:mongo_database])
@internal_func = InternalFunc.new
- @iot_connector = IotFunctions_2.new(mongoip, mongoport, iotip, mongo_database,
- iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id, real_ip, remote_ip)
+ @iot_connector = IotFunctions_2.new(param_all[:mongoip], param_all[:mongoport], iotip, param_all[:mongo_database],
+ iotplatform_ip, iotplatform_port, cert_path, key_path, telegram_api_url, telegram_chat_id)
end
+
#error list
#:code => 507, :result => "Unknown SDK error"
#{:code => 200, :result => "Request completed successfully", :body => result_ps}
@@ -155,112 +160,115 @@
#imei_list = [{"imei" => 131234123412341233, "description" => "dfdsf", "note"=>"second description", "profile"=>0, "device_type"=>"phone"},
#{"imei" => 56213126347645784, "description" => "dfdsf", "note"=>"second description", "profile"=>0}]
#massive commands
#+++
#iot logic added
- def add_device_to_profile(login, imei_list)
- iot_connector.add_device_to_prof_2(login, imei_list)
+ def add_device_to_profile(login, imei_list, real_ip, remote_ip)
+ iot_connector.add_device_to_prof_2(login, imei_list, real_ip, remote_ip)
end
#!!2 Find device (only mongo datebase. IOT platform not need)
# procedure for data selection from mongo database.
# for this function IOT platform not need
# login
# imei
# imei_list =[41234,23452345,132412]
#++
- def device_find(login, imei_list)
- iot_connector.device_find_2(login, imei_list)
+ def device_find(login, imei_list, real_ip, remote_ip)
+ iot_connector.device_find_2(login, imei_list, real_ip, remote_ip)
end
#!3 device modify, change imei
#login
#imei_old
#imei_new
#massive commands
#im_list = [{"imei_old"=>7967843245667, "imei_new"=>7967843245665}]
#++
- def imei_replace(login, im_list)
- iot_connector.imei_replace_2(login, im_list)
+ def imei_replace(login, im_list, real_ip, remote_ip)
+ iot_connector.imei_replace_2(login, im_list, real_ip, remote_ip)
end
#!!4 remove device
#login
#imei
# not massive commands
#imei=11341341234
#login="test"
#+++
#IOT logic added
- def device_remove(login, imei)
- iot_connector.device_remove_2(login, imei)
+ def device_remove(login, imei, real_ip, remote_ip)
+ iot_connector.device_remove_2(login, imei, real_ip, remote_ip)
end
#!5 add address to device
#login
#imei = newdevice_list
#address = newdevice_list
#newdevice_list=[{:imei=>7967843245665, :address=>"Golubeva51"}]
#+++
#iot platform integration completed
- def device_add_address(login, newdevice_list)
- iot_connector.device_add_address_2(login, newdevice_list)
+ def device_add_address(login, newdevice_list, real_ip, remote_ip)
+ iot_connector.device_add_address_2(login, newdevice_list, real_ip, remote_ip)
end
#6 add service by SPA
#imei
#profile
#imsi
#msisdn
#newdevice_list=[{:imei=>7967843245665, :attributes=>{:address=>"Golubeva51", :profile=>"wqeqcqeqwev", :msisdn=>375298766719, :imsi=>25702858586756875}}]
#+
- def add_service(login, device_list)
- iot_connector.add_service_2(login, device_list)
+ def add_service(login, device_list, real_ip, remote_ip)
+ iot_connector.add_service_2(login, device_list, real_ip, remote_ip)
end
-
#7 procedure for subscriber autorization
- def autorize_subscriber(login, password)
- iot_connector.autorize_subscriber_2(login, password)
+ def autorize_subscriber(login, password, real_ip, remote_ip)
+ iot_connector.autorize_subscriber_2(login, password, real_ip, remote_ip)
end
-
#8 get available profiles for login
- def get_available_profiles(login)
- iot_connector.get_available_prof_2(login)
+ def get_available_profiles(login, real_ip, remote_ip)
+ iot_connector.get_available_prof_2(login, real_ip, remote_ip)
end
-
#9 get available types for login
- def get_available_types(login)
- iot_connector.get_available_types_2(login)
+ def get_available_types(login, real_ip, remote_ip)
+ iot_connector.get_available_types_2(login, real_ip, remote_ip)
end
-
#10 get info for device type
- def get_info_data_type(type)
- iot_connector.get_info_data_type_2(type)
+ def get_info_data_type(type, real_ip, remote_ip)
+ iot_connector.get_info_data_type_2(type, real_ip, remote_ip)
end
-
#11 get info for profile
- def get_info_data_profile(profile)
- iot_connector.get_info_data_profile_2(profile)
+ def get_info_data_profile(profile, real_ip, remote_ip)
+ iot_connector.get_info_data_profile_2(profile, real_ip, remote_ip)
end
+ #13 replace data for imei. Replace Type and Profile
+ #new procedure 2020-06-06
+ #params =
+ # {"autorization"=>{"login"=>"test", "token"=>"token"}, "datalist"=>[{"imei"=>"524523654366", "new_profile"=>"3", "new_type"=>"1000001"}, {"imei"=>"53623413423", "new_profile"=>"1", "new_type"=>"1000003"}]}
+ # answer = {:code=>200, :result=>"Success", :body=>{:processednum=>1, :failednum=>1, :deviceserr=>[{:failedimei=>524523654366}]}}
+ def set_data_replace(soapgw_params, real_ip, remote_ip)
+ iot_connector.set_data_replace_2(soapgw_params, real_ip, remote_ip)
+ end
+
def logger_to_audit_database(proc_name, src_ip, input_json, output_json, real_ip)
mongo_client.audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
end
def test111
iot_connector.test1278493
end
-
end
class Mhub_2
@@ -400,6 +408,6 @@
#1 block all devices by belgim list
def no_pasaran
ukaz60_func.no_pasaran
end
-end
\ No newline at end of file
+end