$LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__) $LOAD_PATH.unshift File.expand_path("../projects/wttx", __dir__) $LOAD_PATH.unshift File.expand_path("../projects/mhub", __dir__) $LOAD_PATH.unshift File.expand_path("../projects/mhub/subs/dabrab", __dir__) $LOAD_PATH.unshift File.expand_path("../platforms/cps", __dir__) $LOAD_PATH.unshift File.expand_path("../platforms/public", __dir__) $LOAD_PATH.unshift File.expand_path("../projects", __dir__) require "imperituroard/version" require "imperituroard/projects/wttx/phpipamdb" require "imperituroard/projects/wttx/phpipamcps" require "imperituroard/projects/iot/mongoconnector" require "imperituroard/projects/iot/hua_oceanconnect_adapter" require "imperituroard/projects/iot/add_functions" require "imperituroard/projects/iot/internal_functions" require 'imperituroard/projects/mhub/infobip' require 'imperituroard/projects/mhub/sk' require 'imperituroard/projects/mhub/subs/dabrab/dabrab_proced' require 'imperituroard/projects/mhub/subs/dabrab/dabrab_platform' require 'imperituroard/projects/mhub' require 'imperituroard/projects/iot' require 'imperituroard/projects/dns' require 'imperituroard/platforms/cps/qps_connector' require 'imperituroard/platforms/public/telegram' require 'json' require 'ipaddr' require 'date' require 'net/http' require 'uri' module Imperituroard class Error < StandardError; end def initialize() end def hhh(jjj) p jjj end # Your code goes here... end module PhpipamModule def test(ggg) p ggg end end class MyJSON def self.valid?(value) result = JSON.parse(value) result.is_a?(Hash) || result.is_a?(Array) rescue JSON::ParserError, TypeError false end end class Pipam attr_accessor :username, :password, :ip, :database_class, :cps_class def initialize(db_username, db_password, db_ip, cps_wsdl, cps_endpoint, cps_namespace) @username = db_username @password = db_password @ip = db_ip @database_class = Pdb.new("phpipam", db_username, db_password, db_ip, "3306") @cps_class = Pcps.new(cps_wsdl, cps_endpoint, cps_namespace) end def update_phpipam_rewr_msisdn(old_msisdn, new_msisdn) dst_num_exists = database_class.check_if_msisdn_exists(new_msisdn, "ipaddresses") if dst_num_exists == 0 database_class.update_database_rewrite_msisdn(old_msisdn, new_msisdn) "updated" else "failed" end end def final_change_msisdn(old_msisdn, new_msisdn) dst_num_exists = database_class.check_if_msisdn_exists(new_msisdn, "ipaddresses") if dst_num_exists == 0 response_from_db = database_class.update_database_rewrite_msisdn(old_msisdn, new_msisdn) if response_from_db=="success" response_from_cps = cps_class.change_attr_cps(old_msisdn, new_msisdn) if response_from_cps == "ok" "updated" else "cps failed" end else "db failed" end else "failed" end end include PhpipamModule end class Iot attr_accessor :mongoip, :mongoport, :iotip, :mongo_database, :iotplatform_ip, :iotplatform_port, :cert_path, :key_path, :mongo_client, :add_functions_connector, :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) @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) @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) end #error list #:code => 507, :result => "Unknown SDK error" #{:code => 200, :result => "Request completed successfully", :body => result_ps} #!!1. Add device to profile (only for new device) #login - login for client identification #profile - profile for device #imei_list - device identificator #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) 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) 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) 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) 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) 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) end #7 procedure for subscriber autorization def autorize_subscriber(login, password) iot_connector.autorize_subscriber_2(login, password) end #8 get available profiles for login def get_available_profiles(login) iot_connector.get_available_prof_2(login) end #9 get available types for login def get_available_types(login) iot_connector.get_available_types_2(login) end #10 get info for device type def get_info_data_type(type) iot_connector.get_info_data_type_2(type) end #11 get info for profile def get_info_data_profile(profile) iot_connector.get_info_data_profile_2(profile) 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.test end end class Mhub_2 attr_accessor :sk_url, :sk_login, :sk_password, :mhub_connector, :internal_func, :dabrab_connecter, :static_callback, :crm_connector def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname) @sk_url = sk_url_simple @sk_login = sk_login @sk_password = sk_password @internal_func = InternalFunc.new @mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id) @internal_func = InternalFunc.new @dabrab_connecter = Dabrab.new @static_callback = static_callback @crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id) @mhub_connector = MhubFunctions_2.new(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname) end #{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}], # "scenarioKey"=>"1", "viber"=>nil, "sms"=>{"text"=>"карточка готова"}, # "sendAt"=>"2019-08-15T08:40:00.000", "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports", # "notifyContentType"=>"application/json", "controller"=>"bank", "action"=>"api", # "bank"=>{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}], "scenarioKey"=>"1", # "viber"=>nil, "sms"=>{"text"=>"карточка готова"}, "sendAt"=>"2019-08-15T08:40:00.000", # "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports", # "notifyContentType"=>"application/json"}} def get_send_message(params, ip_src, ip_real, ip_vip) mhub_connector.get_send_message_2(params, ip_src, ip_real, ip_vip) end def recieve_delivery_report(params, ip_src, ip_real, ip_vip) mhub_connector.rec_deliv_report_2(params, ip_src, ip_real, ip_vip) end end class CpsFunctions_2 attr_accessor :qps_connector def initialize(cps_wsdl, cps_endpoint, cps_namespace) @qps_connector = Qps_2.new(cps_wsdl, cps_endpoint, cps_namespace) end def recreate_cps_profile(msisdn) p gettt = qps_connector.get_subscriber_msisdn(msisdn) p qps_connector.delete_subscriber(msisdn) p qps_connector.recreate_subscriber(gettt) end def get_subscriber_profile(msisdn) qps_connector.get_subscriber_msisdn(msisdn) end end class Ukaz60Automation_2 attr_accessor :dns, :ukaz60_func def initialize(telegram_api_url, telegram_chat_id, work_directory, filename_blocked, filename_tmp_blocked, ip_for_redirect, add_bl_memory_script, del_bl_memory_script, dns_login, dns_password, belgim_login, belgim_password, belgim_url, ansible_tmp_folder, local_tmp_directory, ansible_ssh_user, ansible_ssh_password, ansible_host, url_backup_dir) @ukaz69_dns_func = Dns_2.new(telegram_api_url, telegram_chat_id, work_directory, filename_blocked, filename_tmp_blocked, ip_for_redirect, add_bl_memory_script, del_bl_memory_script, dns_login, dns_password, belgim_login, belgim_password, belgim_url) @ukaz60_func = Ukaz60All_2(telegram_api_url, telegram_chat_id, belgim_login, belgim_password, belgim_url, ansible_tmp_folder, local_tmp_directory, ansible_ssh_user, ansible_ssh_password, ansible_host, url_backup_dir) end def no_pasaran ukaz60_func.no_pasaran end end